935090232@qq.com
2022-04-20 281dc31c4a4d4e2cf266dd65a470c7d29e4e7332
zq-erp/src/main/java/com/matrix/component/ueditor/ConfigManager.java
@@ -10,18 +10,20 @@
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;
import com.alibaba.fastjson.JSON;
import com.matrix.component.tools.JSONUtil;
import com.matrix.component.ueditor.define.ActionMap;
import com.matrix.core.tools.EnvironmentHolder;
import com.matrix.system.common.constance.PropertiesConstance;
import org.apache.commons.io.IOUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import com.matrix.core.tools.PropertiesUtil;
/**
 * 配置管理器
 *
 *
 * @author hancong03@baidu.com
 *
 */
@@ -37,16 +39,18 @@
   private final static String SCRAWL_FILE_NAME = "scrawl";
   // 远程图片抓取filename定义
   private final static String REMOTE_FILE_NAME = "remote";
   private final static String FILES_TORAGE_PATH ="file_storage_path";
   private UeditorProperties ueditorProperties = null;
   /*
    * 通过一个给定的路径构建一个配置管理器, 该管理器要求地址路径所在目录下必须存在config.properties文件
    */
   private ConfigManager(String rootPath, String contextPath, String uri) throws FileNotFoundException, IOException {
   private ConfigManager(String rootPath, String contextPath, String uri, UeditorProperties ueditorProperties ) throws FileNotFoundException, IOException {
      rootPath = rootPath.replace("\\", "/");
      this.ueditorProperties=ueditorProperties;
      this.rootPath = rootPath;
      this.contextPath = contextPath;
      if (contextPath.length() > 0) {
@@ -60,19 +64,20 @@
   /**
    * 配置管理器构造工厂
    *
    *
    * @param rootPath
    *            服务器根路径
    * @param contextPath
    *            服务器所在项目路径
    * @param uri
    *            当前访问的uri
    * @param ueditorProperties
    * @return 配置管理器实例或者null
    */
   public static ConfigManager getInstance(String rootPath, String contextPath, String uri) {
   public static ConfigManager getInstance(String rootPath, String contextPath, String uri, UeditorProperties ueditorProperties) {
      try {
         return new ConfigManager(rootPath, contextPath, uri);
         return new ConfigManager(rootPath, contextPath, uri,ueditorProperties);
      } catch (Exception e) {
         return null;
      }
@@ -152,7 +157,9 @@
      }
      conf.put("savePath", savePath);
      conf.put("rootPath", PropertiesUtil.getString(this.FILES_TORAGE_PATH));
      String fileStoragePath = EnvironmentHolder.getPropertis(PropertiesConstance.FILE_STORAGE_PATH);
      conf.put("rootPath",fileStoragePath);
      return conf;
@@ -170,8 +177,14 @@
      //String configContent = this.readFile(this.getConfigPath());
      String configContent = this.filter(IOUtils.toString(this.getClass().getClassLoader().getResourceAsStream("config/config.json")));
      try {
         JSONObject jsonConfig = new JSONObject(configContent);
         com.alibaba.fastjson.JSONObject extend = JSONUtil.extend(
               JSON.parseObject(configContent),
               JSON.parseObject(JSON.toJSONString(ueditorProperties)));
         jsonConfig=new JSONObject(extend.toJSONString());
         this.jsonConfig = jsonConfig;
      } catch (Exception e) {
         this.jsonConfig = null;