提交 574c763f 编写于 作者: O o2null

Merge branch 'fix/删除clientInit配置' into 'wrdp'

[平台配置]删除clientInit配置

See merge request o2oa/o2oa!2601
{
"enable": true,
"enable": false,
"mq":"kafka",
"kafka":{
"bootstrap_servers": "localhost:9092",
......@@ -28,4 +28,4 @@
},
"###enable": "是否启用.###",
"###mq": "消息服务类型.###"
}
\ No newline at end of file
}
......@@ -33,7 +33,6 @@ public class CreateConfigSample {
List<Class<?>> classes = new ArrayList<Class<?>>();
classes.add(AppStyle.class);
classes.add(CenterServer.class);
classes.add(ClientInit.class);
classes.add(Collect.class);
classes.add(Communicate.class);
classes.add(Components.class);
......
package com.x.base.core.project.config;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.BooleanUtils;
import com.x.base.core.project.annotation.FieldDescribe;
public class ClientInit extends ConfigObject {
@FieldDescribe("是否启用.")
private Boolean enable;
@FieldDescribe("center节点信息.")
private List<CenterAddress> center;
@FieldDescribe("网页底部说明.")
private String footer = "";
@FieldDescribe("网页头部说明.")
private String title = "";
@FieldDescribe("APP使用协议,auto,http,https.")
private String app_protocol = "auto";
@FieldDescribe("登录页面配置.")
private LoginPage loginPage;
@FieldDescribe("是否启用webSocket")
private Boolean webSocketEnable;
public ClientInit() {
this.enable = DEFAULT_ENABLE;
this.center = new ArrayList<>();
this.loginPage = new LoginPage();
}
public static ClientInit defaultInstance() {
return new ClientInit();
}
public static final Boolean DEFAULT_ENABLE = false;
public static class LoginPage extends ConfigObject {
public static LoginPage defaultInstance() {
return new LoginPage();
}
@FieldDescribe("是否启用定制的登录页面.")
private Boolean enable;
@FieldDescribe("登录的门户.")
private String portal;
@FieldDescribe("登录页面.")
private String page;
public Boolean getEnable() {
return enable;
}
public void setEnable(Boolean enable) {
this.enable = enable;
}
public String getPortal() {
return portal;
}
public void setPortal(String portal) {
this.portal = portal;
}
public String getPage() {
return page;
}
public void setPage(String page) {
this.page = page;
}
}
public static class CenterAddress extends ConfigObject {
public static CenterAddress defaultInstance() {
return new CenterAddress();
}
private String port;
private String host;
public String getPort() {
return port;
}
public void setPort(String port) {
this.port = port;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
}
public Boolean getEnable() {
return BooleanUtils.isTrue(this.enable);
}
public void setEnable(Boolean enable) {
this.enable = enable;
}
public List<CenterAddress> getCenter() {
return center;
}
public void setCenter(List<CenterAddress> center) {
this.center = center;
}
public String getFooter() {
return footer;
}
public void setFooter(String footer) {
this.footer = footer;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getApp_protocol() {
return app_protocol;
}
public void setApp_protocol(String app_protocol) {
this.app_protocol = app_protocol;
}
public LoginPage getLoginPage() {
return loginPage;
}
public void setLoginPage(LoginPage loginPage) {
this.loginPage = loginPage;
}
public Boolean getWebSocketEnable() {
return webSocketEnable;
}
public void setWebSocketEnable(Boolean webSocketEnable) {
this.webSocketEnable = webSocketEnable;
}
}
\ No newline at end of file
......@@ -1050,19 +1050,6 @@ public class Config {
return instance().logLevel;
}
private ClientInit clientInit;
public static synchronized ClientInit clientInit() throws Exception {
if (null == instance().clientInit) {
ClientInit obj = BaseTools.readConfigObject(PATH_CONFIG_CLIENTINIT, ClientInit.class);
if (null == obj) {
obj = ClientInit.defaultInstance();
}
instance().clientInit = obj;
}
return instance().clientInit;
}
private byte[] bindLogo;
public static synchronized byte[] bindLogo() throws Exception {
......
......@@ -178,85 +178,82 @@ public class WebServerTools extends JettySeverTools {
File file = new File(dir, "config.json");
Gson gson = XGsonBuilder.instance();
if (Config.clientInit().getEnable()) {
FileUtils.write(file, gson.toJson(Config.clientInit()), DefaultCharset.charset);
} else {
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
/** 覆盖掉配置的参数 */
com.x.base.core.project.config.CenterServer centerServerConfig = Config.nodes().centerServers().first()
.getValue();
map.putAll(centerServerConfig.getConfig());
List<Map<String, String>> centers = new ArrayList<>();
map.put("center", centers);
/** 写入center地址 */
Map<String, String> center = new HashMap<String, String>();
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
/** 覆盖掉配置的参数 */
com.x.base.core.project.config.CenterServer centerServerConfig = Config.nodes().centerServers().first()
.getValue();
map.putAll(centerServerConfig.getConfig());
List<Map<String, String>> centers = new ArrayList<>();
map.put("center", centers);
/** 写入center地址 */
Map<String, String> center = new HashMap<String, String>();
center = new HashMap<String, String>();
center.put("host", "");
center.put("port", centerServerConfig.getPort().toString());
centers.add(center);
if (!Objects.equals(centerServerConfig.getProxyPort(), centerServerConfig.getPort())) {
center = new HashMap<String, String>();
center.put("host", "");
center.put("port", centerServerConfig.getProxyPort().toString());
centers.add(center);
}
String host = Config.nodes().primaryCenterNode();
if (!Host.isRollback(host)) {
center = new HashMap<String, String>();
center.put("host", host);
center.put("port", centerServerConfig.getPort().toString());
centers.add(center);
if (!Objects.equals(centerServerConfig.getProxyPort(), centerServerConfig.getPort())) {
center = new HashMap<String, String>();
center.put("host", "");
center.put("port", centerServerConfig.getProxyPort().toString());
centers.add(center);
}
String host = Config.nodes().primaryCenterNode();
if (!Host.isRollback(host)) {
center = new HashMap<String, String>();
center.put("host", host);
center.put("port", centerServerConfig.getPort().toString());
centers.add(center);
}
/** 写入proxy地址 */
if (StringUtils.isNotEmpty(centerServerConfig.getProxyHost())) {
center = new HashMap<String, String>();
center.put("host", centerServerConfig.getProxyHost());
center.put("port", centerServerConfig.getProxyPort().toString());
centers.add(center);
}
}
/** 写入proxy地址 */
if (StringUtils.isNotEmpty(centerServerConfig.getProxyHost())) {
center = new HashMap<String, String>();
center.put("host", centerServerConfig.getProxyHost());
center.put("port", centerServerConfig.getProxyPort().toString());
centers.add(center);
}
/** 写入systemName */
map.put("footer", Config.collect().getFooter());
map.put("title", Config.collect().getTitle());
map.put("appUrl", Config.collect().getAppUrl());
/***/
if (centerServerConfig.getSslEnable()) {
map.put("app_protocol", "https:");
} else {
map.put("app_protocol", "http:");
}
/* 上面的无效 */
map.put("app_protocol", "auto");
if ((null != Config.portal().getLoginPage())
&& (BooleanUtils.isTrue(Config.portal().getLoginPage().getEnable()))) {
map.put(MAP_LOGINPAGE, Config.portal().getLoginPage());
} else if ((null != Config.person().getLoginPage())
&& (BooleanUtils.isTrue(Config.person().getLoginPage().getEnable()))) {
map.put(MAP_LOGINPAGE, Config.person().getLoginPage());
} else {
map.put(MAP_LOGINPAGE, Config.portal().getLoginPage());
}
map.put("indexPage", Config.portal().getIndexPage());
map.put("webSocketEnable", Config.communicate().wsEnable());
map.put("urlMapping", Config.portal().getUrlMapping());
/* 密码规则 */
map.put("passwordRegex", Config.person().getPasswordRegex());
map.put("passwordRegexHint", Config.person().getPasswordRegexHint());
/* RSA */
File publicKeyFile = new File(Config.base(), "config/public.key");
if (publicKeyFile.exists() && publicKeyFile.isFile()) {
String publicKey = FileUtils.readFileToString(publicKeyFile, "utf-8");
byte[] publicKeyB = Base64.decodeBase64(publicKey);
publicKey = new String(Base64.encodeBase64(publicKeyB));
map.put("publicKey", publicKey);
}
for (Entry<String, JsonElement> en : Config.web().entrySet()) {
map.put(en.getKey(), en.getValue());
}
FileUtils.writeStringToFile(file, gson.toJson(map), DefaultCharset.charset);
/** 写入systemName */
map.put("footer", Config.collect().getFooter());
map.put("title", Config.collect().getTitle());
map.put("appUrl", Config.collect().getAppUrl());
/***/
if (centerServerConfig.getSslEnable()) {
map.put("app_protocol", "https:");
} else {
map.put("app_protocol", "http:");
}
/* 上面的无效 */
map.put("app_protocol", "auto");
if ((null != Config.portal().getLoginPage())
&& (BooleanUtils.isTrue(Config.portal().getLoginPage().getEnable()))) {
map.put(MAP_LOGINPAGE, Config.portal().getLoginPage());
} else if ((null != Config.person().getLoginPage())
&& (BooleanUtils.isTrue(Config.person().getLoginPage().getEnable()))) {
map.put(MAP_LOGINPAGE, Config.person().getLoginPage());
} else {
map.put(MAP_LOGINPAGE, Config.portal().getLoginPage());
}
map.put("indexPage", Config.portal().getIndexPage());
map.put("webSocketEnable", Config.communicate().wsEnable());
map.put("urlMapping", Config.portal().getUrlMapping());
/* 密码规则 */
map.put("passwordRegex", Config.person().getPasswordRegex());
map.put("passwordRegexHint", Config.person().getPasswordRegexHint());
/* RSA */
File publicKeyFile = new File(Config.base(), "config/public.key");
if (publicKeyFile.exists() && publicKeyFile.isFile()) {
String publicKey = FileUtils.readFileToString(publicKeyFile, "utf-8");
byte[] publicKeyB = Base64.decodeBase64(publicKey);
publicKey = new String(Base64.encodeBase64(publicKeyB));
map.put("publicKey", publicKey);
}
for (Entry<String, JsonElement> en : Config.web().entrySet()) {
map.put(en.getKey(), en.getValue());
}
FileUtils.writeStringToFile(file, gson.toJson(map), DefaultCharset.charset);
}
private static void createIndexPage() throws Exception {
......@@ -300,4 +297,4 @@ public class WebServerTools extends JettySeverTools {
FileUtils.copyDirectory(p.toFile(), Config.path_servers_webServer(true).toFile());
}
}
}
\ No newline at end of file
}
......@@ -16,6 +16,9 @@ class ActionValidateDirect extends BaseAction {
ActionResult<Wo> execute(JsonElement jsonElement) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
if (!Config.nodes().centerServers().first().getValue().getConfigApiEnable()) {
throw new ExceptionModifyConfig();
}
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Wo wo = new Wo();
wo.setValue(true);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册