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

The following examples show how to use org.jboss.as.controller.OperationContext#addModelStep() . 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: PrepareStepHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static void executeDirectOperation(OperationContext context, ModelNode operation, boolean checkPrivate) throws OperationFailedException {
    final String operationName =  operation.require(OP).asString();

    final ImmutableManagementResourceRegistration registration = context.getResourceRegistration();
    PathAddress pathAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
    final OperationEntry stepEntry = context.getRootResourceRegistration().getOperationEntry(pathAddress, operationName);
    if (stepEntry != null) {
        boolean illegalPrivateStep = checkPrivate
                && stepEntry.getType() == OperationEntry.EntryType.PRIVATE
                && operation.hasDefined(OPERATION_HEADERS, CALLER_TYPE)
                && USER.equals(operation.get(OPERATION_HEADERS, CALLER_TYPE).asString());
        if (illegalPrivateStep) {
            context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, pathAddress));
        } else {
            context.addModelStep(stepEntry.getOperationDefinition(), stepEntry.getOperationHandler(), false);
        }
    } else {
        if (! context.isBooting()) {
            if (registration == null) {
                context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noSuchResourceType(pathAddress));
            } else {
                context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, pathAddress));
            }
        }
    }
}
 
Example 2
Source File: OperationSlaveStepHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Directly handles the op in the standard way the default prepare step handler would
 * @param context the operation execution context
 * @param operation the operation
 * @throws OperationFailedException if no handler is registered for the operation
 */
private void addBasicStep(OperationContext context, ModelNode operation, ModelNode localReponse) throws OperationFailedException {
    final String operationName = operation.require(OP).asString();
    final PathAddress pathAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
    final OperationEntry entry = context.getRootResourceRegistration().getOperationEntry(pathAddress, operationName);
    if (entry != null) {
        if (!context.isBooting()
                && entry.getType() == OperationEntry.EntryType.PRIVATE
                && operation.hasDefined(OPERATION_HEADERS, CALLER_TYPE)
                && USER.equals(operation.get(OPERATION_HEADERS, CALLER_TYPE).asString())) {
            throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, pathAddress));
        }
        if (context.isBooting() || localHostControllerInfo.isMasterDomainController()) {
            context.addModelStep(localReponse, operation, entry.getOperationDefinition(), entry.getOperationHandler(), false);
        } else {
            final OperationStepHandler wrapper;
            // For slave host controllers wrap the operation handler to synchronize missing configuration
            // TODO better configuration of ignore unaffected configuration
            if (localHostControllerInfo.isRemoteDomainControllerIgnoreUnaffectedConfiguration()) {
                final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
                wrapper = SyncModelOperationHandlerWrapper.wrapHandler(localHostControllerInfo.getLocalHostName(), operationName, address, entry);
            } else {
                wrapper = entry.getOperationHandler();
            }
            context.addModelStep(localReponse, operation, entry.getOperationDefinition(), wrapper, false);
        }
    } else {
        throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, pathAddress));
    }
}
 
Example 3
Source File: MultistepUtil.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 {
    // Try again to get the OpData but this time allowDeferredResolution == false so it will
    // fail if the MRR is still not available
    OpData opData = getOpData(context, deferredOperation, deferredResponse, deferredAddress, handlerResolver,
            rejectPrivateOperations, false, false);
    context.addModelStep(opData.response, opData.operation, opData.definition, opData.handler, true);
}