org.apache.cxf.jaxrs.ext.multipart.Multipart.type()方法的使用及代码示例

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

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

Multipart.type介绍

暂无

代码示例

代码示例来源: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

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

代码示例来源: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

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

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

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

代码示例来源:origin: org.apache.cxf/cxf-rt-rs-client

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: 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: 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: org.apache.cxf/cxf-bundle-jaxrs

private List<Attachment> handleMultipart(MultivaluedMap<ParameterType, Parameter> map,
                     OperationResourceInfo ori,
                     Object[] params) {
  
  List<Attachment> atts = new LinkedList<Attachment>();
  List<Parameter> fm = getParameters(map, ParameterType.REQUEST_BODY);
  for (Parameter p : fm) {
    Multipart part = getMultipart(ori, p.getIndex());
    if (part != null) {
      Object objectPart = params[p.getIndex()];
      if (objectPart != null) {   
        atts.add(new Attachment(part.value(), part.type(), objectPart));
      }
    }
  }
  return atts;        
}

代码示例来源: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; 
}

相关文章