if (curated) {
// Happy ending
if (task.equals("curation-response")) {
log.info("Confirmation of curated object '{}'.", oid);
// Send out upstream responses to objects waiting
JSONArray responses = data.writeArray("responses");
for (Object thisResponse : responses) {
JsonSimple json = new JsonSimple((JsonObject) thisResponse);
String broker = json.getString(brokerUrl, "broker");
String responseOid = json.getString(null, "oid");
String responseTask = json.getString(null, "task");
JsonObject responseObj = createTask(response, broker,
responseOid, responseTask);
// Don't forget to tell them where it came from
String id = json.getString(null, "quoteId");
if (id != null) {
responseObj.put("originId", id);
}
responseObj.put("originOid", oid);
// If NLA Integration is enabled, use the NLA ID instead
if (nlaIntegrationEnabled && metadata.containsKey(nlaIdProperty)) {
responseObj.put("curatedPid", metadata.getProperty(nlaIdProperty));
} else {
responseObj.put("curatedPid", thisPid);
}
}
//JCU: now that the responses have been sent, remove them, so they are not sent again. Otherwise, they just keep getting resent and performance suffers greatly.
responses.clear();
saveObjectData(data, oid);
private void publishRelations(JsonSimple response, String oid) throws TransactionException {
log.debug("Publishing Children of '{}'", oid);
JsonSimple data = getDataFromStorage(oid);
if (data == null) {
log.error("Error accessing item data! '{}'", oid);
emailObjectLink(response, oid,
"An error occured publishing the related objects for this"
+ " record. Please check the system logs.");
return;
}
boolean saveData = false;
JSONArray relations = data.writeArray("relationships");
for (Object relation : relations) {
JsonSimple json = new JsonSimple((JsonObject) relation);
String broker = json.getString(brokerUrl, "broker");
boolean localRecord = broker.equals(brokerUrl);
String relatedId = json.getString(null, "identifier");
// We need to find OIDs to match IDs (only for local records)
String relatedOid = json.getString(null, "oid");
if (relatedOid == null && localRecord) {
String identifier = json.getString(null, "identifier");
if (identifier == null) {
log.error("NULL identifer provided!");
}
relatedOid = idToOid(identifier);
if (relatedOid == null) {
log.error("Cannot resolve identifer: '{}'", identifier);
}
}
boolean authority = json.getBoolean(false, "authority");
if (authority) {
// Is this relationship using a curated ID?
boolean isCurated = json.getBoolean(false, "isCurated");
//JCU: adding check for publishMsgSent
boolean publishMsgSent = json.getBoolean(false, "publishMsgSent");
if (isCurated && !publishMsgSent) {
log.debug(" * Publishing '{}'", relatedId);
// It is a local object
if (localRecord) {
createTask(response, relatedOid, "publish");
// Or remote
} else {
JsonObject task = createTask(response, broker, relatedOid,
"publish");
// We won't know OIDs for remote systems
task.remove("oid") ;
task.put("identifier", relatedId);
}
//JCU: Adding tag to indicate the publish message has been sent.
((JsonObject) relation).put("publishMsgSent", "true");
saveData = true;
} else if (publishMsgSent){
log.debug(" * Ignoring already published relationship '{}'",
relatedId);
}
else {
log.debug(" * Ignoring non-curated relationship '{}'",
relatedId);
}
}
}
if (saveData){
//updating the relations with publishMsgSent
saveObjectData(data, oid);
}
}
--
You received this message because you are subscribed to the Google Groups "ReDBox Development" group.
To post to this group, send an email to redbo...@googlegroups.com.
To unsubscribe from this group, send email to redbox-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
To view this discussion on the web, visit https://groups.google.com/d/msg/redbox-dev/-/8Q9xdPC5NlEJ.