use of org.apache.cxf.jaxrs.ext.multipart.Multipart in project cxf by apache.
the class WadlGenerator method doWriteParam.
// CHECKSTYLE:OFF
protected void doWriteParam(OperationResourceInfo ori, StringBuilder sb, Parameter pm, Class<?> type, Type genericType, String paramName, Annotation[] anns, boolean isJson) {
// CHECKSTYLE:ON
ParameterType pType = pm.getType();
boolean isForm = isFormParameter(pm, type, anns);
if (paramName == null && isForm) {
Multipart m = AnnotationUtils.getAnnotation(anns, Multipart.class);
if (m != null) {
paramName = m.value();
}
}
sb.append("<param name=\"").append(paramName).append("\" ");
String style = ParameterType.PATH == pType ? "template" : isForm ? "query" : ParameterType.REQUEST_BODY == pType ? "plain" : pType.toString().toLowerCase();
sb.append("style=\"").append(style).append("\"");
if (pm.getDefaultValue() != null) {
sb.append(" default=\"").append(xmlEncodeIfNeeded(pm.getDefaultValue())).append("\"");
}
if (InjectionUtils.isSupportedCollectionOrArray(type)) {
type = InjectionUtils.getActualType(genericType);
sb.append(" repeating=\"true\"");
}
String value = XmlSchemaPrimitiveUtils.getSchemaRepresentation(type);
if (value == null) {
if (type.isEnum()) {
value = "xs:string";
} else if (type == InputStream.class) {
value = "xs:anyType";
}
}
if (value != null) {
if (isJson) {
value = value.substring(3);
}
sb.append(" type=\"").append(value).append("\"");
}
if (type.isEnum()) {
sb.append(">");
handleDocs(anns, sb, DocTarget.PARAM, true, isJson);
setEnumOptions(sb, type);
sb.append("</param>");
} else {
addDocsAndCloseElement(ori, pm.getIndex(), sb, anns, "param", DocTarget.PARAM, true, isJson);
}
}
use of org.apache.cxf.jaxrs.ext.multipart.Multipart in project cxf by apache.
the class MultipartProvider method getRootMediaType.
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;
}
Aggregations