Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
slm-fileview
Project
Project
Details
Activity
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
jenkins
slm-fileview
Commits
5af3a977
Commit
5af3a977
authored
Apr 11, 2019
by
陈精华
Committed by
kl
Apr 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持部分配置在运行时动态改变
parent
bf08c2c2
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
131 additions
and
12 deletions
+131
-12
pom.xml
jodconverter-web/pom.xml
+0
-3
startup.bat
jodconverter-web/src/main/bin/startup.bat
+2
-2
startup.sh
jodconverter-web/src/main/bin/startup.sh
+2
-2
application.properties
jodconverter-web/src/main/conf/application.properties
+10
-5
ConfigConstants.java
...r-web/src/main/java/cn/keking/config/ConfigConstants.java
+38
-0
ConfigRefreshComponent.java
...rc/main/java/cn/keking/config/ConfigRefreshComponent.java
+69
-0
FileUtils.java
...onverter-web/src/main/java/cn/keking/utils/FileUtils.java
+10
-0
No files found.
jodconverter-web/pom.xml
View file @
5af3a977
...
@@ -164,9 +164,6 @@
...
@@ -164,9 +164,6 @@
</includes>
</includes>
<filtering>
true
</filtering>
<filtering>
true
</filtering>
</resource>
</resource>
<resource>
<directory>
src/main/conf
</directory>
</resource>
</resources>
</resources>
<plugins>
<plugins>
<plugin>
<plugin>
...
...
jodconverter-web/src/main/bin/startup.bat
View file @
5af3a977
java -jar jodconverter-web-1.5.8.RELEASE.jar -> ..\\log\\kkFileView.log
java -Dspring.config.location=..\conf\application.properties -jar jodconverter-web-1.5.8.RELEASE.jar -> ..\log\kkFileView.log
\ No newline at end of file
\ No newline at end of file
jodconverter-web/src/main/bin/startup.sh
View file @
5af3a977
#!/bin/bash
#!/bin/bash
nohup
java
-jar
jodconverter-web-1.5.8.RELEASE.jar ../log/kkFileView.log 2>&1 &
nohup
java
-Dspring
.config.location
=
../conf/application.properties
-jar
jodconverter-web-1.5.8.RELEASE.jar ../log/kkFileView.log 2>&1 &
\ No newline at end of file
\ No newline at end of file
jodconverter-web/src/main/conf/application.properties
View file @
5af3a977
#######################################不可动态配置,需要重启生效#######################################
server.port
=
8012
server.port
=
8012
spring.http.encoding.charset
=
utf8
spring.http.encoding.charset
=
utf8
## Freemarker 配置
## Freemarker 配置
...
@@ -17,14 +18,18 @@ spring.resources.static-locations = classpath:/META-INF/resources/,classpath:/re
...
@@ -17,14 +18,18 @@ spring.resources.static-locations = classpath:/META-INF/resources/,classpath:/re
## openoffice home路径
## openoffice home路径
office.home
=
C:
\\
Program Files (x86)
\\
OpenOffice 4
office.home
=
C:
\\
Program Files (x86)
\\
OpenOffice 4
server.tomcat.uri-encoding
=
UTF-8
server.tomcat.uri-encoding
=
UTF-8
converted.file.charset
=
GBK
#文件上传限制
#文件上传限制
spring.http.multipart.max-file-size
=
100MB
spring.http.multipart.max-file-size
=
100MB
##文本类型
simText
=
txt,html,xml,java,properties,mp3,mp4,sql
#多媒体类型
media
=
mp3,mp4,flv,
#缓存实现类型,不配默认为JDK实现,可配置为redis实现(需要配置spring.redisson.address等参数)
#缓存实现类型,不配默认为JDK实现,可配置为redis实现(需要配置spring.redisson.address等参数)
#cache.type = redis
#cache.type = redis
#redis连接
#redis连接
#spring.redisson.address = 192.168.1.204:6379
#spring.redisson.address = 192.168.1.204:6379
#######################################可在运行时动态配置#######################################
##文本类型
simText
=
txt,html,xml,java,properties,mp3,mp4,sql
#多媒体类型
media
=
mp3,mp4,flv,
#文件转换编码
converted.file.charset
=
GBK
jodconverter-web/src/main/java/cn/keking/config/ConfigConstants.java
0 → 100644
View file @
5af3a977
package
cn
.
keking
.
config
;
/**
* @auther: chenjh
* @time: 2019/4/10 17:22
* @description
*/
public
class
ConfigConstants
{
private
static
String
[]
simText
=
{};
private
static
String
[]
media
=
{};
private
static
String
convertedFileCharset
;
public
static
String
[]
getSimText
()
{
return
simText
;
}
public
static
void
setSimText
(
String
[]
simText
)
{
ConfigConstants
.
simText
=
simText
;
}
public
static
String
[]
getMedia
()
{
return
media
;
}
public
static
void
setMedia
(
String
[]
media
)
{
ConfigConstants
.
media
=
media
;
}
public
static
String
getConvertedFileCharset
()
{
return
convertedFileCharset
;
}
public
static
void
setConvertedFileCharset
(
String
convertedFileCharset
)
{
ConfigConstants
.
convertedFileCharset
=
convertedFileCharset
;
}
}
jodconverter-web/src/main/java/cn/keking/config/ConfigRefreshComponent.java
0 → 100644
View file @
5af3a977
package
cn
.
keking
.
config
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.util.Properties
;
/**
* @auther: chenjh
* @time: 2019/4/10 16:16
* @description 每隔1s读取并更新一次配置文件
*/
@Component
public
class
ConfigRefreshComponent
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ConfigRefreshComponent
.
class
);
@PostConstruct
void
refresh
()
{
Thread
configRefreshThread
=
new
Thread
(
new
ConfigRefreshThread
());
configRefreshThread
.
start
();
}
class
ConfigRefreshThread
implements
Runnable
{
@Override
public
void
run
()
{
try
{
Properties
properties
=
new
Properties
();
String
userDir
=
System
.
getProperty
(
"user.dir"
);
Properties
properties1
=
System
.
getProperties
();
if
(
userDir
.
endsWith
(
"bin"
))
{
userDir
=
userDir
.
substring
(
0
,
userDir
.
length
()
-
4
);
}
String
separator
=
java
.
io
.
File
.
separator
;
String
configFilePath
=
userDir
+
separator
+
"conf"
+
separator
+
"application.properties"
;
File
file
=
new
File
(
configFilePath
);
if
(!
file
.
exists
())
{
configFilePath
=
userDir
+
separator
+
"jodconverter-web"
+
separator
+
"src"
+
separator
+
"main"
+
separator
+
"conf"
+
separator
+
"application.properties"
;
}
String
text
=
null
;
String
media
=
null
;
String
convertedFileCharset
=
null
;
String
[]
textArray
=
{};
String
[]
mediaArray
=
{};
while
(
true
)
{
BufferedReader
bufferedReader
=
new
BufferedReader
(
new
FileReader
(
configFilePath
));
properties
.
load
(
bufferedReader
);
text
=
properties
.
get
(
"simText"
)
==
null
?
""
:
properties
.
get
(
"simText"
).
toString
();
media
=
properties
.
get
(
"media"
)
==
null
?
""
:
properties
.
get
(
"media"
).
toString
();
convertedFileCharset
=
properties
.
get
(
"converted.file.charset"
)
==
null
?
""
:
properties
.
get
(
"converted.file.charset"
).
toString
();
textArray
=
text
.
split
(
","
);
mediaArray
=
media
.
split
(
","
);
ConfigConstants
.
setSimText
(
textArray
);
ConfigConstants
.
setMedia
(
mediaArray
);
ConfigConstants
.
setConvertedFileCharset
(
convertedFileCharset
);
Thread
.
sleep
(
1000L
);
}
}
catch
(
IOException
|
InterruptedException
e
)
{
LOGGER
.
error
(
"读取配置文件异常:{}"
,
e
);
}
}
}
}
jodconverter-web/src/main/java/cn/keking/utils/FileUtils.java
View file @
5af3a977
package
cn
.
keking
.
utils
;
package
cn
.
keking
.
utils
;
import
cn.keking.config.ConfigConstants
;
import
cn.keking.model.FileAttribute
;
import
cn.keking.model.FileAttribute
;
import
cn.keking.model.FileType
;
import
cn.keking.model.FileType
;
import
cn.keking.service.cache.CacheService
;
import
cn.keking.service.cache.CacheService
;
...
@@ -63,6 +64,12 @@ public class FileUtils {
...
@@ -63,6 +64,12 @@ public class FileUtils {
* @return
* @return
*/
*/
public
FileType
typeFromUrl
(
String
url
)
{
public
FileType
typeFromUrl
(
String
url
)
{
if
(
ConfigConstants
.
getSimText
()
!=
null
&&
ConfigConstants
.
getSimText
().
length
>
0
)
{
simText
=
ConfigConstants
.
getSimText
();
}
if
(
ConfigConstants
.
getMedia
()
!=
null
&&
ConfigConstants
.
getMedia
().
length
>
0
)
{
media
=
ConfigConstants
.
getMedia
();
}
String
nonPramStr
=
url
.
substring
(
0
,
url
.
indexOf
(
"?"
)
!=
-
1
?
url
.
indexOf
(
"?"
)
:
url
.
length
());
String
nonPramStr
=
url
.
substring
(
0
,
url
.
indexOf
(
"?"
)
!=
-
1
?
url
.
indexOf
(
"?"
)
:
url
.
length
());
String
fileName
=
nonPramStr
.
substring
(
nonPramStr
.
lastIndexOf
(
"/"
)
+
1
);
String
fileName
=
nonPramStr
.
substring
(
nonPramStr
.
lastIndexOf
(
"/"
)
+
1
);
String
fileType
=
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
)
+
1
);
String
fileType
=
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
)
+
1
);
...
@@ -217,6 +224,9 @@ public class FileUtils {
...
@@ -217,6 +224,9 @@ public class FileUtils {
*/
*/
public
void
doActionConvertedFile
(
String
outFilePath
)
{
public
void
doActionConvertedFile
(
String
outFilePath
)
{
StringBuffer
sb
=
new
StringBuffer
();
StringBuffer
sb
=
new
StringBuffer
();
if
(
ConfigConstants
.
getConvertedFileCharset
()
!=
null
)
{
charset
=
ConfigConstants
.
getConvertedFileCharset
();
}
try
(
InputStream
inputStream
=
new
FileInputStream
(
outFilePath
);
try
(
InputStream
inputStream
=
new
FileInputStream
(
outFilePath
);
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
inputStream
,
charset
))){
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
inputStream
,
charset
))){
String
line
;
String
line
;
...
...
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