下面列出了org.apache.log4j.lf5.util.StreamUtils#org.glassfish.jersey.media.multipart.FormDataContentDisposition 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@JaxrsMethodDescribe(value = "创建会议附件.", action = ActionUpload.class)
@POST
@Path("meeting/{meetingId}/upload/{summary}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
public void upload(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("会议标识") @PathParam("meetingId") String meetingId,
@JaxrsParameterDescribe("是否是会议纪要") @PathParam("summary") boolean summary,
@FormDataParam(FILENAME_FIELD) String fileName, @FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionUpload.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionUpload().execute(effectivePerson, meetingId, summary, fileName, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "上传需要导入的数据文件XLS", action = StandardJaxrsAction.class)
@POST
@Path("upload")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void upload(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@FormDataParam(FILE_FIELD) final byte[] bytes,
@FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition
) {
ActionResult<WrapOutId> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionImportFileUpload().execute(request, effectivePerson, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "上传附件.", action = StandardJaxrsAction.class)
@POST
@Path("upload/subject/{subjectId}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void upload(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("主贴ID") @PathParam("subjectId") String subjectId,
@JaxrsParameterDescribe("位置") @FormDataParam("site") String site,
@FormDataParam(FILE_FIELD) final byte[] bytes,
@FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionUpload.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionUpload().execute(request, effectivePerson, subjectId, site, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "为工作信息上传附件.", action = ActionTaskAttachmentUpload.class)
@POST
@Path("upload/task/{id}/site/{site}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void taskAttachmentUpload(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("工作任务ID") @PathParam("id") String id,
@JaxrsParameterDescribe("位置") @PathParam("site") String site,
@FormDataParam(FILE_FIELD) final byte[] bytes,
@FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionTaskAttachmentUpload.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionTaskAttachmentUpload().execute(request, effectivePerson, id, site, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "上传模块文件,并和本地模块进行对比.", action = ActionCompareUpload.class)
@PUT
@Path("compare/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
public void compareUpload(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe(".xapp文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionCompareUpload.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionCompareUpload().execute(effectivePerson, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "上传文件内容.", action = ActionUpload.class)
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Path("{id}/upload")
public void upload(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id,
@JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName,
@FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("文件内容") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionUpload.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = ((ActionUpload)proxy.getProxy(ActionUpload.class)).execute(effectivePerson, id, fileName, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
/** callback方法与前台ie低版本兼容使用post方法 */
@JaxrsMethodDescribe(value = "更新会议附件内容", action = ActionUpdateCallback.class)
@POST
@Path("{id}/update/callback/{ballback}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.TEXT_HTML_UTF_8)
public void updateCallback(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("会议标识") @PathParam("id") String id,
@JaxrsParameterDescribe("回调函数名") @PathParam("callback") String callback,
@FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionUpdateCallback.Wo<ActionUpdateCallback.WoObject>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionUpdateCallback().execute(effectivePerson, id, callback, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "设置图片:流程、应用的默认图片,90x90.", action = ActionImageProcessDefault.class)
@PUT
@Path("image/process/default")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
public void imageProcessDefault(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("图片文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionImageProcessDefault.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionImageProcessDefault().execute(effectivePerson, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "进行工作信息导入", action = ActionWorkImport.class)
@POST
@Path("center/{centerId}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void importWork(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("中心工作ID") @PathParam("centerId") String centerId,
@JaxrsParameterDescribe("位置") @FormDataParam("site") String site,
@FormDataParam(FILE_FIELD) final byte[] bytes,
@FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
EffectivePerson effectivePerson = this.effectivePerson(request);
ActionResult<Object> result = new ActionResult<>();
try {
result = new ActionWorkImport().execute(request, effectivePerson, centerId, site, bytes, disposition);
} catch (Exception e) {
result = new ActionResult<>();
logger.warn("系统根据中心工作ID获取中心工作所有附件信息过程发生异常。");
logger.error(e, effectivePerson, request, null);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@POST
@ApiOperation(value = "Creates a new Pulsar Function in cluster mode")
@ApiResponses(value = {
@ApiResponse(code = 403, message = "The requester doesn't have admin permissions"),
@ApiResponse(code = 400, message = "Invalid request (function already exists, etc.)"),
@ApiResponse(code = 408, message = "Request timeout"),
@ApiResponse(code = 200, message = "Pulsar Function successfully created")
})
@Path("/{tenant}/{namespace}/{functionName}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response registerFunction(final @PathParam("tenant") String tenant,
final @PathParam("namespace") String namespace,
final @PathParam("functionName") String functionName,
final @FormDataParam("data") InputStream uploadedInputStream,
final @FormDataParam("data") FormDataContentDisposition fileDetail,
final @FormDataParam("url") String functionPkgUrl,
final @FormDataParam("functionDetails") String functionDetailsJson) {
return functions.registerFunction(tenant, namespace, functionName, uploadedInputStream, fileDetail,
functionPkgUrl, functionDetailsJson, clientAppId());
}
@JaxrsMethodDescribe(value = "更新Portal图标.", action = ActionSetIcon.class)
@PUT
@Path("{id}/icon")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
public void setIcon(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id, @FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("图标文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionSetIcon.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionSetIcon().execute(effectivePerson, id, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@Test
public void uploadFileTest() throws Exception {
FormDataMultiPart fd = new FormDataMultiPart();
fd.field("title", "Title");
fd.field("description", "Description");
fd.field("markdown", "#Markdown");
fd.field("keywords", "keyword");
InputStream content = getClass().getResourceAsStream("/mapping.jsonld");
fd.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("file").fileName("mapping.jsonld").build(),
content, MediaType.APPLICATION_OCTET_STREAM_TYPE));
Response response = target().path("mappings").request().post(Entity.entity(fd, MediaType.MULTIPART_FORM_DATA));
assertEquals(response.getStatus(), 201);
assertEquals(MAPPING_RECORD_IRI, response.readEntity(String.class));
ArgumentCaptor<RecordOperationConfig> config = ArgumentCaptor.forClass(RecordOperationConfig.class);
verify(catalogManager).createRecord(eq(user), config.capture(), eq(MappingRecord.class));
assertEquals("Title", config.getValue().get(RecordCreateSettings.RECORD_TITLE));
assertEquals("Description", config.getValue().get(RecordCreateSettings.RECORD_DESCRIPTION));
assertEquals("#Markdown", config.getValue().get(RecordCreateSettings.RECORD_MARKDOWN));
assertEquals(Collections.singleton("keyword"), config.getValue().get(RecordCreateSettings.RECORD_KEYWORDS));
assertEquals(Collections.singleton(user), config.getValue().get(RecordCreateSettings.RECORD_PUBLISHERS));
assertNotNull(config.getValue().get(MappingRecordCreateSettings.INPUT_STREAM));
assertNotNull(config.getValue().get(MappingRecordCreateSettings.RDF_FORMAT));
verify(engineManager, atLeastOnce()).retrieveUser(anyString());
}
@JaxrsMethodDescribe(value = "为文档信息上传附件.", action = ActionFileUpload.class)
@POST
@Path("upload/document/{docId}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void attachmentUpload(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("文档ID") @PathParam("docId") String docId,
@JaxrsParameterDescribe("位置") @FormDataParam("site") String site,
@JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName,
@FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("附件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionFileUpload.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = ((ActionFileUpload)proxy.getProxy(ActionFileUpload.class)).execute(request, effectivePerson, docId, site, fileName, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "转换成html.", action = ActionToHtml.class)
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
public void input(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("office文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionToHtml.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionToHtml().execute(effectivePerson, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
/**
* Upload file to IOResource
*
* @param filename name of file
* @param stream stream of file content
* @return the object ID of that file
* @throws IOException
*/
private String uploadFile(final String filename, final InputStream stream)
throws IOException
{
try (final FormDataMultiPart multiPart = new FormDataMultiPart()) {
multiPart.bodyPart(new BodyPart(stream,
MediaType.MULTIPART_FORM_DATA_TYPE).contentDisposition(
FormDataContentDisposition.name("file").fileName(filename).build()));
final String response = resources.client().register(
MultiPartFeature.class).target("/objects/upload").request().post(Entity
.entity(multiPart, multiPart.getMediaType()), String.class);
final Matcher matcher = Pattern.compile("\\{\"id\":\"([^\"]+)\"\\}")
.matcher(response);
assertTrue(matcher.find());
return matcher.group(1);
}
}
@JaxrsMethodDescribe(value = "上传项目信息附件.", action = ActionProjectAttachmentUpload.class)
@POST
@Path("upload/project/{id}/site/{site}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void projectAttachmentUpload(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("项目信息ID") @PathParam("id") String id,
@JaxrsParameterDescribe("位置") @PathParam("site") String site,
@FormDataParam(FILE_FIELD) final byte[] bytes,
@FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionProjectAttachmentUpload.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionProjectAttachmentUpload().execute(request, effectivePerson, id, site, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "更新查询图标.", action = ActionSetIcon.class)
@PUT
@Path("{flag}/icon")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
public void setIcon(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("应用标识") @PathParam("flag") String flag,
@FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("头像文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionSetIcon.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionSetIcon().execute(effectivePerson, flag, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
/**
* Save the uploaded XSD file (or zip file) into the (XMLValidAgainstXSD) assertion.
* Use @POST instead of @PUT because ng-file-upload seems not working with PUT.
* @param assertionId
* @param inputStream
* @param contentDispositionHeader
* @return
*/
@POST @Path("assertions/{assertionId}/xsdFile")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@PermitAll
public void saveXSDFile(@PathParam("assertionId") long assertionId,
@FormDataParam("file") InputStream inputStream,
@FormDataParam("file") FormDataContentDisposition contentDispositionHeader) throws IOException {
// check the file
String fileName = contentDispositionHeader.getFileName();
if (!(fileName.toLowerCase().endsWith(".xsd") || fileName.toLowerCase().endsWith(".zip"))) {
throw new IllegalArgumentException("Only XSD file and Zip file are supported.");
}
XMLValidAgainstXSDAssertionProperties properties = new XMLValidAgainstXSDAssertionProperties();
properties.setFileName(fileName);
byte[] fileBytes;
try {
fileBytes = IOUtils.toByteArray(inputStream);
} finally {
inputStream.close();
}
properties.setFileBytes(fileBytes);
assertionDAO.updateOtherProperties(assertionId, properties);
}
@JaxrsMethodDescribe(value = "上传或者替换栏目的图标内容,可以指定压缩大小 .", action = ActionMindIconUpdate.class)
@POST
@Path("{mindId}/icon/size/{size}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void changeMindIcon(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("脑图信息ID") @PathParam("mindId") String mindId,
@JaxrsParameterDescribe("最大宽度") @PathParam("size") Integer size,
@FormDataParam(FILE_FIELD) final byte[] bytes,
@FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionMindIconUpdate.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = ((ActionMindIconUpdate) proxy.getProxy(ActionMindIconUpdate.class)).execute(request,
effectivePerson, mindId, size, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "创建Attachment的内容并返回回调.", action = ActionUploadCallback.class)
@POST
@Path("upload/folder/{folderId}/callback/{callback}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.TEXT_HTML_UTF_8)
public void uploadCallback(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("目录") @PathParam("folderId") String folderId,
@JaxrsParameterDescribe("回调函数名") @PathParam("callback") String callback,
@JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName,
@JaxrsParameterDescribe("附件md5值") @FormDataParam("fileMd5") String fileMd5,
@JaxrsParameterDescribe("附件标识") @FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("上传文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionUploadCallback.Wo<WoObject>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionUploadCallback().execute(effectivePerson, folderId, callback, fileName, fileMd5, bytes,
disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
protected ActionResult<WrapOutString> execute( HttpServletRequest request, EffectivePerson effectivePerson,
Integer size, byte[] bytes, FormDataContentDisposition disposition) {
ActionResult<WrapOutString> result = new ActionResult<>();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try ( InputStream input = new ByteArrayInputStream(bytes)) {
BufferedImage image = ImageIO.read(input);
int width = image.getWidth();
int height = image.getHeight();
if (size > 0) {
if (width * height > size * size) {
image = Scalr.resize(image, size);
}
}
ImageIO.write(image, "png", baos);
byte[] byteArray = baos.toByteArray();
WrapOutString wrap = new WrapOutString();
wrap.setValue(Base64.encodeBase64String(byteArray));
result.setData( wrap);
} catch (IOException e) {
e.printStackTrace();
result.error(e);
}
return result;
}
@JaxrsMethodDescribe(value = "更新Attachment的内容", action = ActionUpdateContent.class)
@PUT
@Path("{id}/update")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
public void updateContent(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("附件标识") @PathParam("id") String id, @FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("上传文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionUpdateContent.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionUpdateContent().execute(effectivePerson, id, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
/** callback方法与前台ie低版本兼容使用post方法 */
@JaxrsMethodDescribe(value = "更新会议附件内容", action = ActionUpdateCallback.class)
@POST
@Path("{id}/update/callback/{ballback}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.TEXT_HTML_UTF_8)
public void updateCallback(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("会议标识") @PathParam("id") String id,
@JaxrsParameterDescribe("回调函数名") @PathParam("callback") String callback,
@FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionUpdateCallback.Wo<ActionUpdateCallback.WoObject>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionUpdateCallback().execute(effectivePerson, id, callback, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@POST
@Path("/granite/security/post/truststore")
@Consumes({ "multipart/form-data" })
@Produces({ "text/plain" })
@io.swagger.annotations.ApiOperation(value = "", notes = "", response = String.class, authorizations = {
@io.swagger.annotations.Authorization(value = "aemAuth")
}, tags={ "sling", })
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "Default response", response = String.class) })
public Response postTruststore(@ApiParam(value = "") @QueryParam(":operation") String colonOperation
,@ApiParam(value = "") @QueryParam("newPassword") String newPassword
,@ApiParam(value = "") @QueryParam("rePassword") String rePassword
,@ApiParam(value = "") @QueryParam("keyStoreType") String keyStoreType
,@ApiParam(value = "") @QueryParam("removeAlias") String removeAlias
,
@FormDataParam("certificate") InputStream certificateInputStream,
@FormDataParam("certificate") FormDataContentDisposition certificateDetail
,@Context SecurityContext securityContext)
throws NotFoundException {
return delegate.postTruststore(colonOperation,newPassword,rePassword,keyStoreType,removeAlias,certificateInputStream, certificateDetail,securityContext);
}
@JaxrsMethodDescribe(value = "创建Attachment的内容", action = ActionUpload.class)
@POST
@Path("upload/folder/{folderId}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
public void upload(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("目录") @PathParam("folderId") String folderId,
@JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName,
@JaxrsParameterDescribe("附件md5值") @FormDataParam("fileMd5") String fileMd5,
@JaxrsParameterDescribe("附件标识") @FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("上传文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionUpload.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionUpload().execute(effectivePerson, folderId, fileName, fileMd5, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "上传文件,并进行压缩,如果文件大小小于指定宽度或者宽度<0,则不进行压缩.", action = ActionUpload.class)
@PUT
@Path("upload/referencetype/{referenceType}/reference/{reference}/scale/{scale}")
@Consumes({ MediaType.MULTIPART_FORM_DATA, MediaType.APPLICATION_OCTET_STREAM })
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
public void upload(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("文件类型") @PathParam("referenceType") String referenceType,
@JaxrsParameterDescribe("关联id") @PathParam("reference") String reference,
@JaxrsParameterDescribe("缩放") @PathParam("scale") Integer scale,
@FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("上传文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionUpload.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionUpload().execute(effectivePerson, referenceType, reference, scale, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "创建Attachment的内容并返回回调.", action = ActionUploadCallback.class)
@POST
@Path("upload/referencetype/{referenceType}/reference/{reference}/scale/{scale}/callback/{callback}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.TEXT_HTML_UTF_8)
public void uploadCallback(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("文件类型") @PathParam("referenceType") String referenceType,
@JaxrsParameterDescribe("关联id") @PathParam("reference") String reference,
@JaxrsParameterDescribe("缩放") @PathParam("scale") Integer scale,
@JaxrsParameterDescribe("回调函数名") @PathParam("callback") String callback,
@FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("上传文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionUploadCallback.Wo<ActionUploadCallback.WoObject>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionUploadCallback().execute(effectivePerson, referenceType, reference, scale, callback,
bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
/**
* @see StateQueries
*/
@Path("{sanitizedServiceName}/state/files/{name}")
@PUT
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response putFile(
@PathParam("sanitizedServiceName") String sanitizedServiceName,
@PathParam("name") String name,
@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetails)
{
Optional<StateStore> stateStore = getStateStore(sanitizedServiceName);
if (!stateStore.isPresent()) {
return ResponseUtils.serviceNotFoundResponse(sanitizedServiceName);
}
return StateQueries.putFile(stateStore.get(), name, uploadedInputStream, fileDetails);
}
@JaxrsMethodDescribe(value = "创建Attachment的内容并返回回调.", action = ActionUploadCallback.class)
@POST
@Path("upload/folder/{folderId}/callback/{callback}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.TEXT_HTML_UTF_8)
public void uploadCallback(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("目录") @PathParam("folderId") String folderId,
@JaxrsParameterDescribe("回调函数名") @PathParam("callback") String callback,
@JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName,
@JaxrsParameterDescribe("附件标识") @FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("上传文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
ActionResult<ActionUploadCallback.Wo<WoObject>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionUploadCallback().execute(effectivePerson, folderId, callback, fileName, bytes,
disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "上传附件.", action = ActionUpload.class)
@POST
@Path("upload/work/{workId}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.MULTIPART_FORM_DATA)
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) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}