org.apache.cxf.jaxrs.ext.multipart.Multipart类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中org.apache.cxf.jaxrs.ext.multipart.Multipart类的一些代码示例,展示了Multipart类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Multipart类的具体详情如下:
包路径:org.apache.cxf.jaxrs.ext.multipart.Multipart
类名称:Multipart

Multipart介绍

暂无

代码示例

代码示例来源:origin: Talend/tesb-rt-se

/**
 * 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);

代码示例来源:origin: apache/cxf

public static List<Attachment> getMatchingAttachments(Multipart id,
                        List<Attachment> infos) {
  return getMatchingAttachments(id.value(), id.type(), infos);
}

代码示例来源:origin: apache/cxf

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;
}

代码示例来源:origin: apache/cxf

private String getContentId(Annotation[] anns, int id) {
  Multipart part = AnnotationUtils.getAnnotation(anns, Multipart.class);
  if (part != null && !"".equals(part.value())) {
    return part.value();
  }
  return id == 0 ? AttachmentUtil.BODY_ATTACHMENT_ID : Integer.toString(id);
}

代码示例来源:origin: apache/cxf

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;
}

代码示例来源:origin: apache/cxf

if (id != null && !id.required()) {

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

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; 
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

private String getContentId(Annotation[] anns, int id) {
  Multipart part = AnnotationUtils.getAnnotation(anns, Multipart.class);
  if (part != null && !"".equals(part.value())) {
    return part.value();
  }
  return id == 0 ? AttachmentUtil.BODY_ATTACHMENT_ID : Integer.toString(id);
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

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;
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

if (id != null && !id.required()) {

代码示例来源:origin: geoserver/geofence

/**
 * @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;

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

public static List<Attachment> getMatchingAttachments(Multipart id,
                        List<Attachment> infos) {
  return getMatchingAttachments(id.value(), id.type(), infos);
}

代码示例来源:origin: apache/cxf

public static Attachment getFirstMatchingPart(MessageContext mc, Multipart id) {
  return getFirstMatchingPart(mc, id.value());
}

代码示例来源:origin: geoserver/geofence

@PUT
@Path("/restore")
@Consumes({MediaType.APPLICATION_XML, MediaType.TEXT_XML})
void restore(@Multipart("batch")RESTBatch batch)
    throws BadRequestRestEx, NotFoundRestEx, InternalErrorRestEx;

代码示例来源:origin: org.apache.camel/camel-cxf

Multipart multipart = (Multipart) a;
answer.multipart = true;
answer.multipartNames[i] = multipart.value();
answer.multipartTypes[i] = multipart.type();

代码示例来源:origin: apache/cxf

public static boolean matchAttachmentId(Attachment at, Multipart mid) {
  return matchAttachmentId(at, mid.value());
}

代码示例来源:origin: geoserver/geofence

/**
 * @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;

代码示例来源:origin: apache/cxf

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;
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

public static Attachment getFirstMatchingPart(MessageContext mc, Multipart id) {
  return getFirstMatchingPart(mc, id.value());
}

代码示例来源:origin: geoserver/geofence

/**
 * @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;

相关文章