123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424 |
- package cn.keking.config;
- import cn.keking.utils.ConfigUtils;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.stereotype.Component;
- import java.io.File;
- import java.util.Arrays;
- import java.util.Set;
- import java.util.concurrent.CopyOnWriteArraySet;
- /**
- * @author: chenjh
- * @since: 2019/4/10 17:22
- */
- @Component
- public class ConfigConstants {
- static {
- //pdfbox兼容低版本jdk
- System.setProperty("sun.java2d.cmm", "sun.java2d.cmm.kcms.KcmsServiceProvider");
- }
- private static Boolean cacheEnabled;
- private static String[] simTexts = {};
- private static String[] medias = {};
- private static String[] convertMedias = {};
- private static String mediaConvertDisable;
- private static String officePreviewType;
- private static String officePreviewSwitchDisabled;
- private static String ftpUsername;
- private static String ftpPassword;
- private static String ftpControlEncoding;
- private static String baseUrl;
- private static String fileDir = ConfigUtils.getHomePath() + File.separator + "file" + File.separator;
- private static String localPreviewDir;
- private static CopyOnWriteArraySet<String> trustHostSet;
- private static String pdfPresentationModeDisable;
- private static String pdfOpenFileDisable;
- private static String pdfPrintDisable;
- private static String pdfDownloadDisable;
- private static String pdfBookmarkDisable;
- private static Boolean fileUploadDisable;
- private static String tifPreviewType;
- private static String BeiAn;
- private static String[] prohibit= {};
- private static String size;
- private static String password;
- private static Boolean deletesourcefile;
- 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_LOCAL_PREVIEW_DIR_VALUE = "default";
- public static final String DEFAULT_TRUST_HOST = "default";
- public static final String DEFAULT_PDF_PRESENTATION_MODE_DISABLE = "true";
- public static final String DEFAULT_PDF_OPEN_FILE_DISABLE = "true";
- public static final String DEFAULT_PDF_PRINT_DISABLE = "true";
- public static final String DEFAULT_PDF_DOWNLOAD_DISABLE = "true";
- public static final String DEFAULT_PDF_BOOKMARK_DISABLE = "true";
- public static final String DEFAULT_FILE_UPLOAD_DISABLE = "false";
- public static final String DEFAULT_TIF_PREVIEW_TYPE = "tif";
- public static final String DEFAULT_BeiAn_DISABLE = "无";
- public static final String DEFAULT_size_DISABLE = "500MB";
- public static final String DEFAULT_prohibit_DISABLE = "exe,dll";
- public static final String DEFAULT_password_DISABLE = "123456";
- public static final String DEFAULT_Delete_Source_File_PREVIEW_TYPE = "true";
- public static Boolean isCacheEnabled() {
- return cacheEnabled;
- }
- @Value("${cache.enabled:true}")
- public void setCacheEnabled(String cacheEnabled) {
- setCacheEnabledValueValue(Boolean.parseBoolean(cacheEnabled));
- }
- public static void setCacheEnabledValueValue(Boolean cacheEnabled) {
- ConfigConstants.cacheEnabled = cacheEnabled;
- }
- public static String[] getSimText() {
- return simTexts;
- }
- @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) {
- ConfigConstants.simTexts = simText;
- }
- public static String[] getMedia() {
- return medias;
- }
- @Value("${media:mp3,wav,mp4,flv}")
- public void setMedia(String media) {
- String[] mediaArr = media.split(",");
- setMediaValue(mediaArr);
- }
- public static void setMediaValue(String[] Media) {
- ConfigConstants.medias = Media;
- }
- public static String[] getConvertMedias() {
- return convertMedias;
- }
- @Value("${convertMedias:avi,mov,wmv,mkv,3gp,rm}")
- public void setConvertMedias(String convertMedia) {
- String[] mediaArr = convertMedia.split(",");
- setConvertMediaValue(mediaArr);
- }
- public static void setConvertMediaValue(String[] ConvertMedia) {
- ConfigConstants.convertMedias = ConvertMedia;
- }
- public static String getMediaConvertDisable() {
- return mediaConvertDisable;
- }
- @Value("${media.convert.disable:true}")
- public void setMediaConvertDisable(String mediaConvertDisable) {
- setMediaConvertDisableValue(mediaConvertDisable);
- }
- public static void setMediaConvertDisableValue(String mediaConvertDisable) {
- ConfigConstants.mediaConvertDisable = mediaConvertDisable;
- }
- public static String getOfficePreviewType() {
- return officePreviewType;
- }
- @Value("${office.preview.type:image}")
- public void setOfficePreviewType(String officePreviewType) {
- setOfficePreviewTypeValue(officePreviewType);
- }
- public static void setOfficePreviewTypeValue(String officePreviewType) {
- ConfigConstants.officePreviewType = officePreviewType;
- }
- public static String getFtpUsername() {
- return ftpUsername;
- }
- @Value("${ftp.username:}")
- public void setFtpUsername(String ftpUsername) {
- setFtpUsernameValue(ftpUsername);
- }
- public static void setFtpUsernameValue(String ftpUsername) {
- ConfigConstants.ftpUsername = ftpUsername;
- }
- public static String getFtpPassword() {
- return ftpPassword;
- }
- @Value("${ftp.password:}")
- public void setFtpPassword(String ftpPassword) {
- setFtpPasswordValue(ftpPassword);
- }
- public static void setFtpPasswordValue(String ftpPassword) {
- ConfigConstants.ftpPassword = ftpPassword;
- }
- public static String getFtpControlEncoding() {
- return ftpControlEncoding;
- }
- @Value("${ftp.control.encoding:UTF-8}")
- public void setFtpControlEncoding(String ftpControlEncoding) {
- setFtpControlEncodingValue(ftpControlEncoding);
- }
- public static void setFtpControlEncodingValue(String ftpControlEncoding) {
- ConfigConstants.ftpControlEncoding = ftpControlEncoding;
- }
- public static String getBaseUrl() {
- return baseUrl;
- }
- @Value("${base.url:default}")
- public void setBaseUrl(String baseUrl) {
- setBaseUrlValue(baseUrl);
- }
- public static void setBaseUrlValue(String baseUrl) {
- ConfigConstants.baseUrl = baseUrl;
- }
- public static String getFileDir() {
- return fileDir;
- }
- @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;
- }
- ConfigConstants.fileDir = fileDir;
- }
- }
- public static String getLocalPreviewDir() {
- return localPreviewDir;
- }
- @Value("${local.preview.dir:default}")
- public void setLocalPreviewDir(String localPreviewDir) {
- setLocalPreviewDirValue(localPreviewDir);
- }
- public static void setLocalPreviewDirValue(String localPreviewDir) {
- if (!DEFAULT_LOCAL_PREVIEW_DIR_VALUE.equals(localPreviewDir)) {
- if (!localPreviewDir.endsWith(File.separator)) {
- localPreviewDir = localPreviewDir + File.separator;
- }
- }
- ConfigConstants.localPreviewDir = localPreviewDir;
- }
- @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 trustHostSet;
- }
- private static void setTrustHostSet(CopyOnWriteArraySet<String> trustHostSet) {
- ConfigConstants.trustHostSet = trustHostSet;
- }
- public static String getPdfPresentationModeDisable() {
- return pdfPresentationModeDisable;
- }
- @Value("${pdf.presentationMode.disable:true}")
- public void setPdfPresentationModeDisable(String pdfPresentationModeDisable) {
- setPdfPresentationModeDisableValue(pdfPresentationModeDisable);
- }
- public static void setPdfPresentationModeDisableValue(String pdfPresentationModeDisable) {
- ConfigConstants.pdfPresentationModeDisable = pdfPresentationModeDisable;
- }
- public static String getPdfOpenFileDisable() {
- return pdfOpenFileDisable;
- }
- @Value("${pdf.openFile.disable:true}")
- public void setPdfOpenFileDisable(String pdfOpenFileDisable) {
- setPdfOpenFileDisableValue(pdfOpenFileDisable);
- }
- public static void setPdfOpenFileDisableValue(String pdfOpenFileDisable) {
- ConfigConstants.pdfOpenFileDisable = pdfOpenFileDisable;
- }
- public static String getPdfPrintDisable() {
- return pdfPrintDisable;
- }
- @Value("${pdf.print.disable:true}")
- public void setPdfPrintDisable(String pdfPrintDisable) {
- setPdfPrintDisableValue(pdfPrintDisable);
- }
- public static void setPdfPrintDisableValue(String pdfPrintDisable) {
- ConfigConstants.pdfPrintDisable = pdfPrintDisable;
- }
- public static String getPdfDownloadDisable() {
- return pdfDownloadDisable;
- }
- @Value("${pdf.download.disable:true}")
- public void setPdfDownloadDisable(String pdfDownloadDisable) {
- setPdfDownloadDisableValue(pdfDownloadDisable);
- }
- public static void setPdfDownloadDisableValue(String pdfDownloadDisable) {
- ConfigConstants.pdfDownloadDisable = pdfDownloadDisable;
- }
- public static String getPdfBookmarkDisable() {
- return pdfBookmarkDisable;
- }
- @Value("${pdf.bookmark.disable:true}")
- public void setPdfBookmarkDisable(String pdfBookmarkDisable) {
- setPdfBookmarkDisableValue(pdfBookmarkDisable);
- }
- public static void setPdfBookmarkDisableValue(String pdfBookmarkDisable) {
- ConfigConstants.pdfBookmarkDisable = pdfBookmarkDisable;
- }
- public static String getOfficePreviewSwitchDisabled() {
- return officePreviewSwitchDisabled;
- }
- @Value("${office.preview.switch.disabled:true}")
- public void setOfficePreviewSwitchDisabled(String officePreviewSwitchDisabled) {
- ConfigConstants.officePreviewSwitchDisabled = officePreviewSwitchDisabled;
- }
- public static void setOfficePreviewSwitchDisabledValue(String officePreviewSwitchDisabled) {
- ConfigConstants.officePreviewSwitchDisabled = officePreviewSwitchDisabled;
- }
- public static Boolean getFileUploadDisable() {
- return fileUploadDisable;
- }
- @Value("${file.upload.disable:false}")
- public void setFileUploadDisable(Boolean fileUploadDisable) {
- setFileUploadDisableValue(fileUploadDisable);
- }
- public static void setFileUploadDisableValue(Boolean fileUploadDisable) {
- ConfigConstants.fileUploadDisable = fileUploadDisable;
- }
- public static String getTifPreviewType() {
- return tifPreviewType;
- }
- @Value("${tif.preview.type:tif}")
- public void setTifPreviewType(String tifPreviewType) {
- setTifPreviewTypeValue(tifPreviewType);
- }
- public static void setTifPreviewTypeValue(String tifPreviewType) {
- ConfigConstants.tifPreviewType = tifPreviewType;
- }
- public static String getBeiAn() {
- return BeiAn;
- }
- @Value("${BeiAn:无}")
- public void setBeiAn(String BeiAn) {
- setBeiAnValue(BeiAn);
- }
- public static void setBeiAnValue(String BeiAn) {
- ConfigConstants.BeiAn = BeiAn;
- }
- public static String[] getprohibit() {
- return prohibit;
- }
- @Value("${prohibit:exe,dll}")
- public void setprohibit(String prohibit) {
- String[] prohibittArr = prohibit.split(",");
- setprohibitValue(prohibittArr);
- }
- public static void setprohibitValue(String[] prohibit) {
- ConfigConstants.prohibit = prohibit;
- }
- public static String maxsize() {
- return size;
- }
- @Value("${spring.servlet.multipart.max-file-size:500MB}")
- public void setsize(String size) {
- setsizeValue(size);
- }
- public static void setsizeValue(String size) {
- ConfigConstants.size = size;
- }
- public static String getpassword() {
- return password;
- }
- @Value("${sc.password:123456}")
- public void setpassword(String password) {
- setpasswordValue(password);
- }
- public static void setpasswordValue(String password) {
- ConfigConstants.password = password;
- }
- public static Boolean getdeletesourcefile() {
- return deletesourcefile;
- }
- @Value("${delete.source.file:true}")
- public void setdeletesourcefile(Boolean deletesourcefile) {
- setdeletesourcefileValue(deletesourcefile);
- }
- public static void setdeletesourcefileValue(Boolean deletesourcefile) {
- ConfigConstants.deletesourcefile = deletesourcefile;
- }
- }
|