Java Code Examples for org.jboss.as.controller.AttributeDefinition#getName()
The following examples show how to use
org.jboss.as.controller.AttributeDefinition#getName() .
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: InterfaceAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
protected 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 4
Source File: ReadConfigAsFeaturesOperationHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private ModelNode readObjectAttributeAsFeature(final ImmutableManagementResourceRegistration registration, ObjectTypeAttributeDefinition attrDef, ModelNode idParams, Set<String> idParamNames, ModelNode objectValue, boolean nest) { final ModelNode featureNode = new ModelNode(); featureNode.get(SPEC).set(registration.getFeature() + '.' + attrDef.getName()); if(!nest) { featureNode.get(ID).set(idParams.clone()); } final ModelNode params = featureNode.get(PARAMS); final AttributeDefinition[] attrs = attrDef.getValueTypes(); for(AttributeDefinition attr : attrs) { String attrName = attr.getName(); if(!objectValue.hasDefined(attrName)) { continue; } final ModelNode attrValue = objectValue.get(attrName); if(idParamNames.contains(attrName)) { attrName += "-feature"; } params.get(attrName).set(attrValue); } return featureNode; }
Example 5
Source File: InterfaceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Deprecated static ParameterValidator createNestedParamValidator() { return new ModelTypeValidator(ModelType.OBJECT, true, false, true) { @Override public void validateParameter(final String parameterName, final ModelNode value) throws OperationFailedException { super.validateParameter(parameterName, value); for (final AttributeDefinition def : NESTED_ATTRIBUTES) { final String name = def.getName(); if (value.hasDefined(name)) { final ModelNode v = value.get(name); if (NESTED_LIST_ATTRIBUTES.contains(def)) { if (ModelType.LIST != v.getType()) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalidType(v.getType())); } } else { def.getValidator().validateParameter(name, v); } } } } }; }
Example 6
Source File: RemotingEndpointRemove.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void performRemove(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { // For any attribute that is defined in the parent resource, add an immediate 'write-attribute' // step against the parent to undefine it PathAddress parentAddress = context.getCurrentAddress().getParent(); ModelNode parentModel = context.readResourceFromRoot(parentAddress, false).getModel(); OperationStepHandler writeHandler = null; ModelNode baseWriteOp = null; for (AttributeDefinition ad : RemotingEndpointResource.ATTRIBUTES.values()) { String attr = ad.getName(); if (parentModel.hasDefined(attr)) { if (writeHandler == null) { writeHandler = context.getRootResourceRegistration().getOperationHandler(parentAddress, WRITE_ATTRIBUTE_OPERATION); baseWriteOp = Util.createEmptyOperation(WRITE_ATTRIBUTE_OPERATION, parentAddress); } ModelNode writeOp = baseWriteOp.clone(); writeOp.get(NAME).set(attr); writeOp.get(VALUE).set(new ModelNode()); context.addStep(writeOp, writeHandler, OperationContext.Stage.MODEL, true); } } }
Example 7
Source File: RemotingEndpointAdd.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void populateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { // For any attribute where the value in 'operation' differs from the model in the // parent resource, add an immediate 'write-attribute' step against the parent PathAddress parentAddress = context.getCurrentAddress().getParent(); ModelNode parentModel = context.readResourceFromRoot(parentAddress, false).getModel(); OperationStepHandler writeHandler = null; ModelNode baseWriteOp = null; for (AttributeDefinition ad : RemotingEndpointResource.ATTRIBUTES.values()) { String attr = ad.getName(); ModelNode parentVal = parentModel.get(attr); ModelNode opVal = operation.has(attr) ? operation.get(attr) : new ModelNode(); if (!parentVal.equals(opVal)) { if (writeHandler == null) { writeHandler = context.getRootResourceRegistration().getOperationHandler(parentAddress, WRITE_ATTRIBUTE_OPERATION); baseWriteOp = Util.createEmptyOperation(WRITE_ATTRIBUTE_OPERATION, parentAddress); } ModelNode writeOp = baseWriteOp.clone(); writeOp.get(NAME).set(attr); writeOp.get(VALUE).set(opVal); context.addStep(writeOp, writeHandler, OperationContext.Stage.MODEL, true); } } }
Example 8
Source File: ModifiableRealmDecorator.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void executeRuntimeStep(final OperationContext context, final ModelNode operation) throws OperationFailedException { String principalName = IDENTITY.resolveModelAttribute(context, operation).asString(); ModifiableRealmIdentity realmIdentity = getRealmIdentity(context, principalName); List<Credential> passwords = new ArrayList<>(); try { for (AttributeDefinition passwordDef : SUPPORTED_PASSWORDS) { String passwordType = passwordDef.getName(); if (operation.hasDefined(passwordType)) { passwords.add(new PasswordCredential(createPassword(context, principalName, passwordType, operation.get(passwordType)))); } } realmIdentity.setCredentials(passwords); } catch (NoSuchAlgorithmException | InvalidKeySpecException | RealmUnavailableException e) { throw ROOT_LOGGER.couldNotCreatePassword(e); } }
Example 9
Source File: RemotingTransformers.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode operation) throws OperationFailedException { ModelNode transformed; ModelNode trimmedAdd = null; ModelNode endPointAdd = null; for (AttributeDefinition ad : RemotingEndpointResource.ATTRIBUTES.values()) { String adName = ad.getName(); if (operation.hasDefined(adName)) { if (endPointAdd == null) { trimmedAdd = operation.clone(); PathAddress endpointAddress = address.append(RemotingEndpointResource.ENDPOINT_PATH); endPointAdd = Util.createEmptyOperation(operation.get(OP).asString(), endpointAddress); } endPointAdd.get(adName).set(operation.get(adName)); trimmedAdd.remove(adName); } } if (endPointAdd != null) { transformed = Util.createEmptyOperation(COMPOSITE, PathAddress.EMPTY_ADDRESS); ModelNode steps = transformed.get(STEPS); steps.add(trimmedAdd); steps.add(endPointAdd); } else { transformed = operation; } return new TransformedOperation(transformed, OperationResultTransformer.ORIGINAL_RESULT); }
Example 10
Source File: ObjectTypeValidator.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void validateParameter(final String parameterName, final ModelNode value) throws OperationFailedException { super.validateParameter(parameterName, value); if (value.isDefined()) { for (AttributeDefinition ad : allowedValues.values()) { String key = ad.getName(); // Don't modify the value by calls to get(), because that's best in general. // Plus modifying it results in an irrelevant test failure in full where the test // isn't expecting the modification and complains. // Changing the test is too much trouble. ModelNode toTest = value.has(key) ? value.get(key) : new ModelNode(); ad.getValidator().validateParameter(key, toTest); } } }
Example 11
Source File: ManagedServerOperationsFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void addManagementAuthorization(ModelNodeList updates) { ModelNode domainConfig = domainModel.get(CORE_SERVICE, MANAGEMENT, ACCESS, AUTHORIZATION); if (domainConfig.isDefined()) { ModelNode baseAddress = new ModelNode(); baseAddress.add(CORE_SERVICE, MANAGEMENT); baseAddress.add(ACCESS, AUTHORIZATION); if (domainConfig.hasDefined(PROVIDER)) { ModelNode providerOp = Util.getWriteAttributeOperation(baseAddress, PROVIDER, domainConfig.get(PROVIDER)); updates.add(providerOp); } addRoleMappings(domainConfig, baseAddress, updates); convertSimpleResources(domainConfig, SERVER_GROUP_SCOPED_ROLE, baseAddress, updates); convertSimpleResources(domainConfig, HOST_SCOPED_ROLE, baseAddress, updates); if (domainConfig.hasDefined(CONSTRAINT)) { ModelNode constraints = domainConfig.get(CONSTRAINT); if (constraints.hasDefined(APPLICATION_CLASSIFICATION)) { convertApplicationClassificationConstraints(constraints.get(APPLICATION_CLASSIFICATION), baseAddress, updates); } if (constraints.hasDefined(SENSITIVITY_CLASSIFICATION)) { convertSensitivityClassificationConstraints(constraints.get(SENSITIVITY_CLASSIFICATION), baseAddress, updates); } if (constraints.hasDefined(VAULT_EXPRESSION)) { ModelNode address = baseAddress.clone().add(CONSTRAINT, VAULT_EXPRESSION); ModelNode ve = constraints.get(VAULT_EXPRESSION); // No add for this one; need to write attributes for (AttributeDefinition ad : SensitivityResourceDefinition.getWritableVaultAttributeDefinitions()) { String attr = ad.getName(); if (ve.hasDefined(attr)) { updates.add(Util.getWriteAttributeOperation(address, attr, ve.get(attr))); } } } } } }
Example 12
Source File: InterfaceCriteriaWriteHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void execute(final OperationContext context, final ModelNode ignored) throws OperationFailedException { final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); final ModelNode model = resource.getModel(); for(final AttributeDefinition definition : InterfaceDefinition.ROOT_ATTRIBUTES) { final String attributeName = definition.getName(); final boolean has = model.hasDefined(attributeName); if(! has && isRequired(definition, model)) { throw ControllerLogger.ROOT_LOGGER.required(attributeName); } if(has) { // Just ignore 'false' if(definition.getType() == ModelType.BOOLEAN && ! model.get(attributeName).asBoolean()) { continue; } if(! isAllowed(definition, model)) { // TODO probably move this into AttributeDefinition String[] alts = definition.getAlternatives(); StringBuilder sb = null; if (alts != null) { for (String alt : alts) { if (model.hasDefined(alt)) { if (sb == null) { sb = new StringBuilder(); } else { sb.append(", "); } sb.append(alt); } } } throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalidAttributeCombo(attributeName, sb)); } } } context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); }
Example 13
Source File: FormatterOperationsTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@BeforeClass public static void setup() { for (AttributeDefinition attribute : StructuredFormatterResourceDefinition.KEY_OVERRIDES.getValueTypes()) { final String key = attribute.getName(); TEST_KEY_OVERRIDES.put(key, convertKey(key)); } EXPECTED_META_DATA.put("key1", "value1"); EXPECTED_META_DATA.put("key2", "value2"); EXPECTED_META_DATA.put("key3", null); }
Example 14
Source File: PathInfoHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public DiskUsagePathResourceDescriptionResolver(final String operationName, List<AttributeDefinition> replyParameters) { super(FILESYSTEM, ControllerResolver.RESOURCE_NAME, ResolvePathHandler.class.getClassLoader(), false, false); this.operationName = operationName; Set<String> set = new HashSet<>(); for (AttributeDefinition replyParameter : replyParameters) { String name = replyParameter.getName(); set.add(name); } replyParameterKeys = set; }
Example 15
Source File: ConcreteResourceRegistration.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void storeAttribute(AttributeDefinition definition, AttributeAccess aa) { String attributeName = definition.getName(); writeLock.lock(); try { if (attributes.containsKey(attributeName)) { throw alreadyRegistered("attribute", attributeName); } attributes.put(attributeName, aa); registerAttributeAccessConstraints(definition); } finally { writeLock.unlock(); } }
Example 16
Source File: ProxyControllerRegistration.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void registerReadWriteAttribute(final AttributeDefinition definition, final OperationStepHandler readHandler, final OperationStepHandler writeHandler) { final String attributeName = definition.getName(); AttributeAccess.Storage storage = definition.getImmutableFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME) ? AttributeAccess.Storage.RUNTIME : AttributeAccess.Storage.CONFIGURATION; AttributeAccess aa = new AttributeAccess(AttributeAccess.AccessType.READ_WRITE, storage, readHandler, writeHandler, definition); if (attributesUpdater.putIfAbsent(this, attributeName, aa) != null) { throw alreadyRegistered("attribute", attributeName); } }
Example 17
Source File: ProxyControllerRegistration.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void registerReadOnlyAttribute(final AttributeDefinition definition, final OperationStepHandler readHandler) { final String attributeName = definition.getName(); AttributeAccess.Storage storage = definition.getImmutableFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME) ? AttributeAccess.Storage.RUNTIME : AttributeAccess.Storage.CONFIGURATION; AttributeAccess aa = new AttributeAccess(AttributeAccess.AccessType.READ_ONLY, storage, readHandler, null, definition); if (attributesUpdater.putIfAbsent(this, attributeName, aa) != null) { throw alreadyRegistered("attribute", attributeName); } }
Example 18
Source File: AttributeTransformationDescriptionBuilderImpl.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
protected String getAttributeName(AttributeDefinition attr) { return attr.getName(); }