ByteArrayOutputStream out = new ByteArrayOutputStream();
serializer.serialize(out, metadata, SupportedFormat.RDF_XML);
String rdfContent = new String(out.toByteArray(),UTF8);
//The multipart entity for the contentItem
MultipartEntity contentItem = new MultipartEntity(null, null ,UTF8);
//the "metadata" MUST BE the first element
/*
* NOTE: We need here to override the getFilename, because this MUST
* BE the URI of the ContentItem. This is important, because the
* Metadata do contain triples about that ContentItem and therefore
* it MUST BE assured that the URI of the ContentItem created by
* the Stanbol Enhancer is the same of as the URI used in the
* Metadata!
*/
contentItem.addPart(
"metadata", //the name MUST BE "metadata"
new StringBody(rdfContent,SupportedFormat.RDF_XML,UTF8){
@Override
public String getFilename() { //The filename MUST BE the
return contentItemId.getUnicodeString(); //uri of the ContentItem
}
});
//Add the Content
/*
* NOTE: If we only parse a single content than we can also directly
* add it with the name "content". This means that the useage of
* a "multipart/alternate" container is in such cases optional.
*/
contentItem.addPart(
"content", //the name MUST BE "content"
new StringBody(HTML_CONTENT,"text/html",UTF8));
//send the request
String receivedContent = executor.execute(