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