Search in sources :

Example 1 with AlternativeAttributeValidationStepHandler

use of org.wildfly.extension.picketlink.common.model.validator.AlternativeAttributeValidationStepHandler in project wildfly by wildfly.

the class AbstractFederationResourceDefinition method createAttributeWriterHandler.

@Override
protected OperationStepHandler createAttributeWriterHandler() {
    List<SimpleAttributeDefinition> attributes = getAttributes();
    final List<AttributeDefinition> alternativeAttributes = getAlternativesAttributes();
    return new ReloadRequiredWriteAttributeHandler(attributes.toArray(new AttributeDefinition[attributes.size()])) {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            if (!alternativeAttributes.isEmpty()) {
                context.addStep(new AlternativeAttributeValidationStepHandler(alternativeAttributes.toArray(new AttributeDefinition[alternativeAttributes.size()])), OperationContext.Stage.MODEL);
            }
            doRegisterModelWriteAttributeHandler(context, operation);
            super.execute(context, operation);
        }
    };
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler) AlternativeAttributeValidationStepHandler(org.wildfly.extension.picketlink.common.model.validator.AlternativeAttributeValidationStepHandler)

Example 2 with AlternativeAttributeValidationStepHandler

use of org.wildfly.extension.picketlink.common.model.validator.AlternativeAttributeValidationStepHandler in project wildfly by wildfly.

the class AbstractIDMResourceDefinition method createAttributeWriterHandler.

@Override
protected OperationStepHandler createAttributeWriterHandler() {
    List<SimpleAttributeDefinition> attributes = getAttributes();
    final List<AttributeDefinition> alternativeAttributes = getAlternativesAttributes();
    return new IDMConfigWriteAttributeHandler(attributes.toArray(new AttributeDefinition[attributes.size()])) {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            if (!alternativeAttributes.isEmpty()) {
                context.addStep(new AlternativeAttributeValidationStepHandler(alternativeAttributes.toArray(new AttributeDefinition[alternativeAttributes.size()])), OperationContext.Stage.MODEL);
            }
            doRegisterModelWriteAttributeHandler(context, operation);
            super.execute(context, operation);
        }
    };
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode) AlternativeAttributeValidationStepHandler(org.wildfly.extension.picketlink.common.model.validator.AlternativeAttributeValidationStepHandler)

Example 3 with AlternativeAttributeValidationStepHandler

use of org.wildfly.extension.picketlink.common.model.validator.AlternativeAttributeValidationStepHandler in project wildfly by wildfly.

the class IDMConfigAddStepHandler method configureModelValidators.

private void configureModelValidators(ModelValidationStepHandler[] modelValidators) {
    List<AttributeDefinition> alternativeAttributes = new ArrayList<AttributeDefinition>();
    for (AttributeDefinition attribute : this.attributes) {
        if (attribute.getAlternatives() != null && attribute.getAlternatives().length > 0) {
            alternativeAttributes.add(attribute);
        }
    }
    if (!alternativeAttributes.isEmpty()) {
        this.modelValidators.add(new AlternativeAttributeValidationStepHandler(alternativeAttributes.toArray(new AttributeDefinition[alternativeAttributes.size()]), isAlternativesRequired()));
    }
    if (modelValidators != null) {
        this.modelValidators.addAll(Arrays.asList(modelValidators));
    }
    this.modelValidators.add(new ModelValidationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            final PathAddress address = getParentAddress(PathAddress.pathAddress(operation.require(OP_ADDR)));
            Resource resource = context.readResourceFromRoot(address);
            final ModelNode parentModel = Resource.Tools.readModel(resource);
            PartitionManagerAddHandler.INSTANCE.validateModel(context, address.getLastElement().getValue(), parentModel);
            context.stepCompleted();
        }
    });
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) PathAddress(org.jboss.as.controller.PathAddress) ArrayList(java.util.ArrayList) OperationFailedException(org.jboss.as.controller.OperationFailedException) Resource(org.jboss.as.controller.registry.Resource) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelValidationStepHandler(org.wildfly.extension.picketlink.common.model.validator.ModelValidationStepHandler) ModelNode(org.jboss.dmr.ModelNode) AlternativeAttributeValidationStepHandler(org.wildfly.extension.picketlink.common.model.validator.AlternativeAttributeValidationStepHandler)

Aggregations

AttributeDefinition (org.jboss.as.controller.AttributeDefinition)3 OperationContext (org.jboss.as.controller.OperationContext)3 ModelNode (org.jboss.dmr.ModelNode)3 AlternativeAttributeValidationStepHandler (org.wildfly.extension.picketlink.common.model.validator.AlternativeAttributeValidationStepHandler)3 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)2 ArrayList (java.util.ArrayList)1 OperationFailedException (org.jboss.as.controller.OperationFailedException)1 PathAddress (org.jboss.as.controller.PathAddress)1 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)1 Resource (org.jboss.as.controller.registry.Resource)1 ModelValidationStepHandler (org.wildfly.extension.picketlink.common.model.validator.ModelValidationStepHandler)1