*
* @throws IOException if an error occurs executing the operation.
* @throws RuntimeException if the operation fails.
*/
private boolean resourceExists(final ModelNode address, final ModelControllerClient client) throws IOException {
final Property childAddress = Operations.getChildAddress(address);
final ModelNode parentAddress = Operations.getParentAddress(address);
final ModelNode r = client.execute(Operations.createOperation(Operations.READ_RESOURCE, parentAddress, false));
reportFailure(r);
boolean found = false;
final String name = childAddress.getName();
if (r.get(Operations.RESULT).get(name).isDefined()) {
for (ModelNode dataSource : r.get(Operations.RESULT).get(name).asList()) {
if (dataSource.asProperty().getName().equals(childAddress.getValue().asString())) {
found = true;
}
}
}
return found;