String content = null;
try {
Entry<UriRef, Blob> contentPart = ContentItemHelper.getBlob(ci,
Collections.singleton("text/plain"));
if (contentPart == null) {
throw new StoreException(
"There is no textual for the content item");
}
content = ContentItemHelper.getText(contentPart.getValue());
} catch (IOException ex) {
String msg = "Cannot read the stream of the ContentItem.";
log.error(msg, ex);
throw new StoreException(msg, ex);
}
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
String creationDate = sdf.format(cal.getTime());
doc.addField(SolrFieldName.ID.toString(), ci.getUri()
.getUnicodeString());
doc.addField(SolrFieldName.CONTENT.toString(), content);
try {
doc.addField(SolrFieldName.BINARYCONTENT.toString(),
IOUtils.toByteArray(ci.getStream()));
} catch (IOException e) {
throw new StoreException(
"Failed to get bytes of conten item stream", e);
}
doc.addField(SolrFieldName.MIMETYPE.toString(), ci.getMimeType());
doc.addField(SolrFieldName.CREATIONDATE.toString(), creationDate);