org.jboss.as.controller.registry.Resource Java Examples

The following examples show how to use org.jboss.as.controller.registry.Resource. 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: AbstractAddStepHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Record any new {@link org.jboss.as.controller.capability.RuntimeCapability capabilities} that are available as
 * a result of this operation, as well as any requirements for other capabilities that now exist. This method is
 * invoked during {@link org.jboss.as.controller.OperationContext.Stage#MODEL}.
 * <p>
 * Any changes made by this method will automatically be discarded if the operation rolls back.
 * </p>
 * <p>
 * This default implementation registers any capabilities provided to the constructor and asks any
 * {@code AttributeDefinition} provided to the constructor to
 * {@link AttributeDefinition#addCapabilityRequirements(OperationContext, Resource, ModelNode) add capability requirements}.
 * </p>
 *
 * @param context the context. Will not be {@code null}
 * @param operation the operation that is executing Will not be {@code null}
 * @param resource the resource that has been added. Will reflect any updates made by
 * {@link #populateModel(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource)}. Will
 *                 not be {@code null}
 */
protected void recordCapabilitiesAndRequirements(final OperationContext context, final ModelNode operation, Resource resource) throws OperationFailedException {
    Set<RuntimeCapability> capabilitySet = capabilities.isEmpty() ? context.getResourceRegistration().getCapabilities() : capabilities;

    for (RuntimeCapability capability : capabilitySet) {
        if (capability.isDynamicallyNamed()) {
            context.registerCapability(capability.fromBaseCapability(context.getCurrentAddress()));
        } else {
            context.registerCapability(capability);
        }
    }

    ModelNode model = resource.getModel();
    for (AttributeDefinition ad : attributes) {
        if (model.hasDefined(ad.getName()) || ad.hasCapabilityRequirements()) {
            ad.addCapabilityRequirements(context, resource, model.get(ad.getName()));
        }
    }
    ImmutableManagementResourceRegistration mrr = context.getResourceRegistration();
    assert mrr.getRequirements() != null;
    for (CapabilityReferenceRecorder recorder : mrr.getRequirements()) {
        recorder.addCapabilityRequirements(context, resource, null);
    }
}
 
Example #2
Source File: RbacSanityCheckOperation.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
boolean doRoleMappingsExist() throws OperationFailedException {
    Resource authorizationResource = managementResource.getChild(PathElement.pathElement(ACCESS, AUTHORIZATION));
    Set<String> roleNames = authorizationResource.getChildrenNames(ROLE_MAPPING);
    for (String current : roleNames) {
        Resource roleResource = authorizationResource.getChild(PathElement.pathElement(ROLE_MAPPING, current));
        ModelNode roleModel = roleResource.getModel();
        if (roleModel.get(INCLUDE_ALL).isDefined() && roleModel.require(INCLUDE_ALL).asBoolean()) {
            return true;
        }

        if (roleResource.getChildren(INCLUDE).size() > 0) {
            return true;
        }
    }

    return false;
}
 
Example #3
Source File: AttributesTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testSimpleAccept() throws Exception {
    //Set up the model
    resourceModel.get("reject").set(true);

    final ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createInstance(PATH);
    builder.getAttributeBuilder().addRejectCheck(new RejectAttributeChecker.SimpleAcceptAttributeChecker(ModelNode.FALSE), "reject").end();
    TransformationDescription.Tools.register(builder.build(), transformersSubRegistration);

    final Resource resource = transformResource();
    Assert.assertNotNull(resource);
    final Resource toto = resource.getChild(PATH);
    Assert.assertNotNull(toto);
    final ModelNode model = toto.getModel();
    //The rejection does not trigger for resource transformation
    Assert.assertTrue(model.hasDefined("reject"));

    ModelNode add = Util.createAddOperation(PathAddress.pathAddress(PATH));
    add.get("reject").set(true);
    OperationTransformer.TransformedOperation transformedAdd = transformOperation(add);
    Assert.assertTrue(transformedAdd.rejectOperation(success()));

    ModelNode write = Util.getWriteAttributeOperation(PathAddress.pathAddress(PATH), "reject", ModelNode.TRUE);
    OperationTransformer.TransformedOperation transformedWrite = transformOperation(write);
    Assert.assertTrue(transformedWrite.rejectOperation(success()));
}
 
Example #4
Source File: SubsystemAdd.java    From gmlc with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void performBoottime(OperationContext context, ModelNode operation, ModelNode model,
                            ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers)
    throws OperationFailedException {

  ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));

  GmlcService service = GmlcService.INSTANCE;
  service.setModel(fullModel);

  ServiceName name = GmlcService.getServiceName();
  ServiceController<GmlcService> controller = context.getServiceTarget()
      .addService(name, service)
      .addDependency(PathManagerService.SERVICE_NAME, PathManager.class, service.getPathManagerInjector())
      .addDependency(MBeanServerService.SERVICE_NAME, MBeanServer.class, service.getMbeanServer())
      .addDependency(SS7ExtensionService.getServiceName(), SS7ServiceInterface.class, service.getSS7Service())
      .addListener(verificationHandler)
      .setInitialMode(ServiceController.Mode.ACTIVE)
      .install();
  newControllers.add(controller);

}
 
Example #5
Source File: RoleMappingAdd.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    Resource resource = context.createResource(PathAddress.EMPTY_ADDRESS);
    PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    final String roleName = address.getLastElement().getValue();

    if (authorizerConfiguration.getStandardRoles().contains(roleName) == false) {
        if (domainMode) {
            ScopedRoleRequiredHandler.addOperation(context, roleName);
        } else {
            // Standalone mode so no scoped roles so if it is not a standard role it is invalid.
            throw DomainManagementLogger.ROOT_LOGGER.invalidRoleName(roleName);
        }
    }

    ModelNode model = resource.getModel();
    RoleMappingResourceDefinition.INCLUDE_ALL.validateAndSet(operation, model);

    registerRuntimeAdd(context, roleName.toUpperCase(Locale.ENGLISH));
}
 
Example #6
Source File: IgnoredNonAffectedServerGroupsUtil.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private boolean ignoreResourceInternal(final Resource domainResource, final Collection<ServerConfigInfo> serverConfigs, final PathAddress pathAddress) {
        String type = pathAddress.getElement(0).getKey();
        switch (type) {
        case PROFILE:
            return ignoreProfile(domainResource, serverConfigs, pathAddress.getElement(0).getValue());
        case SERVER_GROUP:
            return ignoreServerGroup(domainResource, serverConfigs, pathAddress.getElement(0).getValue());
        // We don't automatically ignore extensions for now
//        case EXTENSION:
//            return ignoreExtension(domainResource, serverConfigs, pathAddress.getElement(0).getValue());
        case SOCKET_BINDING_GROUP:
            return ignoreSocketBindingGroups(domainResource, serverConfigs, pathAddress.getElement(0).getValue());
        default:
            return false;
        }
    }
 
Example #7
Source File: RemoveNotEsistingResourceTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected void initModel(ManagementModel managementModel, Resource modelControllerResource) {
    ManagementResourceRegistration rootRegistration = managementModel.getRootResourceRegistration();
    GlobalOperationHandlers.registerGlobalOperations(rootRegistration, processType);

    GlobalNotifications.registerGlobalNotifications(rootRegistration, processType);

    SimpleResourceDefinition subsystemResource = new SimpleResourceDefinition(
            PathElement.pathElement(EXTENSION),
            new NonResolvingResourceDescriptionResolver(),
            new FakeExtensionAddHandler(rootRegistration, getMutableRootResourceRegistrationProvider()),
            ReloadRequiredRemoveStepHandler.INSTANCE
    ){
        @Override
        public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
            super.registerAttributes(resourceRegistration);
            resourceRegistration.registerReadOnlyAttribute(MODULE, null);
        }
    };
    rootRegistration.registerSubModel(subsystemResource);

}
 
Example #8
Source File: DeploymentOverlayContentDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    Resource resource = context.getOriginalRootResource();
    for (final PathElement element : address) {
        resource = resource.getChild(element);
    }
    byte[] contentHash = resource.getModel().get(CONTENT).asBytes();
    try {
        TypedInputStream inputStream = contentRepository.readContent(contentHash, "");
        String uuid = context.attachResultStream(inputStream.getContentType(), inputStream);
        context.getResult().get(UUID).set(uuid);
    } catch (ExplodedContentException ex) {
        throw new RuntimeException(ex.getMessage(), ex);
    }
}
 
Example #9
Source File: OrderedChildMoreLevelsResourceSyncModelTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testAddedOrderedChildrenModelSync() throws Exception {
    //Adds a child to the end
    ModelNode originalModel = readResourceRecursive();

    Resource rootResource = createMasterDcResources();
    createAndRegisterSubsystemChildFromRoot(rootResource, ORDERED_CHILD.getKey(), "pear");
    Resource orangeResource = findSubsystemResource(rootResource)
            .requireChild(PathElement.pathElement(ORDERED_CHILD.getKey(), "orange"));
    createChildResource(orangeResource, EXTRA_CHILD.getKey(), "pancake", -1);
    ModelNode master = Resource.Tools.readModel(rootResource);

    executeTriggerSyncOperation(rootResource);
    ModelNode currentModel = readResourceRecursive();

    Assert.assertNotEquals(originalModel, currentModel);
    compare(findSubsystemResource(currentModel).get(ORDERED_CHILD.getKey()).keys(), "apple", "orange", "pear");
    compare(findSubsystemResource(
            currentModel).get(ORDERED_CHILD.getKey(), "orange", EXTRA_CHILD.getKey()).keys(), "jam", "juice", "pancake");
    compareSubsystemModels(master, currentModel);
}
 
Example #10
Source File: ReloadRequiredServerTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private Resource getServerResolutionResource() {

        final Resource result = Resource.Factory.create();
        final Resource host =  Resource.Factory.create();
        result.registerChild(PathElement.pathElement(HOST, "localhost"), host);
        final Resource serverOne = Resource.Factory.create();
        serverOne.getModel().get(GROUP).set("group-one");
        serverOne.getModel().get(SOCKET_BINDING_GROUP).set("group-one");
        host.registerChild(PathElement.pathElement(SERVER_CONFIG, "server-one"), serverOne);
        final Resource serverTwo = Resource.Factory.create();
        serverTwo.getModel().get(GROUP).set("nope");
        host.registerChild(PathElement.pathElement(SERVER_CONFIG, "server-two"), serverTwo);
        final Resource serverThree = Resource.Factory.create();
        serverThree.getModel().get(GROUP).set("nope");
        host.registerChild(PathElement.pathElement(SERVER_CONFIG, "server-three"), serverThree);

        return result;
    }
 
Example #11
Source File: DeploymentResourceSupport.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Checks to see if a resource has already been registered for the specified address on the subsystem.
 *
 * @param subsystemName the name of the subsystem
 * @param address       the address to check
 *
 * @return {@code true} if the address exists on the subsystem otherwise {@code false}
 */
public boolean hasDeploymentSubModel(final String subsystemName, final PathAddress address) {
    final Resource root = deploymentUnit.getAttachment(DEPLOYMENT_RESOURCE);
    final PathElement subsystem = PathElement.pathElement(SUBSYSTEM, subsystemName);
    boolean found = false;
    if (root.hasChild(subsystem)) {
        if (address == PathAddress.EMPTY_ADDRESS) {
            return true;
        }
        Resource parent = root.getChild(subsystem);
        for (PathElement child : address) {
            if (parent.hasChild(child)) {
                found = true;
                parent = parent.getChild(child);
            } else {
                found = false;
                break;
            }
        }
    }
    return found;
}
 
Example #12
Source File: VersionModelInitializer.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void registerRootResource(Resource rootResource, ProductConfig cfg) {
    ModelNode model = rootResource.getModel();
    model.get(ModelDescriptionConstants.MANAGEMENT_MAJOR_VERSION).set(Version.MANAGEMENT_MAJOR_VERSION);
    model.get(ModelDescriptionConstants.MANAGEMENT_MINOR_VERSION).set(Version.MANAGEMENT_MINOR_VERSION);
    model.get(ModelDescriptionConstants.MANAGEMENT_MICRO_VERSION).set(Version.MANAGEMENT_MICRO_VERSION);

    model.get(ModelDescriptionConstants.RELEASE_VERSION).set(Version.AS_VERSION);
    model.get(ModelDescriptionConstants.RELEASE_CODENAME).set(Version.AS_RELEASE_CODENAME);

    if (cfg != null) {
        if (cfg.getProductVersion() != null) {
            model.get(ModelDescriptionConstants.PRODUCT_VERSION).set(cfg.getProductVersion());
        }
        if (cfg.getProductName() != null) {
            model.get(ModelDescriptionConstants.PRODUCT_NAME).set(cfg.getProductName());
        }
    }
}
 
Example #13
Source File: AbstractOrderedChildResourceSyncModelTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {

    final ModelNode syncOperation = new ModelNode();
    syncOperation.get(OP).set("calculate-diff-and-sync");
    syncOperation.get(OP_ADDR).setEmptyList();
    syncOperation.get(DOMAIN_MODEL).set(operation.get(DOMAIN_MODEL));

    Resource original = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS);

    final TestRepository repo = new TestRepository();
    final HostControllerRegistrationHandler.OperationExecutor internalExecutor = getControllerService().getInternalExecutor();
    SyncModelParameters parameters =
            new SyncModelParameters(new MockDomainController(), ignoredDomainResourceRegistry,
                    hostControllerEnvironment, extensionRegistry, internalExecutor, true,
                    Collections.<String, ProxyController>emptyMap(), repo, repo);
    final SyncServerGroupOperationHandler handler =
            new SyncServerGroupOperationHandler("slave", original, parameters);
    context.addStep(syncOperation, handler, OperationContext.Stage.MODEL, true);
}
 
Example #14
Source File: SecurityRealmChildRemoveHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void updateModel(OperationContext context, ModelNode operation) throws OperationFailedException {
    // verify that the resource exist before removing it
    context.readResource(PathAddress.EMPTY_ADDRESS, false);
    Resource resource = context.removeResource(PathAddress.EMPTY_ADDRESS);
    recordCapabilitiesAndRequirements(context, operation, resource);

    if (validateAuthentication && !context.isBooting()) {
        ModelNode validationOp = AuthenticationValidatingHandler.createOperation(operation);
        context.addStep(validationOp, AuthenticationValidatingHandler.INSTANCE, OperationContext.Stage.MODEL);
    } // else we know the SecurityRealmAddHandler is part of this overall set of ops and it added AuthenticationValidatingHandler
}
 
Example #15
Source File: AliasTransformerTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Before
public void setUp() {
    // Cleanup
    resourceRoot = Resource.Factory.create();
    registry = TransformerRegistry.Factory.create();
    resourceRegistration = ManagementResourceRegistration.Factory.forProcessType(ProcessType.EMBEDDED_SERVER).createRegistration(ROOT);
    ManagementResourceRegistration ss = resourceRegistration.registerSubModel(new AbstractChildResourceDefinition(PATH));
    ManagementResourceRegistration target = ss.registerSubModel(new AbstractChildResourceDefinition(CHILD));
    ss.registerAlias(CHILD_ALIAS, new AliasEntry(target) {
        @Override
        public PathAddress convertToTargetAddress(PathAddress aliasAddress, AliasContext aliasContext) {
            Resource resource = aliasContext.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, true);
            Assert.assertNotNull(resource.navigate(PathAddress.pathAddress(PATH).append(CHILD.getKey(), "one")));
            try {
                resource.navigate(PathAddress.pathAddress(PATH).append(CHILD_ALIAS.getKey(), "one"));
                Assert.fail("Should not have found alias child in the model");
            } catch (Exception expected) {
                                }
            return PathAddress.pathAddress(PATH).append(CHILD.getKey(), aliasAddress.getLastElement().getValue());
        }
    });
    // test
    final Resource toto = Resource.Factory.create();
    resourceRoot.registerChild(PATH, toto);
    //resourceModel = toto.getModel();

    final Resource childOne = Resource.Factory.create();
    toto.registerChild(PathElement.pathElement(CHILD.getKey(), "one"), childOne);
    toto.getModel().setEmptyObject();

    // Register the description
    transformersSubRegistration = registry.getServerRegistration(ModelVersion.create(1));

    final ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createInstance(PATH);
    builder.addChildRedirection(CHILD, LEGACY_CHILD);
    TransformationDescription.Tools.register(builder.build(), transformersSubRegistration);
}
 
Example #16
Source File: ReadFeatureDescriptionHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private String getExtension(OperationContext context, String subsystem) {
    for (String extensionName : context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).getChildrenNames(EXTENSION)) {
        Resource extension = context.readResourceFromRoot(PathAddress.pathAddress(EXTENSION, extensionName), false);
        if (extension.getChildrenNames(SUBSYSTEM).contains(subsystem)) {
            return extensionName;
        }
    }
    return null;
}
 
Example #17
Source File: FindNonProgressingOpUnitTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testMultipleDelayedServers() {
    // WFCORE-263 case
    Resource res = assemble(getSlaveResource(), getDelayedServerResource(), getDelayedServerResource());
    try {
        findNonProgressingOp(res, false, 50);
        fail("multiple servers should fail");
    } catch (OperationFailedException good) {
        OperationFailedException expected = DomainManagementLogger.ROOT_LOGGER.domainRolloutNotProgressing("0", 50, "uuid", Arrays.asList("1", "2"));
        assertTrue(good.getLocalizedMessage().contains(expected.getLocalizedMessage()));
    }
}
 
Example #18
Source File: ObjectMapAttributeDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void addCapabilityRequirements(OperationContext context, Resource resource, ModelNode attributeValue) {
    if (attributeValue.isDefined()) {
        valueType.addCapabilityRequirements(context, resource, attributeValue);

    }
}
 
Example #19
Source File: SyslogAuditLogHandlerResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static SyslogAuditLogHandler createHandler(final PathManagerService pathManager,
                                           final OperationContext context,
                                           final EnvironmentNameReader environmentReader) throws OperationFailedException {
    final PathAddress pathAddress = getAffectedHandlerAddress(context);
    final String name = Util.getNameFromAddress(pathAddress);
    final Resource handlerResource = context.readResourceFromRoot(pathAddress);
    return createHandler(pathManager, context, name, handlerResource, environmentReader);
}
 
Example #20
Source File: RbacSanityCheckOperation.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private ModelNode getAccessAuthorization() {
    if (accessAuthorization == null) {
        PathElement pathElement = PathElement.pathElement(ACCESS, AUTHORIZATION);
        if (managementResource.hasChild(pathElement)) {
            Resource authorizationResource = managementResource.getChild(pathElement);
            if (authorizationResource.isModelDefined()) {
                accessAuthorization = authorizationResource.getModel();
            }
        }
    }

    return accessAuthorization;
}
 
Example #21
Source File: OperationContextImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Resource createResourceInternal(PathAddress relativeAddress, int index) throws UnsupportedOperationException {
    ImmutableManagementResourceRegistration current = getResourceRegistration();
    ImmutableManagementResourceRegistration mrr = relativeAddress == PathAddress.EMPTY_ADDRESS ? current : current.getSubModel(relativeAddress);
    final Resource toAdd = Resource.Factory.create(mrr.isRuntimeOnly());
    addResourceInternal(relativeAddress, index, toAdd);
    return toAdd;
}
 
Example #22
Source File: DomainIncludesValidationWriteAttributeHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void finishModelStage(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue,
                                ModelNode oldValue, Resource model) throws OperationFailedException {
    super.finishModelStage(context, operation, attributeName, newValue, oldValue, model);
    if (newValue.equals(oldValue)) {
        //Set an attachment to avoid propagation to the servers, we don't want them to go into restart-required if nothing changed
        ServerOperationResolver.addToDontPropagateToServersAttachment(context, operation);
    }

    DomainModelIncludesValidator.addValidationStep(context, operation);
}
 
Example #23
Source File: ModelControllerImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Resource requireChild(PathElement element) {
    final Resource resource = getChild(element);
    if(resource == null) {
        throw new NoSuchResourceException(element);
    }
    return resource;
}
 
Example #24
Source File: SyncModelServerStateTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void registerRootDeploymentOverlay(Resource root, String name, String path, byte[] bytes) {
    Resource overlay = Resource.Factory.create();
    root.registerChild(PathElement.pathElement(DEPLOYMENT_OVERLAY, name), overlay);
    Resource content = Resource.Factory.create();
    content.getModel().get(CONTENT).set(bytes);
    overlay.registerChild(PathElement.pathElement(CONTENT, path), content);
}
 
Example #25
Source File: LocalOutboundConnectionWriteHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Boolean handback) throws OperationFailedException {
    if (handback != null && !handback.booleanValue()) {
        final ModelNode restored = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
        restored.get(attributeName).set(valueToRestore);
        applyModelToRuntime(context, operation);
    } // else we didn't update the runtime in applyUpdateToRuntime
}
 
Example #26
Source File: JmxAuditLogHandlerReferenceResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private boolean lookForResource(final Resource root, final PathAddress pathAddress) {
    Resource current = root;
    for (PathElement element : pathAddress) {
        current = current.getChild(element);
        if (current == null) {
            return false;
        }
    }
    return true;
}
 
Example #27
Source File: JmxAuditLogHandlerReferenceResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private boolean lookForHandlerForHc(OperationContext context, String name) {
    final Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS);
    for (ResourceEntry entry : root.getChildren(ModelDescriptionConstants.HOST)) {
        if (entry.getModel().isDefined()) {
            return lookForHandler(PathAddress.pathAddress(ModelDescriptionConstants.HOST, entry.getName()), root, name);
        }
    }
    return false;
}
 
Example #28
Source File: ReadResourceDescriptionAccessControlTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void registerAttributeVaultSensitivityResource() {
    ChildResourceDefinition oneChild = new ChildResourceDefinition(ONE);
    oneChild.addAttribute(ATTR_NONE);
    oneChild.addAttribute(ATTR_VAULT);
    rootRegistration.registerSubModel(oneChild);
    Resource resourceA = Resource.Factory.create();
    ModelNode modelA = resourceA.getModel();
    modelA.get(ATTR_NONE).set("hello");
    modelA.get(ATTR_VAULT).set("${VAULT::AA::bb::cc}");
    rootResource.registerChild(ONE_A, resourceA);
    rootResource.registerChild(ONE_B, Resource.Factory.create());
}
 
Example #29
Source File: ResourceTransformationContextImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private ResourceTransformationContextImpl(Resource root, PathAddress address, PathAddress read,
                                          final OriginalModel originalModel,
                                          TransformerOperationAttachment transformerOperationAttachment,
                                          final Transformers.ResourceIgnoredTransformationRegistry ignoredTransformationRegistry) {
    this.root = root;
    this.current = address;
    this.read = read;
    this.originalModel = originalModel;
    this.logger = TransformersLogger.getLogger(originalModel.target);
    this.transformerOperationAttachment = transformerOperationAttachment;
    this.ignoredTransformationRegistry = ignoredTransformationRegistry;
}
 
Example #30
Source File: SyslogAuditLogProtocolResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    PathAddress handlerAddress = SyslogAuditLogHandlerResourceDefinition.getAffectedHandlerAddress(context);
    try {
        Resource handleResource = context.readResourceFromRoot(handlerAddress);
        String name = Util.getNameFromAddress(handlerAddress);
        auditLogger.getUpdater().updateHandler(SyslogAuditLogHandlerResourceDefinition.createHandler(pathManager, context, name, handleResource, environmentReader));
    } catch (Resource.NoSuchResourceException ignored) {
        // WFCORE-810 handler resource has been removed in this same op, so we do nothing
    }
}