Java Code Examples for org.jboss.as.controller.client.helpers.Operations#getFailureDescription()

The following examples show how to use org.jboss.as.controller.client.helpers.Operations#getFailureDescription() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TrustedDomainsConfigurator.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void create(ModelControllerClient client, CLIWrapper cli) throws Exception {
    final PathAddress domainAddress = PathAddress.pathAddress().append("subsystem", "elytron").append("security-domain",
            name);
    ModelNode op = Util.createEmptyOperation("read-attribute", domainAddress);
    op.get("name").set("trusted-security-domains");
    ModelNode result = client.execute(op);
    if (Operations.isSuccessfulOutcome(result)) {
        result = Operations.readResult(result);
        originalDomains = result.isDefined() ? result : null;
    } else {
        throw new RuntimeException("Reading existing value of trusted-security-domains attribute failed: "
                + Operations.getFailureDescription(result));
    }

    op = Util.createEmptyOperation("write-attribute", domainAddress);
    op.get("name").set("trusted-security-domains");
    for (String domain : trustedSecurityDomains) {
        op.get("value").add(domain);
    }
    CoreUtils.applyUpdate(op, client);
}
 
Example 2
Source File: TrustedDomainsConfigurator.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void create(ModelControllerClient client, CLIWrapper cli) throws Exception {
    final PathAddress domainAddress = PathAddress.pathAddress().append("subsystem", "elytron").append("security-domain",
            name);
    ModelNode op = Util.createEmptyOperation("read-attribute", domainAddress);
    op.get("name").set("trusted-security-domains");
    ModelNode result = client.execute(op);
    if (Operations.isSuccessfulOutcome(result)) {
        result = Operations.readResult(result);
        originalDomains = result.isDefined() ? result : null;
    } else {
        throw new RuntimeException("Reading existing value of trusted-security-domains attribute failed: "
                + Operations.getFailureDescription(result));
    }

    op = Util.createEmptyOperation("write-attribute", domainAddress);
    op.get("name").set("trusted-security-domains");
    for (String domain : trustedSecurityDomains) {
        op.get("value").add(domain);
    }
    CoreUtils.applyUpdate(op, client);
}
 
Example 3
Source File: HttpMgmtConfigurator.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private String readAttribute(ModelControllerClient client, String name) throws Exception {
    String originalVal;
    ModelNode op = Util.createEmptyOperation("read-attribute", HTTP_IFACE_ADDR);
    op.get("name").set(name);
    ModelNode result = client.execute(op);
    if (Operations.isSuccessfulOutcome(result)) {
        result = Operations.readResult(result);
        originalVal = result.isDefined() ? result.asString() : null;
    } else {
        throw new RuntimeException(
                "Reading existing value of attribute " + name + " failed: " + Operations.getFailureDescription(result));
    }
    return originalVal;
}
 
Example 4
Source File: FullReplaceUndeployTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static ModelNode execute(final ModelControllerClient client, final Operation op, final boolean expectFailure) throws IOException {
    final ModelNode result = client.execute(op);
    if (Operations.isSuccessfulOutcome(result)) {
        return Operations.readResult(result);
    }
    if (!expectFailure) {
        throw new RuntimeException(String.format("Failed to execute operation: %s%n%s", op.getOperation(), Operations.getFailureDescription(result)));
    }
    return Operations.getFailureDescription(result);
}