* been built with the appropriate error number, error type and error descriptions.
*/
protected void publishSyncError(String action, java.util.List errors) {
XmlDocumentReader xmlReader = new XmlDocumentReader();
Document syncErrorDoc = null;
try {
syncErrorDoc =
xmlReader.initializeDocument(getSyncErrorSyncPrimedDocumentUri(), getOutboundXmlValidation());
if (syncErrorDoc == null) {
String errMessage = "[PublishSyncError] Missing 'SyncErrorSyncPrimedDocumentUri' property in configuration document. Can't publish sync error.";
logger.fatal(errMessage);
return;
}
}
catch (XmlDocumentReaderException e) {
logger.fatal("[PublishSyncError] Error initializing Sync-Error-Sync primed document, could not publish the sync error sync message.");
logger.fatal(e.getMessage(), e);
return;
}
Element eControlArea = getControlArea(syncErrorDoc.getRootElement());
Result aResult = new Result();
ProcessedMessageId processedMsgId = new ProcessedMessageId();
// Build the dynamic portion of the sync document's control area
// Our sender information will go in the "Sender" element of the primed
// document and in the ProcessedMessageId of the Result that gets built
// Set the sender element
// Build the ProcessedMessageId Object out of the contents of the
// application that had the error.
String messageSequence = Integer.toString(getSyncErrorPublisher().incrementMessageSequence());
try {
// processedMsgId is going to be the same as MessageId (built below)
processedMsgId.setProducerId(getSyncErrorPublisher().getProducerId(null).getId());
processedMsgId.setSenderAppId(getAppName());
processedMsgId.setMessageSeq(messageSequence);
}
catch (Exception e) {
logger.fatal("Error building ProcessedMessageId Element in Sync-Error-Sync message!");
logger.fatal(e.getMessage(), e);
}
// This is the control area information relevant to this Gateway
eControlArea.removeChild("Result");
eControlArea.removeChild("Datetime");
eControlArea.removeChild("Sender");
Sender sender = new Sender();
MessageId msgId = new MessageId();
msgId.setProducerId(getSyncErrorPublisher().getProducerId(null).getId());
msgId.setSenderAppId(getAppName());
msgId.setMessageSeq(messageSequence);
sender.setMessageId(msgId);
Authentication auth = new Authentication();
auth.setAuthUserId(getAppName());
sender.setAuthentication(auth);
Element eSender = null;
try {
eSender = (Element)sender.buildOutputFromObject();
}
catch (Exception e) {
logger.fatal("[publishSyncError1] Exception occurred building an Element from the Sender object. Can't publish Sync error. Exception: " + e.getMessage());
logger.fatal(e.getMessage(), e);
return;
}
// Set the datetime element
Datetime dt = new Datetime();
Element eDatetime = null;
try {
eDatetime = (Element)dt.buildOutputFromObject();
}
catch (Exception e) {
logger.fatal("[publishSyncError1] Exception occurred building an Element from the Datetime object. Can't publish Sync error. Exception: " + e.getMessage());
logger.fatal(e.getMessage(), e);
return;
}
eControlArea.addContent(eSender);
eControlArea.addContent(eDatetime);
if (action == null) {
action = "Unknown";
}
aResult.setAction(action);
aResult.setStatus("failure");
aResult.setProcessedMessageId(processedMsgId);
for (int i=0; i<errors.size(); i++) {
org.openeai.moa.objects.resources.Error anError =
(org.openeai.moa.objects.resources.Error)errors.get(i);
aResult.addError(anError);
}
try {
Element eResult = (Element)aResult.buildOutputFromObject();
eControlArea.addContent(eResult);
syncErrorDoc.getRootElement().removeContent(eControlArea);
syncErrorDoc.getRootElement().addContent(eControlArea);
TextMessage syncErrorMessage = getSyncErrorPublisher().createTextMessage();
XMLOutputter xmlOut = new XMLOutputter();
syncErrorMessage.setText(xmlOut.outputString(syncErrorDoc));
if (getSyncErrorPublisher().getDefaultCommandName().length() == 0 ||
getSyncErrorPublisher().getDefaultCommandName() == null) {