Java Code Examples for org.jboss.dmr.ModelNode#setEmptyObject()
The following examples show how to use
org.jboss.dmr.ModelNode#setEmptyObject() .
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: XmlToJson.java From revapi with Apache License 2.0 | 6 votes |
private ModelNode convertObject(Xml configuration, ModelNode jsonSchema, ModelNode rootSchema) { ModelNode object = new ModelNode(); object.setEmptyObject(); ModelNode propertySchemas = jsonSchema.get("properties"); ModelNode additionalPropSchemas = jsonSchema.get("additionalProperties"); for (Xml childConfig : getChildren.apply(configuration)) { String name = getName.apply(childConfig); ModelNode childSchema = propertySchemas.get(name); if (!childSchema.isDefined()) { if (additionalPropSchemas.getType() == ModelType.BOOLEAN) { throw new IllegalArgumentException("Cannot determine the format for the '" + name + "' XML tag during the XML-to-JSON conversion."); } childSchema = additionalPropSchemas; } if (!childSchema.isDefined()) { throw new IllegalArgumentException("Could not determine the format for the '" + name + "' XML tag during the XML-to-JSON conversion."); } ModelNode jsonChild = convert(childConfig, childSchema, rootSchema); object.get(name).set(jsonChild); } return object; }
Example 2
Source File: IgnoredNonAffectedServerGroupsUtil.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public static void addServerGroupsToModel(Resource hostModel, ModelNode model) { ModelNode initialServerGroups = new ModelNode(); initialServerGroups.setEmptyObject(); for (ResourceEntry entry : hostModel.getChildren(SERVER_CONFIG)) { ModelNode serverNode = new ModelNode(); serverNode.get(GROUP).set(entry.getModel().get(GROUP)); if (entry.getModel().hasDefined(SOCKET_BINDING_GROUP)) { serverNode.get(SOCKET_BINDING_GROUP).set(entry.getModel().get(SOCKET_BINDING_GROUP).asString()); } initialServerGroups.get(entry.getName()).set(serverNode); } model.get(ModelDescriptionConstants.INITIAL_SERVER_GROUPS).set(initialServerGroups); }
Example 3
Source File: FileSystemDeploymentServiceUnitTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ModelNode getDeploymentNamesResponse() { ModelNode content = new ModelNode(); content.get(OUTCOME).set(SUCCESS); ModelNode result = content.get(RESULT); result.setEmptyObject(); for (String deployment : added.keySet()) { result.get(deployment, ENABLED).set(deployed.containsKey(deployment)); if (externallyDeployed.containsKey(deployment)) { ExternalDeployment externalDeployment = externallyDeployed.get(deployment); if (externalDeployment != null) { // Report what a different owner (e.g. different scanner) would configure result.get(deployment, PERSISTENT).set(externalDeployment.persistent); ModelNode ownerNode = result.get(deployment, OWNER); if (externalDeployment.ownerAddress != null) { ownerNode.set(externalDeployment.ownerAddress.toModelNode()); } // else leave undefined } else { // Report what a non-scanner deployment would configure result.get(deployment, PERSISTENT).set(true); result.get(deployment, OWNER).set(new ModelNode()); } } else { // Report what our scanner would configure result.get(deployment, PERSISTENT).set(false); result.get(deployment, OWNER).set(resourceAddress.toModelNode()); } } return content; }
Example 4
Source File: ShutdownFileSystemDeploymentServiceUnitTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ModelNode getDeploymentNamesResponse() { ModelNode content = new ModelNode(); content.get(OUTCOME).set(SUCCESS); ModelNode result = content.get(RESULT); result.setEmptyObject(); for (String deployment : added.keySet()) { result.get(deployment, ENABLED).set(deployed.containsKey(deployment)); result.get(deployment, PERSISTENT).set(externallyDeployed.contains(deployment)); } return content; }
Example 5
Source File: TransformationUtils.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private static Resource modelToResource(final PathAddress startAddress, final ImmutableManagementResourceRegistration reg, final ModelNode model, boolean includeUndefined, PathAddress fullPath) { Resource res = Resource.Factory.create(); ModelNode value = new ModelNode(); Set<String> allFields = new HashSet<String>(model.keys()); for (String name : reg.getAttributeNames(PathAddress.EMPTY_ADDRESS)) { AttributeAccess aa = reg.getAttributeAccess(PathAddress.EMPTY_ADDRESS, name); if (aa.getStorageType() == AttributeAccess.Storage.RUNTIME){ allFields.remove(name); continue; } if (includeUndefined) { value.get(name).set(model.get(name)); } else { if (model.hasDefined(name)) { value.get(name).set(model.get(name)); } } allFields.remove(name); } if (!value.isDefined() && model.isDefined() && reg.getChildAddresses(PathAddress.EMPTY_ADDRESS).size() == 0) { value.setEmptyObject(); } res.writeModel(value); for (String childType : reg.getChildNames(PathAddress.EMPTY_ADDRESS)) { if (model.hasDefined(childType)) { for (Property property : model.get(childType).asPropertyList()) { PathElement childPath = PathElement.pathElement(childType, property.getName()); ImmutableManagementResourceRegistration subRegistration = reg.getSubModel(PathAddress.pathAddress(childPath)); Resource child = modelToResource(startAddress, subRegistration, property.getValue(), includeUndefined, fullPath.append(childPath)); res.registerChild(childPath, child); } } allFields.remove(childType); } if (!allFields.isEmpty()){ throw ControllerLogger.ROOT_LOGGER.modelFieldsNotKnown(allFields, startAddress.append(fullPath)); } return res; }
Example 6
Source File: SubsystemAdd.java From gmlc with GNU Affero General Public License v3.0 | 4 votes |
/** * {@inheritDoc} */ @Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { log.info("Populating the model"); model.setEmptyObject(); }
Example 7
Source File: SimpleSubsystemAdd.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** {@inheritDoc} */ @Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { model.setEmptyObject(); }
Example 8
Source File: SubsystemAddBlank.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** {@inheritDoc} */ @Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { model.setEmptyObject(); }
Example 9
Source File: SubsystemAddWithSocketBindingUserService.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** {@inheritDoc} */ @Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { model.setEmptyObject(); }
Example 10
Source File: KeycloakSubsystemAdd.java From keycloak with Apache License 2.0 | 4 votes |
@Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { model.setEmptyObject(); }
Example 11
Source File: SubsystemAddWithPathUserService.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** {@inheritDoc} */ @Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { model.setEmptyObject(); }
Example 12
Source File: DependencySubsystemAdd.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** {@inheritDoc} */ @Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { model.setEmptyObject(); }
Example 13
Source File: MainSubsystemAdd.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** {@inheritDoc} */ @Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { model.setEmptyObject(); }
Example 14
Source File: CamelSubsystemAdd.java From wildfly-camel with Apache License 2.0 | 4 votes |
@Override protected void populateModel(ModelNode operation, ModelNode model) { model.setEmptyObject(); }
Example 15
Source File: ModelHarmonizer.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void harmonizeModel(ModelVersion modelVersion, ModelNode source, ModelNode target) { if (source.getType() == ModelType.OBJECT && source.asInt() == 0 && !target.isDefined()) { target.setEmptyObject(); } }
Example 16
Source File: NativeRemotingManagementAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override protected void populateModel(ModelNode operation, ModelNode model) { model.setEmptyObject(); }
Example 17
Source File: ReadResourceDescriptionHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { ModelNode result = new ModelNode(); boolean customDefaultCheck = operation.get(OP).asString().equals(GlobalOperationHandlers.CHECK_DEFAULT_RESOURCE_ACCESS); ResourceAuthorization authResp = context.authorizeResource(true, customDefaultCheck); if (authResp == null || authResp.getResourceResult(ActionEffect.ADDRESS).getDecision() == Decision.DENY) { if (!defaultSetting || authResp == null) { //We are not allowed to see the resource, so we don't set the accessControlResult, meaning that the ReadResourceAssemblyHandler will ignore it for this address } else { result.get(ActionEffect.ADDRESS.toString()).set(false); } } else { // if (!defaultSetting) { // result.get(ADDRESS).set(operation.get(OP_ADDR)); // } addResourceAuthorizationResults(result, authResp); ModelNode attributes = new ModelNode(); attributes.setEmptyObject(); if (result.get(READ).asBoolean()) { if (nodeDescription.hasDefined(ATTRIBUTES)) { for (Property attrProp : nodeDescription.require(ATTRIBUTES).asPropertyList()) { ModelNode attributeResult = new ModelNode(); Storage storage = Storage.valueOf(attrProp.getValue().get(STORAGE).asString().toUpperCase(Locale.ENGLISH)); addAttributeAuthorizationResults(attributeResult, attrProp.getName(), authResp, storage == Storage.RUNTIME); if (attributeResult.isDefined()) { attributes.get(attrProp.getName()).set(attributeResult); } } } result.get(ATTRIBUTES).set(attributes); if (operations != null) { ModelNode ops = new ModelNode(); ops.setEmptyObject(); PathAddress currentAddress = context.getCurrentAddress(); for (Map.Entry<String, ModelNode> entry : operations.entrySet()) { ModelNode operationToCheck = Util.createOperation(entry.getKey(), currentAddress); ModelNode operationResult = new ModelNode(); addOperationAuthorizationResult(context, operationResult, operationToCheck, entry.getKey()); ops.get(entry.getKey()).set(operationResult); } result.get(ModelDescriptionConstants.OPERATIONS).set(ops); } } } accessControlResult.set(result); }
Example 18
Source File: MapOperations.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
void updateModel(final OperationContext context, ModelNode model, AttributeDefinition attributeDefinition, ModelNode attribute) throws OperationFailedException { attribute.setEmptyObject(); }
Example 19
Source File: ServerOperationsResolverHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { if (multiPhaseLocalContext.getLocalResponse().has(FAILURE_DESCRIPTION)) { // We do not allow failures on the host controllers in a 2-phase op context.setRollbackOnly(); } else { // Temporary hack to prevent CompositeOperationHandler throwing away domain failure data context.attachIfAbsent(CompositeOperationHandler.DOMAIN_EXECUTION_KEY, Boolean.TRUE); // Figure out what server ops are needed to correspond to the domain op we have boolean nullDomainOp = hostControllerExecutionSupport.getDomainOperation() == null; // Transformed operations might need to simulate certain behavior, so allow read-only operations to be pushed as well final boolean pushToServers= operation.hasDefined(OPERATION_HEADERS) && operation.get(OPERATION_HEADERS, DOMAIN_PUSH_TO_SERVERS).asBoolean(false); HostControllerExecutionSupport.ServerOperationProvider provider = nullDomainOp ? NO_OP_PROVIDER : new HostControllerExecutionSupport.ServerOperationProvider() { @Override public Map<Set<ServerIdentity>, ModelNode> getServerOperations(ModelNode domainOp, PathAddress address) { Map<Set<ServerIdentity>, ModelNode> ops = ServerOperationsResolverHandler.this.getServerOperations(context, domainOp, address, pushToServers); for (Map.Entry<Set<ServerIdentity>, ModelNode> entry : ops.entrySet()) { ModelNode op = entry.getValue(); //Remove the caller-type=user header if (op.hasDefined(OPERATION_HEADERS, CALLER_TYPE) && op.get(OPERATION_HEADERS, CALLER_TYPE).asString().equals(USER)) { op.get(OPERATION_HEADERS).remove(CALLER_TYPE); } } HOST_CONTROLLER_LOGGER.tracef("Server ops for %s -- %s", domainOp, ops); return ops; } }; Map<ServerIdentity, ModelNode> serverOps = hostControllerExecutionSupport.getServerOps(provider); // Format that data and provide it to the coordinator ModelNode formattedServerOps = getFormattedServerOps(serverOps); if (! serverOps.isEmpty()) { final Set<String> serversStarting = new HashSet<>(); for (Map.Entry<ServerIdentity, ModelNode> serverIdentityModelNodeEntry : serverOps.entrySet()) { String serverName = serverIdentityModelNodeEntry.getKey().getServerName(); ServerStatus serverStatus = serverInventory.determineServerStatus(serverName); if (serverStatus == ServerStatus.STARTING) { serversStarting.add(serverName); } } if (! serversStarting.isEmpty()) { throw HOST_CONTROLLER_LOGGER.serverManagementUnavailableDuringBoot(serversStarting.toString()); } } if (multiPhaseLocalContext.isCoordinator()) { // We're the coordinator, so just stash the server ops in the multiphase context // for use in the rollout plan multiPhaseLocalContext.getLocalServerOps().set(formattedServerOps); if (HOST_CONTROLLER_LOGGER.isTraceEnabled()) { HOST_CONTROLLER_LOGGER.tracef("%s server ops local response node is %s", getClass().getSimpleName(), formattedServerOps); } } else { // We're not the coordinator, so we need to propagate the server ops // to the coordinator via the response we send in the prepare part of Stage.DONE // So, change the context result to the special format used for this data ModelNode localResult = nullDomainOp ? new ModelNode(IGNORED) : multiPhaseLocalContext.getLocalResponse().get(RESULT); ModelNode domainResult = hostControllerExecutionSupport.getFormattedDomainResult(localResult); ModelNode contextResult = context.getResult(); contextResult.setEmptyObject(); contextResult.get(DOMAIN_RESULTS).set(domainResult); contextResult.get(SERVER_OPERATIONS).set(formattedServerOps); if (HOST_CONTROLLER_LOGGER.isTraceEnabled()) { HOST_CONTROLLER_LOGGER.tracef("%s server ops remote response node is %s", getClass().getSimpleName(), contextResult); } } } }
Example 20
Source File: LoggingProfileOperations.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override protected void populateModel(final ModelNode operation, final ModelNode model) { model.setEmptyObject(); }