mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-03-14 05:03:49 +08:00
调整项目模块,jodconverter-core重命名为office-plugin。jdocnverter-web重命名为server
This commit is contained in:
217
server/src/main/java/cn/keking/config/ConfigConstants.java
Normal file
217
server/src/main/java/cn/keking/config/ConfigConstants.java
Normal file
@@ -0,0 +1,217 @@
|
||||
package cn.keking.config;
|
||||
|
||||
import org.artofsolving.jodconverter.util.ConfigUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author: chenjh
|
||||
* @since: 2019/4/10 17:22
|
||||
*/
|
||||
@Component
|
||||
public class ConfigConstants {
|
||||
|
||||
private static Boolean CACHE_ENABLED;
|
||||
private static String[] SIM_TEXT = {};
|
||||
private static String[] MEDIA = {};
|
||||
private static String OFFICE_PREVIEW_TYPE;
|
||||
private static String OFFICE_PREVIEW_SWITCH_DISABLED;
|
||||
private static String FTP_USERNAME;
|
||||
private static String FTP_PASSWORD;
|
||||
private static String FTP_CONTROL_ENCODING;
|
||||
private static String BASE_URL;
|
||||
private static String FILE_DIR = ConfigUtils.getHomePath() + File.separator + "file" + File.separator;
|
||||
private static CopyOnWriteArraySet<String> TRUST_HOST_SET;
|
||||
private static String PDF_DOWNLOAD_DISABLE;
|
||||
|
||||
public static final String DEFAULT_CACHE_ENABLED = "true";
|
||||
public static final String DEFAULT_TXT_TYPE = "txt,html,htm,asp,jsp,xml,json,properties,md,gitignore,log,java,py,c,cpp,sql,sh,bat,m,bas,prg,cmd";
|
||||
public static final String DEFAULT_MEDIA_TYPE = "mp3,wav,mp4,flv";
|
||||
public static final String DEFAULT_OFFICE_PREVIEW_TYPE = "image";
|
||||
public static final String DEFAULT_OFFICE_PREVIEW_SWITCH_DISABLED = "false";
|
||||
public static final String DEFAULT_FTP_USERNAME = null;
|
||||
public static final String DEFAULT_FTP_PASSWORD = null;
|
||||
public static final String DEFAULT_FTP_CONTROL_ENCODING = "UTF-8";
|
||||
public static final String DEFAULT_BASE_URL = "default";
|
||||
public static final String DEFAULT_FILE_DIR_VALUE = "default";
|
||||
public static final String DEFAULT_TRUST_HOST = "default";
|
||||
public static final String DEFAULT_PDF_DOWNLOAD_DISABLE = "true";
|
||||
|
||||
public static Boolean isCacheEnabled() {
|
||||
return CACHE_ENABLED;
|
||||
}
|
||||
|
||||
@Value("${cache.enabled:true}")
|
||||
public void setCacheEnabled(String cacheEnabled) {
|
||||
setCacheEnabledValueValue(Boolean.parseBoolean(cacheEnabled));
|
||||
}
|
||||
|
||||
public static void setCacheEnabledValueValue(Boolean cacheEnabled) {
|
||||
CACHE_ENABLED = cacheEnabled;
|
||||
}
|
||||
|
||||
public static String[] getSimText() {
|
||||
return SIM_TEXT;
|
||||
}
|
||||
|
||||
@Value("${simText:txt,html,htm,asp,jsp,xml,json,properties,md,gitignore,log,java,py,c,cpp,sql,sh,bat,m,bas,prg,cmd}")
|
||||
public void setSimText(String simText) {
|
||||
String[] simTextArr = simText.split(",");
|
||||
setSimTextValue(simTextArr);
|
||||
}
|
||||
|
||||
public static void setSimTextValue(String[] simText) {
|
||||
SIM_TEXT = simText;
|
||||
}
|
||||
|
||||
public static String[] getMedia() {
|
||||
return MEDIA;
|
||||
}
|
||||
|
||||
@Value("${media:mp3,wav,mp4,flv}")
|
||||
public void setMedia(String media) {
|
||||
String[] mediaArr = media.split(",");
|
||||
setMediaValue(mediaArr);
|
||||
}
|
||||
|
||||
public static void setMediaValue(String[] Media) {
|
||||
MEDIA = Media;
|
||||
}
|
||||
|
||||
public static String getOfficePreviewType() {
|
||||
return OFFICE_PREVIEW_TYPE;
|
||||
}
|
||||
|
||||
@Value("${office.preview.type:image}")
|
||||
public void setOfficePreviewType(String officePreviewType) {
|
||||
setOfficePreviewTypeValue(officePreviewType);
|
||||
}
|
||||
|
||||
public static void setOfficePreviewTypeValue(String officePreviewType) {
|
||||
OFFICE_PREVIEW_TYPE = officePreviewType;
|
||||
}
|
||||
|
||||
public static String getFtpUsername() {
|
||||
return FTP_USERNAME;
|
||||
}
|
||||
|
||||
@Value("${ftp.username:}")
|
||||
public void setFtpUsername(String ftpUsername) {
|
||||
setFtpUsernameValue(ftpUsername);
|
||||
}
|
||||
|
||||
public static void setFtpUsernameValue(String ftpUsername) {
|
||||
FTP_USERNAME = ftpUsername;
|
||||
}
|
||||
|
||||
public static String getFtpPassword() {
|
||||
return FTP_PASSWORD;
|
||||
}
|
||||
|
||||
@Value("${ftp.password:}")
|
||||
public void setFtpPassword(String ftpPassword) {
|
||||
setFtpPasswordValue(ftpPassword);
|
||||
}
|
||||
|
||||
public static void setFtpPasswordValue(String ftpPassword) {
|
||||
FTP_PASSWORD = ftpPassword;
|
||||
}
|
||||
|
||||
public static String getFtpControlEncoding() {
|
||||
return FTP_CONTROL_ENCODING;
|
||||
}
|
||||
|
||||
@Value("${ftp.control.encoding:UTF-8}")
|
||||
public void setFtpControlEncoding(String ftpControlEncoding) {
|
||||
setFtpControlEncodingValue(ftpControlEncoding);
|
||||
}
|
||||
|
||||
public static void setFtpControlEncodingValue(String ftpControlEncoding) {
|
||||
FTP_CONTROL_ENCODING = ftpControlEncoding;
|
||||
}
|
||||
|
||||
public static String getBaseUrl() {
|
||||
return BASE_URL;
|
||||
}
|
||||
|
||||
@Value("${base.url:default}")
|
||||
public void setBaseUrl(String baseUrl) {
|
||||
setBaseUrlValue(baseUrl);
|
||||
}
|
||||
|
||||
public static void setBaseUrlValue(String baseUrl) {
|
||||
BASE_URL = baseUrl;
|
||||
}
|
||||
|
||||
public static String getFileDir() {
|
||||
return FILE_DIR;
|
||||
}
|
||||
|
||||
@Value("${file.dir:default}")
|
||||
public void setFileDir(String fileDir) {
|
||||
setFileDirValue(fileDir);
|
||||
}
|
||||
|
||||
public static void setFileDirValue(String fileDir) {
|
||||
if (!DEFAULT_FILE_DIR_VALUE.equalsIgnoreCase(fileDir)) {
|
||||
if (!fileDir.endsWith(File.separator)) {
|
||||
fileDir = fileDir + File.separator;
|
||||
}
|
||||
FILE_DIR = fileDir;
|
||||
}
|
||||
}
|
||||
|
||||
@Value("${trust.host:default}")
|
||||
public void setTrustHost(String trustHost) {
|
||||
setTrustHostValue(trustHost);
|
||||
}
|
||||
|
||||
public static void setTrustHostValue(String trustHost) {
|
||||
CopyOnWriteArraySet<String> trustHostSet;
|
||||
if (DEFAULT_TRUST_HOST.equalsIgnoreCase(trustHost)) {
|
||||
trustHostSet = new CopyOnWriteArraySet<>();
|
||||
} else {
|
||||
String[] trustHostArray = trustHost.toLowerCase().split(",");
|
||||
trustHostSet = new CopyOnWriteArraySet<>(Arrays.asList(trustHostArray));
|
||||
setTrustHostSet(trustHostSet);
|
||||
}
|
||||
setTrustHostSet(trustHostSet);
|
||||
}
|
||||
|
||||
public static Set<String> getTrustHostSet() {
|
||||
return TRUST_HOST_SET;
|
||||
}
|
||||
|
||||
private static void setTrustHostSet(CopyOnWriteArraySet<String> trustHostSet) {
|
||||
ConfigConstants.TRUST_HOST_SET = trustHostSet;
|
||||
}
|
||||
|
||||
public static String getPdfDownloadDisable() {
|
||||
return PDF_DOWNLOAD_DISABLE;
|
||||
}
|
||||
|
||||
|
||||
@Value("${pdf.download.disable:true}")
|
||||
public void setPdfDownloadDisable(String pdfDownloadDisable) {
|
||||
setPdfDownloadDisableValue(pdfDownloadDisable);
|
||||
}
|
||||
public static void setPdfDownloadDisableValue(String pdfDownloadDisable) {
|
||||
PDF_DOWNLOAD_DISABLE = pdfDownloadDisable;
|
||||
}
|
||||
|
||||
public static String getOfficePreviewSwitchDisabled() {
|
||||
return OFFICE_PREVIEW_SWITCH_DISABLED;
|
||||
}
|
||||
@Value("${office.preview.switch.disabled:true}")
|
||||
public void setOfficePreviewSwitchDisabled(String officePreviewSwitchDisabled) {
|
||||
OFFICE_PREVIEW_SWITCH_DISABLED = officePreviewSwitchDisabled;
|
||||
}
|
||||
public static void setOfficePreviewSwitchDisabledValue(String officePreviewSwitchDisabled) {
|
||||
OFFICE_PREVIEW_SWITCH_DISABLED = officePreviewSwitchDisabled;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user