Search in sources :

Example 6 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class WebExtension method registerTransformers_2_x_0.

//todo, could probably be removed as 2_x was never in EAP 6.x
private void registerTransformers_2_x_0(SubsystemRegistration registration, int minor) {
    final ResourceTransformationDescriptionBuilder subsystemRoot = TransformationDescriptionBuilder.Factory.createSubsystemInstance();
    subsystemRoot.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, WebDefinition.DEFAULT_SESSION_TIMEOUT).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, true, new ModelNode(30)), WebDefinition.DEFAULT_SESSION_TIMEOUT).end();
    final ResourceTransformationDescriptionBuilder hostBuilder = subsystemRoot.addChildResource(HOST_PATH);
    final ResourceTransformationDescriptionBuilder ssoBuilder = hostBuilder.addChildResource(SSO_PATH);
    ssoBuilder.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, WebSSODefinition.HTTP_ONLY).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, true, new ModelNode(true)), WebSSODefinition.HTTP_ONLY).end();
    if (minor == 0) {
        final ResourceTransformationDescriptionBuilder connectorBuilder = subsystemRoot.addChildResource(CONNECTOR_PATH);
        connectorBuilder.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, WebConnectorDefinition.PROXY_BINDING, WebConnectorDefinition.REDIRECT_BINDING).setDiscard(DiscardAttributeChecker.UNDEFINED, WebSSLDefinition.SSL_PROTOCOL, WebConnectorDefinition.PROXY_BINDING, WebConnectorDefinition.REDIRECT_BINDING).end();
        connectorBuilder.addChildResource(SSL_PATH).getAttributeBuilder().addRejectCheck(RejectAttributeChecker.UNDEFINED, WebSSLDefinition.CIPHER_SUITE).end();
    }
    TransformationDescription.Tools.register(subsystemRoot.build(), registration, ModelVersion.create(2, minor, 0));
}
Also used : ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) ModelNode(org.jboss.dmr.ModelNode)

Example 7 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class WebExtension method registerTransformers_1_4_0.

private void registerTransformers_1_4_0(SubsystemRegistration registration) {
    final ResourceTransformationDescriptionBuilder subsystemRoot = TransformationDescriptionBuilder.Factory.createSubsystemInstance();
    subsystemRoot.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, WebDefinition.DEFAULT_SESSION_TIMEOUT).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, true, new ModelNode(30)), WebDefinition.DEFAULT_SESSION_TIMEOUT).end();
    final ResourceTransformationDescriptionBuilder hostBuilder = subsystemRoot.addChildResource(HOST_PATH);
    final ResourceTransformationDescriptionBuilder ssoBuilder = hostBuilder.addChildResource(SSO_PATH);
    ssoBuilder.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, WebSSODefinition.HTTP_ONLY).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, true, new ModelNode(true)), WebSSODefinition.HTTP_ONLY).end();
    TransformationDescription.Tools.register(subsystemRoot.build(), registration, ModelVersion.create(1, 4, 0));
}
Also used : ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) ModelNode(org.jboss.dmr.ModelNode)

Example 8 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class WebMigrateOperation method migrateVirtualHostChildren.

