private static String formatMessage(final String message, final ModelNode operation, final ModelNode result) { if (message == null) { return String.format("Failed to execute %s%nReason:%s", operation, Operations.getFailureDescription(result).asString()); } final String msg = (message.endsWith(".") ? message : message + "."); return String.format("%s Failed to execute %s%nReason:%s", msg, operation, Operations.getFailureDescription(result).asString()); } }
/** * Parses the result and returns the failure description. If the result was successful, an empty string is * returned. * * @param result the result of executing an operation * * @return the failure message or an empty string */ public static String getFailureDescriptionAsString(final ModelNode result) { if (isSuccessfulOutcome(result)) { return ""; } return Operations.getFailureDescription(result).asString(); }
/** * Parses the result and returns the failure description. If the result was successful, an empty string is * returned. * * @param result the result of executing an operation * * @return the failure message or an empty string */ public static String getFailureDescriptionAsString(final ModelNode result) { if (isSuccessfulOutcome(result)) { return ""; } return Operations.getFailureDescription(result).asString(); }
/** * Parses the result and returns the failure description. If the result was successful, an empty string is * returned. * * @param result the result of executing an operation * * @return the failure message or an empty string */ public static String getFailureDescriptionAsString(final ModelNode result) { if (isSuccessfulOutcome(result)) { return ""; } return Operations.getFailureDescription(result).asString(); }
@Override public Set<String> getDeploymentNames() throws IOException { final ModelNode readDeployments = Operations.createOperation(READ_CHILDREN_NAMES_OPERATION); readDeployments.get(CHILD_TYPE).set(DEPLOYMENT); final Set<String> deployments = new LinkedHashSet<>(); final ModelNode result = client.execute(readDeployments); if (Operations.isSuccessfulOutcome(result)) { for (ModelNode deployment : Operations.readResult(result).asList()) { final String deploymentName = deployment.asString(); deployments.add(deploymentName); } return deployments; } throw new RuntimeException("Failed to get listing of deployments. Reason: " + Operations.getFailureDescription(result).asString()); }
private ModelNode executeForSuccess(final ModelNode op) throws IOException { final ModelControllerClient client = Objects.requireNonNull(getModelControllerClient(), "The client cannot be null"); final ModelNode result = client.execute(op); if (!Operations.isSuccessfulOutcome(result)) { throw new RuntimeException(Operations.getFailureDescription(result).asString()); } return Operations.readResult(result); } }
protected ModelNode executeOperation(final ModelNode op) throws IOException { final ModelNode result = client.execute(op); if (!Operations.isSuccessfulOutcome(result)) { fail(Operations.getFailureDescription(result).asString()); } return result; }
private boolean hasDeployment(final ModelNode address, final String name) { final ModelNode op = Operations.createOperation(READ_CHILDREN_NAMES_OPERATION, address); op.get(CHILD_TYPE).set(DEPLOYMENT); final ModelNode listDeploymentsResult; try { listDeploymentsResult = client.execute(op); // Check to make sure there is an outcome if (Operations.isSuccessfulOutcome(listDeploymentsResult)) { final List<ModelNode> deployments = Operations.readResult(listDeploymentsResult).asList(); for (ModelNode deployment : deployments) { if (name.equals(deployment.asString())) { return true; } } } else { throw new IllegalStateException(Operations.getFailureDescription(listDeploymentsResult).asString()); } } catch (IOException e) { throw new IllegalStateException(String.format("Could not execute operation '%s'", op), e); } return false; }
private boolean isEnabled(final ModelNode address) { final ModelNode op = Operations.createReadAttributeOperation(address, DeploymentOperations.ENABLED); try { final ModelNode result = client.execute(op); // Check to make sure there is an outcome if (Operations.isSuccessfulOutcome(result)) { return Operations.readResult(result).asBoolean(); } else { throw new IllegalStateException(Operations.getFailureDescription(result).asString()); } } catch (IOException e) { throw new IllegalStateException(String.format("Could not execute operation '%s'", op), e); } }
/** * Creates a new deployment result based on the DMR result from the deployment operation. * * @param result the DMR result from the operation */ DeploymentResult(final ModelNode result) { successful = Operations.isSuccessfulOutcome(result); if (successful) { failureMessage = null; } else { failureMessage = Operations.getFailureDescription(result).asString(); } this.result = result.clone(); this.result.protect(); }
public ModelNode processModelNode(ModelNode op) { LOGGER.fine(op.toJSONString(false)); ModelControllerClient client = cmdCtx.getModelControllerClient(); ModelNode result = null; try { result = client.execute(op); } catch (Exception e) { throw new RuntimeException("Could not execute operation " + op.toJSONString(false), e); } if (result != null) { LOGGER.fine(result.toJSONString(false)); if (!Operations.isSuccessfulOutcome(result)) { String value = Operations.getFailureDescription(result).asString(); throw new RuntimeException("Error execute the command! Error: " + value); } } return result; }
msg = String.format("Failed to determine if attribute %s is supported for operation %s. %s", attributeName, operationName, Operations.getFailureDescription(result)); } else { msg = String.format("Failed to determine if attribute %s is supported for operation %s:%s. %s", attributeName, addressToCliString(address), operationName, Operations.getFailureDescription(result));
msg = String.format("Failed to determine if attribute %s is supported for operation %s. %s", attributeName, operationName, Operations.getFailureDescription(result)); } else { msg = String.format("Failed to determine if attribute %s is supported for operation %s:%s. %s", attributeName, addressToCliString(address), operationName, Operations.getFailureDescription(result));
throw new RuntimeException(Operations.getFailureDescription(response).asString());
throw new RuntimeException(Operations.getFailureDescription(response).asString());
private DeploymentDescription getServerGroupDeployment(final String name) throws IOException { final Set<String> serverGroups = new LinkedHashSet<>(); final ModelNode address = createAddress(SERVER_GROUP, "*", DEPLOYMENT, name); final ModelNode result = client.execute(Operations.createReadResourceOperation(address)); if (Operations.isSuccessfulOutcome(result)) { // Load the server groups for (ModelNode r : Operations.readResult(result).asList()) { final List<Property> resultAddress = Operations.getOperationAddress(r).asPropertyList(); String foundServerGroup = null; for (Property property : resultAddress) { if (SERVER_GROUP.equals(property.getName())) { foundServerGroup = property.getValue().asString(); } } // Add the server-group to the map of deployments serverGroups.add(foundServerGroup); } return SimpleDeploymentDescription.of(name, serverGroups); } throw new RuntimeException("Failed to get listing of deployments. Reason: " + Operations.getFailureDescription(result).asString()); }
if (!Operations.isSuccessfulOutcome(outcome)) { cancel(false); String error = "Failure at server: " + Operations.getFailureDescription(outcome).asString(); JOptionPane.showMessageDialog(cliGuiCtx.getMainWindow(), error, "Download Failed", JOptionPane.ERROR_MESSAGE); return null;
if (!Operations.isSuccessfulOutcome(outcome)) { cancel(false); String error = "Failure at server: " + Operations.getFailureDescription(outcome).asString(); JOptionPane.showMessageDialog(cliGuiCtx.getMainWindow(), error, "Download Failed", JOptionPane.ERROR_MESSAGE); return null;
Logger.getLogger(StandardContainerDescription.class).errorf("Failed to read the root resource: ", Operations.getFailureDescription(result));
Logger.getLogger(StandardContainerDescription.class).errorf("Failed to read the root resource: ", Operations.getFailureDescription(result));