|
|
@@ -1,8 +1,8 @@
|
|
|
package com.x.processplatform.assemble.surface.jaxrs.attachment;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
-import javax.jws.WebParam;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.ws.rs.*;
|
|
|
import javax.ws.rs.container.AsyncResponse;
|
|
|
@@ -10,7 +10,10 @@ 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;
|
|
|
@@ -337,16 +340,29 @@ public class AttachmentAction extends StandardJaxrsAction {
|
|
|
@Path("upload/work/{workId}")
|
|
|
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
|
|
|
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
|
|
- public void upload(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
|
|
|
- @JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId,
|
|
|
- @JaxrsParameterDescribe("位置") @FormDataParam("site") String site,
|
|
|
- @JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName,
|
|
|
- @JaxrsParameterDescribe("天印扩展字段") @FormDataParam("extraParam") String extraParam,
|
|
|
- @FormDataParam(FILE_FIELD) final byte[] bytes,
|
|
|
- @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
|
|
|
+ public void upload(FormDataMultiPart form, @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
|
|
|
+ @JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId,
|
|
|
+ @JaxrsParameterDescribe("位置") @FormDataParam("site") String site,
|
|
|
+ @JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName,
|
|
|
+ @JaxrsParameterDescribe("天印扩展字段") @FormDataParam("extraParam") String extraParam,
|
|
|
+ @FormDataParam(FILE_FIELD) byte[] bytes,
|
|
|
+ @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
|
|
|
ActionResult<ActionUpload.Wo> result = new ActionResult<>();
|
|
|
EffectivePerson effectivePerson = this.effectivePerson(request);
|
|
|
try {
|
|
|
+ if(StringUtils.isEmpty(extraParam)){
|
|
|
+ extraParam = this.request2Json(request);
|
|
|
+ }
|
|
|
+ if(bytes==null){
|
|
|
+ Map<String, List<FormDataBodyPart>> map = form.getFields();
|
|
|
+ for(String key: map.keySet()){
|
|
|
+ FormDataBodyPart part = map.get(key).get(0);
|
|
|
+ if("application".equals(part.getMediaType().getType())){
|
|
|
+ bytes = part.getValueAs(byte[].class);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
result = new ActionUpload().execute(effectivePerson, workId, site, fileName, bytes, disposition,
|
|
|
extraParam);
|
|
|
} catch (Exception e) {
|
|
|
@@ -361,17 +377,30 @@ public class AttachmentAction extends StandardJaxrsAction {
|
|
|
@Path("upload/workcompleted/{workCompletedId}")
|
|
|
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
|
|
|
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
|
|
- public void uploadWithWorkCompleted(@Suspended final AsyncResponse asyncResponse,
|
|
|
+ public void uploadWithWorkCompleted(FormDataMultiPart form, @Suspended final AsyncResponse asyncResponse,
|
|
|
@Context HttpServletRequest request,
|
|
|
@JaxrsParameterDescribe("已完成工作标识") @PathParam("workCompletedId") String workCompletedId,
|
|
|
@JaxrsParameterDescribe("位置") @FormDataParam("site") String site,
|
|
|
@JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName,
|
|
|
@JaxrsParameterDescribe("天印扩展字段") @FormDataParam("extraParam") String extraParam,
|
|
|
- @FormDataParam(FILE_FIELD) final byte[] bytes,
|
|
|
+ @FormDataParam(FILE_FIELD) byte[] bytes,
|
|
|
@FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
|
|
|
ActionResult<ActionUploadWithWorkCompleted.Wo> result = new ActionResult<>();
|
|
|
EffectivePerson effectivePerson = this.effectivePerson(request);
|
|
|
try {
|
|
|
+ if(StringUtils.isEmpty(extraParam)){
|
|
|
+ extraParam = this.request2Json(request);
|
|
|
+ }
|
|
|
+ if(bytes==null){
|
|
|
+ Map<String, List<FormDataBodyPart>> map = form.getFields();
|
|
|
+ for(String key: map.keySet()){
|
|
|
+ FormDataBodyPart part = map.get(key).get(0);
|
|
|
+ if("application".equals(part.getMediaType().getType())){
|
|
|
+ bytes = part.getValueAs(byte[].class);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
result = new ActionUploadWithWorkCompleted().execute(effectivePerson, workCompletedId, site, fileName,
|
|
|
bytes, disposition, extraParam);
|
|
|
} catch (Exception e) {
|
|
|
@@ -411,16 +440,29 @@ public class AttachmentAction extends StandardJaxrsAction {
|
|
|
@Path("update/{id}/work/{workId}")
|
|
|
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
|
|
|
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
|
|
- public void update(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
|
|
|
+ public void update(FormDataMultiPart form, @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
|
|
|
@JaxrsParameterDescribe("附件标识") @PathParam("id") String id,
|
|
|
@JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId,
|
|
|
@JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName,
|
|
|
@JaxrsParameterDescribe("天印扩展字段") @FormDataParam("extraParam") String extraParam,
|
|
|
- @FormDataParam(FILE_FIELD) final byte[] bytes,
|
|
|
+ @FormDataParam(FILE_FIELD) byte[] bytes,
|
|
|
@JaxrsParameterDescribe("附件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
|
|
|
ActionResult<ActionUpdate.Wo> result = new ActionResult<>();
|
|
|
EffectivePerson effectivePerson = this.effectivePerson(request);
|
|
|
try {
|
|
|
+ if(StringUtils.isEmpty(extraParam)){
|
|
|
+ extraParam = this.request2Json(request);
|
|
|
+ }
|
|
|
+ if(bytes==null){
|
|
|
+ Map<String, List<FormDataBodyPart>> map = form.getFields();
|
|
|
+ for(String key: map.keySet()){
|
|
|
+ FormDataBodyPart part = map.get(key).get(0);
|
|
|
+ if("application".equals(part.getMediaType().getType())){
|
|
|
+ bytes = part.getValueAs(byte[].class);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
result = new ActionUpdate().execute(effectivePerson, id, workId, fileName, bytes, disposition, extraParam);
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e, effectivePerson, request, null);
|
|
|
@@ -478,16 +520,29 @@ public class AttachmentAction extends StandardJaxrsAction {
|
|
|
@Path("update/{id}/work/{workId}")
|
|
|
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
|
|
|
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
|
|
- public void updatePost(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
|
|
|
+ public void updatePost(FormDataMultiPart form, @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
|
|
|
@JaxrsParameterDescribe("附件标识") @PathParam("id") String id,
|
|
|
@JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId,
|
|
|
@JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName,
|
|
|
@JaxrsParameterDescribe("天印扩展字段") @FormDataParam("extraParam") String extraParam,
|
|
|
- @FormDataParam(FILE_FIELD) final byte[] bytes,
|
|
|
+ @FormDataParam(FILE_FIELD) byte[] bytes,
|
|
|
@JaxrsParameterDescribe("附件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
|
|
|
ActionResult<ActionUpdate.Wo> result = new ActionResult<>();
|
|
|
EffectivePerson effectivePerson = this.effectivePerson(request);
|
|
|
try {
|
|
|
+ if(StringUtils.isEmpty(extraParam)){
|
|
|
+ extraParam = this.request2Json(request);
|
|
|
+ }
|
|
|
+ if(bytes==null){
|
|
|
+ Map<String, List<FormDataBodyPart>> map = form.getFields();
|
|
|
+ for(String key: map.keySet()){
|
|
|
+ FormDataBodyPart part = map.get(key).get(0);
|
|
|
+ if("application".equals(part.getMediaType().getType())){
|
|
|
+ bytes = part.getValueAs(byte[].class);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
result = new ActionUpdate().execute(effectivePerson, id, workId, fileName, bytes, disposition, extraParam);
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e, effectivePerson, request, null);
|