You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.9 KiB
86 lines
2.9 KiB
package com.fr.design.mainframe.share.config; |
|
|
|
import com.fr.design.DesignerCloudURLManager; |
|
import com.fr.log.FineLoggerFactory; |
|
import com.fanruan.product.ProductConstants; |
|
import com.fr.stable.StableUtils; |
|
import com.fr.stable.StringUtils; |
|
|
|
import java.io.File; |
|
import java.io.FileInputStream; |
|
import java.io.InputStream; |
|
import java.util.Properties; |
|
|
|
/** |
|
* Created by kerry on 2020-12-14 |
|
*/ |
|
public class ComponentReuseConfigManager { |
|
|
|
private static class Holder { |
|
private static final ComponentReuseConfigManager HOLDER = new ComponentReuseConfigManager(); |
|
} |
|
|
|
private static final String PROPERTIES_FILE_NAME = "reuse.properties"; |
|
private static final String MINI_SHOP_URL = "MINI_SHOP_URL"; |
|
private static final String WEB_MINI_SHOP_URL = "WEB_MINI_SHOP_URL"; |
|
private static final String COMPONENT_UPLOAD_URL = "COMPONENT_UPLOAD_URL"; |
|
private static final String MARKET_LOGIN_URL = "MARKET_LOGIN_URL"; |
|
private static final String UPLOAD_REU_SUPPORT = "UPLOAD_REU_SUPPORT"; |
|
|
|
public static ComponentReuseConfigManager getInstance() { |
|
return ComponentReuseConfigManager.Holder.HOLDER; |
|
} |
|
|
|
private Properties properties; |
|
|
|
private ComponentReuseConfigManager() { |
|
} |
|
|
|
private File getReusePropertyFile() { |
|
File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), PROPERTIES_FILE_NAME)); |
|
return file; |
|
} |
|
|
|
private String loadAttribute(String key, String defaultValue) { |
|
if (properties == null) { |
|
properties = new Properties(); |
|
File file = getReusePropertyFile(); |
|
if (!file.exists()) { |
|
return defaultValue; |
|
} |
|
try { |
|
InputStream in = new FileInputStream(file); |
|
properties.load(in); |
|
} catch (Exception e) { |
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
} |
|
} |
|
String p = properties.getProperty(key); |
|
if (StringUtils.isEmpty(p)) { |
|
p = defaultValue; |
|
} |
|
return p; |
|
} |
|
|
|
public String getWebMiniShopUrl() { |
|
return loadAttribute(WEB_MINI_SHOP_URL, DesignerCloudURLManager.getInstance().acquireUrlByKind("component.miniShop")); |
|
} |
|
|
|
public String getMiniShopUrl() { |
|
return loadAttribute(MINI_SHOP_URL, DesignerCloudURLManager.getInstance().acquireUrlByKind("af.reuseInfo")); |
|
} |
|
|
|
public String getComponentUploadUrl() { |
|
//云中心暂时没有上传网址,这边默认值为空,后续再添加 |
|
return loadAttribute(COMPONENT_UPLOAD_URL, StringUtils.EMPTY); |
|
} |
|
|
|
public String getMarketLoginUrl() { |
|
return loadAttribute(MARKET_LOGIN_URL, DesignerCloudURLManager.getInstance().acquireUrlByKind("market.login")); |
|
} |
|
|
|
public boolean supportUploadReu() { |
|
String uploadReuSupport = loadAttribute(UPLOAD_REU_SUPPORT, "false"); |
|
return Boolean.valueOf(uploadReuSupport); |
|
} |
|
}
|
|
|