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

The following examples show how to use org.jboss.as.controller.OperationContext#hasResult() . 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: ReadAttributeHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    if (filteredData == null) {
        doExecuteInternal(context, operation);
    } else {
        try {
            doExecuteInternal(context, operation);
        } catch (UnauthorizedException ue) {
            if (context.hasResult()) {
                context.getResult().set(new ModelNode());
            }
            // Report the failure to the filter and complete normally
            PathAddress pa = context.getCurrentAddress();
            filteredData.addReadRestrictedAttribute(pa, operation.get(NAME).asString());
            context.getResult().set(new ModelNode());
        }
    }
}
 
Example 2
Source File: ReadResourceHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void handleMissingResource(OperationContext context) {
    // Our target resource has disappeared
    if (context.hasResult()) {
        context.getResult().set(new ModelNode());
    }
    if (!ignoreMissingResource) {
        throw ControllerLogger.MGMT_OP_LOGGER.managementResourceNotFound(address);
    }
}
 
Example 3
Source File: ReadAttributeHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void doExecuteInternal(OperationContext context, ModelNode operation) throws OperationFailedException {
    ModelNode value = context.hasResult() ? context.getResult().clone() : new ModelNode();
    AuthorizationResult authorizationResult = context.authorize(operation, operation.require(NAME).asString(), value);
    if (authorizationResult.getDecision() == AuthorizationResult.Decision.DENY) {
        context.getResult().clear();
        throw ControllerLogger.ROOT_LOGGER.unauthorized(operation.require(OP).asString(), context.getCurrentAddress(), authorizationResult.getExplanation());
    }
}
 
Example 4
Source File: ReadAttributeHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    ModelNode result = context.hasResult() ? context.getResult().clone() : new ModelNode();
    // For now, don't use the context to resolve, as we don't want to support vault resolution
    // from a remote management client. The purpose of the vault is to require someone to have
    // access to both the config (i.e. the expression) and to the vault itself in order to read, and
    // allowing a remote user to use the management API to read defeats the purpose.
    //ModelNode resolved = context.resolveExpressions(result);
    // Instead we use a resolver that will not complain about unresolvable stuff (i.e. vault expressions),
    // simply returning them unresolved.
    ModelNode resolved = ExpressionResolver.SIMPLE_LENIENT.resolveExpressions(result);
    context.getResult().set(resolved);
}
 
Example 5
Source File: GlobalInstallationReportHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void handleMissingResource(OperationContext context) {
    // Our target resource has disappeared
    if (context.hasResult()) {
        context.getResult().set(new ModelNode());
    }
    if (!ignoreMissingResource) {
        throw ControllerLogger.MGMT_OP_LOGGER.managementResourceNotFound(context.getCurrentAddress());
    }
}
 
Example 6
Source File: ReadAttributeGroupHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void handleMissingResource(OperationContext context) {
    // Our target resource has disappeared
    if (context.hasResult()) {
        context.getResult().set(new ModelNode());
    }
    if (!ignoreMissingResource) {
        throw ControllerLogger.MGMT_OP_LOGGER.managementResourceNotFound(context.getCurrentAddress());
    }
}