private void addReadAttributeStep(OperationContext context, PathAddress address, boolean defaults, FilteredData localFilteredData, ImmutableManagementResourceRegistration registry, String attributeName, Map<String, ModelNode> responseMap) { // See if there was an override registered for the standard :read-attribute handling (unlikely!!!) OperationStepHandler overrideHandler = registry.getOperationHandler(PathAddress.EMPTY_ADDRESS, READ_ATTRIBUTE_OPERATION); if (overrideHandler != null && overrideHandler == ReadAttributeHandler.INSTANCE) { // not an override overrideHandler = null; } OperationStepHandler readAttributeHandler = new ReadAttributeHandler(localFilteredData, overrideHandler); final ModelNode attributeOperation = Util.getReadAttributeOperation(address, attributeName); attributeOperation.get(ModelDescriptionConstants.INCLUDE_DEFAULTS).set(defaults); final ModelNode attrResponse = new ModelNode(); responseMap.put(attributeName, attrResponse); context.addStep(attrResponse, attributeOperation, readAttributeHandler, OperationContext.Stage.MODEL, true); }
private void addReadAttributeStep(OperationContext context, PathAddress address, boolean defaults, boolean resolve, boolean includeUndefinedMetricValues, FilteredData localFilteredData, ImmutableManagementResourceRegistration registry, AttributeDefinition.NameAndGroup attributeKey, Map<AttributeDefinition.NameAndGroup, GlobalOperationHandlers.AvailableResponse> responseMap) { // See if there was an override registered for the standard :read-attribute handling (unlikely!!!) OperationStepHandler overrideHandler = registry.getOperationHandler(PathAddress.EMPTY_ADDRESS, READ_ATTRIBUTE_OPERATION); if (overrideHandler != null && (overrideHandler == ReadAttributeHandler.INSTANCE || overrideHandler == ReadAttributeHandler.RESOLVE_INSTANCE)) { // not an override overrideHandler = null; } OperationStepHandler readAttributeHandler = new ReadAttributeHandler(localFilteredData, overrideHandler, (resolve && resolvable)); final ModelNode attributeOperation = Util.getReadAttributeOperation(address, attributeKey.getName()); attributeOperation.get(ModelDescriptionConstants.INCLUDE_DEFAULTS).set(defaults); attributeOperation.get(ModelDescriptionConstants.RESOLVE_EXPRESSIONS).set(resolve); attributeOperation.get(ModelDescriptionConstants.INCLUDE_UNDEFINED_METRIC_VALUES).set(includeUndefinedMetricValues); final ModelNode attrResponse = new ModelNode(); GlobalOperationHandlers.AvailableResponse availableResponse = new GlobalOperationHandlers.AvailableResponse(attrResponse); responseMap.put(attributeKey, availableResponse); GlobalOperationHandlers.AvailableResponseWrapper wrapper = new GlobalOperationHandlers.AvailableResponseWrapper(readAttributeHandler, availableResponse); context.addStep(attrResponse, attributeOperation, wrapper, OperationContext.Stage.MODEL, true); }
void cleanObsoleteContent() { if (controlledProcessStateService.getCurrentState() == ControlledProcessState.State.RUNNING) { PathAddress address = PathAddress.EMPTY_ADDRESS; if (!server) { ModelNode request = Util.getReadAttributeOperation(PathAddress.EMPTY_ADDRESS, LOCAL_HOST_NAME); ModelNode response = privilegedExecution().execute(client::execute, request); if (SUCCESS.equals(response.get(OUTCOME).asString()) && response.get(RESULT).isDefined()) { address = address.append(HOST, response.get(RESULT).asString()); } else if (CANCELLED.equals(response.get(OUTCOME).asString())) { return; } else if (FAILED.equals(response.get(OUTCOME).asString())) { error(response); // if we can't read the local-host-name on a host controller, don't try and run the content cleaner return; } } ModelNode request = Util.createOperation(CleanObsoleteContentHandler.OPERATION_NAME, address); ModelNode response = privilegedExecution().execute(client::execute, request); if (SUCCESS.equals(response.get(OUTCOME).asString())) { if(response.get(RESULT).isDefined()) { ServerLogger.ROOT_LOGGER.debug(response.get(RESULT)); } } else if (FAILED.equals(response.get(OUTCOME).asString())) { error(response); } } }
private void addReadAttributeStep(OperationContext context, PathAddress address, boolean defaults, boolean resolve, boolean includeUndefinedMetricValues, FilteredData localFilteredData, ImmutableManagementResourceRegistration registry, AttributeDefinition.NameAndGroup attributeKey, Map<AttributeDefinition.NameAndGroup, GlobalOperationHandlers.AvailableResponse> responseMap) { // See if there was an override registered for the standard :read-attribute handling (unlikely!!!) OperationStepHandler overrideHandler = registry.getOperationHandler(PathAddress.EMPTY_ADDRESS, READ_ATTRIBUTE_OPERATION); if (overrideHandler != null && (overrideHandler == ReadAttributeHandler.INSTANCE || overrideHandler == ReadAttributeHandler.RESOLVE_INSTANCE)) { // not an override overrideHandler = null; } OperationStepHandler readAttributeHandler = new ReadAttributeHandler(localFilteredData, overrideHandler, (resolve && resolvable)); final ModelNode attributeOperation = Util.getReadAttributeOperation(address, attributeKey.getName()); attributeOperation.get(ModelDescriptionConstants.INCLUDE_DEFAULTS).set(defaults); attributeOperation.get(ModelDescriptionConstants.RESOLVE_EXPRESSIONS).set(resolve); attributeOperation.get(ModelDescriptionConstants.INCLUDE_UNDEFINED_METRIC_VALUES).set(includeUndefinedMetricValues); final ModelNode attrResponse = new ModelNode(); GlobalOperationHandlers.AvailableResponse availableResponse = new GlobalOperationHandlers.AvailableResponse(attrResponse); responseMap.put(attributeKey, availableResponse); GlobalOperationHandlers.AvailableResponseWrapper wrapper = new GlobalOperationHandlers.AvailableResponseWrapper(readAttributeHandler, availableResponse); context.addStep(attrResponse, attributeOperation, wrapper, OperationContext.Stage.MODEL, true); }
private void addReadAttributeStep(OperationContext context, PathAddress address, boolean defaults, boolean resolve, FilteredData localFilteredData, ImmutableManagementResourceRegistration registry, AttributeDefinition.NameAndGroup attributeKey, Map<AttributeDefinition.NameAndGroup, GlobalOperationHandlers.AvailableResponse> responseMap) { // See if there was an override registered for the standard :read-attribute handling (unlikely!!!) OperationStepHandler overrideHandler = registry.getOperationHandler(PathAddress.EMPTY_ADDRESS, READ_ATTRIBUTE_OPERATION); if (overrideHandler != null && (overrideHandler == ReadAttributeHandler.INSTANCE || overrideHandler == ReadAttributeHandler.RESOLVE_INSTANCE)) { // not an override overrideHandler = null; } OperationStepHandler readAttributeHandler = new ReadAttributeHandler(localFilteredData, overrideHandler, (resolve && resolvable)); final ModelNode attributeOperation = Util.getReadAttributeOperation(address, attributeKey.getName()); attributeOperation.get(ModelDescriptionConstants.INCLUDE_DEFAULTS).set(defaults); attributeOperation.get(ModelDescriptionConstants.RESOLVE_EXPRESSIONS).set(resolve); final ModelNode attrResponse = new ModelNode(); GlobalOperationHandlers.AvailableResponse availableResponse = new GlobalOperationHandlers.AvailableResponse(attrResponse); responseMap.put(attributeKey, availableResponse); GlobalOperationHandlers.AvailableResponseWrapper wrapper = new GlobalOperationHandlers.AvailableResponseWrapper(readAttributeHandler, availableResponse); context.addStep(attrResponse, attributeOperation, wrapper, OperationContext.Stage.MODEL, true); }
private void addReadAttributeStep(OperationContext context, PathAddress address, boolean defaults, boolean resolve, FilteredData localFilteredData, ImmutableManagementResourceRegistration registry, AttributeDefinition.NameAndGroup attributeKey, Map<AttributeDefinition.NameAndGroup, GlobalOperationHandlers.AvailableResponse> responseMap) { // See if there was an override registered for the standard :read-attribute handling (unlikely!!!) OperationStepHandler overrideHandler = registry.getOperationHandler(PathAddress.EMPTY_ADDRESS, READ_ATTRIBUTE_OPERATION); if (overrideHandler != null && (overrideHandler == ReadAttributeHandler.INSTANCE || overrideHandler == ReadAttributeHandler.RESOLVE_INSTANCE)) { // not an override overrideHandler = null; } OperationStepHandler readAttributeHandler = new ReadAttributeHandler(localFilteredData, overrideHandler, (resolve && resolvable)); final ModelNode attributeOperation = Util.getReadAttributeOperation(address, attributeKey.getName()); attributeOperation.get(ModelDescriptionConstants.INCLUDE_DEFAULTS).set(defaults); attributeOperation.get(ModelDescriptionConstants.RESOLVE_EXPRESSIONS).set(resolve); final ModelNode attrResponse = new ModelNode(); GlobalOperationHandlers.AvailableResponse availableResponse = new GlobalOperationHandlers.AvailableResponse(attrResponse); responseMap.put(attributeKey, availableResponse); GlobalOperationHandlers.AvailableResponseWrapper wrapper = new GlobalOperationHandlers.AvailableResponseWrapper(readAttributeHandler, availableResponse); context.addStep(attrResponse, attributeOperation, wrapper, OperationContext.Stage.MODEL, true); }
void cleanObsoleteContent() { if (controlledProcessStateService.getCurrentState() == ControlledProcessState.State.RUNNING) { PathAddress address = PathAddress.EMPTY_ADDRESS; if (!server) { ModelNode request = Util.getReadAttributeOperation(PathAddress.EMPTY_ADDRESS, LOCAL_HOST_NAME); ModelNode response = privilegedExecution().execute(client::execute, request); if (SUCCESS.equals(response.get(OUTCOME).asString()) && response.get(RESULT).isDefined()) { address = address.append(HOST, response.get(RESULT).asString()); } else if (CANCELLED.equals(response.get(OUTCOME).asString())) { return; } else if (FAILED.equals(response.get(OUTCOME).asString())) { error(response); // if we can't read the local-host-name on a host controller, don't try and run the content cleaner return; } } ModelNode request = Util.createOperation(CleanObsoleteContentHandler.OPERATION_NAME, address); ModelNode response = privilegedExecution().execute(client::execute, request); if (SUCCESS.equals(response.get(OUTCOME).asString())) { if(response.get(RESULT).isDefined()) { ServerLogger.ROOT_LOGGER.debug(response.get(RESULT)); } } else if (FAILED.equals(response.get(OUTCOME).asString())) { error(response); } } }
private void attemptReadMissingAttributeValueFromHandler(final OperationContext context, final PathAddress address, final AttributeAccess attributeAccess, final String attributeName, final ErrorHandler errorHandler) throws OperationFailedException { OperationStepHandler handler = attributeAccess.getReadHandler(); if (handler == null) { errorHandler.throwError(); } else { final ModelNode readAttr = Util.getReadAttributeOperation(address, attributeName); //Do a read-attribute as an immediate step final ModelNode resultHolder = new ModelNode(); context.addStep(resultHolder, readAttr, handler, Stage.MODEL, true); //Then check the read-attribute result in a later step and throw the error if it is not set context.addStep(new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (!resultHolder.isDefined() && !resultHolder.hasDefined(RESULT)) { errorHandler.throwError(); } } }, Stage.MODEL); } }
private void attemptReadMissingAttributeValueFromHandler(final OperationContext context, final PathAddress address, final AttributeAccess attributeAccess, final String attributeName, final ErrorHandler errorHandler) throws OperationFailedException { OperationStepHandler handler = attributeAccess.getReadHandler(); if (handler == null) { errorHandler.throwError(); } else { final ModelNode readAttr = Util.getReadAttributeOperation(address, attributeName); //Do a read-attribute as an immediate step final ModelNode resultHolder = new ModelNode(); context.addStep(resultHolder, readAttr, handler, Stage.MODEL, true); //Then check the read-attribute result in a later step and throw the error if it is not set context.addStep(new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (!resultHolder.isDefined() && !resultHolder.hasDefined(RESULT)) { errorHandler.throwError(); } } }, Stage.MODEL); } }
op = Util.getReadAttributeOperation(VAULT_PATH, VAULT_OPTIONS); originalVault = (managementClient.getControllerClient().execute(new OperationBuilder(op).build())).get(RESULT);
ModelNode readAttributeOperation = Util.getReadAttributeOperation(address, useEnhancedSyntax ? attributeExpression : attributeName); context.addStep(readResponse, readAttributeOperation, ReadAttributeHandler.INSTANCE, OperationContext.Stage.MODEL, true); } else { ModelNode readAttributeOperation = Util.getReadAttributeOperation(address, useEnhancedSyntax ? attributeExpression : attributeName); context.addStep(readResponse, readAttributeOperation, ReadAttributeHandler.INSTANCE, OperationContext.Stage.MODEL, true);
ModelNode readAttributeOperation = Util.getReadAttributeOperation(address, useEnhancedSyntax ? attributeExpression : attributeName); context.addStep(readResponse, readAttributeOperation, ReadAttributeHandler.INSTANCE, OperationContext.Stage.MODEL, true); } else { ModelNode readAttributeOperation = Util.getReadAttributeOperation(address, useEnhancedSyntax ? attributeExpression : attributeName); context.addStep(readResponse, readAttributeOperation, ReadAttributeHandler.INSTANCE, OperationContext.Stage.MODEL, true);
private ModelNode readAttributeValue(OperationContext context, AttributeDefinition attribute) throws OperationFailedException { final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode model = resource.getModel(); if(this.parentAttribute != null && !this.parentAttribute.equals(attribute)) { model = readAttributeValue(context, this.parentAttribute); } final String attributeName = attribute.getName(); if(model.hasDefined(attributeName)) { return attribute.resolveModelAttribute(context, model); } AttributeAccess access = context.getResourceRegistration().getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName); if(access == null) { return new ModelNode(); } OperationStepHandler handler = access.getReadHandler(); ModelNode path; if(handler != null) { ClassLoader oldTccl = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(handler.getClass()); try { handler.execute(context, Util.getReadAttributeOperation(context.getCurrentAddress(), attributeName)); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl); } path = context.getResult().clone(); context.getResult().setEmptyObject(); } else { path = new ModelNode(); } return path; }
private ModelNode readAttributeValue(OperationContext context, AttributeDefinition attribute) throws OperationFailedException { final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode model = resource.getModel(); if(this.parentAttribute != null && !this.parentAttribute.equals(attribute)) { model = readAttributeValue(context, this.parentAttribute); } final String attributeName = attribute.getName(); if(model.hasDefined(attributeName)) { return attribute.resolveModelAttribute(context, model); } AttributeAccess access = context.getResourceRegistration().getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName); if(access == null) { return new ModelNode(); } OperationStepHandler handler = access.getReadHandler(); ModelNode path; if(handler != null) { ClassLoader oldTccl = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(handler.getClass()); try { handler.execute(context, Util.getReadAttributeOperation(context.getCurrentAddress(), attributeName)); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl); } path = context.getResult().clone(); context.getResult().setEmptyObject(); } else { path = new ModelNode(); } return path; }