StepResultHandler<PageNavigation> stepResultHandler = new StepResultHandler<PageNavigation>(address) {
@Override
public void failed(String failureDescription) {
if (address.equals(getCurrentAddress())) {
throw new OperationException(operationName, "Navigation export failed. Reason: " + failureDescription);
} else {
throw new OperationException(operationName, "Navigation export failed. Reason: " + failureDescription
+ " [Step Address: " + getCurrentAddress() + "]");
}
}
@Override
protected void doCompleted(PageNavigation result) {
if (getResults().isEmpty()) {
super.doCompleted(result);
} else {
PageNavigation navigation = getResults().get(0);
merge(navigation, result);
}
}
};
try {
executeHandlers(resource, operationContext, address, OperationNames.READ_CONFIG, stepResultHandler, filter, true);
List<PageNavigation> results = stepResultHandler.getResults();
if (results.isEmpty()) {
resultHandler.completed(new ExportResourceModel(Collections.<ExportTask> emptyList()));
} else {
NavigationExportTask task = new NavigationExportTask(stepResultHandler.getResults().get(0), marshaller);
resultHandler.completed(new ExportResourceModel(task));
}
} catch (ResourceNotFoundException e) {
throw e;
} catch (OperationException e) {
throw new OperationException(e.getOperationName(), getStepMessage(e, address, stepResultHandler), e);
} catch (Throwable t) {
throw new OperationException(operationName, getStepMessage(t, address, stepResultHandler), t);
}
}