use of dk.dbc.opensearch.commons.repository.RepositoryException in project solr-document-store by DBCDK.
the class SolrWorker method deployRecords.
/**
* Pushes records to SolrDocStore
*
* @param foXml the original FoXML
* @param updater Object containing all generated documents
*/
public void deployRecords(String foXml, SolrUpdaterCallback updater) {
String trackingId = updater.getTrackingId();
HashSet<String> marc002a = otherRecordIds.fromFoXML(foXml);
try {
String pid = updater.getPid();
String unit = docBuilder.unitFor(pid);
String work = docBuilder.workFor(unit);
for (Map<String, Set<String>> updatedDocument : updater.getUpdatedDocuments()) {
ObjectNode record = O.createObjectNode();
String id = updatedDocument.get("id").iterator().next();
makeMetadata(record, id, false, unit, work, trackingId, marc002a);
ObjectNode document = record.putObject("indexKeys");
for (Map.Entry<String, Set<String>> entry : updatedDocument.entrySet()) {
ArrayNode documentKey = document.putArray(entry.getKey());
for (String value : entry.getValue()) {
documentKey.add(value);
}
}
sendRecordToSolrDocStore(id, record);
}
for (DeleteMessage deletedDocument : updater.getDeletedDocuments()) {
ObjectNode record = O.createObjectNode();
String id = deletedDocument.getDocumentId();
makeMetadata(record, id, true, unit, work, trackingId, Collections.EMPTY_SET);
sendRecordToSolrDocStore(id, record);
}
} catch (RepositoryException ex) {
throw new RuntimeException("Defect unit structure", ex);
} catch (JsonProcessingException ex) {
throw new RuntimeException("Error making JSON", ex);
} catch (IOException ex) {
throw new RuntimeException("Error communicating with solrDocStore", ex);
}
}
Aggregations