Java Code Examples for org.jboss.as.controller.OperationContext#getFailureDescription()

The following examples show how to use org.jboss.as.controller.OperationContext#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: DomainFinalResultHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private boolean collectContextFailure(OperationContext context, final boolean isDomain) {
    // We ignore a context failure description if the request failed on all servers, as the
    // DomainRolloutStepHandler would have had to set that to trigger model rollback
    // but we still want to record the server results so the user can see the problem
    if (!multiphaseContext.isFailureReported() && context.hasFailureDescription()) {
        ModelNode formattedFailure = new ModelNode();
        if (isDomain) {
            ModelNode failure = context.getFailureDescription();
            if (failure.isDefined())
                formattedFailure.get(DOMAIN_FAILURE_DESCRIPTION).set(failure);
            else
                formattedFailure.get(DOMAIN_FAILURE_DESCRIPTION).set(DomainControllerLogger.HOST_CONTROLLER_LOGGER.unexplainedFailure());
        } else {
            ModelNode hostFailureProperty = new ModelNode();
            ModelNode contextFailure = context.getFailureDescription();
            ModelNode hostFailure = contextFailure.isDefined() ? contextFailure : new ModelNode(DomainControllerLogger.HOST_CONTROLLER_LOGGER.unexplainedFailure());
            hostFailureProperty.add(multiphaseContext.getLocalHostInfo().getLocalHostName(), hostFailure);

            formattedFailure.get(HOST_FAILURE_DESCRIPTIONS).set(hostFailureProperty);
        }
        context.getFailureDescription().set(formattedFailure);

        return false;
    }
    return true;
}
 
Example 2
Source File: DeploymentHandlerUtil.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static String getFormattedFailureDescription(OperationContext context) {
        ModelNode failureDescNode = context.getFailureDescription();
        String failureDesc = failureDescNode.toString();
//        // Strip the wrapping {} from ModelType.OBJECT types
//        if (failureDescNode.getType() == ModelType.OBJECT && failureDesc.length() > 2
//                && failureDesc.charAt(0) == '{' && failureDesc.charAt(failureDesc.length() - 1) == '}') {
//            failureDesc = failureDesc.substring(1, failureDesc.length() - 1);
//        }

        if (failureDesc.contains("\n") && failureDesc.charAt(0) != '\n') {
            failureDesc = "\n" + failureDesc;
        }
        return failureDesc;
    }