Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ejercicio2-framework-back
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Josue
ejercicio2-framework-back
Commits
7dd9e1b1
Commit
7dd9e1b1
authored
Oct 21, 2020
by
Aaron Gutierrez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mejoras y corrección de errores BYTEBOT WEB
parent
8e2cd9d8
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
128 additions
and
33 deletions
+128
-33
ChannelBean.java
src/main/java/com/bytesw/bytebot/bean/ChannelBean.java
+8
-0
ChannelParamBean.java
src/main/java/com/bytesw/bytebot/bean/ChannelParamBean.java
+4
-0
AgentController.java
...n/java/com/bytesw/bytebot/controller/AgentController.java
+9
-4
FileValidationResponse.java
.../java/com/bytesw/bytebot/http/FileValidationResponse.java
+4
-0
Channel.java
src/main/java/com/bytesw/bytebot/model/Channel.java
+6
-0
ChannelParam.java
src/main/java/com/bytesw/bytebot/model/ChannelParam.java
+2
-0
QuestionFileRepository.java
...com/bytesw/bytebot/repository/QuestionFileRepository.java
+6
-1
AgentService.java
src/main/java/com/bytesw/bytebot/service/AgentService.java
+15
-3
FileManagementService.java
...ava/com/bytesw/bytebot/service/FileManagementService.java
+10
-0
application.yml
src/main/resources/application.yml
+64
-25
No files found.
src/main/java/com/bytesw/bytebot/bean/ChannelBean.java
View file @
7dd9e1b1
...
...
@@ -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
)
{
...
...
src/main/java/com/bytesw/bytebot/bean/ChannelParamBean.java
View file @
7dd9e1b1
...
...
@@ -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
;
}
...
...
src/main/java/com/bytesw/bytebot/controller/AgentController.java
View file @
7dd9e1b1
...
...
@@ -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 {
}
}
@P
os
tMapping
(
value
=
"/"
)
@P
u
tMapping
(
value
=
"/"
)
@PreAuthorize
(
"hasPermission(this, 'new')"
)
public
ResponseEntity
<
String
>
createConversationalAgent
(
@RequestBody
AgentBean
agentBean
)
{
...
...
@@ -87,7 +91,7 @@ public class AgentController {
}
}
@P
os
tMapping
(
value
=
"/{id}"
)
@P
u
tMapping
(
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
();
...
...
src/main/java/com/bytesw/bytebot/http/FileValidationResponse.java
View file @
7dd9e1b1
...
...
@@ -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
;
}
src/main/java/com/bytesw/bytebot/model/Channel.java
View file @
7dd9e1b1
...
...
@@ -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
;
}
src/main/java/com/bytesw/bytebot/model/ChannelParam.java
View file @
7dd9e1b1
...
...
@@ -60,4 +60,6 @@ public class ChannelParam {
@Column
(
name
=
"CHPA_MAXLE"
)
private
Integer
maxlength
;
@Column
(
name
=
"CHPA_REGEX"
)
private
String
regex
;
}
src/main/java/com/bytesw/bytebot/repository/QuestionFileRepository.java
View file @
7dd9e1b1
...
...
@@ -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
);
}
src/main/java/com/bytesw/bytebot/service/AgentService.java
View file @
7dd9e1b1
...
...
@@ -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
);
}
...
...
src/main/java/com/bytesw/bytebot/service/FileManagementService.java
View file @
7dd9e1b1
...
...
@@ -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
<>();
...
...
src/main/resources/application.yml
View file @
7dd9e1b1
...
...
@@ -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
:
fals
e
multi-tenant
:
tru
e
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
:
upload
FS
/IMG/
host
:
localhost
username
:
ftp
password
:
ftp
directory
:
upload
BYTEBOT
/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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment