提交 e380ab54 编写于 作者: Z zhourui

添加配置应用列表

上级 a65af4d7
......@@ -2,6 +2,7 @@ package com.x.base.core.project;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
......@@ -13,6 +14,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.CRC32;
import org.apache.commons.collections4.list.UnmodifiableList;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -32,7 +34,19 @@ import com.x.base.core.project.tools.StringTools;
public class Applications extends ConcurrentHashMap<String, CopyOnWriteArrayList<Application>> {
private static final Logger LOGGER = LoggerFactory.getLogger(Applications.class);
public static final List<String> OFFICIAL_APPLICATIONS = UnmodifiableList.unmodifiableList(Arrays.asList(
x_general_assemble_control.class.getName(), x_organization_assemble_authentication.class.getName(),
x_organization_assemble_express.class.getName(), x_organization_assemble_control.class.getName(),
x_organization_assemble_personal.class.getName(), x_component_assemble_control.class.getName(),
x_message_assemble_communicate.class.getName(), x_calendar_assemble_control.class.getName(),
x_processplatform_service_processing.class.getName(), x_processplatform_assemble_designer.class.getName(),
x_processplatform_assemble_surface.class.getName(), x_processplatform_assemble_bam.class.getName(),
x_cms_assemble_control.class.getName(), x_portal_assemble_designer.class.getName(),
x_portal_assemble_surface.class.getName(), x_attendance_assemble_control.class.getName(),
x_bbs_assemble_control.class.getName(), x_file_assemble_control.class.getName(),
x_meeting_assemble_control.class.getName(), x_mind_assemble_control.class.getName(),
x_hotpic_assemble_control.class.getName(), x_query_service_processing.class.getName(),
x_query_assemble_designer.class.getName(), x_query_assemble_surface.class.getName()));
private static final long serialVersionUID = -2416559829493154858L;
......@@ -50,7 +64,7 @@ public class Applications extends ConcurrentHashMap<String, CopyOnWriteArrayList
this.token = token;
}
public Application get(String className, String tokenOrNode) throws Exception {
public Application get(String className, String tokenOrNode) {
List<Application> list = this.get(className);
if (null != list) {
for (Application application : list) {
......
......@@ -23,8 +23,8 @@ public class CenterServer extends ConfigObject {
public static CenterServer defaultInstance() {
CenterServer o = new CenterServer();
o.enable = DEFAULT_ENABLE;
o.sslEnable = false;
o.order = DEFAULT_ORDER;
o.sslEnable = false;
o.port = DEFAULT_PORT;
o.httpProtocol = "";
o.proxyHost = "";
......
......@@ -38,7 +38,7 @@ public class Token extends ConfigObject {
public static final String defaultInitialManagerDistinguishedName = "xadmin@o2oa@P";
public static final String initPassword = "o2";
public static final String initPassword = "o2oa@2022";
public static final String defaultSslKeyStorePassword = "123456";
public static final String defaultSslKeyManagerPassword = "123456";
......
......@@ -16,6 +16,8 @@ public class WebServer extends ConfigObject {
o.sslEnable = false;
o.proxyHost = "";
o.proxyPort = null;
o.proxyCenterEnable = DEFAULT_PROXYCENTERENABLE;
o.proxyApplicationEnable = DEFAULT_PROXYAPPLICATIONENABLE;
return o;
}
......@@ -35,10 +37,8 @@ public class WebServer extends ConfigObject {
private String proxyHost;
@FieldDescribe("代理端口,当服务器是通过apache/nginx等代理服务器映射到公网或者通过路由器做端口映射,在这样的情况下需要设置此地址以标明公网访问端口.")
private Integer proxyPort;
@FieldDescribe("是否启用center服务器代理.")
private Boolean proxyCenterEnable;
@FieldDescribe("是否启用application服务器代理")
private Boolean proxyApplicationEnable;
......
......@@ -44,6 +44,7 @@ import org.w3c.dom.Document;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import com.x.base.core.project.Applications;
import com.x.base.core.project.x_attendance_assemble_control;
import com.x.base.core.project.x_bbs_assemble_control;
import com.x.base.core.project.x_calendar_assemble_control;
......@@ -99,20 +100,6 @@ public class ApplicationServerTools extends JettySeverTools {
private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationServerTools.class);
private static final List<String> OFFICIAL_MODULE_SORTED = UnmodifiableList.unmodifiableList(Arrays.asList(
x_general_assemble_control.class.getName(), x_organization_assemble_authentication.class.getName(),
x_organization_assemble_express.class.getName(), x_organization_assemble_control.class.getName(),
x_organization_assemble_personal.class.getName(), x_component_assemble_control.class.getName(),
x_message_assemble_communicate.class.getName(), x_calendar_assemble_control.class.getName(),
x_processplatform_service_processing.class.getName(), x_processplatform_assemble_designer.class.getName(),
x_processplatform_assemble_surface.class.getName(), x_processplatform_assemble_bam.class.getName(),
x_cms_assemble_control.class.getName(), x_portal_assemble_designer.class.getName(),
x_portal_assemble_surface.class.getName(), x_attendance_assemble_control.class.getName(),
x_bbs_assemble_control.class.getName(), x_file_assemble_control.class.getName(),
x_meeting_assemble_control.class.getName(), x_mind_assemble_control.class.getName(),
x_hotpic_assemble_control.class.getName(), x_query_service_processing.class.getName(),
x_query_assemble_designer.class.getName(), x_query_assemble_surface.class.getName()));
public static Server start(ApplicationServer applicationServer) throws Exception {
List<ClassInfo> officialClassInfos = listOfficial();
......@@ -324,8 +311,8 @@ public class ApplicationServerTools extends JettySeverTools {
Config.currentNode().getApplication().getExcludes());
return classInfos.stream().filter(info -> names.contains(info.getName()))
.sorted(Comparator.comparing(ClassInfo::getName, (x, y) -> {
int indx = OFFICIAL_MODULE_SORTED.indexOf(x);
int indy = OFFICIAL_MODULE_SORTED.indexOf(y);
int indx = Applications.OFFICIAL_APPLICATIONS.indexOf(x);
int indy = Applications.OFFICIAL_APPLICATIONS.indexOf(y);
if (indx == indy) {
return 0;
} else if (indx == -1) {
......
package com.x.program.center.jaxrs.config;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.x.base.core.project.Applications;
import com.x.base.core.project.bean.NameValuePair;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ClassLoaderTools;
import com.x.base.core.project.annotation.Module;
public class ActionListApplication extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionListApplication.class);
private ClassLoader classLoader;
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson) throws Exception {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
classLoader = ClassLoaderTools.urlClassLoader(Thread.currentThread().getContextClassLoader(), true, true, true,
true);
ActionResult<List<Wo>> result = new ActionResult<>();
@SuppressWarnings("unchecked")
List<Wo> wos = Applications.OFFICIAL_APPLICATIONS.stream().map(mapper).collect(Collectors.toList());
result.setData(wos);
return result;
}
private Function<String, Wo> mapper = s -> {
Wo wo = new Wo();
wo.setValue(s);
try {
Class<?> clz = classLoader.loadClass(s);
Module module = clz.getAnnotation(Module.class);
if (null != module) {
wo.setName(module.name());
}
} catch (ClassNotFoundException e) {
LOGGER.error(e);
}
return wo;
};
public static class Wo extends NameValuePair {
private static final long serialVersionUID = 1L;
}
}
......@@ -25,11 +25,20 @@ import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@JaxrsDescribe("配置")
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
@Tag(name = "ConfigAction", description = "配置接口.")
@JaxrsDescribe("配置接口.")
@Path("config")
public class ConfigAction extends StandardJaxrsAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigAction.class);
private static final String OPERATIONID_PREFIX = "ConfigAction::";
@JaxrsMethodDescribe(value = "获取设置.", action = ActionGet.class)
@GET
......@@ -382,7 +391,10 @@ public class ConfigAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result, jsonElement));
}
@JaxrsMethodDescribe(value = "获取所有配置文件信息", action = ActionListEntity.class)
@Operation(summary = "列示所有可配置实体类名称.", operationId = OPERATIONID_PREFIX + "listEntity", responses = {
@ApiResponse(content = {
@Content(array = @ArraySchema(schema = @Schema(implementation = ActionListEntity.Wo.class))) }) })
@JaxrsMethodDescribe(value = "列示所有可配置实体类名称.", action = ActionListEntity.class)
@GET
@Path("list/entity")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
......@@ -399,4 +411,24 @@ public class ConfigAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@Operation(summary = "列示所有可配置应用名称.", operationId = OPERATIONID_PREFIX + "listApplication", responses = {
@ApiResponse(content = {
@Content(array = @ArraySchema(schema = @Schema(implementation = ActionListApplication.Wo.class))) }) })
@JaxrsMethodDescribe(value = "列示所有可配置应用名称.", action = ActionListApplication.class)
@GET
@Path("list/application")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listApplication(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
EffectivePerson effectivePerson = this.effectivePerson(request);
ActionResult<List<ActionListApplication.Wo>> result = new ActionResult<>();
try {
result = new ActionListApplication().execute(effectivePerson);
} catch (Exception e) {
e.printStackTrace();
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册