Java Code Examples for org.jboss.as.controller.AttributeDefinition#validateAndSet()
The following examples show how to use
org.jboss.as.controller.AttributeDefinition#validateAndSet() .
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: LoggingOperations.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
/** * Updates the model based on the operation. * * @param context the operation context * @param operation the operation being executed * @param model the model to update * * @throws OperationFailedException if a processing error occurs */ public void updateModel(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException { final Resource resource = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS); final ModelNode submodel = resource.getModel(); for (AttributeDefinition attribute : attributes) { final String attributeName = attribute.getName(); final ModelNode currentValue = submodel.get(attributeName).clone(); // Filter attribute needs to be converted to filter spec if (CommonAttributes.FILTER.equals(attribute)) { final ModelNode filter = CommonAttributes.FILTER.validateOperation(operation); if (filter.isDefined()) { final String value = Filters.filterToFilterSpec(filter); model.get(LoggerAttributes.FILTER_SPEC.getName()).set(value.isEmpty() ? new ModelNode() : new ModelNode(value)); } } else { // Only update the model for attributes that are defined in the operation if (operation.has(attribute.getName())) { attribute.validateAndSet(operation, model); } } final ModelNode newValue = model.get(attributeName).clone(); recordCapabilitiesAndRequirements(context, resource, attribute, newValue, currentValue); } }
Example 2
Source File: SpecifiedInterfaceResolveHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void validateAndSet(final AttributeDefinition definition, final ModelNode operation, final ModelNode subModel) throws OperationFailedException { final String attributeName = definition.getName(); final boolean has = operation.has(attributeName); if(! has && definition.isRequired(operation)) { throw ControllerLogger.ROOT_LOGGER.required(attributeName); } if(has) { if(! definition.isAllowed(operation)) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalid(attributeName)); } definition.validateAndSet(operation, subModel); } else { // create the undefined node subModel.get(definition.getName()); } }
Example 3
Source File: InterfaceCriteriaWriteHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { nameValidator.validate(operation); final String attributeName = operation.require(NAME).asString(); final ModelNode newValue = operation.hasDefined(VALUE) ? operation.get(VALUE) : new ModelNode(); final ModelNode submodel = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS).getModel(); final AttributeDefinition attributeDefinition = ATTRIBUTES.get(attributeName); if (attributeDefinition != null) { final ModelNode syntheticOp = new ModelNode(); syntheticOp.get(attributeName).set(newValue); attributeDefinition.validateAndSet(syntheticOp, submodel); } else { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.unknownAttribute(attributeName)); } if (updateRuntime) { // Require a reload context.reloadRequired(); } // Verify the model in a later step context.addStep(VERIFY_HANDLER, OperationContext.Stage.MODEL); OperationContext.RollbackHandler rollbackHandler = updateRuntime ? OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER : OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER; context.completeStep(rollbackHandler); }
Example 4
Source File: ThemeResourceAddHandler.java From keycloak with Apache License 2.0 | 6 votes |
@Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { // TODO: localize exception. get id number if (!operation.get(OP).asString().equals(ADD)) { throw new OperationFailedException("Unexpected operation for add Theme. operation=" + operation.toString()); } PathAddress address = PathAddress.pathAddress(operation.get(ADDRESS)); PathElement last = address.getLastElement(); if (!last.getValue().equals(ThemeResourceDefinition.RESOURCE_NAME)) { throw new OperationFailedException("Theme resource with name " + last.getValue() + " not allowed."); } for (AttributeDefinition def : ALL_ATTRIBUTES) { def.validateAndSet(operation, model); } KeycloakAdapterConfigService.INSTANCE.updateConfig(operation, model); }
Example 5
Source File: HandlerOperations.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void populateModel(final ModelNode operation, final ModelNode model) throws OperationFailedException { for (AttributeDefinition attribute : attributes) { // Filter attribute needs to be converted to filter spec if (CommonAttributes.FILTER.equals(attribute)) { final ModelNode filter = CommonAttributes.FILTER.validateOperation(operation); if (filter.isDefined()) { final String value = Filters.filterToFilterSpec(filter); model.get(FILTER_SPEC.getName()).set(value.isEmpty() ? new ModelNode() : new ModelNode(value)); } } else { attribute.validateAndSet(operation, model); } } }
Example 6
Source File: RealmAddHandler.java From keycloak with Apache License 2.0 | 5 votes |
@Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { // TODO: localize exception. get id number if (!operation.get(OP).asString().equals(ADD)) { throw new OperationFailedException("Unexpected operation for add realm. operation=" + operation.toString()); } for (AttributeDefinition attrib : RealmDefinition.ALL_ATTRIBUTES) { attrib.validateAndSet(operation, model); } }
Example 7
Source File: RealmAddHandler.java From keycloak with Apache License 2.0 | 5 votes |
@Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { for (AttributeDefinition attrib : RealmDefinition.ALL_ATTRIBUTES) { attrib.validateAndSet(operation, model); } if (!SharedAttributeDefinitons.validateTruststoreSetIfRequired(model.clone())) { //TODO: externalize message throw new OperationFailedException("truststore and truststore-password must be set if ssl-required is not none and disable-trust-manager is false."); } }
Example 8
Source File: KeycloakSubsystemAdd.java From keycloak with Apache License 2.0 | 5 votes |
@Override protected void populateModel(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException { ModelNode model = resource.getModel(); // set attribute values from parsed model for (AttributeDefinition attrDef : ALL_ATTRIBUTES) { attrDef.validateAndSet(operation, model); } // returns early if on domain controller if (!requiresRuntime(context)) { return; } // don't want to try to start server on host controller if (!context.isNormalServer()) { return; } ModelNode webContextNode = resource.getModel().get(WEB_CONTEXT.getName()); if (!webContextNode.isDefined()) { webContextNode = WEB_CONTEXT.getDefaultValue(); } String webContext = webContextNode.asString(); ServerUtil serverUtil = new ServerUtil(operation); serverUtil.addStepToUploadServerWar(context); KeycloakAdapterConfigService.INSTANCE.setWebContext(webContext); KeycloakAdapterConfigService.INSTANCE.updateConfig(operation, model); }
Example 9
Source File: DeploymentOverlayContentAdd.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void populateModel(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final String path = address.getLastElement().getValue(); final String name = address.getElement(address.size() - 2).getValue(); final ModelNode content = DeploymentOverlayContentDefinition.CONTENT_PARAMETER.validateOperation(operation); validateOnePieceOfContent(content); final byte[] hash; if (content.hasDefined(HASH)) { hash = content.require(HASH).asBytes(); addFromHash(hash, name, path, address, context); } else { hash = addFromContentAdditionParameter(context, content); final ModelNode slave = operation.clone(); slave.get(CONTENT).clear(); slave.get(CONTENT).get(HASH).set(hash); List<DomainOperationTransmuter> transformers = context.getAttachment(OperationAttachments.SLAVE_SERVER_OPERATION_TRANSMUTERS); if(transformers == null) { context.attach(OperationAttachments.SLAVE_SERVER_OPERATION_TRANSMUTERS, transformers = new ArrayList<DomainOperationTransmuter>()); } transformers.add(new CompositeOperationAwareTransmuter(slave)); } contentRepository.addContentReference(ModelContentReference.fromModelAddress(address, hash)); ModelNode modified = operation.clone(); modified.get(CONTENT).clone(); modified.get(CONTENT).set(hash); for (AttributeDefinition attr : DeploymentOverlayContentDefinition.attributes()) { attr.validateAndSet(modified, resource.getModel()); } if (!contentRepository.syncContent(ModelContentReference.fromModelAddress(address, hash))) { throw ServerLogger.ROOT_LOGGER.noSuchDeploymentContent(Arrays.toString(hash)); } }
Example 10
Source File: AbstractCollectionHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
protected void populateModel(final ModelNode operation, final ModelNode model) throws OperationFailedException { NAME.validateAndSet(operation, model); for (AttributeDefinition attr : attributes) { if (attr == VALUE){//don't validate VALUE attribute WFCORE-826 model.get(VALUE.getName()).set(operation.get(VALUE.getName())); }else { attr.validateAndSet(operation, model); } } }
Example 11
Source File: LoggerOperations.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void populateModel(final ModelNode operation, final ModelNode model) throws OperationFailedException { for (AttributeDefinition attribute : attributes) { // Filter attribute needs to be converted to filter spec if (CommonAttributes.FILTER.equals(attribute)) { final ModelNode filter = CommonAttributes.FILTER.validateOperation(operation); if (filter.isDefined()) { final String value = Filters.filterToFilterSpec(filter); model.get(LoggerAttributes.FILTER_SPEC.getName()).set(value.isEmpty() ? new ModelNode() : new ModelNode(value)); } } else { attribute.validateAndSet(operation, model); } } }
Example 12
Source File: ModuleInfoHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
protected void populateModel(final ModelNode operation, final ModelNode model) throws OperationFailedException { for (AttributeDefinition attr : DEFINITION.getParameters()) { attr.validateAndSet(operation, model); } }
Example 13
Source File: JobAcquisitionAdd.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { for (AttributeDefinition attr : SubsystemAttributeDefinitons.JOB_ACQUISITION_ATTRIBUTES) { attr.validateAndSet(operation, model); } }
Example 14
Source File: ConnectorChildResource.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { for (AttributeDefinition ad : attributes) { validateProperty(operation); ad.validateAndSet(operation, model); } }
Example 15
Source File: SslLoopbackResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { for (AttributeDefinition attr : ATTRIBUTES) { attr.validateAndSet(operation, model); } }
Example 16
Source File: JobExecutorAdd.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { for (AttributeDefinition attr : SubsystemAttributeDefinitons.JOB_EXECUTOR_ATTRIBUTES) { attr.validateAndSet(operation, model); } }
Example 17
Source File: KeyAddHandler.java From keycloak with Apache License 2.0 | 4 votes |
@Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { for (AttributeDefinition attr : KeyDefinition.ALL_ATTRIBUTES) { attr.validateAndSet(operation, model); } }
Example 18
Source File: LdapConnectionAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { for (AttributeDefinition attr : LdapConnectionResourceDefinition.ATTRIBUTE_DEFINITIONS) { attr.validateAndSet(operation, model); } }
Example 19
Source File: ServiceProviderAddHandler.java From keycloak with Apache License 2.0 | 4 votes |
@Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { for (AttributeDefinition attr : ServiceProviderDefinition.ALL_ATTRIBUTES) { attr.validateAndSet(operation, model); } }
Example 20
Source File: IdentityProviderAddHandler.java From keycloak with Apache License 2.0 | 4 votes |
@Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { for (AttributeDefinition attr : IdentityProviderDefinition.ALL_ATTRIBUTES) { attr.validateAndSet(operation, model); } }