private void migrateVirtualHostChildren(Map<PathAddress, ModelNode> newAddOperations, Set<String> hosts) {
    final PathAddress customFilterAddresses = pathAddress(UndertowExtension.SUBSYSTEM_PATH, PATH_FILTERS, pathElement(CustomFilterDefinition.INSTANCE.getPathElement().getKey()));
    final PathAddress expressionFilterAddresses = pathAddress(UndertowExtension.SUBSYSTEM_PATH, PATH_FILTERS, pathElement(ExpressionFilterDefinition.INSTANCE.getPathElement().getKey()));
    List<PathAddress> filterAddresses = new ArrayList<>();
    for (PathAddress a : newAddOperations.keySet()) {
        if (wildcardEquals(customFilterAddresses, a) || wildcardEquals(expressionFilterAddresses, a)) {
            filterAddresses.add(a);
        }
    }
    boolean hasAccessLogValve = newAddOperations.containsKey(VALVE_ACCESS_LOG_ADDRESS);
    if (hasAccessLogValve || !filterAddresses.isEmpty()) {
        for (String host : hosts) {
            PathAddress hostAddress = pathAddress(UndertowExtension.SUBSYSTEM_PATH, DEFAULT_SERVER_PATH, pathElement(Constants.HOST, host));
            for (PathAddress filterAddress : filterAddresses) {
                PathAddress filterRefAddress = pathAddress(hostAddress, pathElement(Constants.FILTER_REF, filterAddress.getLastElement().getValue()));
                ModelNode filterRefAdd = createAddOperation(filterRefAddress);
                newAddOperations.put(filterRefAddress, filterRefAdd);
            }
            if (hasAccessLogValve) {
                PathAddress accessLogAddress = pathAddress(hostAddress, UndertowExtension.PATH_ACCESS_LOG);
                if (!newAddOperations.containsKey(accessLogAddress)) {
                    ModelNode operation = newAddOperations.get(VALVE_ACCESS_LOG_ADDRESS).clone();
                    operation.get(OP_ADDR).set(accessLogAddress.toModelNode());
                    newAddOperations.put(accessLogAddress, operation);
                }
            }
        }
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ArrayList(java.util.ArrayList) ModelNode(org.jboss.dmr.ModelNode)

Example 9 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class WebMigrateOperation method migrateAccessLogValve.

private void migrateAccessLogValve(Map<PathAddress, ModelNode> newAddOperations, ModelNode newAddOp, String valveName, List<String> warnings) {
    ModelNode add = createAddOperation(VALVE_ACCESS_LOG_ADDRESS);
    final ModelNode params = newAddOp.get(WebValveDefinition.PARAMS.getName());
    //TODO: parse the pattern and modify to Undertow version
    final ModelNode patternNode = params.get(Constants.PATTERN);
    if (patternNode.isDefined()) {
        add.get(Constants.PATTERN).set(migrateAccessLogPattern(patternNode.asString()));
    }
    add.get(Constants.PREFIX).set(params.get(Constants.PREFIX).clone());
    add.get(Constants.SUFFIX).set(params.get(Constants.SUFFIX).clone());
    add.get(Constants.ROTATE).set(params.get("rotatable").clone());
    add.get(Constants.EXTENDED).set(newAddOp.get(Constants.EXTENDED).clone());
    if (params.hasDefined(Constants.DIRECTORY)) {
        add.get(Constants.DIRECTORY).set(params.get(Constants.DIRECTORY).clone());
    }
    if (params.hasDefined("conditionIf")) {
        add.get(Constants.PREDICATE).set("exists(%{r," + params.get("conditionIf").asString() + "})");
    }
    if (params.hasDefined("conditionUnless")) {
        add.get(Constants.PREDICATE).set("not exists(%{r," + params.get("conditionUnless").asString() + "})");
    }
    if (params.hasDefined("condition")) {
        add.get(Constants.PREDICATE).set("not exists(%{r," + params.get("condition").asString() + "})");
    }
    final String[] unsupportedConfigParams = new String[] { "resolveHosts", "fileDateFormat", "renameOnRotate", "encoding", "locale", "requestAttributesEnabled", "buffered" };
    for (String unsupportedConfigParam : unsupportedConfigParams) {
        if (params.hasDefined(unsupportedConfigParam)) {
            warnings.add(WebLogger.ROOT_LOGGER.couldNotMigrateValveAttribute(unsupportedConfigParam, valveName));
        }
    }
    newAddOperations.put(VALVE_ACCESS_LOG_ADDRESS, add);
}
Also used : ModelNode(org.jboss.dmr.ModelNode)

Example 10 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class WebMigrateOperation method createExpressionFilter.

private void createExpressionFilter(Map<PathAddress, ModelNode> newAddOperations, String name, String expression) {
    newAddOperations.putIfAbsent(pathAddress(UndertowExtension.SUBSYSTEM_PATH, PATH_FILTERS), createAddOperation(pathAddress(UndertowExtension.SUBSYSTEM_PATH, PATH_FILTERS)));
    PathAddress filterAddress = pathAddress(UndertowExtension.SUBSYSTEM_PATH, PATH_FILTERS, pathElement(ExpressionFilterDefinition.INSTANCE.getPathElement().getKey(), name));
    ModelNode filterAdd = createAddOperation(filterAddress);
    filterAdd.get(ExpressionFilterDefinition.EXPRESSION.getName()).set(expression);
    newAddOperations.put(filterAddress, filterAdd);
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

ModelNode (org.jboss.dmr.ModelNode)1634 PathAddress (org.jboss.as.controller.PathAddress)351 Test (org.junit.Test)344 KernelServices (org.jboss.as.subsystem.test.KernelServices)102 Property (org.jboss.dmr.Property)92 OperationFailedException (org.jboss.as.controller.OperationFailedException)89 OperationContext (org.jboss.as.controller.OperationContext)68 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)68 ArrayList (java.util.ArrayList)58 Resource (org.jboss.as.controller.registry.Resource)54 PathElement (org.jboss.as.controller.PathElement)53 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)52 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)50 IOException (java.io.IOException)49 ServiceName (org.jboss.msc.service.ServiceName)49 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)47 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)44 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)42 OperationBuilder (org.jboss.as.controller.client.OperationBuilder)42 Map (java.util.Map)38