log.warn("No matching item in Solr for the given id {}.", id);
return null;
}
} catch (SolrServerException ex) {
log.error("", ex);
throw new StoreException(ex.getMessage(), ex);
}
String enhancementQuery = QueryGenerator.getEnhancementsOfContent(id);
SelectQuery selectQuery = null;
try {
selectQuery = (SelectQuery) QueryParser.getInstance().parse(enhancementQuery);
} catch (ParseException e) {
String msg = "Cannot parse the SPARQL while trying to retrieve the enhancements of the ContentItem";
log.error(msg, e);
throw new StoreException(msg, e);
}
ResultSet resultSet = tcManager.executeSparqlQuery(selectQuery, this.getEnhancementGraph());
MGraph metadata = new IndexedMGraph();
while (resultSet.hasNext()) {
SolutionMapping mapping = resultSet.next();
UriRef ref = (UriRef) mapping.get("enhID");
Iterator<Triple> tripleItr = this.getEnhancementGraph().filter(ref, null, null);
while (tripleItr.hasNext()) {
Triple triple = tripleItr.next();
metadata.add(triple);
}
}
ContentItem ci = null;
try {
ci = ciFactory
.createContentItem(new UriRef(id), new ByteArraySource(content, mimeType), metadata);
} catch (IOException e) {
log.error("Failed to create contentitem with uri: {}", id);
throw new StoreException(String.format("Failed to create contentitem with uri: %s", id));
}
return ci;
}