use of org.apache.camel.component.salesforce.api.dto.composite.SObjectTreeResponse in project camel by apache.
the class CompositeApiProcessor method processCompositeTreeResponse.
void processCompositeTreeResponse(final Exchange exchange, final Optional<SObjectTreeResponse> responseBody, final SalesforceException exception, final AsyncCallback callback) {
try {
if (!responseBody.isPresent()) {
exchange.setException(exception);
} else {
final Message in = exchange.getIn();
final Message out = exchange.getOut();
final SObjectTree tree = in.getBody(SObjectTree.class);
final SObjectTreeResponse response = responseBody.get();
final boolean hasErrors = response.hasErrors();
for (final ReferenceId referenceId : response.getResults()) {
tree.setIdFor(referenceId.getReferenceId(), referenceId.getId());
if (hasErrors) {
tree.setErrorFor(referenceId.getReferenceId(), referenceId.getErrors());
}
}
if (hasErrors) {
final SalesforceException withErrors = new SalesforceException(response.getAllErrors(), exception.getStatusCode(), exception);
exchange.setException(withErrors);
}
out.copyFromWithNewBody(in, tree);
}
} finally {
// notify callback that exchange is done
callback.done(false);
}
}
Aggregations