sFileName = sExplicitPath;
Publisher publisher = getSelectablePublishers().selectedAsPublisher(context,false);
HttpClientRequest httpClient = HttpClientRequest.newRequest();
ProcessingContext pContext = new ProcessingContext(context,publisher,httpClient,null,bValidateOnly);
pContext.setMessageBroker(msgBroker);
ProcessorFactory factory = new ProcessorFactory();
ResourceProcessor processor = factory.interrogate(pContext,sExplicitPath);
if (processor == null) {
throw new IOException("Unable to process resource.");
}
processor.process();
boolean wasSingleSource = pContext.getWasSingleSource();
// summary messages
if (bValidateOnly) {
if (wasSingleSource && (pContext.getNumberValidated() == 1)) {
msgBroker.addSuccessMessage("catalog.publication.success.validated");
} else if (pContext.getNumberValidated() > 0) {
addSummaryMessage(pContext,msgBroker,"catalog.publication.uploadMetadata.summary.valid",
ProcessedRecord.StatusType.VALIDATED,pContext.getNumberValidated());
}
if (wasSingleSource && (pContext.getNumberFailed() == 1)) {
Exception lastException = pContext.getLastException();
if (pContext.getLastException() != null) {
throw lastException;
} else {
// TODO message here ??
}
} else if (pContext.getNumberFailed() > 0) {
addErrorMessages(pContext,msgBroker,"catalog.publication.uploadMetadata.summary.invalid",
ProcessedRecord.StatusType.FAILED,pContext.getNumberFailed());
}
if ((pContext.getNumberValidated() == 0) && (pContext.getNumberFailed() == 0)) {
msgBroker.addErrorMessage("catalog.publication.uploadMetadata.summary.valid",new Integer[]{0});
}
// publication related messages
} else {
if (wasSingleSource && (pContext.getNumberCreated() == 1)) {
msgBroker.addSuccessMessage("publication.success.created");
} else if (pContext.getNumberCreated() > 0) {
addSummaryMessage(pContext,msgBroker,"catalog.publication.uploadMetadata.summary.created",
ProcessedRecord.StatusType.CREATED,pContext.getNumberCreated());
}
if (wasSingleSource && (pContext.getNumberReplaced() == 1)) {
msgBroker.addSuccessMessage("publication.success.replaced");
} else if (pContext.getNumberReplaced() > 0) {
addSummaryMessage(pContext,msgBroker,"catalog.publication.uploadMetadata.summary.replaced",
ProcessedRecord.StatusType.REPLACED,pContext.getNumberReplaced());
}
if (wasSingleSource && (pContext.getNumberUnchanged() == 1)) {
msgBroker.addSuccessMessage("publication.success.unchanged");
} else if (pContext.getNumberUnchanged() > 0) {
addSummaryMessage(pContext,msgBroker,"catalog.publication.uploadMetadata.summary.unchanged",
ProcessedRecord.StatusType.UNCHNAGED,pContext.getNumberUnchanged());
}
if (pContext.getNumberDeleted() > 0) {
addSummaryMessage(pContext,msgBroker,"catalog.publication.uploadMetadata.summary.deleted",
ProcessedRecord.StatusType.DELETED,pContext.getNumberDeleted());
}
if (wasSingleSource && (pContext.getNumberFailed() == 1)) {
Exception lastException = pContext.getLastException();
if (pContext.getLastException() != null) {
throw lastException;
} else {
// TODO message here ??
}
} else if (pContext.getNumberFailed() > 0) {
addErrorMessages(pContext,msgBroker,"catalog.publication.uploadMetadata.summary.failed",
ProcessedRecord.StatusType.FAILED,pContext.getNumberFailed());
}
}
}