/** * Echoes the XOPBean. * Note that the type parameter set in the Produces media type indicates to * the JAX-RS Multipart Provider that a provider capable of dealing with@Multipart */ @POST @Consumes("multipart/related") @Produces("multipart/related;type=text/xml") @Multipart("xop") public XopBean echoXopAttachment(@Multipart XopBean xop);
public static Attachment getMultipart(Multipart id, MediaType mt, List<Attachment> infos) throws IOException { if (id != null) { for (Attachment a : infos) { if (matchAttachmentId(a, id)) { checkMediaTypes(a.getContentType(), id.type()); return a; } } if (id.required()) { org.apache.cxf.common.i18n.Message errorMsg = new org.apache.cxf.common.i18n.Message("MULTTIPART_ID_NOT_FOUND", BUNDLE, id.value(), mt.toString()); LOG.warning(errorMsg.toString()); throw ExceptionUtils.toBadRequestException( new MultipartReadException(id.value(), id.type(), errorMsg.toString()), null); } return null; } return !infos.isEmpty() ? infos.get(0) : null; }
private String getRootMediaType(Annotation[] anns, MediaType mt) { String mimeType = mt.getParameters().get("type"); if (mimeType != null) { return mimeType; } Multipart id = AnnotationUtils.getAnnotation(anns, Multipart.class); if (id != null && !MediaType.WILDCARD.equals(id.type())) { mimeType = id.type(); } if (mimeType == null) { if (PropertyUtils.isTrue(mc.getContextualProperty(Message.MTOM_ENABLED))) { mimeType = "text/xml"; } else { mimeType = MediaType.APPLICATION_OCTET_STREAM; } } return mimeType; }
if (id != null && !id.required()) {
public static Attachment getMultipart(Multipart id, MediaType mt, List<Attachment> infos) throws IOException { if (id != null) { for (Attachment a : infos) { if (matchAttachmentId(a, id)) { checkMediaTypes(a.getContentType(), id.type()); return a; } } if (id.required()) { org.apache.cxf.common.i18n.Message errorMsg = new org.apache.cxf.common.i18n.Message("MULTTIPART_ID_NOT_FOUND", BUNDLE, id.value(), mt.toString()); LOG.warning(errorMsg.toString()); throw ExceptionUtils.toBadRequestException( new MultipartReadException(id.value(), id.type(), errorMsg.toString()), null); } else { return null; } } return infos.size() > 0 ? infos.get(0) : null; }
private String getRootMediaType(Annotation[] anns, MediaType mt) { String mimeType = mt.getParameters().get("type"); if (mimeType != null) { return mimeType; } Multipart id = AnnotationUtils.getAnnotation(anns, Multipart.class); if (id != null && !MediaType.WILDCARD.equals(id.type())) { mimeType = id.type(); } if (mimeType == null) { if (MessageUtils.isTrue(mc.getContextualProperty(Message.MTOM_ENABLED))) { mimeType = "text/xml"; } else { mimeType = MediaType.APPLICATION_OCTET_STREAM; } } return mimeType; }
if (id != null && !id.required()) {
/** * @deprecated used for testing only */ @POST @Path("/instances/short") @Consumes({MediaType.APPLICATION_XML, MediaType.TEXT_XML}) void setInstances(@Multipart("instances")RESTShortInstanceList instances) throws BadRequestRestEx, NotFoundRestEx, InternalErrorRestEx;
public static Attachment getFirstMatchingPart(MessageContext mc, Multipart id) { return getFirstMatchingPart(mc, id.value()); }
@PUT @Path("/restore") @Consumes({MediaType.APPLICATION_XML, MediaType.TEXT_XML}) void restore(@Multipart("batch")RESTBatch batch) throws BadRequestRestEx, NotFoundRestEx, InternalErrorRestEx;
public static boolean matchAttachmentId(Attachment at, Multipart mid) { return matchAttachmentId(at, mid.value()); }
/** * @deprecated used for testing only */ @POST @Path("/groups") @Consumes({MediaType.APPLICATION_XML, MediaType.TEXT_XML}) void setUserGroups(@Multipart("groups")RESTFullUserGroupList groups) throws BadRequestRestEx, NotFoundRestEx, InternalErrorRestEx;
protected List<Attachment> handleMultipart(MultivaluedMap<ParameterType, Parameter> map, OperationResourceInfo ori, Object[] params) { List<Attachment> atts = new LinkedList<>(); List<Parameter> fm = getParameters(map, ParameterType.REQUEST_BODY); fm.forEach(p -> { Multipart part = getMultipart(ori, p.getIndex()); if (part != null) { Object partObject = params[p.getIndex()]; if (partObject != null) { atts.add(new Attachment(part.value(), part.type(), partObject)); } } }); return atts; }
public static Attachment getFirstMatchingPart(MessageContext mc, Multipart id) { return getFirstMatchingPart(mc, id.value()); }
/** * @deprecated used for testing only */ @POST @Path("/rules/short") @Consumes({MediaType.APPLICATION_XML, MediaType.TEXT_XML}) void setRules(@Multipart("rules")RESTOutputRuleList rules) throws BadRequestRestEx, NotFoundRestEx, InternalErrorRestEx;