Commit 7dd9e1b1 authored by Aaron Gutierrez's avatar Aaron Gutierrez

Mejoras y corrección de errores BYTEBOT WEB

parent 8e2cd9d8
......@@ -40,6 +40,12 @@ public class ChannelBean {
@Expose
private List<ChannelParamBean> parameters;
@Expose
private String suggestTitle;
@Expose
private String suggestDetail;
public static ChannelBean clone(Channel channel) {
ChannelBean bean = new ChannelBean();
......@@ -47,6 +53,8 @@ public class ChannelBean {
bean.setName(channel.getName());
bean.setImage(channel.getImage());
bean.setParameters(new ArrayList<>());
bean.setSuggestTitle(channel.getSuggestTitle());
bean.setSuggestDetail(channel.getSuggestDetail());
if (channel.getParameters() != null) {
......
......@@ -43,6 +43,9 @@ public class ChannelParamBean {
@Expose
private String traductions;
@Expose
private String regex;
public static ChannelParamBean clone(ChannelParam channelParam) {
ChannelParamBean bean = new ChannelParamBean();
......@@ -53,6 +56,7 @@ public class ChannelParamBean {
bean.setType(channelParam.getType());
bean.setOrder(channelParam.getOrder());
bean.setTraductions(channelParam.getTraductions());
bean.setRegex(channelParam.getRegex());
return bean;
}
......
......@@ -13,6 +13,8 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import io.swagger.annotations.ApiParam;
import java.security.Principal;
import java.time.LocalDate;
import java.util.UUID;
import lombok.extern.log4j.Log4j2;
......@@ -24,6 +26,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
@Log4j2
@RestController
@RequestMapping("/service/agent")
......@@ -70,7 +74,7 @@ public class AgentController {
}
}
@PostMapping(value = "/")
@PutMapping(value = "/")
@PreAuthorize("hasPermission(this, 'new')")
public ResponseEntity<String> createConversationalAgent(@RequestBody AgentBean agentBean) {
......@@ -87,7 +91,7 @@ public class AgentController {
}
}
@PostMapping(value = "/{id}")
@PutMapping(value = "/{id}")
@PreAuthorize("hasPermission(this, 'edit')")
public ResponseEntity<String> updateConversationalAgent(@PathVariable("id") Long id,
@RequestBody AgentBean agentBean) {
......@@ -165,11 +169,12 @@ public class AgentController {
}
@PostMapping("/file-upload")
public ResponseEntity<String> uploadFile(@RequestParam("file") MultipartFile file) {
Gson gson = new GsonBuilder().create();
public ResponseEntity<String> uploadFile(@RequestParam("file") MultipartFile file, Principal principal) {
Gson gson = gsonBuilder.create();
try {
String uuid = UUID.randomUUID().toString();
FileValidationResponse response = fileManagementService.validateAndSaveFile(uuid, file);
response.setUser(principal != null ? principal.getName() : null);
return new ResponseEntity<>(gson.toJson(response), HttpStatus.OK);
} catch (Exception e) {
e.printStackTrace();
......
......@@ -8,6 +8,8 @@ package com.bytesw.bytebot.http;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDate;
@Getter @Setter
public class FileValidationResponse {
......@@ -15,6 +17,8 @@ public class FileValidationResponse {
private String uuid;
private String fileName;
private String status;
private String user;
private String uploadDate;
private FileValidationResult fileValidationResult;
}
......@@ -43,4 +43,10 @@ public class Channel {
@OneToMany(mappedBy = "channel")
private List<ChannelParam> parameters;
@Column(name = "CHAN_TITLE")
private String suggestTitle;
@Column(name = "CHAN_DETAIL")
private String suggestDetail;
}
......@@ -60,4 +60,6 @@ public class ChannelParam {
@Column(name = "CHPA_MAXLE")
private Integer maxlength;
@Column(name = "CHPA_REGEX")
private String regex;
}
......@@ -6,8 +6,11 @@
package com.bytesw.bytebot.repository;
import com.bytesw.bytebot.model.QuestionFile;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import java.time.LocalDateTime;
import java.util.Optional;
/**
......@@ -24,5 +27,7 @@ import java.util.Optional;
public interface QuestionFileRepository extends CrudRepository<QuestionFile, Long> {
public Optional<QuestionFile> findByUuid(String uuid);
@Query("Select q.uploadDate from QuestionFile q where q.uuid = :uuid")
LocalDateTime findUploadDateByUuid(@Param("uuid") String uuid);
}
......@@ -167,11 +167,13 @@ public class AgentService extends CustomPaginationService<Agent> {
for (FrequentQuestionBean frequentQuestionBean : agent.getFrequentQuestions()) {
FrequentQuestion frequentQuestionBD = null;
boolean existInDB = false;
if (frequentQuestionBean.getId() != null) {
Optional<FrequentQuestion> frequentQuestionFound = frequentQuestionRepository.findById(frequentQuestionBean.getId());
if (frequentQuestionFound.isPresent()) {
existInDB = true;
frequentQuestionBD = frequentQuestionFound.get();
}
}
......@@ -190,6 +192,11 @@ public class AgentService extends CustomPaginationService<Agent> {
frequentQuestionBD.setStatus(FrequentQuestionStatusEnum.fromString(frequentQuestionBean.getStatus()));
frequentQuestionBD.setUser(frequentQuestionBean.getUser());
if (!existInDB) {
LocalDateTime uploadDate = questionFileRepository.findUploadDateByUuid(frequentQuestionBean.getUuid());
frequentQuestionBD.setUploadDate(uploadDate);
}
frequentQuestionRepository.save(frequentQuestionBD);
}
......@@ -224,12 +231,14 @@ public class AgentService extends CustomPaginationService<Agent> {
for (DeploymentChannelBean deploymentChannelBean : agent.getDeploymentChannels()) {
DeploymentChannel deploymentChannelBD = null;
boolean existInBD = false;
if (deploymentChannelBean.getId() != null) {
Optional<DeploymentChannel> deploymentChannelFound = deploymentChannelRepository.findById(deploymentChannelBean.getId());
if (deploymentChannelFound.isPresent()) {
deploymentChannelBD = deploymentChannelFound.get();
existInBD = true;
}
}
......@@ -238,7 +247,6 @@ public class AgentService extends CustomPaginationService<Agent> {
}
deploymentChannelBD.setAgent(agentBD);
deploymentChannelBD.setName(deploymentChannelBean.getName());
deploymentChannelBD.setStatus(StatusEnum.fromString(deploymentChannelBean.getStatus()));
if (deploymentChannelBean.getChannelId() != null) {
......@@ -246,8 +254,12 @@ public class AgentService extends CustomPaginationService<Agent> {
if (channelFound.isPresent()) {
deploymentChannelBD.setChannel(channelFound.get());
if (!existInBD) {
deploymentChannelBD.setName(agentBD.getName() + "_" + channelFound.get().getName());
}
}
} else {
deploymentChannelBD.setName(agentBD.getName() + "_" + UUID.randomUUID());
deploymentChannelBD.setChannel(null);
}
......@@ -460,8 +472,8 @@ public class AgentService extends CustomPaginationService<Agent> {
}
frequentQuestion.setStatus(FrequentQuestionStatusEnum.UPLOADED);
frequentQuestion.setUser(user);
frequentQuestion.setUploadDate(LocalDateTime.now());
//frequentQuestion.setUser(user);
//frequentQuestion.setUploadDate(LocalDateTime.now());
frequentQuestionRepository.save(frequentQuestion);
}
......
......@@ -14,7 +14,9 @@ import com.bytesw.bytebot.repository.QuestionFileRepository;
import com.bytesw.bytebot.utils.Utilities;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
......@@ -197,12 +199,20 @@ public class FileManagementService {
response.setUuid(questionFileBD.getUuid());
response.setFileName(questionFileBD.getName());
response.setStatus(FrequentQuestionStatusEnum.PENDING_SYNCHRONIZED.getName());
response.setUploadDate(getUploadDate(questionFileBD.getUploadDate()));
response.setFileValidationResult(result);
return response;
}
private String getUploadDate(LocalDateTime uploadDate) {
if (uploadDate != null) {
return uploadDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy"));
}
return null;
}
private Map<String, String> validateHeaders(List<String> headersList) {
Map<String, Integer> headerOcurrencesMap = new HashMap<>();
......
......@@ -4,7 +4,7 @@ server:
servlet.context-path: ${APPLICATION_PATH:/bytebot}
port: ${APPLICATION_PORT:9077}
web:
static-content-location: file:/home/hernan/java-projects/byte-projects/BYTEBOT/bytebot-projects/dist/bytebot-html/
static-content-location: file:/home/agutierrez/Documentos/Proyectos/BYTE_BOT/bytebot-workspace/dist/bytebot-html/
#NOTA debe terminar con /
security:
......@@ -24,6 +24,7 @@ management:
web.exposure.include: "*"
application:
show-side-bar: false
test: ENC(OEchnTXpIZnCVdPNthgCZBfQjMt1AUS1)
name: xdf-example
license:
......@@ -53,7 +54,7 @@ application:
security-exclude: /service/oauth/userinfo, /actuator/**, /mylogout, /login, /logout, /goodbye, /error, /anon, /cache.manifest, /favicon.ico, /service/file, /goodbye
messaging:
queue-support: activemq
multi-tenant: false
multi-tenant: true
clustering: true
database: true
send-email: false
......@@ -66,10 +67,10 @@ application:
topic-test: topic-test
bytebot-integration:
ftp:
host: 192.168.27.36
username: testuser
password: byte2k20
directory: uploadFS/IMG/
host: localhost
username: ftp
password: ftp
directory: uploadBYTEBOT/IMG/
# email.info:
# smtp:
# host: smtp.gmail.com
......@@ -93,29 +94,67 @@ spring:
mbeans.exclude: dataSource
application:
name: xdf-example
datasource:
database-type: mysql
schemaName: BYTEBOT
url: jdbc:mysql://localhost:43306/BYTEBOT?useSSL=false
schemaName: BYTEBOT_BASE
url: jdbc:mysql://localhost:3306/BYTEBOT_BASE?useSSL=false
driverClassName: 'com.mysql.cj.jdbc.Driver'
username: BYTEBOT
password: BYTEBOT
username: root
password: secret
minimum-idle: 10
maximum-pool-size: 10
validationQuery: SELECT 1
testWhileIdle: true
hikari.registerMbeans: true
security:
basepath: http://localhost:9077/bytebot
provider: byte # oracle, amazon
oauth2-client:
clientId: xdf-client
clientSecret: xdf-secret
accessTokenUri: http://cdb.tigo.bfm:8080/oauth/token
userAuthorizationUri: http://cdb.tigo.bfm:8080/oauth/authorize
oauth2-resource:
userInfoUri: http://cdb.tigo.bfm:8080/oauth/userinfo
logoutUri: http://cdb.tigo.bfm:8080/oauth/userlogout
tenants:
-
id: T186A1
servername: cdb.bytebot.t186a1
datasource:
url: jdbc:mysql://localhost:3306/BYTEBOT_T186A1
username: root
password: secret
minimum-idle: 10
maximum-pool-size: 100
validationQuery: SELECT 1
testWhileIdle: true
hikari.registerMbeans: true
security:
basepath: http://cdb.bytebot.t186a1:9077/bytebot
provider: byte # oracle, amazon
oauth2-client:
clientId: xdf-client
clientSecret: xdf-secret
accessTokenUri: http://cdb.bytebot.sso:8080/oauth/token
userAuthorizationUri: http://cdb.bytebot.sso:8080/oauth/authorize
oauth2-resource:
userInfoUri: http://cdb.bytebot.sso:8080/oauth/userinfo
logoutUri: http://cdb.bytebot.sso:8080/oauth/userlogout
-
id: T186A2
servername: cdb.bytebot.local
datasource:
url: jdbc:mysql://localhost:3306/BYTEBOT_T186A2
username: root
password: secret
minimum-idle: 10
maximum-pool-size: 100
validationQuery: SELECT 1
testWhileIdle: true
hikari.registerMbeans: true
security:
basepath: http://cdb.bytebot.local:9077/bytebot
provider: byte # oracle, amazon
oauth2-client:
clientId: xdf-client
clientSecret: xdf-secret
accessTokenUri: http://cdb.bytebot.sso:8080/oauth/token
userAuthorizationUri: http://cdb.bytebot.sso:8080/oauth/authorize
oauth2-resource:
userInfoUri: http://cdb.bytebot.sso:8080/oauth/userinfo
logoutUri: http://cdb.bytebot.sso:8080/oauth/userlogout
jpa:
open-in-view: false
properties.hibernate:
......@@ -142,8 +181,8 @@ logging.level.com.github.alturkovic.lock: ERROR
logging.level.com.ulisesbocchio.jasyptspringboot: ERROR
logging.level.org.hibernate.SQL: ERROR
logging.level.org.hibernate.type: ERROR
logging.level.net.sf.hibernate.type: ERROR
logging.level.org.hibernate.SQL: TRACE
logging.level.org.hibernate.type: TRACE
logging.level.net.sf.hibernate.type: TRACE
jasypt.encryptor.password: 179CD78D24F9BC63D6E677272D1A7
jasypt.encryptor.password: 179CD78D24F9BC63D6E677272D1A7
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment