Java Code Examples for org.jboss.as.controller.PathAddress#getElement()

The following examples show how to use org.jboss.as.controller.PathAddress#getElement() . 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: ServerOperationResolver.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private Map<Set<ServerIdentity>, ModelNode> getServerProfileOperations(ModelNode operation, PathAddress address,
                                                                       ModelNode domain, ModelNode host) {
    if (address.size() == 1) {
        return Collections.emptyMap();
    }
    String profileName = address.getElement(0).getValue();
    PathElement subsystem = address.getElement(1);
    Set<String> relatedProfiles = getRelatedElements(PROFILE, profileName, subsystem.getKey(), subsystem.getValue(), domain);
    Set<ServerIdentity> allServers = new HashSet<ServerIdentity>();
    for (String profile : relatedProfiles) {
        allServers.addAll(getServersForType(PROFILE, profile, domain, host, localHostName, serverProxies));
    }
    ModelNode serverOp = operation.clone();
    PathAddress serverAddress = address.subAddress(1);
    serverOp.get(OP_ADDR).set(serverAddress.toModelNode());
    return Collections.singletonMap(allServers, serverOp);
}
 
Example 2
Source File: SimpleSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Tests that the xml is parsed into the correct operations
 */
@Test
public void testParseSubsystem() throws Exception {
    //Parse the subsystem xml into operations
    String subsystemXml =
            "<subsystem xmlns=\"" + SimpleSubsystemExtension.NAMESPACE + "\">" +
            "</subsystem>";
    List<ModelNode> operations = super.parse(subsystemXml);

    ///Check that we have the expected number of operations
    Assert.assertEquals(1, operations.size());

    //Check that each operation has the correct content
    ModelNode addSubsystem = operations.get(0);
    Assert.assertEquals(ADD, addSubsystem.get(OP).asString());
    PathAddress addr = PathAddress.pathAddress(addSubsystem.get(OP_ADDR));
    Assert.assertEquals(1, addr.size());
    PathElement element = addr.getElement(0);
    Assert.assertEquals(SUBSYSTEM, element.getKey());
    Assert.assertEquals(SimpleSubsystemExtension.SUBSYSTEM_NAME, element.getValue());
}
 
Example 3
Source File: CoreModelTestDelegate.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void harmonizeModel(ModelVersion modelVersion, ModelNode legacyModel, ModelNode transformed,
                                              PathAddress address, ModelHarmonizer harmonizer) {

    if (address.size() > 0) {
        PathElement pathElement = address.getElement(0);
        if (legacyModel.hasDefined(pathElement.getKey()) && transformed.hasDefined(pathElement.getKey())) {
            ModelNode legacyType = legacyModel.get(pathElement.getKey());
            ModelNode transformedType = transformed.get(pathElement.getKey());
            PathAddress childAddress = address.size() > 1 ? address.subAddress(1) : PathAddress.EMPTY_ADDRESS;
            if (pathElement.isWildcard()) {
                for (String key : legacyType.keys()) {
                    if (transformedType.has(key)) {
                        harmonizeModel(modelVersion, legacyType.get(key),
                                transformedType.get(key), childAddress, harmonizer);
                    }
                }
            } else {
                harmonizeModel(modelVersion, legacyType.get(pathElement.getValue()),
                        transformedType.get(pathElement.getValue()), address, harmonizer);
            }
        }
    } else {
        harmonizer.harmonizeModel(modelVersion, legacyModel, transformed);
    }
}
 
Example 4
Source File: JMXSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testParseEmptySubsystem() throws Exception {
    //Parse the subsystem xml into operations
    String subsystemXml =
            "<subsystem xmlns=\"" + Namespace.CURRENT.getUriString() + "\">" +
            "</subsystem>";
    List<ModelNode> operations = super.parse(subsystemXml);

    ///Check that we have the expected number of operations
    Assert.assertEquals(1, operations.size());

    //Check that each operation has the correct content
    ModelNode addSubsystem = operations.get(0);
    Assert.assertEquals(ADD, addSubsystem.get(OP).asString());
    PathAddress addr = PathAddress.pathAddress(addSubsystem.get(OP_ADDR));
    Assert.assertEquals(1, addr.size());
    PathElement element = addr.getElement(0);
    Assert.assertEquals(SUBSYSTEM, element.getKey());
    Assert.assertEquals(JMXExtension.SUBSYSTEM_NAME, element.getValue());
}
 
Example 5
Source File: ImmutableManagementResourceRegistration.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
default String getFeature() {
    if(PathAddress.EMPTY_ADDRESS.equals(getPathAddress())) {
        if(getProcessType().isServer()) {
            return "server-root";
        }
        return "";
    }
    StringJoiner joiner = new StringJoiner(".");
    final PathAddress pathAddress = getPathAddress();
    final String initialKey = pathAddress.getElement(0).getKey();
    if (getProcessType().isManagedDomain() && !HOST.equals(initialKey) && !PROFILE.equals(initialKey)) {
        joiner.add(DOMAIN);
    }
    for (int i = 0; i < pathAddress.size(); i++) {
        PathElement elt = pathAddress.getElement(i);
        joiner.add(elt.getKey());
        if (!elt.isWildcard() && (i > 0 || !HOST.equals(elt.getKey()))) {
            joiner.add(elt.getValue());
        }
    }
    return joiner.toString();
}
 
Example 6
Source File: HostInfo.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static Transformers.ResourceIgnoredTransformationRegistry createIgnoredRegistry(final ModelNode modelNode,
                                                                                        Set<String> domainIgnoredExtensions) {
    final Map<String, IgnoredType> ignoredResources = processIgnoredResource(modelNode, domainIgnoredExtensions);
    return new Transformers.ResourceIgnoredTransformationRegistry() {
        @Override
        public boolean isResourceTransformationIgnored(PathAddress address) {
            if (ignoredResources != null && address.size() > 0) {
                PathElement firstElement = address.getElement(0);
                IgnoredType ignoredType = ignoredResources.get(firstElement.getKey());
                if (ignoredType != null) {
                    if (ignoredType.hasName(firstElement.getValue())) {
                        return true;
                    }
                }
            }
            return false;
        }
    };
}
 
Example 7
Source File: HostInfo.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public boolean isOperationExcluded(PathAddress address, String operationName) {

    if (address.size() > 0) {
        final PathElement element = address.getElement(0);
        final String type = element.getKey();
        final String name = element.getValue();
        final boolean domainExcluding = ignoreUnaffectedConfig && !hostDeclaredIgnoreUnaffected && requiredConfigurationHolder != null;
        switch (type) {
            case ModelDescriptionConstants.EXTENSION:
                return domainIgnoredExtensions != null && domainIgnoredExtensions.contains(element.getValue());
            case PROFILE:
                return domainExcluding
                        && ((CLONE.equals(operationName) && address.size() == 1)
                               || !requiredConfigurationHolder.getProfiles().contains(name));
            case SERVER_GROUP:
                return domainExcluding && !requiredConfigurationHolder.getServerGroups().contains(name);
            case SOCKET_BINDING_GROUP:
                return domainExcluding
                        && ((CLONE.equals(operationName) && address.size() == 1)
                        || !requiredConfigurationHolder.getSocketBindings().contains(name));
        }
    }
    return false;
}
 
Example 8
Source File: CapabilityScope.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Create a {@code CapabilityScope} appropriate for the given process type and address
 *
 * @param processType the type of process in which the {@code CapabilityScope} exists
 * @param address the address with which the {@code CapabilityScope} is associated
 */
public static CapabilityScope create(ProcessType processType, PathAddress address) {
    CapabilityScope context = CapabilityScope.GLOBAL;
    PathElement pe = processType.isServer() || address.size() == 0 ? null : address.getElement(0);
    if (pe != null) {
        String type = pe.getKey();
        switch (type) {
            case PROFILE: {
                context = address.size() == 1 ? ProfilesCapabilityScope.INSTANCE : new ProfileChildCapabilityScope(pe.getValue());
                break;
            }
            case SOCKET_BINDING_GROUP: {
                context = address.size() == 1 ? SocketBindingGroupsCapabilityScope.INSTANCE : new SocketBindingGroupChildScope(pe.getValue());
                break;
            }
            case HOST: {
                if (address.size() >= 2) {
                    PathElement hostElement = address.getElement(1);
                    final String hostType = hostElement.getKey();
                    switch (hostType) {
                        case SUBSYSTEM:
                        case SOCKET_BINDING_GROUP:
                            context = HostCapabilityScope.INSTANCE;
                            break;
                        case SERVER_CONFIG:
                            context = ServerConfigCapabilityScope.INSTANCE;
                    }
                }
                break;
            }
            case SERVER_GROUP :  {
                context = ServerGroupsCapabilityScope.INSTANCE;
                break;
            }
        }
    }
    return context;

}
 
Example 9
Source File: SubsystemTestDelegate.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public ManagementResourceRegistration getSubModel(PathAddress address) {
    if (address.size() == 0) {
        return MOCK_RESOURCE_REG;
    } else if (address.size() == 1) {
        PathElement pe = address.getElement(0);
        String key = pe.getKey();
        if (pe.isWildcard()
                && (ModelDescriptionConstants.PROFILE.equals(key) || ModelDescriptionConstants.DEPLOYMENT.equals(key))) {
            return MOCK_RESOURCE_REG;
        }
    }
    return null;
}
 
Example 10
Source File: ExtraSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Tests that the xml is parsed into the correct operations
 */
@Test
public void testParseSubsystem() throws Exception {
    //Parse the subsystem xml into operations
    String subsystemXml =
            "<subsystem xmlns=\"" + DependencySubsystemExtension.NAMESPACE + "\">" +
            "</subsystem>" +
            "<subsystem xmlns=\"" + MainSubsystemExtension.NAMESPACE + "\">" +
            "</subsystem>";
    List<ModelNode> operations = super.parse(new DependencyAdditionalInitialization(), subsystemXml);

    ///Check that we have the expected number of operations
    Assert.assertEquals(2, operations.size());

    //Check that each operation has the correct content
    ModelNode addSubsystem = operations.get(0);
    Assert.assertEquals(ADD, addSubsystem.get(OP).asString());
    PathAddress addr = PathAddress.pathAddress(addSubsystem.get(OP_ADDR));
    Assert.assertEquals(1, addr.size());
    PathElement element = addr.getElement(0);
    Assert.assertEquals(SUBSYSTEM, element.getKey());
    Assert.assertEquals(DependencySubsystemExtension.SUBSYSTEM_NAME, element.getValue());

    addSubsystem = operations.get(1);
    Assert.assertEquals(ADD, addSubsystem.get(OP).asString());
    addr = PathAddress.pathAddress(addSubsystem.get(OP_ADDR));
    Assert.assertEquals(1, addr.size());
    element = addr.getElement(0);
    Assert.assertEquals(SUBSYSTEM, element.getKey());
    Assert.assertEquals(MainSubsystemExtension.SUBSYSTEM_NAME, element.getValue());
}
 
Example 11
Source File: DMRLocationResolver.java    From hawkular-agent with Apache License 2.0 5 votes vote down vote up
private static boolean matches(int length, PathAddress pattern, PathAddress address) {
    for (int i = 0; i < length; i++) {
        PathElement otherElem = address.getElement(i);
        Property prop = new Property(otherElem.getKey(), new ModelNode(otherElem.getValue()));
        if (!pattern.getElement(i).matches(prop)) {
            return false;
        }
    }
    return true;
}
 
Example 12
Source File: LoggingResource.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Resource navigate(final PathAddress address) {
    if (address.size() > 0 && LogFileResourceDefinition.NAME.equals(address.getElement(0).getKey())) {
        if (address.size() > 1) {
            throw new NoSuchResourceException(address.getElement(1));
        }
        return PlaceholderResource.INSTANCE;
    }
    return delegate.navigate(address);
}
 
Example 13
Source File: JMXSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void assertJmxSubsystemAddress(ModelNode address) {
    PathAddress addr = PathAddress.pathAddress(address);
    Assert.assertEquals(1, addr.size());
    PathElement element = addr.getElement(0);
    Assert.assertEquals(SUBSYSTEM, element.getKey());
    Assert.assertEquals(JMXExtension.SUBSYSTEM_NAME, element.getValue());
}
 
Example 14
Source File: ElementProviderAttributeReadHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected String getPatchStreamName(OperationContext context) {
    final PathAddress currentAddress = context.getCurrentAddress();
    final PathElement stream = currentAddress.getElement(currentAddress.size() - 2);
    final String streamName;
    if(Constants.PATCH_STREAM.equals(stream.getKey())) {
        streamName = stream.getValue();
    } else {
        streamName = null;
    }
    return streamName;

}
 
Example 15
Source File: SubsystemTestDelegate.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void removeIgnoredChildren(final Collection<PathAddress> ignoredChildAddresses, final Collection<PathAddress> addresses) {
    // Remove all known ignored children
    addresses.removeAll(ignoredChildAddresses);
    // Checked for wildcards removals
    for (PathAddress ignoredChildAddress : ignoredChildAddresses) {
        final PathElement lastIgnoredElement = ignoredChildAddress.getLastElement();
        if (lastIgnoredElement.isWildcard()) {
            // Check each address
            for (final Iterator<PathAddress> iterator = addresses.iterator(); iterator.hasNext(); ) {
                final PathAddress childAddress = iterator.next();
                if (childAddress.size() == ignoredChildAddress.size()) {
                    // Check the last element key for a match
                    if (lastIgnoredElement.getKey().equals(childAddress.getLastElement().getKey())) {
                        boolean match = true;
                        // Check for matches on previous elements
                        for (int i = 0; i < ignoredChildAddress.size() - 1; i++) {
                            final PathElement e1 = ignoredChildAddress.getElement(i);
                            final PathElement e2 = childAddress.getElement(i);
                            if (!e1.equals(e2)) {
                                match = false;
                                break;
                            }
                        }
                        if (match) {
                            iterator.remove();
                        }
                    }
                }
            }
        }
    }
}
 
Example 16
Source File: DMRLocationResolver.java    From hawkular-agent with Apache License 2.0 5 votes vote down vote up
@Override
public String findWildcardMatch(DMRNodeLocation multiTargetLocation, DMRNodeLocation singleLocation)
        throws ProtocolException {

    if (multiTargetLocation == null) {
        throw new ProtocolException("multiTargetLocation is null");
    }

    PathAddress multiTargetPaths = multiTargetLocation.getPathAddress();
    for (int i = 0; i < multiTargetPaths.size(); i++) {
        PathElement multiTargetPathElement = multiTargetPaths.getElement(i);
        if (multiTargetPathElement.isWildcard()) {
            PathElement singleLocationPathElement;
            try {
                singleLocationPathElement = singleLocation.getPathAddress().getElement(i);
            } catch (Exception e) {
                throw new ProtocolException(String.format("[%s] doesn't have the same path size as [%s]",
                        singleLocation, multiTargetLocation));
            }

            // DMR wildcards are only in values ("/name=*" not "/*=value")
            if (singleLocationPathElement.getKey().equals(multiTargetPathElement.getKey())) {
                return singleLocationPathElement.getValue();
            } else {
                throw new ProtocolException(String.format("[%s] doesn't match the multi-target key in [%s]",
                        singleLocation, multiTargetLocation));
            }
        }
    }

    // nothing matched - single location must not have resulted from a query using the given multi-target location
    throw new ProtocolException(String.format("[%s] doesn't match the wildcard from [%s]", singleLocation,
            multiTargetLocation));
}
 
Example 17
Source File: ReadMasterDomainModelUtil.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
     * Create the ResourceIgnoredTransformationRegistry for connection/reconnection process.
     *
     * @param hostInfo the host info
     * @param rc       the resolution context
     * @return
     */
    public static Transformers.ResourceIgnoredTransformationRegistry createHostIgnoredRegistry(final HostInfo hostInfo, final RequiredConfigurationHolder rc) {
        return new Transformers.ResourceIgnoredTransformationRegistry() {
            @Override
            public boolean isResourceTransformationIgnored(PathAddress address) {
                if (hostInfo.isResourceTransformationIgnored(address)) {
                    return true;
                }
                if (address.size() == 1 && hostInfo.isIgnoreUnaffectedConfig()) {
                    final PathElement element = address.getElement(0);
                    final String type = element.getKey();
                    switch (type) {
                        case ModelDescriptionConstants.EXTENSION:
                            // Don't ignore extensions for now
                            return false;
//                            if (local) {
//                                return false; // Always include all local extensions
//                            } else if (!rc.getExtensions().contains(element.getValue())) {
//                                return true;
//                            }
//                            break;
                        case PROFILE:
                            if (!rc.getProfiles().contains(element.getValue())) {
                                return true;
                            }
                            break;
                        case SERVER_GROUP:
                            if (!rc.getServerGroups().contains(element.getValue())) {
                                return true;
                            }
                            break;
                        case SOCKET_BINDING_GROUP:
                            if (!rc.getSocketBindings().contains(element.getValue())) {
                                return true;
                            }
                            break;
                    }
                }
                return false;
            }
        };
    }
 
Example 18
Source File: HostControllerExecutionSupport.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Create a HostControllerExecutionSupport for a given operation.
 *
 *
 * @param context
 * @param operation the operation
 * @param hostName the name of the host executing the operation
 * @param domainModelProvider source for the domain model
 * @param ignoredDomainResourceRegistry registry of resource addresses that should be ignored
 * @throws OperationFailedException
 *
 * @return the HostControllerExecutionSupport
 */
public static HostControllerExecutionSupport create(OperationContext context, final ModelNode operation,
                                                    final String hostName,
                                                    final DomainModelProvider domainModelProvider,
                                                    final IgnoredDomainResourceRegistry ignoredDomainResourceRegistry,
                                                    final boolean isRemoteDomainControllerIgnoreUnaffectedConfiguration,
                                                    final ExtensionRegistry extensionRegistry) throws OperationFailedException {
    String targetHost = null;
    PathElement runningServerTarget = null;
    ModelNode runningServerOp = null;

    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    if (address.size() > 0) {
        PathElement first = address.getElement(0);
        if (HOST.equals(first.getKey()) && !first.isMultiTarget()) {
            targetHost = first.getValue();
            if (address.size() > 1 && RUNNING_SERVER.equals(address.getElement(1).getKey())) {
                runningServerTarget = address.getElement(1);
                ModelNode relativeAddress = new ModelNode().setEmptyList();
                for (int i = 2; i < address.size(); i++) {
                    PathElement element = address.getElement(i);
                    relativeAddress.add(element.getKey(), element.getValue());
                }
                runningServerOp = operation.clone();
                runningServerOp.get(OP_ADDR).set(relativeAddress);
            }
        }
    }

    HostControllerExecutionSupport result;


    if (targetHost != null && !hostName.equals(targetHost)) {
        // HostControllerExecutionSupport representing another host
        result = new IgnoredOpExecutionSupport(ignoredDomainResourceRegistry);
    }
    else if (runningServerTarget != null) {
        // HostControllerExecutionSupport representing a server op
        final Resource domainModel = domainModelProvider.getDomainModel();
        final Resource hostModel = domainModel.getChild(PathElement.pathElement(HOST, targetHost));
        if (runningServerTarget.isMultiTarget()) {
            return new DomainOpExecutionSupport(ignoredDomainResourceRegistry, operation, PathAddress.EMPTY_ADDRESS);
        } else {
            final String serverName = runningServerTarget.getValue();
            // TODO prevent NPE
            final String serverGroup = hostModel.getChild(PathElement.pathElement(SERVER_CONFIG, serverName)).getModel().require(GROUP).asString();
            final ServerIdentity serverIdentity = new ServerIdentity(targetHost, serverGroup, serverName);
            result = new DirectServerOpExecutionSupport(ignoredDomainResourceRegistry, serverIdentity, runningServerOp);
        }
    }
    else if (COMPOSITE.equals(operation.require(OP).asString())) {
        // Recurse into the steps to see what's required
        if (operation.hasDefined(STEPS)) {
            List<HostControllerExecutionSupport> parsedSteps = new ArrayList<HostControllerExecutionSupport>();
            for (ModelNode step : operation.get(STEPS).asList()) {
                // Propagate the caller-type=user header
                if (operation.hasDefined(OPERATION_HEADERS, CALLER_TYPE) && operation.get(OPERATION_HEADERS, CALLER_TYPE).asString().equals(USER)) {
                    step = step.clone();
                    step.get(OPERATION_HEADERS, CALLER_TYPE).set(USER);
                }
                parsedSteps.add(create(context, step, hostName, domainModelProvider, ignoredDomainResourceRegistry, isRemoteDomainControllerIgnoreUnaffectedConfiguration, extensionRegistry));
            }
            result = new MultiStepOpExecutionSupport(ignoredDomainResourceRegistry, parsedSteps);
        }
        else {
            // Will fail later
            result = new DomainOpExecutionSupport(ignoredDomainResourceRegistry, operation, address);
        }
    }
    else if (targetHost == null && isResourceExcluded(context, ignoredDomainResourceRegistry, isRemoteDomainControllerIgnoreUnaffectedConfiguration, domainModelProvider, hostName, address, extensionRegistry, operation)) {
        result = new IgnoredOpExecutionSupport(ignoredDomainResourceRegistry);
    }
    else {
        result = new DomainOpExecutionSupport(ignoredDomainResourceRegistry, operation, address);
    }

    return result;

}
 
Example 19
Source File: SyncServerStateOperationHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
void checkContent(ModelNode operation, PathAddress operationAddress) {
    if (!operation.get(OP).asString().equals(ADD) || operationAddress.size() == 0) {
        return;
    }
    final PathElement firstElement = operationAddress.getElement(0);
    final String contentType = firstElement.getKey();
    if (contentType == null) {
        return;
    }
    if (operationAddress.size() == 1) {
        switch (contentType) {
            case DEPLOYMENT:
                final String deployment = firstElement.getValue();
                Set<ContentReference> hashes = deploymentHashes.get(deployment);
                if (hashes == null) {
                    hashes = new HashSet<>();
                    deploymentHashes.put(deployment, hashes);
                    for (ModelNode contentItem : operation.get(CONTENT).asList()) {
                        hashes.add(ModelContentReference.fromModelAddress(operationAddress, contentItem.get(HASH).asBytes()));
                        if (parameters.getHostControllerEnvironment().isBackupDomainFiles()) {
                            relevantDeployments.add(firstElement.getValue());
                        }
                    }
                }
                makeExistingDeploymentUpdatedAffected(firstElement, operation);
                break;
            case DEPLOYMENT_OVERLAY:
                break;
            case MANAGEMENT_CLIENT_CONTENT:
                if (firstElement.getValue().equals(ROLLOUT_PLANS)) {
                    updateRolloutPlans = true;
                    //This needs special handling. Drop the existing resource and add a new one
                    if (operation.hasDefined(HASH)) {
                        rolloutPlansHash = operation.get(HASH).asBytes();
                        requiredContent.add(ModelContentReference.fromModelAddress(operationAddress, rolloutPlansHash));
                    }
                }
                break;
            default:
                return;
        }
    } else if (operationAddress.size() == 2) {
        if( firstElement.getKey().equals(SERVER_GROUP) &&
            serversByGroup.containsKey(firstElement.getValue())) {
            PathElement secondElement = operationAddress.getElement(1);
            if (secondElement.getKey().equals(DEPLOYMENT)) {
                relevantDeployments.add(secondElement.getValue());
                affectedGroups.add(firstElement.getValue());
            }
        } else if (firstElement.getKey().equals(DEPLOYMENT_OVERLAY)) {
            requiredContent.add(ModelContentReference.fromModelAddress(operationAddress, operation.get(CONTENT).asBytes()));
        }
    }
    return;
}
 
Example 20
Source File: ReadMasterDomainModelUtil.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
     * Create the ResourceIgnoredTransformationRegistry when fetching missing content, only including relevant pieces
     * to a server-config.
     *
     * @param rc       the resolution context
     * @param delegate the delegate ignored resource transformation registry for manually ignored resources
     * @return
     */
    public static Transformers.ResourceIgnoredTransformationRegistry createServerIgnoredRegistry(final RequiredConfigurationHolder rc, final Transformers.ResourceIgnoredTransformationRegistry delegate) {
        return new Transformers.ResourceIgnoredTransformationRegistry() {
            @Override
            public boolean isResourceTransformationIgnored(PathAddress address) {
                final int length = address.size();
                if (length == 0) {
                    return false;
                } else if (length >= 1) {
                    if (delegate.isResourceTransformationIgnored(address)) {
                        return true;
                    }

                    final PathElement element = address.getElement(0);
                    final String type = element.getKey();
                    switch (type) {
                        case ModelDescriptionConstants.EXTENSION:
                            // Don't ignore extensions for now
                            return false;
//                            if (local) {
//                                return false; // Always include all local extensions
//                            } else if (rc.getExtensions().contains(element.getValue())) {
//                                return false;
//                            }
//                            break;
                        case ModelDescriptionConstants.PROFILE:
                            if (rc.getProfiles().contains(element.getValue())) {
                                return false;
                            }
                            break;
                        case ModelDescriptionConstants.SERVER_GROUP:
                            if (rc.getServerGroups().contains(element.getValue())) {
                                return false;
                            }
                            break;
                        case ModelDescriptionConstants.SOCKET_BINDING_GROUP:
                            if (rc.getSocketBindings().contains(element.getValue())) {
                                return false;
                            }
                            break;
                    }
                }
                return true;
            }
        };
    }