if (handler != null && !root && address.accepts(filter)) {
handler.execute(operationContext, stepResultHandler);
} else {
OperationHandler readResource = resource.getOperationHandler(address, OperationNames.READ_RESOURCE);
BasicResultHandler readResourceResult = new BasicResultHandler();
readResource.execute(new OperationContextDelegate(operationContext) {
@Override
public String getOperationName() {
return OperationNames.READ_RESOURCE;
}
}, readResourceResult);
if (readResourceResult.getFailureDescription() != null) {
throw new OperationException(operationName, "Failure '" + readResourceResult.getFailureDescription()
+ "' encountered executing " + OperationNames.READ_RESOURCE);
}
Object model = readResourceResult.getResult();
if (!(model instanceof ReadResourceModel)) {
throw new RuntimeException("Was expecting " + ReadResourceModel.class + " to be returned for operation "
+ OperationNames.READ_RESOURCE + " at address " + address);
}
for (String child : ((ReadResourceModel) model).getChildren()) {
final PathAddress childAddress = address.append(child);
OperationContext childContext = new OperationContextDelegate(operationContext) {
@Override
public PathAddress getAddress() {
return childAddress;
}
};