use of org.apache.http.entity.mime.FormBodyPartBuilder in project jackrabbit by apache.
the class Utils method addPart.
/**
*
* @param paramName
* @param value
* @param resolver
* @throws RepositoryException
*/
static void addPart(String paramName, QValue value, NamePathResolver resolver, List<FormBodyPart> parts, List<QValue> binaries) throws RepositoryException {
FormBodyPartBuilder builder = FormBodyPartBuilder.create().setName(paramName);
ContentType ctype = ContentType.create(JcrValueType.contentTypeFromType(value.getType()), DEFAULT_CHARSET);
FormBodyPart part;
switch(value.getType()) {
case PropertyType.BINARY:
binaries.add(value);
part = builder.setBody(new InputStreamBody(value.getStream(), ctype)).build();
break;
case PropertyType.NAME:
part = builder.setBody(new StringBody(resolver.getJCRName(value.getName()), ctype)).build();
break;
case PropertyType.PATH:
part = builder.setBody(new StringBody(resolver.getJCRPath(value.getPath()), ctype)).build();
break;
default:
part = builder.setBody(new StringBody(value.getString(), ctype)).build();
}
parts.add(part);
}
Aggregations