@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { Resource existing = context.readResource(PathAddress.EMPTY_ADDRESS); OperationStepHandler addHandler = context.getResourceRegistration().getSubModel(PathAddress.EMPTY_ADDRESS.append(newKeyName)).getOperationHandler(PathAddress.EMPTY_ADDRESS, "add"); ModelNode value = operation.get(VALUE); if (value.isDefined()) { List<ModelNode> modules = new ArrayList<ModelNode>(value.asList()); Collections.reverse(modules); //need to reverse it to make sure they are added in proper order for (ModelNode module : modules) { ModelNode addModuleOp = module.clone(); String code = addModuleOp.get(Constants.CODE).asString(); PathElement relativePath = PathElement.pathElement(newKeyName, code); PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)).append(relativePath); addModuleOp.get(OP_ADDR).set(address.toModelNode()); addModuleOp.get(OP).set(ADD); context.addStep(new ModelNode(), addModuleOp, addHandler, OperationContext.Stage.MODEL, true); } } //remove on the end to make sure it is executed first for (Resource.ResourceEntry entry : existing.getChildren(newKeyName)) { PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)).append(entry.getPathElement()); ModelNode removeModuleOp = Util.createRemoveOperation(address); context.addStep(new ModelNode(), removeModuleOp, new SecurityDomainReloadRemoveHandler(), OperationContext.Stage.MODEL, true); } } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { Resource existing = context.readResource(PathAddress.EMPTY_ADDRESS); OperationStepHandler addHandler = context.getResourceRegistration().getSubModel(PathAddress.EMPTY_ADDRESS.append(newKeyName)).getOperationHandler(PathAddress.EMPTY_ADDRESS, "add"); oldAttribute.validateOperation(operation); List<ModelNode> modules = new ArrayList<ModelNode>(operation.get(oldAttribute.getName()).asList()); Collections.reverse(modules); //need to reverse it to make sure they are added in proper order for (ModelNode module : modules) { ModelNode addModuleOp = module.clone(); String code = addModuleOp.get(Constants.CODE).asString(); PathElement relativePath = PathElement.pathElement(newKeyName, code); PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)).append(relativePath); addModuleOp.get(OP_ADDR).set(address.toModelNode()); addModuleOp.get(OP).set(ADD); context.addStep(new ModelNode(), addModuleOp, addHandler, OperationContext.Stage.MODEL, true); } //remove on the end to make sure it is executed first for (Resource.ResourceEntry entry : existing.getChildren(newKeyName)) { PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)).append(entry.getPathElement()); ModelNode removeModuleOp = Util.createRemoveOperation(address); context.addStep(new ModelNode(), removeModuleOp, new SecurityDomainReloadRemoveHandler(), OperationContext.Stage.MODEL, true); } } }
@Override protected void describe(OrderedChildTypesAttachment orderedChildTypesAttachment, Resource resource, ModelNode addressModel, ModelNode result, ImmutableManagementResourceRegistration registration) { if (resource == null || registration.isRemote() || registration.isRuntimeOnly() || resource.isProxy() || resource.isRuntime() || registration.isAlias()) return; result.add(createAddOperation(orderedChildTypesAttachment, addressModel, resource, registration.getChildAddresses(PathAddress.EMPTY_ADDRESS))); PathAddress address = PathAddress.pathAddress(addressModel); for (String type : resource.getChildTypes()) { for (Resource.ResourceEntry entry : resource.getChildren(type)) { PathElement path = entry.getPathElement(); ImmutableManagementResourceRegistration childRegistration = Optional.ofNullable(registration.getSubModel(PathAddress.pathAddress(path))).orElse(registration.getSubModel(PathAddress.pathAddress(PathElement.pathElement(path.getKey())))); PathAddress childAddress = address.append(path); this.describe(orderedChildTypesAttachment, entry, childAddress.toModelNode(), result, childRegistration); } } }
@Override public ImmutableManagementResourceRegistration getSubModel(PathAddress address) { ImmutableManagementResourceRegistration sub = delegate.getSubModel(address); return sub == null ? null : new DelegatingImmutableManagementResourceRegistration(sub); }
@Override public ImmutableManagementResourceRegistration getResourceRegistration() { ImmutableManagementResourceRegistration parent = primaryContext.getResourceRegistration(); return parent.getSubModel(activeStep.address); }
@Override public ImmutableManagementResourceRegistration getResourceRegistration() { ImmutableManagementResourceRegistration parent = primaryContext.getResourceRegistration(); return parent.getSubModel(activeStep.address); }
@Override public ImmutableManagementResourceRegistration getSubModel(PathAddress address) { ImmutableManagementResourceRegistration sub = delegate.getSubModel(address); return sub == null ? null : new DelegatingImmutableManagementResourceRegistration(sub); }
@Override public ImmutableManagementResourceRegistration getSubModel(PathAddress address) { ImmutableManagementResourceRegistration sub = delegate.getSubModel(address); return sub == null ? null : new DelegatingImmutableManagementResourceRegistration(sub); }
private ImmutableManagementResourceRegistration getResourceRegistrationCheckForAlias(OperationContext context, PathAddress opAddr, ReadResourceDescriptionAccessControlContext accessControlContext) { //The direct root registration is only needed if we are doing access-control=true final ImmutableManagementResourceRegistration root = context.getRootResourceRegistration(); final ImmutableManagementResourceRegistration registry = root.getSubModel(opAddr); AliasEntry aliasEntry = registry.getAliasEntry(); if (aliasEntry == null) { return registry; } //Get hold of the real registry if it was an alias return root.getSubModel(aliasEntry.convertToTargetAddress(opAddr)); }
public static ModelNode readFullModelDescription(PathAddress address, ImmutableManagementResourceRegistration reg) { ModelNode node = new ModelNode(); node.get(ModelDescriptionConstants.MODEL_DESCRIPTION).set(reg.getModelDescription(PathAddress.EMPTY_ADDRESS).getModelDescription(Locale.getDefault())); node.get(ModelDescriptionConstants.ADDRESS).set(address.toModelNode()); for (PathElement pe : reg.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { ModelNode children = node.get(ModelDescriptionConstants.CHILDREN); ImmutableManagementResourceRegistration sub = reg.getSubModel(PathAddress.pathAddress(pe)); children.add(readFullModelDescription(address.append(pe), sub)); } return node; }
static Map<PathElement, ChildAddOperationEntry> findAddChildOperations(ImmutableManagementResourceRegistration resourceRegistration){ Map<PathElement, ChildAddOperationEntry> operations = new HashMap<PathElement, ChildAddOperationEntry>(); for(PathElement childElement : resourceRegistration.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { final ImmutableManagementResourceRegistration childReg = resourceRegistration.getSubModel(PathAddress.pathAddress(childElement)); final Map<String, OperationEntry> registeredOps = childReg.getOperationDescriptions(PathAddress.EMPTY_ADDRESS, false); final OperationEntry childAdd = registeredOps.get(ADD); if (childAdd != null) { operations.put(childElement, new ChildAddOperationEntry(childAdd, childElement)); } } return operations; }
private static Set<String> getNonIgnoredChildTypes(ImmutableManagementResourceRegistration mrr) { Set<String> result = new HashSet<>(); for (PathElement pe : mrr.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { ImmutableManagementResourceRegistration childMrr = mrr.getSubModel(PathAddress.pathAddress(pe)); if (childMrr != null && !childMrr.isRemote() && !childMrr.isRuntimeOnly()) { result.add(pe.getKey()); } } return result; }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { String path = PATH.resolveModelAttribute(context, operation).asString(); PathAddress profileAddress = PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.PROFILE)); ImmutableManagementResourceRegistration profileRegistration = context.getResourceRegistration().getSubModel(profileAddress); dumpManagementResourceRegistration(profileRegistration, extensionRegistry, path); }
@Override protected void executeSingleTargetChild(PathAddress base, PathElement currentElement, PathAddress newRemaining, OperationContext context, boolean ignoreMissing) { final PathAddress next = base.append(currentElement); final ImmutableManagementResourceRegistration nr = context.getResourceRegistration().getSubModel(next); if (nr != null) { execute(next, newRemaining, context, nr, ignoreMissing); } else { throw new NoSuchResourceTypeException(next); } }
@Override protected void executeSingleTargetChild(PathAddress base, PathElement currentElement, PathAddress newRemaining, OperationContext context, boolean ignoreMissing) { final PathAddress next = base.append(currentElement); final ImmutableManagementResourceRegistration nr = context.getResourceRegistration().getSubModel(next); if (nr != null) { execute(next, newRemaining, context, nr, ignoreMissing); } else { throw new NoSuchResourceTypeException(next); } }
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; }
private void addAllAddresses(ImmutableManagementResourceRegistration mrr, PathAddress current, Resource resource, Set<PathAddress> addresses) { addresses.add(current); for (String name : getNonIgnoredChildTypes(mrr)) { for (ResourceEntry entry : resource.getChildren(name)) { if (!entry.isProxy() && !entry.isRuntime()) { addAllAddresses(mrr.getSubModel(PathAddress.pathAddress(entry.getPathElement())), current.append(entry.getPathElement()), entry, addresses); } } } }
private void addAllAddresses(ImmutableManagementResourceRegistration mrr, PathAddress current, Resource resource, Set<PathAddress> addresses) { addresses.add(current); for (String name : getNonIgnoredChildTypes(mrr)) { for (ResourceEntry entry : resource.getChildren(name)) { if (!entry.isProxy() && !entry.isRuntime()) { addAllAddresses(mrr.getSubModel(PathAddress.pathAddress(entry.getPathElement())), current.append(entry.getPathElement()), entry, addresses); } } } }
static ResourceTransformationContext create(final OperationContext context, final TransformationTarget target, final PathAddress current, final PathAddress read, boolean skipRuntimeIgnoreCheck) { final Resource root = Resource.Factory.create(); final Resource original = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, true); final ImmutableManagementResourceRegistration registration = context.getRootResourceRegistration().getSubModel(PathAddress.EMPTY_ADDRESS); final ExpressionResolver expressionResolver = TransformerExpressionResolver.create(context, target.getTargetType()); final OriginalModel originalModel = new OriginalModel(original, context.getRunningMode(), context.getProcessType(), target, registration, expressionResolver); return new ResourceTransformationContextImpl(root, current, read, originalModel, skipRuntimeIgnoreCheck); }
static ResourceTransformationContext create(final OperationContext context, final TransformationTarget target, final PathAddress current, final PathAddress read) { final Resource root = Resource.Factory.create(); final Resource original = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, true); final ImmutableManagementResourceRegistration registration = context.getRootResourceRegistration().getSubModel(PathAddress.EMPTY_ADDRESS); final ExpressionResolver expressionResolver = TransformerExpressionResolver.create(context, target.getTargetType()); final OriginalModel originalModel = new OriginalModel(original, context.getRunningMode(), context.getProcessType(), target, registration, expressionResolver); return new ResourceTransformationContextImpl(root, current, read, originalModel); }