@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { operationDeprecated(context, operation); PathAddress address = translateProxyPath(context); String type = operation.require(LoadMetricResourceDefinition.Attribute.TYPE.getName()).asString(); PathAddress metricPath = PathAddress.pathAddress(DynamicLoadProviderResourceDefinition.LEGACY_PATH, LoadMetricResourceDefinition.pathElement(type)); PathAddress metricPathAddress = address.append(metricPath); ModelNode metricOperation = Util.createAddOperation(metricPathAddress); OperationEntry addOperationEntry = context.getResourceRegistration().getOperationEntry(PathAddress.pathAddress(metricPath), ModelDescriptionConstants.ADD); for (AttributeDefinition attribute : addOperationEntry.getOperationDefinition().getParameters()) { String name = attribute.getName(); if (operation.hasDefined(name)) { metricOperation.get(name).set(operation.get(name)); } } context.addStep(metricOperation, addOperationEntry.getOperationHandler(), OperationContext.Stage.MODEL, true); } };
@Override public void execute(OperationContext context, ModelNode operation) { operationDeprecated(context, operation); PathAddress address = context.getCurrentAddress(); String protocol = operation.require(AbstractProtocolResourceDefinition.DeprecatedAttribute.TYPE.getName()).asString(); PathElement protocolPath = ProtocolResourceDefinition.pathElement(protocol); PathAddress protocolAddress = address.append(protocolPath); ModelNode protocolOperation = Util.createAddOperation(protocolAddress); OperationEntry addOperationEntry = context.getResourceRegistration().getOperationEntry(PathAddress.pathAddress(protocolPath), ModelDescriptionConstants.ADD); for (AttributeDefinition attribute : addOperationEntry.getOperationDefinition().getParameters()) { String name = attribute.getName(); if (operation.hasDefined(name)) { protocolOperation.get(name).set(operation.get(name)); } } context.addStep(protocolOperation, addOperationEntry.getOperationHandler(), OperationContext.Stage.MODEL, true); } };
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { operationDeprecated(context, operation); PathAddress address = translateProxyPath(context); String type = operation.require(CustomLoadMetricResourceDefinition.Attribute.CLASS.getName()).asString(); PathAddress metricPath = PathAddress.pathAddress(DynamicLoadProviderResourceDefinition.LEGACY_PATH, LoadMetricResourceDefinition.pathElement(type)); PathAddress metricPathAddress = address.append(metricPath); ModelNode metricOperation = Util.createAddOperation(metricPathAddress); OperationEntry addOperationEntry = context.getResourceRegistration().getOperationEntry(PathAddress.pathAddress(metricPath), ModelDescriptionConstants.ADD); for (AttributeDefinition attribute : addOperationEntry.getOperationDefinition().getParameters()) { String name = attribute.getName(); if (operation.hasDefined(name)) { metricOperation.get(name).set(operation.get(name)); } } context.addStep(metricOperation, addOperationEntry.getOperationHandler(), OperationContext.Stage.MODEL, true); } };
ModelNode transportOperation = Util.createAddOperation(transportAddress); OperationEntry addOperationEntry = context.getResourceRegistration().getOperationEntry(PathAddress.pathAddress(TransportResourceDefinition.WILDCARD_PATH), ModelDescriptionConstants.ADD); for (AttributeDefinition attribute : addOperationEntry.getOperationDefinition().getParameters()) { String name = attribute.getName(); if (transport.hasDefined(name)) { ModelNode protocolOperation = Util.createAddOperation(protocolAddress); OperationEntry addOperationEntry = context.getResourceRegistration().getOperationEntry(PathAddress.pathAddress(ProtocolResourceDefinition.WILDCARD_PATH), ModelDescriptionConstants.ADD); for (AttributeDefinition attribute : addOperationEntry.getOperationDefinition().getParameters()) { String name = attribute.getName(); if (protocol.hasDefined(name)) {
@Override void getOperationDescriptions(final ListIterator<PathElement> iterator, final Map<String, OperationEntry> providers, final boolean inherited) { Map<String, OperationEntry> temp = new HashMap<String, OperationEntry>(); target.getOperationDescriptions(iterator, temp, inherited); for (Map.Entry<String, OperationEntry> entry : providers.entrySet()) { OperationEntry value = entry.getValue(); providers.put(entry.getKey(), new OperationEntry(value.getOperationDefinition(), handler, value.isInherited())); } }
@Override void getOperationDescriptions(final ListIterator<PathElement> iterator, final Map<String, OperationEntry> providers, final boolean inherited) { Map<String, OperationEntry> temp = new HashMap<String, OperationEntry>(); target.getOperationDescriptions(iterator, temp, inherited); for (Map.Entry<String, OperationEntry> entry : providers.entrySet()) { OperationEntry value = entry.getValue(); providers.put(entry.getKey(), new OperationEntry(value.getOperationDefinition(), handler, value.isInherited())); } }
@Override OperationEntry getOperationEntry(final ListIterator<PathElement> iterator, final String operationName, OperationEntry inherited) { OperationEntry targetOp = target.getOperationEntry(iterator, operationName, inherited); if (targetOp == null) { return null; } return new OperationEntry(targetOp.getOperationDefinition(), handler, targetOp.isInherited()); }
@Override OperationEntry getOperationEntry(final ListIterator<PathElement> iterator, final String operationName, OperationEntry inherited) { OperationEntry targetOp = target.getOperationEntry(iterator, operationName, inherited); if (targetOp == null) { return null; } return new OperationEntry(targetOp.getOperationDefinition(), handler, targetOp.isInherited()); }
public final void execute(final OperationContext context, final ModelNode operation) { if (context.isBooting()) { execute(TARGET); } else { // WFCORE-1781 We should not be called post-boot as the DUP chain can only be modified in boot // Check and see if the OperationDefinition for this op declares reload/restart required and if so // trigger that; otherwise fail. ImmutableManagementResourceRegistration mrr = context.getResourceRegistration(); OperationEntry oe = mrr.getOperationEntry(PathAddress.EMPTY_ADDRESS, operation.get(ModelDescriptionConstants.OP).asString()); Set<OperationEntry.Flag> flags = oe == null ? Collections.emptySet() : oe.getOperationDefinition().getFlags(); if (flags.contains(OperationEntry.Flag.RESTART_JVM)) { context.restartRequired(); context.completeStep((ctx, op) -> ctx.revertRestartRequired()); } else if (flags.contains(OperationEntry.Flag.RESTART_ALL_SERVICES)) { context.reloadRequired(); context.completeStep(OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER); } else { // Coding error we cannot recover from throw new IllegalStateException(); } } }
public final void execute(final OperationContext context, final ModelNode operation) { if (context.isBooting()) { execute(TARGET); } else { // WFCORE-1781 We should not be called post-boot as the DUP chain can only be modified in boot // Check and see if the OperationDefinition for this op declares reload/restart required and if so // trigger that; otherwise fail. ImmutableManagementResourceRegistration mrr = context.getResourceRegistration(); OperationEntry oe = mrr.getOperationEntry(PathAddress.EMPTY_ADDRESS, operation.get(ModelDescriptionConstants.OP).asString()); Set<OperationEntry.Flag> flags = oe == null ? Collections.emptySet() : oe.getOperationDefinition().getFlags(); if (flags.contains(OperationEntry.Flag.RESTART_JVM)) { context.restartRequired(); context.completeStep((ctx, op) -> ctx.revertRestartRequired()); } else if (flags.contains(OperationEntry.Flag.RESTART_ALL_SERVICES)) { context.reloadRequired(); context.completeStep(OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER); } else { // Coding error we cannot recover from throw new IllegalStateException(); } } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (MGMT_OP_LOGGER.isTraceEnabled()) { MGMT_OP_LOGGER.tracef("Executing %s %s", operation.get(OP), operation.get(OP_ADDR)); } final PathAddress address = context.getCurrentAddress(); final String operationName = operation.require(OP).asString(); final OperationEntry stepOperation = resolveOperationHandler(address, operationName); if (stepOperation != null) { if (!context.isBooting() && stepOperation.getType() == OperationEntry.EntryType.PRIVATE && operation.hasDefined(OPERATION_HEADERS, CALLER_TYPE) && USER.equals(operation.get(OPERATION_HEADERS, CALLER_TYPE).asString())) { // End user trying to invoke a private op. Respond as if there is no such operation context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, address)); } else { context.addModelStep(stepOperation.getOperationDefinition(), stepOperation.getOperationHandler(), false); } } else { ImmutableManagementResourceRegistration child = managementModel.get().getRootResourceRegistration().getSubModel(address); if (child == null) { context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noSuchResourceType(address)); } else { context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, address)); } } context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (MGMT_OP_LOGGER.isTraceEnabled()) { MGMT_OP_LOGGER.tracef("Executing %s %s", operation.get(OP), operation.get(OP_ADDR)); } final PathAddress address = context.getCurrentAddress(); final String operationName = operation.require(OP).asString(); final OperationEntry stepOperation = resolveOperationHandler(address, operationName); if (stepOperation != null) { if (!context.isBooting() && stepOperation.getType() == OperationEntry.EntryType.PRIVATE && operation.hasDefined(OPERATION_HEADERS, CALLER_TYPE) && USER.equals(operation.get(OPERATION_HEADERS, CALLER_TYPE).asString())) { // End user trying to invoke a private op. Respond as if there is no such operation context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, address)); } else { context.addModelStep(stepOperation.getOperationDefinition(), stepOperation.getOperationHandler(), false); } } else { ImmutableManagementResourceRegistration child = managementModel.get().getRootResourceRegistration().getSubModel(address); if (child == null) { context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noSuchResourceType(address)); } else { context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, address)); } } context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER); } }
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)); } } } }
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)); } } } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { operationDeprecated(context, operation); PathAddress address = translateProxyPath(context); String type = operation.require(LoadMetricResourceDefinition.Attribute.TYPE.getName()).asString(); PathAddress metricPath = PathAddress.pathAddress(DynamicLoadProviderResourceDefinition.LEGACY_PATH, LoadMetricResourceDefinition.pathElement(type)); PathAddress metricPathAddress = address.append(metricPath); ModelNode metricOperation = Util.createAddOperation(metricPathAddress); OperationEntry addOperationEntry = context.getResourceRegistration().getOperationEntry(PathAddress.pathAddress(metricPath), ModelDescriptionConstants.ADD); for (AttributeDefinition attribute : addOperationEntry.getOperationDefinition().getParameters()) { String name = attribute.getName(); if (operation.hasDefined(name)) { metricOperation.get(name).set(operation.get(name)); } } context.addStep(metricOperation, addOperationEntry.getOperationHandler(), OperationContext.Stage.MODEL, true); } };
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { operationDeprecated(context, operation); PathAddress address = translateProxyPath(context); String type = operation.require(CustomLoadMetricResourceDefinition.Attribute.CLASS.getName()).asString(); PathAddress metricPath = PathAddress.pathAddress(DynamicLoadProviderResourceDefinition.LEGACY_PATH, LoadMetricResourceDefinition.pathElement(type)); PathAddress metricPathAddress = address.append(metricPath); ModelNode metricOperation = Util.createAddOperation(metricPathAddress); OperationEntry addOperationEntry = context.getResourceRegistration().getOperationEntry(PathAddress.pathAddress(metricPath), ModelDescriptionConstants.ADD); for (AttributeDefinition attribute : addOperationEntry.getOperationDefinition().getParameters()) { String name = attribute.getName(); if (operation.hasDefined(name)) { metricOperation.get(name).set(operation.get(name)); } } context.addStep(metricOperation, addOperationEntry.getOperationHandler(), OperationContext.Stage.MODEL, true); } };
private static OpData getOpData(OperationContext context, ModelNode subOperation, ModelNode response, PathAddress stepAddress, OperationHandlerResolver handlerResolver, boolean rejectPrivateOperations) throws OperationFailedException { ImmutableManagementResourceRegistration registry = context.getRootResourceRegistration(); String stepOpName = subOperation.require(OP).asString(); OperationEntry operationEntry = registry.getOperationEntry(stepAddress, stepOpName); if (operationEntry == null) { ImmutableManagementResourceRegistration child = registry.getSubModel(stepAddress); if (child == null) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noSuchResourceType(stepAddress)); } else { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(stepOpName, stepAddress)); } } else if (operationEntry.getType() == OperationEntry.EntryType.PRIVATE) { if (rejectPrivateOperations || (subOperation.hasDefined(OPERATION_HEADERS, CALLER_TYPE) && USER.equals(subOperation.get(OPERATION_HEADERS, CALLER_TYPE).asString()))) { // Not allowed; respond as if there is no such operation throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(stepOpName, stepAddress)); } } OperationStepHandler osh = handlerResolver.getOperationStepHandler(stepOpName, stepAddress, subOperation, operationEntry); return new OpData(subOperation, operationEntry.getOperationDefinition(), osh, response); }
@Override public void execute(OperationContext context, ModelNode operation) { operationDeprecated(context, operation); PathAddress address = context.getCurrentAddress(); String protocol = operation.require(AbstractProtocolResourceDefinition.DeprecatedAttribute.TYPE.getName()).asString(); PathElement protocolPath = ProtocolResourceDefinition.pathElement(protocol); PathAddress protocolAddress = address.append(protocolPath); ModelNode protocolOperation = Util.createAddOperation(protocolAddress); OperationEntry addOperationEntry = context.getResourceRegistration().getOperationEntry(PathAddress.pathAddress(protocolPath), ModelDescriptionConstants.ADD); for (AttributeDefinition attribute : addOperationEntry.getOperationDefinition().getParameters()) { String name = attribute.getName(); if (operation.hasDefined(name)) { protocolOperation.get(name).set(operation.get(name)); } } context.addStep(protocolOperation, addOperationEntry.getOperationHandler(), OperationContext.Stage.MODEL, true); } };
private static OpData getOpData(OperationContext context, ModelNode subOperation, ModelNode response, PathAddress stepAddress, OperationHandlerResolver handlerResolver, boolean rejectPrivateOperations) throws OperationFailedException { ImmutableManagementResourceRegistration registry = context.getRootResourceRegistration(); String stepOpName = subOperation.require(OP).asString(); OperationEntry operationEntry = registry.getOperationEntry(stepAddress, stepOpName); if (operationEntry == null) { ImmutableManagementResourceRegistration child = registry.getSubModel(stepAddress); if (child == null) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noSuchResourceType(stepAddress)); } else { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(stepOpName, stepAddress)); } } else if (operationEntry.getType() == OperationEntry.EntryType.PRIVATE) { if (rejectPrivateOperations || (subOperation.hasDefined(OPERATION_HEADERS, CALLER_TYPE) && USER.equals(subOperation.get(OPERATION_HEADERS, CALLER_TYPE).asString()))) { // Not allowed; respond as if there is no such operation throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(stepOpName, stepAddress)); } } OperationStepHandler osh = handlerResolver.getOperationStepHandler(stepOpName, stepAddress, subOperation, operationEntry); return new OpData(subOperation, operationEntry.getOperationDefinition(), osh, response); }
context.addModelStep(localReponse, operation, entry.getOperationDefinition(), entry.getOperationHandler(), false); } else { final OperationStepHandler wrapper; wrapper = entry.getOperationHandler(); context.addModelStep(localReponse, operation, entry.getOperationDefinition(), wrapper, false);