@Override public FailuresAllowedBlock allowFailures() throws IOException { ensureInitialized(); return delegate.allowFailures(); }
/** * @return {@code true} if the resource specified by {@code address} was actually removed (i.e., it used to exist), * {@code false} if it didn't exist and therefore wasn't actually removed * @throws OperationException if the underlying {@code remove} operation fails with something else than "not found" */ public boolean removeIfExists(Address address) throws IOException, OperationException { FailuresAllowedBlock expectedFailures = client.allowFailures(); try { ModelNodeResult result = remove(address); if (result.isSuccess()) { return true; } if (isResultUnknownOrNotFound(result)) { return false; } throw new OperationException("removeIfExists failed: " + result.asString()); } finally { expectedFailures.close(); } }
/** * @return {@code true} if the resource specified by {@code address} exists, {@code false} otherwise * @throws OperationException if the underlying {@code read-resource} operation fails */ public boolean exists(Address address) throws IOException, OperationException { FailuresAllowedBlock expectedFailures = client.allowFailures(); try { ModelNodeResult result = readResource(address); if (result.isSuccess()) { return result.hasDefinedValue(); // should always be true } if (isResultUnknownOrNotFound(result)) { return false; } throw new OperationException("exists failed: " + result.asString()); } finally { expectedFailures.close(); } }