提交 ab477887 编写于 作者: O o2null

Merge branch 'fix/proxy_invoke_agent' into 'wrdp'

Fix/proxy invoke agent

See merge request o2oa/o2oa!1815
......@@ -108,7 +108,7 @@
"###excludes": "在此节点上不存储的类,和includes一起设置实际存储的类,可以使用通配符*###",
"###jmxEnable": "是否启动jmx,如果启用,可以通过本地的jmx客户端进行访问,不支持远程jmx客户端.###",
"###cacheSize": "H2数据库缓存大小,设置H2用于作为缓存的内存大小,以M作为单位,这里默认为512M.###",
"###logLevel": "默认日志级别###",
"###logLevel": "默认日志级别,FATAL, ERROR, WARN, INFO, TRACE. 完成的配置为DefaultLevel\u003dWARN, Tool\u003dTRACE, Enhance\u003dTRACE, METADATA\u003dTRACE, Runtime\u003dTRACE, Query\u003dTRACE, DataCache\u003dTRACE, JDBC\u003dTRACE, SQL\u003dTRACE###",
"###maxTotal": "最大使用连接数###",
"###maxIdle": "最大空闲连接数###",
"###statEnable": "启用统计,默认启用###",
......
......@@ -3,11 +3,14 @@ package com.x.server.console.server.web;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.proxy.AsyncProxyServlet;
public class Proxy extends AsyncProxyServlet {
private static final long serialVersionUID = 2737360000716631564L;
private static final String X_Real_IP = "X-Real-IP";
@Override
protected String rewriteTarget(HttpServletRequest request) {
......@@ -17,19 +20,30 @@ public class Proxy extends AsyncProxyServlet {
}
private String target(String url, String parameter, String port) {
int x = StringUtils.indexOf(url, ":", 8);
int x = StringUtils.indexOf(url, "://");
int y = StringUtils.indexOf(url, "/", 8);
if ((x > 0) && (y > 0)) {
return url.substring(0, x) + port(url, port) + url.substring(y)
+ (StringUtils.isBlank(parameter) ? "" : "?" + parameter);
} else if (y > 0) {
return url.substring(0, y) + port(url, port) + url.substring(y)
return url.substring(0, x + 3) + "127.0.0.1" + port(url, port) + url.substring(y)
+ (StringUtils.isBlank(parameter) ? "" : "?" + parameter);
} else {
return null;
}
}
// private String target(String url, String parameter, String port) {
// int x = StringUtils.indexOf(url, ":", 8);
// int y = StringUtils.indexOf(url, "/", 8);
// if ((x > 0) && (y > 0)) {
// return url.substring(0, x) + port(url, port) + url.substring(y)
// + (StringUtils.isBlank(parameter) ? "" : "?" + parameter);
// } else if (y > 0) {
// return url.substring(0, y) + port(url, port) + url.substring(y)
// + (StringUtils.isBlank(parameter) ? "" : "?" + parameter);
// } else {
// return null;
// }
// }
private String port(String url, String port) {
if (StringUtils.startsWithIgnoreCase(url, "https://") || StringUtils.startsWithIgnoreCase(url, "wss://")) {
if (StringUtils.equals(port, "443")) {
......@@ -43,4 +57,66 @@ public class Proxy extends AsyncProxyServlet {
return ":" + port;
}
@Override
protected void addXForwardedHeaders(HttpServletRequest clientRequest, Request proxyRequest) {
if (StringUtils.isNotEmpty(clientRequest.getHeader(HttpHeader.X_FORWARDED_FOR.asString()))) {
proxyRequest.header(HttpHeader.X_FORWARDED_FOR,
clientRequest.getHeader(HttpHeader.X_FORWARDED_FOR.asString()));
} else {
proxyRequest.header(HttpHeader.X_FORWARDED_FOR, clientRequest.getRemoteAddr());
}
if (StringUtils.isNotEmpty(clientRequest.getHeader(HttpHeader.X_FORWARDED_PROTO.asString()))) {
proxyRequest.header(HttpHeader.X_FORWARDED_PROTO,
clientRequest.getHeader(HttpHeader.X_FORWARDED_PROTO.asString()));
} else {
proxyRequest.header(HttpHeader.X_FORWARDED_PROTO, clientRequest.getScheme());
}
if (StringUtils.isNotEmpty(clientRequest.getHeader(HttpHeader.X_FORWARDED_HOST.asString()))) {
proxyRequest.header(HttpHeader.X_FORWARDED_HOST,
clientRequest.getHeader(HttpHeader.X_FORWARDED_HOST.asString()));
} else {
proxyRequest.header(HttpHeader.X_FORWARDED_HOST, clientRequest.getHeader(HttpHeader.HOST.asString()));
}
if (StringUtils.isNotEmpty(clientRequest.getHeader(HttpHeader.X_FORWARDED_SERVER.asString()))) {
proxyRequest.header(HttpHeader.X_FORWARDED_SERVER,
clientRequest.getHeader(HttpHeader.X_FORWARDED_SERVER.asString()));
} else {
proxyRequest.header(HttpHeader.X_FORWARDED_SERVER, clientRequest.getLocalName());
}
if (StringUtils.isNotEmpty(clientRequest.getHeader(HttpHeader.HOST.asString()))) {
proxyRequest.header(HttpHeader.HOST, clientRequest.getHeader(HttpHeader.HOST.asString()));
}
if (StringUtils.isNotEmpty(clientRequest.getHeader(X_Real_IP))) {
proxyRequest.header(X_Real_IP, clientRequest.getHeader(X_Real_IP));
} else {
proxyRequest.header(X_Real_IP, clientRequest.getRemoteAddr());
}
// if (StringUtils.isNotEmpty(clientRequest.getHeader(HttpHeader.UPGRADE.asString()))) {
// proxyRequest.header(HttpHeader.UPGRADE, clientRequest.getHeader(HttpHeader.UPGRADE.asString()));
// }
//
// if (StringUtils.isNotEmpty(clientRequest.getHeader(HttpHeader.CONNECTION.asString()))) {
// proxyRequest.header(HttpHeader.CONNECTION, clientRequest.getHeader(HttpHeader.CONNECTION.asString()));
// }
//
// if (StringUtils.isNotEmpty(clientRequest.getHeader(HttpHeader.SEC_WEBSOCKET_EXTENSIONS.asString()))) {
// proxyRequest.header(HttpHeader.SEC_WEBSOCKET_EXTENSIONS,
// clientRequest.getHeader(HttpHeader.SEC_WEBSOCKET_EXTENSIONS.asString()));
// }
//
// if (StringUtils.isNotEmpty(clientRequest.getHeader(HttpHeader.SEC_WEBSOCKET_KEY.asString()))) {
// proxyRequest.header(HttpHeader.SEC_WEBSOCKET_KEY,
// clientRequest.getHeader(HttpHeader.SEC_WEBSOCKET_KEY.asString()));
// }
if (StringUtils.isNotEmpty(clientRequest.getHeader(HttpHeader.SEC_WEBSOCKET_VERSION.asString()))) {
proxyRequest.header(HttpHeader.SEC_WEBSOCKET_VERSION,
clientRequest.getHeader(HttpHeader.SEC_WEBSOCKET_VERSION.asString()));
}
}
}
package com.x.processplatform.assemble.surface.jaxrs.attachment;
import java.util.Optional;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.config.ProcessPlatform.WorkCompletedExtensionEvent;
import com.x.base.core.project.config.StorageMapping;
import com.x.base.core.project.connection.CipherConnectionAction;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoFile;
import com.x.processplatform.assemble.surface.Business;
import com.x.processplatform.assemble.surface.ThisApplication;
import com.x.processplatform.assemble.surface.WorkCompletedControl;
import com.x.processplatform.core.entity.content.Attachment;
import com.x.processplatform.core.entity.content.WorkCompleted;
/**
* 管理员下载
*
* @author zhour
*
*/
class ActionManageDownload extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Attachment attachment = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
attachment = emc.find(id, Attachment.class);
if (null == attachment) {
throw new ExceptionEntityNotExist(id, Attachment.class);
}
if (BooleanUtils.isNotTrue(business.canManageApplicationOrProcess(effectivePerson,
attachment.getApplication(), attachment.getProcess()))) {
throw new ExceptionAccessDenied(effectivePerson, attachment);
}
}
StorageMapping mapping = ThisApplication.context().storageMappings().get(Attachment.class,
attachment.getStorage());
String fileName = attachment.getName()
+ (StringUtils.isNotEmpty(attachment.getExtension()) ? "." + attachment.getExtension() : "");
byte[] bytes = attachment.readContent(mapping);
Wo wo = new Wo(bytes, this.contentType(false, fileName), this.contentDisposition(false, fileName));
result.setData(wo);
return result;
}
public static class Wo extends WoFile {
public Wo(byte[] bytes, String contentType, String contentDisposition) {
super(bytes, contentType, contentDisposition);
}
}
}
\ No newline at end of file
package com.x.processplatform.assemble.surface.jaxrs.attachment;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.config.StorageMapping;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoFile;
import com.x.processplatform.assemble.surface.Business;
import com.x.processplatform.assemble.surface.ThisApplication;
import com.x.processplatform.core.entity.content.Attachment;
/**
* 管理员下载
*
* @author zhour
*
*/
class ActionManageDownloadStream extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Attachment attachment = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
attachment = emc.find(id, Attachment.class);
if (null == attachment) {
throw new ExceptionEntityNotExist(id, Attachment.class);
}
if (BooleanUtils.isNotTrue(business.canManageApplicationOrProcess(effectivePerson,
attachment.getApplication(), attachment.getProcess()))) {
throw new ExceptionAccessDenied(effectivePerson, attachment);
}
}
StorageMapping mapping = ThisApplication.context().storageMappings().get(Attachment.class,
attachment.getStorage());
String fileName = attachment.getName()
+ (StringUtils.isNotEmpty(attachment.getExtension()) ? "." + attachment.getExtension() : "");
byte[] bytes = attachment.readContent(mapping);
Wo wo = new Wo(bytes, this.contentType(true, fileName), this.contentDisposition(true, fileName));
result.setData(wo);
return result;
}
public static class Wo extends WoFile {
public Wo(byte[] bytes, String contentType, String contentDisposition) {
super(bytes, contentType, contentDisposition);
}
}
}
\ No newline at end of file
......@@ -18,6 +18,12 @@ import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import org.apache.commons.lang3.StringUtils;
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
import org.glassfish.jersey.media.multipart.FormDataParam;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
......@@ -30,12 +36,6 @@ 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 org.apache.commons.lang3.StringUtils;
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
import org.glassfish.jersey.media.multipart.FormDataParam;
@Path("attachment")
@JaxrsDescribe("附件操作")
public class AttachmentAction extends StandardJaxrsAction {
......@@ -85,8 +85,8 @@ public class AttachmentAction extends StandardJaxrsAction {
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void getWithWorkCompleted(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("已完成工作标识") @PathParam("workCompletedId") String workCompletedId,
@JaxrsParameterDescribe("附件标识") @PathParam("id") String id) {
@JaxrsParameterDescribe("已完成工作标识") @PathParam("workCompletedId") String workCompletedId,
@JaxrsParameterDescribe("附件标识") @PathParam("id") String id) {
ActionResult<ActionGetWithWorkCompleted.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
......@@ -103,9 +103,10 @@ public class AttachmentAction extends StandardJaxrsAction {
@Path("{id}/workorworkcompleted/{workOrWorkCompleted}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void getWithWorkOrWorkCompleted(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("工作或已完成工作标识") @PathParam("workOrWorkCompleted") String workOrWorkCompleted,
@JaxrsParameterDescribe("附件标识") @PathParam("id") String id) {
public void getWithWorkOrWorkCompleted(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("工作或已完成工作标识") @PathParam("workOrWorkCompleted") String workOrWorkCompleted,
@JaxrsParameterDescribe("附件标识") @PathParam("id") String id) {
ActionResult<ActionGetWithWorkOrWorkCompleted.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
......@@ -604,7 +605,8 @@ public class AttachmentAction extends StandardJaxrsAction {
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void copyToWorkCompleted(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("已完成工作标识") @PathParam("workCompletedId") String workCompletedId, JsonElement jsonElement) {
@JaxrsParameterDescribe("已完成工作标识") @PathParam("workCompletedId") String workCompletedId,
JsonElement jsonElement) {
ActionResult<List<ActionCopyToWorkCompleted.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
......@@ -932,6 +934,40 @@ public class AttachmentAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "管理员角色下载附件", action = ActionManageDownload.class)
@GET
@Path("download/{id}/manage")
@Consumes(MediaType.APPLICATION_JSON)
public void manageDownload(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("附件标识") @PathParam("id") String id) {
ActionResult<ActionManageDownload.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionManageDownload().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "管理员角色下载附件,stream", action = ActionManageDownloadStream.class)
@GET
@Path("download/{id}/manage/stream")
@Consumes(MediaType.APPLICATION_JSON)
public void manageDownloadStream(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("附件标识") @PathParam("id") String id) {
ActionResult<ActionManageDownloadStream.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionManageDownloadStream().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "html转pdf工具类,转换后通过downloadTransfer接口下载", action = ActionHtmlToPdf.class)
@POST
@Path("html/to/pdf")
......
package com.x.processplatform.assemble.surface.jaxrs.snap;
import org.apache.commons.lang3.BooleanUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.Applications;
import com.x.base.core.project.x_processplatform_service_processing;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.processplatform.assemble.surface.Business;
import com.x.processplatform.assemble.surface.ThisApplication;
import com.x.processplatform.core.entity.content.Work;
import com.x.processplatform.core.entity.element.Activity;
class ActionTypeAbandoned extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionTypeAbandoned.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String workId) throws Exception {
String job = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
Work work = emc.find(workId, Work.class);
if (null == work) {
throw new ExceptionEntityNotExist(workId, Work.class);
}
job = work.getJob();
Activity activity = business.getActivity(work.getActivity(), work.getActivityType());
if (BooleanUtils.isNotTrue(
business.canManageApplicationOrProcess(effectivePerson, work.getApplication(), work.getProcess()))
&& ((!business.editable(effectivePerson, work))
|| (BooleanUtils.isNotTrue(activity.getAllowSuspend())))) {
throw new ExceptionAccessDenied(effectivePerson, work);
}
}
Wo wo = ThisApplication.context().applications()
.getQuery(effectivePerson.getDebugger(), x_processplatform_service_processing.class,
Applications.joinQueryUri("snap", "work", workId, "type", "abandoned"), job)
.getData(Wo.class);
ActionResult<Wo> result = new ActionResult<>();
result.setData(wo);
return result;
}
public static class Wo extends WoId {
private static final long serialVersionUID = -2577413577740827608L;
}
}
......@@ -38,7 +38,7 @@ class ActionEdit extends BaseAction {
}
emc.beginTransaction(Agent.class);
Wi.copier.copy(wi, agent);
this.addComment(agent);
//this.addComment(agent);
emc.check(agent, CheckPersistType.all);
emc.commit();
CacheManager.notify(Agent.class);
......
......@@ -17,14 +17,14 @@ class ActionUpdate extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = new Wo();
Agent agent = emc.flag(flag, Agent.class );
Agent agent = emc.flag(flag, Agent.class);
if (null == agent) {
throw new ExceptionAgentNotExist(flag);
}
String text = new String(bytes, DefaultCharset.name);
emc.beginTransaction(Agent.class);
agent.setText(text);
this.addComment(agent);
// this.addComment(agent);
emc.commit();
wo.setId(agent.getId());
result.setData(wo);
......
......@@ -9,31 +9,31 @@ import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.program.center.core.entity.Agent;
abstract class BaseAction extends StandardJaxrsAction {
private static String COMMENT = "";
private static final Pattern COMMENT_REGEX = Pattern.compile("^\\/\\*(\\s|.)*?\\*\\/");
static {
COMMENT = "/*" + StringUtils.LF;
COMMENT += "* resources.getEntityManagerContainer() // 实体管理容器." + StringUtils.LF;
COMMENT += "* resources.getContext() //上下文根." + StringUtils.LF;
COMMENT += "* resources.getOrganization() //组织访问接口." + StringUtils.LF;
COMMENT += "* requestText //请求内容." + StringUtils.LF;
COMMENT += "* request //请求对象." + StringUtils.LF;
COMMENT += "*/" + StringUtils.LF;
}
protected void addComment(Agent agent) {
if (StringUtils.isEmpty(agent.getText())) {
agent.setText(COMMENT);
} else {
Matcher m = COMMENT_REGEX.matcher(agent.getText());
if (m.find()) {
agent.setText(COMMENT + m.replaceFirst(""));
} else {
agent.setText(COMMENT + agent.getText());
}
}
}
// private static String COMMENT = "";
//
// private static final Pattern COMMENT_REGEX = Pattern.compile("^\\/\\*(\\s|.)*?\\*\\/");
//
// static {
// COMMENT = "/*" + StringUtils.LF;
// COMMENT += "* resources.getEntityManagerContainer() // 实体管理容器." + StringUtils.LF;
// COMMENT += "* resources.getContext() //上下文根." + StringUtils.LF;
// COMMENT += "* resources.getOrganization() //组织访问接口." + StringUtils.LF;
// COMMENT += "* requestText //请求内容." + StringUtils.LF;
// COMMENT += "* request //请求对象." + StringUtils.LF;
// COMMENT += "*/" + StringUtils.LF;
// }
//
// protected void addComment(Agent agent) {
// if (StringUtils.isEmpty(agent.getText())) {
// agent.setText(COMMENT);
// } else {
// Matcher m = COMMENT_REGEX.matcher(agent.getText());
// if (m.find()) {
// agent.setText(COMMENT + m.replaceFirst(""));
// } else {
// agent.setText(COMMENT + agent.getText());
// }
// }
// }
}
......@@ -24,7 +24,7 @@ class ActionEdit extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Invoke invoke = emc.flag(flag, Invoke.class );
Invoke invoke = emc.flag(flag, Invoke.class);
if (StringUtils.isEmpty(wi.getName())) {
throw new ExceptionEmptyName();
}
......@@ -38,7 +38,7 @@ class ActionEdit extends BaseAction {
}
emc.beginTransaction(Invoke.class);
Wi.copier.copy(wi, invoke);
this.addComment(invoke);
// this.addComment(invoke);
emc.check(invoke, CheckPersistType.all);
emc.commit();
CacheManager.notify(Invoke.class);
......
......@@ -17,14 +17,14 @@ class ActionUpdate extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = new Wo();
Invoke invoke = emc.flag(flag, Invoke.class );
Invoke invoke = emc.flag(flag, Invoke.class);
if (null == invoke) {
throw new ExceptionInvokeNotExist(flag);
}
String text = new String(bytes, DefaultCharset.name);
emc.beginTransaction(Invoke.class);
invoke.setText(text);
this.addComment(invoke);
// this.addComment(invoke);
emc.commit();
wo.setId(invoke.getId());
result.setData(wo);
......
......@@ -10,31 +10,31 @@ import com.x.program.center.core.entity.Invoke;
abstract class BaseAction extends StandardJaxrsAction {
private static String COMMENT = "";
private static final Pattern COMMENT_REGEX = Pattern.compile("^\\/\\*(\\s|.)*?\\*\\/");
static {
COMMENT = "/*" + StringUtils.LF;
COMMENT += "* resources.getEntityManagerContainer() // 实体管理容器." + StringUtils.LF;
COMMENT += "* resources.getContext() //上下文根." + StringUtils.LF;
COMMENT += "* resources.getOrganization() //组织访问接口." + StringUtils.LF;
COMMENT += "* requestText //请求内容." + StringUtils.LF;
COMMENT += "* request //请求对象." + StringUtils.LF;
COMMENT += "*/" + StringUtils.LF;
}
protected void addComment(Invoke invoke) {
if (StringUtils.isEmpty(invoke.getText())) {
invoke.setText(COMMENT);
} else {
Matcher m = COMMENT_REGEX.matcher(invoke.getText());
if (m.find()) {
invoke.setText(COMMENT + m.replaceFirst(""));
} else {
invoke.setText(COMMENT + invoke.getText());
}
}
}
// private static String COMMENT = "";
//
// private static final Pattern COMMENT_REGEX = Pattern.compile("^\\/\\*(\\s|.)*?\\*\\/");
//
// static {
// COMMENT = "/*" + StringUtils.LF;
// COMMENT += "* resources.getEntityManagerContainer() // 实体管理容器." + StringUtils.LF;
// COMMENT += "* resources.getContext() //上下文根." + StringUtils.LF;
// COMMENT += "* resources.getOrganization() //组织访问接口." + StringUtils.LF;
// COMMENT += "* requestText //请求内容." + StringUtils.LF;
// COMMENT += "* request //请求对象." + StringUtils.LF;
// COMMENT += "*/" + StringUtils.LF;
// }
//
// protected void addComment(Invoke invoke) {
// if (StringUtils.isEmpty(invoke.getText())) {
// invoke.setText(COMMENT);
// } else {
// Matcher m = COMMENT_REGEX.matcher(invoke.getText());
// if (m.find()) {
// invoke.setText(COMMENT + m.replaceFirst(""));
// } else {
// invoke.setText(COMMENT + invoke.getText());
// }
// }
// }
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册