提交 6a2cfc76 编写于 作者: Z zhourui

add swagger

上级 89750917
/.apt_generated/
/.apt_generated_tests/
......@@ -15,10 +15,11 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
public class ActionShowStForPersonInUnitSubNested extends BaseAction {
private static Logger logger = LoggerFactory.getLogger( ActionShowStForPersonInUnitSubNested.class );
protected ActionResult<List<Wo>> execute( HttpServletRequest request, EffectivePerson effectivePerson, String name, String year, String month ) throws Exception {
private static Logger logger = LoggerFactory.getLogger(ActionShowStForPersonInUnitSubNested.class);
protected ActionResult<List<Wo>> execute(HttpServletRequest request, EffectivePerson effectivePerson, String name,
String year, String month) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wraps = null;
List<String> ids = null;
......@@ -27,87 +28,90 @@ public class ActionShowStForPersonInUnitSubNested extends BaseAction {
List<String> personNameList = new ArrayList<String>();
List<StatisticPersonForMonth> statisticPersonForMonth_list = null;
Boolean check = true;
if ( "(0)".equals( year ) ) {
if ("(0)".equals(year)) {
year = null;
}
if ( "(0)".equals( month ) ) {
if ("(0)".equals(month)) {
month = null;
}
if( check ){
if( name == null || name.isEmpty() ){
if (check) {
if (name == null || name.isEmpty()) {
check = false;
Exception exception = new ExceptionQueryStatisticUnitNameEmpty();
result.error( exception );
result.error(exception);
}
}
if( check ){
if (check) {
try {
unitNameList = userManagerService.listSubUnitNameWithParent( name );
unitNameList = userManagerService.listSubUnitNameWithParent(name);
} catch (Exception e) {
check = false;
Exception exception = new ExceptionAttendanceStatisticProcess( e, "根据组织名称列示所有下级组织名称发生异常!Unit:" + name );
result.error( exception );
logger.error( e, effectivePerson, request, null);
Exception exception = new ExceptionAttendanceStatisticProcess(e, "根据组织名称列示所有下级组织名称发生异常!Unit:" + name);
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
}
if( check ){
if( unitNameList == null ){
if (check) {
if (unitNameList == null) {
unitNameList = new ArrayList<>();
}
unitNameList.add( name );
unitNameList.add(name);
unUnitNameList = getUnUnitNameList();
personNameList = getUnPersonNameList();
System.out.println("ActionShowStForPersonInUnitSubNested____unitNameList="+unitNameList);
System.out.println("ActionShowStForPersonInUnitSubNested____unUnitNameList="+unUnitNameList);
System.out.println("ActionShowStForPersonInUnitSubNested____personNameList="+personNameList);
System.out.println("ActionShowStForPersonInUnitSubNested____unitNameList=" + unitNameList);
System.out.println("ActionShowStForPersonInUnitSubNested____unUnitNameList=" + unUnitNameList);
System.out.println("ActionShowStForPersonInUnitSubNested____personNameList=" + personNameList);
}
if( check ){
if (check) {
try {
//ids = attendanceStatisticServiceAdv.listPersonForMonthByUnitYearAndMonth( unitNameList, year, month);
ids = attendanceStatisticServiceAdv.listPersonForMonthByUnitYearMonthAndUn( unitNameList, unUnitNameList,personNameList,year, month);
System.out.println("ActionShowStForPersonInUnitSubNested____ids="+ids.size());
// ids = attendanceStatisticServiceAdv.listPersonForMonthByUnitYearAndMonth(
// unitNameList, year, month);
ids = attendanceStatisticServiceAdv.listPersonForMonthByUnitYearMonthAndUn(unitNameList, unUnitNameList,
personNameList, year, month);
System.out.println("ActionShowStForPersonInUnitSubNested____ids=" + ids.size());
} catch (Exception e) {
check = false;
Exception exception = new ExceptionAttendanceStatisticProcess(e,
"系统根据组织名称列表,年份和月份查询个人统计数据信息ID列表时发生异常.Name:"+unitNameList+", Year:"+year+", Month:" + month
);
result.error( exception );
logger.error( e, effectivePerson, request, null);
Exception exception = new ExceptionAttendanceStatisticProcess(e,
"系统根据组织名称列表,年份和月份查询个人统计数据信息ID列表时发生异常.Name:" + unitNameList + ", Year:" + year + ", Month:"
+ month);
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
}
if( check ){
if( ids != null && !ids.isEmpty() ){
if (check) {
if (ids != null && !ids.isEmpty()) {
try {
statisticPersonForMonth_list = attendanceStatisticServiceAdv.listPersonForMonth( ids );
statisticPersonForMonth_list = attendanceStatisticServiceAdv.listPersonForMonth(ids);
} catch (Exception e) {
check = false;
Exception exception = new ExceptionAttendanceStatisticProcess( e, "系统根据ID列表查询个人每月统计数据信息列表时发生异常." );
result.error( exception );
logger.error( e, effectivePerson, request, null);
Exception exception = new ExceptionAttendanceStatisticProcess(e, "系统根据ID列表查询个人每月统计数据信息列表时发生异常.");
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
}
}
if( check ){
if( statisticPersonForMonth_list != null ){
if (check) {
if (statisticPersonForMonth_list != null) {
try {
wraps = Wo.copier.copy( statisticPersonForMonth_list );
wraps = Wo.copier.copy(statisticPersonForMonth_list);
result.setData(wraps);
} catch (Exception e) {
check = false;
Exception exception = new ExceptionAttendanceStatisticProcess( e, "系统将所有查询到的个人每月统计信息对象转换为可以输出的信息时发生异常." );
result.error( exception );
logger.error( e, effectivePerson, request, null);
Exception exception = new ExceptionAttendanceStatisticProcess(e,
"系统将所有查询到的个人每月统计信息对象转换为可以输出的信息时发生异常.");
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
}
}
return result;
}
public static class Wo extends StatisticPersonForMonth {
private static final long serialVersionUID = -5076990764713538973L;
public static WrapCopier<StatisticPersonForMonth, Wo> copier =
WrapCopierFactory.wo( StatisticPersonForMonth.class, Wo.class, null, JpaObject.FieldsInvisible);
public static class Wo extends StatisticPersonForMonth {
private static final long serialVersionUID = -5076990764713538973L;
public static WrapCopier<StatisticPersonForMonth, Wo> copier = WrapCopierFactory
.wo(StatisticPersonForMonth.class, Wo.class, null, JpaObject.FieldsInvisible);
}
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.entity.tools.JpaObjectTools;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.tools.ListTools;
import com.x.base.core.project.cache.CacheManager;
public class AttendanceSelfHolidayService {
......@@ -48,8 +49,10 @@ public class AttendanceSelfHolidayService {
List<String> ids = getByPersonName(emc, person);
List<AttendanceSelfHoliday> list = list(emc, ids);
// detach
JpaObjectTools.detach(emc.get(AttendanceSelfHoliday.class), list);
CacheManager.put(cache_AttendanceSelfHoliday, cacheKey, list);
if (ListTools.isNotEmpty(list)) {
JpaObjectTools.detach(emc.get(AttendanceSelfHoliday.class), list);
CacheManager.put(cache_AttendanceSelfHoliday, cacheKey, list);
}
return list;
}
}
......
......@@ -2,6 +2,7 @@ package com.x.attendance.assemble.control.service;
import java.util.List;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import com.x.attendance.assemble.control.Business;
......@@ -395,7 +396,7 @@ public class UserManagerService {
} else {
for (String identity : identities) {
Identity obj = business.organization().identity().getObject(identity);
if (obj.getMajor()) {
if ((null != obj) && BooleanUtils.isTrue(obj.getMajor())) {
return identity;
}
}
......@@ -442,20 +443,20 @@ public class UserManagerService {
}
}
public Boolean checkHasPerson(String personName,String unitName,Boolean recursive) throws Exception {
public Boolean checkHasPerson(String personName, String unitName, Boolean recursive) throws Exception {
if (personName == null || personName.isEmpty()) {
throw new Exception("personName is null!");
}
if (unitName == null || unitName.isEmpty()) {
throw new Exception("unitName is null!");
}
if (recursive ==null) {
if (recursive == null) {
throw new Exception("recursive is null!");
}
Business business = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
business = new Business(emc);
return business.organization().unit().checkHasPerson(personName,unitName,recursive);
return business.organization().unit().checkHasPerson(personName, unitName, recursive);
}
}
......
/.apt_generated/
/.apt_generated_tests/
package com.x.base.core.project;
public class Packages {
public static final String PREFIX = "com.x";
public static final String com_x_base_core_project = "com.x.base.core.project";
public static final String com_x_base_core_project_dot = "com.x.base.core.project.";
}
\ No newline at end of file
//package com.x.base.core.project;
//
//public class Packages {
//
// public static final String PREFIX = "com.x";
//
// public static final String com_x_base_core_project = "com.x.base.core.project";
//
// public static final String com_x_base_core_project_dot = "com.x.base.core.project.";
//
//}
\ No newline at end of file
package com.x.base.core.project;
public class Version {
private Version() {
}
public static final String VALUE = "7.2";
}
......@@ -38,12 +38,13 @@ import io.github.classgraph.ScanResult;
public class ApiBuilder {
private static Logger logger = LoggerFactory.getLogger(ApiBuilder.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ApiBuilder.class);
private static final String DESCRIBE_DIR = "src/main/webapp/describe";
public static void main(String[] args) throws IOException {
File basedir = new File(args[0]);
File dir = new File(basedir, "src/main/webapp/describe");
File dir = new File(basedir, DESCRIBE_DIR);
FileUtils.forceMkdir(dir);
ApiBuilder builder = new ApiBuilder();
builder.scan(dir);
......@@ -92,7 +93,7 @@ public class ApiBuilder {
}
private JaxrsClass jaxrsClass(Class<?> clz) {
logger.print("describe class:{}.", clz.getName());
LOGGER.print("describe class:{}.", clz.getName());
JaxrsClass jaxrsClass = new JaxrsClass();
jaxrsClass.setName(clz.getSimpleName());
for (Method method : clz.getMethods()) {
......@@ -150,7 +151,7 @@ public class ApiBuilder {
}
}
public class JaxrsClass {
private class JaxrsClass {
private String name;
private List<JaxrsApiMethod> methods = new ArrayList<>();
......@@ -172,7 +173,8 @@ public class ApiBuilder {
}
}
public class JaxrsApiMethod {
private class JaxrsApiMethod {
private String name;
private String uri;
private String method;
......@@ -212,311 +214,4 @@ public class ApiBuilder {
}
public class JaxsApiMethodProperty {
private String uri;
private String method;
private String enctype;
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public String getEnctype() {
return enctype;
}
public void setEnctype(String enctype) {
this.enctype = enctype;
}
}
public class JaxrsMethod {
private String name;
private String className;
private String description;
private String type;
private String path;
private String contentType;
private String resultContentType;
private Boolean useJsonElementParameter = false;
private Boolean useStringParameter = false;
private List<JaxrsPathParameter> pathParameters = new ArrayList<>();
private List<JaxrsFormParameter> formParameters = new ArrayList<>();
private List<JaxrsQueryParameter> queryParameters = new ArrayList<>();
private List<JaxrsField> ins = new ArrayList<>();
private List<JaxrsField> outs = new ArrayList<>();
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<JaxrsField> getIns() {
return ins;
}
public void setIns(List<JaxrsField> ins) {
this.ins = ins;
}
public List<JaxrsField> getOuts() {
return outs;
}
public void setOuts(List<JaxrsField> outs) {
this.outs = outs;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public List<JaxrsPathParameter> getPathParameters() {
return pathParameters;
}
public void setPathParameters(List<JaxrsPathParameter> pathParameters) {
this.pathParameters = pathParameters;
}
public List<JaxrsFormParameter> getFormParameters() {
return formParameters;
}
public void setFormParameters(List<JaxrsFormParameter> formParameters) {
this.formParameters = formParameters;
}
public List<JaxrsQueryParameter> getQueryParameters() {
return queryParameters;
}
public void setQueryParameters(List<JaxrsQueryParameter> queryParameters) {
this.queryParameters = queryParameters;
}
public Boolean getUseJsonElementParameter() {
return useJsonElementParameter;
}
public void setUseJsonElementParameter(Boolean useJsonElementParameter) {
this.useJsonElementParameter = useJsonElementParameter;
}
public String getResultContentType() {
return resultContentType;
}
public void setResultContentType(String resultContentType) {
this.resultContentType = resultContentType;
}
public Boolean getUseStringParameter() {
return useStringParameter;
}
public void setUseStringParameter(Boolean useStringParameter) {
this.useStringParameter = useStringParameter;
}
}
public class JaxrsField {
private String name;
private String type;
private Boolean isCollection;
private String description;
private Boolean isBaseType;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Boolean getIsCollection() {
return isCollection;
}
public void setIsCollection(Boolean isCollection) {
this.isCollection = isCollection;
}
public Boolean getIsBaseType() {
return isBaseType;
}
public void setIsBaseType(Boolean isBaseType) {
this.isBaseType = isBaseType;
}
}
public class JaxrsPathParameter {
private String name;
private String type;
private String description;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
public class JaxrsFormParameter {
private String name;
private String type;
private String description;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
public class JaxrsQueryParameter {
private String name;
private String type;
private String description;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
}
\ No newline at end of file
......@@ -59,9 +59,9 @@ public class DescribeBuilder {
public static void main(String[] args) throws IOException {
File basedir = new File(args[0]);
System.out.println(args[0]);
System.out.println(args[0]);
File sourcesdir = new File(args[1]);
System.out.println(args[1]);
System.out.println(args[1]);
File dir = new File(basedir, "src/main/webapp/describe");
FileUtils.forceMkdir(dir);
......@@ -84,10 +84,10 @@ public class DescribeBuilder {
}
}
LinkedHashMap<String, List<?>> map = new LinkedHashMap<>();
jaxrsClasses = jaxrsClasses.stream().sorted(Comparator.comparing(JaxrsClass::getName))
.collect(Collectors.toList());
map.put("jaxrs", jaxrsClasses);
File file = new File(dir, "describe.json");
FileUtils.writeStringToFile(file, XGsonBuilder.toJson(map), DefaultCharset.charset);
......@@ -129,7 +129,7 @@ public class DescribeBuilder {
}
jaxrsClass.setMethods(jaxrsClass.getMethods().stream().sorted(Comparator.comparing(JaxrsMethod::getName))
.collect(Collectors.toList()));
return jaxrsClass;
}
......@@ -206,19 +206,20 @@ public class DescribeBuilder {
.sorted(Comparator.comparing(JaxrsFormParameter::getName, Comparator.nullsLast(String::compareTo)))
.collect(Collectors.toList()));
/*
jaxrsMethod.setQueryParameters(jaxrsMethod.getQueryParameters().stream().filter(Objects::nonNull)
.sorted(Comparator.comparing(JaxrsQueryParameter::getName, Comparator.nullsLast(String::compareTo)))
.collect(Collectors.toList()));
*/
jaxrsMethod.setQueryParameters(jaxrsMethod.getQueryParameters().stream().filter(Objects::nonNull)
.collect(Collectors.toList()));
* jaxrsMethod.setQueryParameters(jaxrsMethod.getQueryParameters().stream().
* filter(Objects::nonNull)
* .sorted(Comparator.comparing(JaxrsQueryParameter::getName,
* Comparator.nullsLast(String::compareTo))) .collect(Collectors.toList()));
*/
jaxrsMethod.setQueryParameters(
jaxrsMethod.getQueryParameters().stream().filter(Objects::nonNull).collect(Collectors.toList()));
/*
jaxrsMethod.setPathParameters(jaxrsMethod.getPathParameters().stream().filter(Objects::nonNull)
.sorted(Comparator.comparing(JaxrsPathParameter::getName, Comparator.nullsLast(String::compareTo)))
.collect(Collectors.toList()));
*/
jaxrsMethod.setPathParameters(jaxrsMethod.getPathParameters().stream().filter(Objects::nonNull)
.collect(Collectors.toList()));
* jaxrsMethod.setPathParameters(jaxrsMethod.getPathParameters().stream().filter
* (Objects::nonNull) .sorted(Comparator.comparing(JaxrsPathParameter::getName,
* Comparator.nullsLast(String::compareTo))) .collect(Collectors.toList()));
*/
jaxrsMethod.setPathParameters(
jaxrsMethod.getPathParameters().stream().filter(Objects::nonNull).collect(Collectors.toList()));
return jaxrsMethod;
}
......@@ -306,7 +307,7 @@ public class DescribeBuilder {
private Class<?> getWiClass(Class<?> actionClass) {
for (Class<?> c : actionClass.getDeclaredClasses()) {
if (StringUtils.equals(c.getSimpleName(), "Wi")) {
if ((null != c.getAnnotation(WrapIn.class)) || StringUtils.equals(c.getSimpleName(), "Wi")) {
return c;
}
}
......@@ -315,7 +316,7 @@ public class DescribeBuilder {
private Class<?> getWoClass(Class<?> actionClass) {
for (Class<?> c : actionClass.getDeclaredClasses()) {
if (StringUtils.equals(c.getSimpleName(), "Wo")) {
if ((null != c.getAnnotation(WrapOut.class)) || StringUtils.equals(c.getSimpleName(), "Wo")) {
return c;
}
}
......@@ -350,10 +351,10 @@ public class DescribeBuilder {
if (StringUtils.containsAny(jaxrsField.getType(), "<String>", "<Boolean>", "<Date>", "<Integer>",
"<Double>", "<Long>", "<Float>")) {
jaxrsField.setIsBaseType(true);
}else {
//wwx add 获取类信息
} else {
// wwx add 获取类信息
FieldTypeDescribe fieldTypeDescribe = o.getAnnotation(FieldTypeDescribe.class);
if(null !=fieldTypeDescribe) {
if (null != fieldTypeDescribe) {
jaxrsField.setFieldType(fieldTypeDescribe.fieldType());
jaxrsField.setFieldValue(fieldTypeDescribe.fieldValue());
jaxrsField.setFieldTypeName(fieldTypeDescribe.fieldTypeName());
......@@ -371,14 +372,14 @@ public class DescribeBuilder {
if (StringUtils.startsWithAny(jaxrsField.getType(), "String", "Boolean", "Date", "Integer",
"Double", "Long", "Float")) {
jaxrsField.setIsBaseType(true);
}else {
} else {
FieldTypeDescribe fieldTypeDescribe = o.getAnnotation(FieldTypeDescribe.class);
if(null !=fieldTypeDescribe) {
if (null != fieldTypeDescribe) {
jaxrsField.setFieldType(fieldTypeDescribe.fieldType());
jaxrsField.setFieldValue(fieldTypeDescribe.fieldValue());
jaxrsField.setFieldTypeName(fieldTypeDescribe.fieldTypeName());
}
if (Enum.class.isAssignableFrom(o.getType())) {
jaxrsField.setFieldType("enum");
}
......@@ -654,15 +655,13 @@ public class DescribeBuilder {
private Boolean isCollection;
private String description;
private Boolean isBaseType;
//当参数不是基础类型时,记录类型信息
// 当参数不是基础类型时,记录类型信息
private String fieldType;
private String fieldValue;
private String fieldTypeName;
private String fieldSample;
public String getName() {
return name;
}
......@@ -718,7 +717,7 @@ public class DescribeBuilder {
public void setFieldValue(String fieldValue) {
this.fieldValue = fieldValue;
}
public String getFieldTypeName() {
return fieldTypeName;
}
......@@ -726,7 +725,7 @@ public class DescribeBuilder {
public void setFieldTypeName(String fieldTypeName) {
this.fieldTypeName = fieldTypeName;
}
public String getFieldSample() {
return fieldSample;
}
......
package com.x.base.core.project.annotation;
public enum DescribeScope {
commonly, uncommonly, system;
public static int lengh = 16;
}
......@@ -10,5 +10,8 @@ import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Inherited
public @interface JaxrsDescribe {
String value();
DescribeScope scope() default DescribeScope.commonly;
}
\ No newline at end of file
......@@ -19,4 +19,6 @@ public @interface JaxrsMethodDescribe {
Class<? extends StandardJaxrsAction> action();
DescribeScope scope() default DescribeScope.commonly;
}
\ No newline at end of file
package com.x.base.core.project.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
public @interface WrapIn {
}
\ No newline at end of file
package com.x.base.core.project.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
public @interface WrapOut {
}
\ No newline at end of file
......@@ -40,15 +40,13 @@ public class CacheGuavaImpl implements Cache {
if ((null != category) && (null != key) && (null != o)) {
cache.put(concrete(category, key), o);
} else {
if ((null != category)) {
if (null == category) {
throw new IllegalStateException("cache category is null.");
}
if ((null != key)) {
if (null == key) {
throw new IllegalStateException("cache key is null.");
}
if ((null != o)) {
throw new IllegalStateException("cache value is null.");
}
throw new IllegalStateException("cache value is null.");
}
}
......
......@@ -10,17 +10,23 @@ import org.glassfish.jersey.media.multipart.MultiPartFeature;
import com.x.base.core.project.jaxrs.cache.CacheAction;
import com.x.base.core.project.jaxrs.echo.EchoAction;
import com.x.base.core.project.jaxrs.fireschedule.FireScheduleAction;
import com.x.base.core.project.jaxrs.openapi.OpenApiAction;
import com.x.base.core.project.jaxrs.sysresource.SysResourceAction;
public abstract class AbstractActionApplication extends Application {
protected Set<Object> singletons = new HashSet<>();
protected Set<Class<?>> classes = new HashSet<>();
public AbstractActionApplication() {
@Override
public Set<Class<?>> getClasses() {
return classes;
}
protected AbstractActionApplication() {
classes.add(EchoAction.class);
classes.add(CacheAction.class);
classes.add(FireScheduleAction.class);
classes.add(SysResourceAction.class);
classes.add(OpenApiAction.class);
// providers
classes.add(MessageBodyReaderImpl.class);
classes.add(MultiPartFeature.class);
......
package com.x.base.core.project.jaxrs;
import javax.servlet.annotation.WebFilter;
@WebFilter(urlPatterns = { "/jaxrs/openapi/*" }, asyncSupported = true)
public class OpenApiJaxrsFilter extends AnonymousCipherManagerUserJaxrsFilter {
}
......@@ -3,11 +3,14 @@ package com.x.base.core.project.jaxrs;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
import io.swagger.v3.oas.annotations.media.Schema;
public class WrapBoolean extends GsonPropertyObject {
private static final long serialVersionUID = 19308077998975323L;
@FieldDescribe("布尔值.")
@Schema(description = "布尔值.")
private Boolean value;
public WrapBoolean() {
......
......@@ -6,6 +6,8 @@ import java.util.List;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
import io.swagger.v3.oas.annotations.media.Schema;
public abstract class WrapClearCacheRequest extends GsonPropertyObject {
public static final String TYPE_NOTIFY = "notify";
......@@ -15,13 +17,16 @@ public abstract class WrapClearCacheRequest extends GsonPropertyObject {
private String type;
@FieldDescribe("节点名")
@FieldDescribe("节点名.")
@Schema(description = "节点名.")
private String nodeName;
@FieldDescribe("类名")
@FieldDescribe("类名.")
@Schema(description = "类名.")
private String className;
@FieldDescribe("关键字")
@FieldDescribe("关键字.")
@Schema(description = "关键字.")
private List<Object> keys;
public String getClassName() {
......
......@@ -5,8 +5,12 @@ import java.util.Objects;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
import io.swagger.v3.oas.annotations.media.Schema;
public class WrapString extends GsonPropertyObject {
private static final long serialVersionUID = 4268038806585280159L;
public WrapString() {
}
......@@ -15,7 +19,8 @@ public class WrapString extends GsonPropertyObject {
this.value = Objects.toString(o, "");
}
@FieldDescribe("字符串值")
@FieldDescribe("字符串值.")
@Schema(description = "字符串值.")
private String value;
public String getValue() {
......
......@@ -9,12 +9,14 @@ import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import io.swagger.v3.oas.annotations.media.Schema;
class ActionConfigFlush extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionConfigFlush.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ActionConfigFlush.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, ServletContext servletContext) throws Exception {
logger.debug(effectivePerson, "config flush.");
ActionResult<Wo> execute(EffectivePerson effectivePerson, ServletContext servletContext) {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
ActionResult<Wo> result = new ActionResult<>();
Config.flush();
Wo wo = new Wo();
......@@ -23,6 +25,7 @@ class ActionConfigFlush extends BaseAction {
return result;
}
@Schema(name = "com.x.base.core.project.jaxrs.cache.ActionConfigFlush$Wo")
public static class Wo extends WrapBoolean {
}
......
......@@ -9,25 +9,26 @@ import com.x.base.core.project.jaxrs.WrapString;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import io.swagger.v3.oas.annotations.media.Schema;
class ActionDetail extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionDetail.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, ServletContext servletContext) throws Exception {
LOGGER.debug("{} access by {}.", ActionDetail.class::getName, effectivePerson::getDistinguishedName);
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
ActionResult<Wo> result = new ActionResult<>();
result.setData(new Wo(CacheManager.detail()));
Wo wo = new Wo();
wo.setValue(CacheManager.detail());
result.setData(wo);
return result;
}
@Schema(name = "com.x.base.core.project.jaxrs.cache.ActionDetail$Wo")
public static class Wo extends WrapString {
private static final long serialVersionUID = 6523578259551600220L;
public Wo(String str) {
super(str);
}
}
}
\ No newline at end of file
......@@ -11,26 +11,23 @@ import com.x.base.core.project.jaxrs.WrapString;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import io.swagger.v3.oas.annotations.media.Schema;
class ActionReceive extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionReceive.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ActionReceive.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, ServletContext servletContext, JsonElement jsonElement)
throws Exception {
logger.debug(effectivePerson, "receive:{}.", jsonElement);
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
// AbstractContext ctx = AbstractContext.fromServletContext(servletContext);
// if (null != ctx.clearCa cheRequestQueue()) {
// ctx.clearCacheRequestQueue().send(wi);
// } else {
CacheManager.receive(wi);
// }
result.setData(new Wo(wi.getClassName()));
return result;
}
@Schema(name = "com.x.base.core.project.jaxrs.cache.ActionReceive$Wo")
public static class Wo extends WrapString {
public Wo(String str) {
......@@ -39,6 +36,7 @@ class ActionReceive extends BaseAction {
}
@Schema(name = "com.x.base.core.project.jaxrs.cache.ActionReceive$Wi")
public static class Wi extends WrapClearCacheRequest {
}
......
......@@ -4,7 +4,7 @@ import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
......@@ -13,6 +13,7 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.DescribeScope;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.http.ActionResult;
......@@ -23,16 +24,30 @@ import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
@Tag(name = "CacheAction", description = "缓存操作接口.")
@Path("cache")
@JaxrsDescribe("缓存操作")
@JaxrsDescribe(value = "缓存操作接口", scope = DescribeScope.system)
public class CacheAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(CacheAction.class);
private static final Logger logger = LoggerFactory.getLogger(CacheAction.class);
private static final String OPERATIONID_PREFIX = "CacheAction::";
@PUT
@Operation(summary = "接收缓存刷新指令.", operationId = OPERATIONID_PREFIX + "receive", responses = {
@ApiResponse(content = {
@Content(schema = @Schema(implementation = ActionReceive.Wo.class)) }) }, requestBody = @RequestBody(content = {
@Content(schema = @Schema(implementation = ActionReceive.Wi.class)) }))
@POST
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
@JaxrsMethodDescribe(value = "接收Cache刷新信息.", action = ActionReceive.class)
@JaxrsMethodDescribe(value = "接收缓存刷新指令.", action = ActionReceive.class)
public void receive(@Suspended final AsyncResponse asyncResponse, @Context ServletContext servletContext,
@Context HttpServletRequest request, JsonElement jsonElement) {
ActionResult<ActionReceive.Wo> result = new ActionResult<>();
......@@ -46,11 +61,13 @@ public class CacheAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@Operation(summary = "接收刷新Config配置文件指令.", operationId = OPERATIONID_PREFIX + "configFlush", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = ActionConfigFlush.Wo.class)) }) })
@GET
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
@Path("config/flush")
@JaxrsMethodDescribe(value = "接收config flush 信号.", action = ActionConfigFlush.class)
@JaxrsMethodDescribe(value = "接收刷新Config配置文件指令.", action = ActionConfigFlush.class)
public void configFlush(@Suspended final AsyncResponse asyncResponse, @Context ServletContext servletContext,
@Context HttpServletRequest request) {
ActionResult<ActionConfigFlush.Wo> result = new ActionResult<>();
......@@ -64,6 +81,8 @@ public class CacheAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@Operation(summary = "显示缓存状态.", operationId = OPERATIONID_PREFIX + "detail", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = ActionDetail.Wo.class)) }) })
@GET
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
......
......@@ -11,12 +11,14 @@ 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 io.swagger.v3.oas.annotations.media.Schema;
class ActionGet extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionGet.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ActionGet.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, ServletContext servletContext) throws Exception {
logger.debug(effectivePerson, "echo from:{}.", effectivePerson);
ActionResult<Wo> execute(EffectivePerson effectivePerson, ServletContext servletContext) {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
ActionResult<Wo> result = new ActionResult<>();
Wo wo = new Wo();
wo.setServletContextName(servletContext.getServletContextName());
......@@ -25,14 +27,17 @@ class ActionGet extends BaseAction {
return result;
}
@Schema(name = "com.x.base.core.project.jaxrs.echo.ActionGet.Wo")
public static class Wo extends GsonPropertyObject {
private static final long serialVersionUID = 3728516737526214370L;
@FieldDescribe("上下文根")
@FieldDescribe("上下文根.")
@Schema(description = "上下文根.")
private String servletContextName;
@FieldDescribe("服务器时间")
@FieldDescribe("服务器时间.")
@Schema(description = "服务器时间.")
private Date serverTime;
public String getServletContextName() {
......
......@@ -8,6 +8,7 @@ import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import com.x.base.core.project.annotation.DescribeScope;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.http.ActionResult;
......@@ -17,12 +18,23 @@ import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import io.swagger.v3.oas.annotations.Operation;
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 = "EchoAction", description = "应用响应接口.")
@Path("echo")
@JaxrsDescribe("响应")
@JaxrsDescribe(value = "应用响应接口.", scope = DescribeScope.system)
public class EchoAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(EchoAction.class);
private static final String OPERATIONID_PREFIX = "EchoAction::";
private static final Logger LOGGER = LoggerFactory.getLogger(EchoAction.class);
@Operation(summary = "获取应答.", operationId = OPERATIONID_PREFIX + "get", responses = {
@ApiResponse(content = @Content(schema = @Schema(implementation = ActionGet.Wo.class))) })
@JaxrsMethodDescribe(value = "获取应答.", action = ActionGet.class)
@GET
public void get(@Suspended final AsyncResponse asyncResponse, @Context ServletContext servletContext,
......@@ -32,7 +44,7 @@ public class EchoAction extends StandardJaxrsAction {
try {
result = new ActionGet().execute(effectivePerson, servletContext);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......
......@@ -11,14 +11,16 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.schedule.AbstractJob;
import io.swagger.v3.oas.annotations.media.Schema;
class ActionExecute extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionExecute.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ActionExecute.class);
@SuppressWarnings("unchecked")
ActionResult<Wo> execute(EffectivePerson effectivePerson, @Context ServletContext servletContext, String className)
throws Exception {
logger.debug("execute:{}.", () -> className);
LOGGER.debug("execute:{}, className:{}.", effectivePerson::getDistinguishedName, () -> className);
ActionResult<Wo> result = new ActionResult<>();
AbstractContext ctx = AbstractContext.fromServletContext(servletContext);
Class<?> clz = Thread.currentThread().getContextClassLoader().loadClass(className);
......@@ -29,7 +31,11 @@ class ActionExecute extends BaseAction {
return result;
}
@Schema(name = "com.x.base.core.project.jaxrs.fireschedule.ActionExecute.Wo")
public static class Wo extends WrapBoolean {
private static final long serialVersionUID = -6588426920664208798L;
}
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import com.x.base.core.project.annotation.DescribeScope;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
......@@ -16,26 +17,40 @@ import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import io.swagger.v3.oas.annotations.Operation;
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 = "FireScheduleAction", description = "触发定时任务接口.")
@Path("fireschedule")
@JaxrsDescribe("触发任务")
@JaxrsDescribe(value = "触发定时任务接口.", scope = DescribeScope.system)
public class FireScheduleAction extends StandardJaxrsAction {
@JaxrsMethodDescribe(value = "接受x_program_center发送过来的运行schedule.", action = ActionExecute.class)
private static final String OPERATIONID_PREFIX = "FireScheduleAction::";
private static final Logger LOGGER = LoggerFactory.getLogger(FireScheduleAction.class);
@Operation(summary = "接受x_program_center发送过来的运行定时任务指令.", operationId = OPERATIONID_PREFIX + "execute", responses = {
@ApiResponse(content = @Content(schema = @Schema(implementation = ActionExecute.Wo.class))) })
@JaxrsMethodDescribe(value = "接受x_program_center发送过来的运行定时任务指令.", action = ActionExecute.class)
@GET
@Path("classname/{className}")
public void execute(@Suspended final AsyncResponse asyncResponse, @Context ServletContext servletContext,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("运行类") @PathParam("className") String className) throws Exception {
ActionResult<ActionExecute.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
ActionResult<ActionExecute.Wo> result = new ActionExecute().execute(effectivePerson, servletContext, className);
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
public static class Wo extends WrapBoolean {
public Wo(Boolean value) {
super(value);
try {
result = new ActionExecute().execute(effectivePerson, servletContext, className);
} catch (Exception e) {
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
package com.x.base.core.project.jaxrs.openapi;
import static io.swagger.v3.jaxrs2.integration.ServletConfigContextUtils.getContextIdFromServletConfig;
import java.util.Set;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.ws.rs.core.Application;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoText;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import io.swagger.v3.jaxrs2.integration.JaxrsOpenApiContextBuilder;
import io.swagger.v3.oas.integration.OpenApiConfigurationException;
import io.swagger.v3.oas.integration.api.OpenAPIConfiguration;
import io.swagger.v3.oas.integration.api.OpenApiContext;
public class ActionGet extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionGet.class);
private static Wo wo;
ActionResult<Wo> execute(EffectivePerson effectivePerson, ServletContext servletContext,
ServletConfig servletConfig, Application application) throws Exception {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
ActionResult<Wo> result = new ActionResult<>();
Wo wo = get(servletConfig, application);
result.setData(wo);
return result;
}
protected String getContextId(ServletConfig config) {
return getContextIdFromServletConfig(config);
}
protected Wo get(ServletConfig config, Application application) throws OpenApiConfigurationException {
synchronized (ActionGet.class) {
if (null == wo) {
String ctxId = getContextId(config);
@SuppressWarnings("rawtypes")
OpenApiContext ctx = new JaxrsOpenApiContextBuilder().servletConfig(config).application(application)
// .resourcePackages(resourcePackages).configLocation(configLocation)
// .openApiConfiguration(openApiConfiguration)
.ctxId(ctxId).buildContext(true);
wo = new Wo();
wo.setText(gson.toJson(ctx.read()));
}
return wo;
}
}
protected String configLocation;
public String getConfigLocation() {
return configLocation;
}
public void setConfigLocation(String configLocation) {
this.configLocation = configLocation;
}
public ActionGet configLocation(String configLocation) {
setConfigLocation(configLocation);
return this;
}
protected Set<String> resourcePackages;
public Set<String> getResourcePackages() {
return resourcePackages;
}
public void setResourcePackages(Set<String> resourcePackages) {
this.resourcePackages = resourcePackages;
}
public ActionGet resourcePackages(Set<String> resourcePackages) {
setResourcePackages(resourcePackages);
return this;
}
protected OpenAPIConfiguration openApiConfiguration;
public OpenAPIConfiguration getOpenApiConfiguration() {
return openApiConfiguration;
}
public void setOpenApiConfiguration(OpenAPIConfiguration openApiConfiguration) {
this.openApiConfiguration = openApiConfiguration;
}
public ActionGet openApiConfiguration(OpenAPIConfiguration openApiConfiguration) {
setOpenApiConfiguration(openApiConfiguration);
return this;
}
public static class Wo extends WoText {
private static final long serialVersionUID = 2588451195416207384L;
}
}
package com.x.base.core.project.jaxrs.openapi;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
abstract class BaseAction extends StandardJaxrsAction {
}
package com.x.base.core.project.jaxrs.openapi;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Context;
import com.x.base.core.project.annotation.DescribeScope;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import io.swagger.v3.oas.annotations.Operation;
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 = "OpenApiAction", description = "OpenAPI接口规范.")
@Path("openapi")
@JaxrsDescribe(value = "OpenAPI接口规范.", scope = DescribeScope.system)
public class OpenApiAction extends StandardJaxrsAction {
private static final String OPERATIONID_PREFIX = "OpenApiAction::";
private static final Logger LOGGER = LoggerFactory.getLogger(OpenApiAction.class);
@Context
ServletConfig servletConfig;
@Context
Application application;
@Operation(summary = "获取openapi描述文件.", operationId = OPERATIONID_PREFIX + "get", responses = {
@ApiResponse(content = @Content(schema = @Schema(implementation = ActionGet.Wo.class))) })
@JaxrsMethodDescribe(value = "获取openapi描述文件.", action = ActionGet.class)
@GET
public void get(@Suspended final AsyncResponse asyncResponse, @Context ServletContext servletContext,
@Context HttpServletRequest request) {
ActionResult<ActionGet.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionGet().execute(effectivePerson, servletContext, servletConfig, application);
} catch (Exception e) {
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
package com.x.base.core.project.jaxrs.sysresource;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
......@@ -14,21 +16,25 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.FileTools;
import io.swagger.v3.oas.annotations.media.Schema;
class ActionListResource extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionListResource.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ActionListResource.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String filePath) throws Exception {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String filePath) throws IOException, URISyntaxException {
LOGGER.debug("execute:{}, filePath:{}.", effectivePerson::getDistinguishedName, () -> filePath);
ActionResult<Wo> result = new ActionResult<>();
File dist = new File(Config.base(), Config.DIR_SERVERS_WEBSERVER);
if(StringUtils.isNotEmpty(filePath) && !filePath.equals(EMPTY_SYMBOL)){
if (StringUtils.isNotEmpty(filePath) && !filePath.equals(EMPTY_SYMBOL)) {
dist = new File(dist, filePath);
if(!dist.exists()){
throw new Exception("filePath not exist!");
if (!dist.exists()) {
throw new IllegalStateException("filePath not exist!");
}
}
Map<String, List<FileTools.FileInfo>> fileMap = FileTools.getFiles(dist.getAbsolutePath(), null, Config.DIR_SERVERS_WEBSERVER);
Map<String, List<FileTools.FileInfo>> fileMap = FileTools.getFiles(dist.getAbsolutePath(), null,
Config.DIR_SERVERS_WEBSERVER);
Wo wo = new Wo();
wo.setFiles(fileMap.get("files"));
......@@ -37,13 +43,15 @@ class ActionListResource extends BaseAction {
return result;
}
@Schema(name = "com.x.base.core.project.jaxrs.sysresource.ActionListResource.Wo")
public static class Wo extends GsonPropertyObject {
private static final long serialVersionUID = -5820494266964710342L;
private List<FileTools.FileInfo> files;
private List<FileTools.FileInfo> folders;
public List<FileTools.FileInfo> getFiles() {
return files;
}
......
......@@ -11,6 +11,7 @@ import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.x.base.core.project.annotation.DescribeScope;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
......@@ -19,28 +20,40 @@ import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.jaxrs.openapi.ActionGet;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import io.swagger.v3.oas.annotations.Operation;
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 = "SysResourceAction", description = "系统资源接口.")
@Path("sysresource")
@JaxrsDescribe("系统资源")
@JaxrsDescribe(value = "系统资源接口.", scope = DescribeScope.system)
public class SysResourceAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(SysResourceAction.class);
private static final Logger LOGGER = LoggerFactory.getLogger(SysResourceAction.class);
private static final String OPERATIONID_PREFIX = "SysResourceAction::";
@Operation(summary = "获取静态资源信息.", operationId = OPERATIONID_PREFIX + "listResource", responses = {
@ApiResponse(content = @Content(schema = @Schema(implementation = ActionListResource.Wo.class))) })
@JaxrsMethodDescribe(value = "获取静态资源信息.", action = ActionListResource.class)
@GET
@Path("filePath/{filePath}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listResource(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("查找路径(根路径:(0))") @PathParam("filePath") String filePath) {
@JaxrsParameterDescribe("查找路径(根路径:(0))") @PathParam("filePath") String filePath) {
ActionResult<ActionListResource.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListResource().execute(effectivePerson, filePath);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......
/.apt_generated/
/.apt_generated_tests/
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册