Search in sources :

Example 11 with Property

use of org.jboss.hal.dmr.Property in project console by hal.

the class Json method iterateMap.

private static ModelNode iterateMap(JsPropertyMap<Object> map, Metadata metadata, Map<String, String> mappping) {
    ModelNode node = new ModelNode();
    List<Property> attributeDescriptions = metadata.getDescription().getAttributes(ATTRIBUTES);
    map.forEach(jsonName -> {
        String dmrName = mappping.get(jsonName);
        if (dmrName != null) {
            ModelNode attributeDescription = findAttributeDescription(dmrName, attributeDescriptions);
            if (attributeDescription != null) {
                if (map.has(jsonName)) {
                    Any any = map.getAny(jsonName);
                    ModelNode value = anyValue(jsonName, dmrName, attributeDescription, any);
                    if (value.isDefined()) {
                        node.get(dmrName).set(value);
                    }
                }
            } else {
                logger.warn("No attribute description found for JSON key '{}' / DMR attribute '{}'", jsonName, dmrName);
            }
        } else {
            logger.warn("No mapping from JSON to DMR found for JSON key '{}'", jsonName);
        }
    });
    return node;
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) Property(org.jboss.hal.dmr.Property) Any(jsinterop.base.Any)

Example 12 with Property

use of org.jboss.hal.dmr.Property in project console by hal.

the class Deployment method parseSubsystems.

/**
 * Expects a "subsystem" child resource. Modeled as a static helper method to make it usable from both deployments and
 * subdeployments.
 */
static void parseSubsystems(ModelNode node, List<Subsystem> subsystems) {
    List<Property> properties = node.get(SUBSYSTEM).asPropertyList();
    for (Property property : properties) {
        Subsystem subsystem = new Subsystem(property);
        subsystems.add(subsystem);
    }
}
Also used : Property(org.jboss.hal.dmr.Property)

Example 13 with Property

use of org.jboss.hal.dmr.Property in project console by hal.

the class AddressTemplateTest method assertResolved.

private void assertResolved(String[][] tuples, ResourceAddress resourceAddress) {
    List<Property> properties = resourceAddress.asPropertyList();
    assertEquals(tuples.length, properties.size());
    int i = 0;
    for (Property property : properties) {
        assertEquals(tuples[i][0], property.getName());
        assertEquals(tuples[i][1], property.getValue().asString());
        i++;
    }
}
Also used : Property(org.jboss.hal.dmr.Property)

Example 14 with Property

use of org.jboss.hal.dmr.Property in project console by hal.

the class AccessControl method reload.

void reload(Callback callback) {
    reset();
    List<Operation> operations = new ArrayList<>();
    operations.add(new Operation.Builder(AddressTemplates.root(), READ_RESOURCE_OPERATION).param(INCLUDE_RUNTIME, true).param(ATTRIBUTES_ONLY, true).build());
    if (!environment.isStandalone()) {
        operations.add(new Operation.Builder(AddressTemplates.root(), READ_CHILDREN_RESOURCES_OPERATION).param(CHILD_TYPE, HOST_SCOPED_ROLE).param(RECURSIVE, true).build());
        operations.add(new Operation.Builder(AddressTemplates.root(), READ_CHILDREN_RESOURCES_OPERATION).param(CHILD_TYPE, SERVER_GROUP_SCOPED_ROLE).param(RECURSIVE, true).build());
    }
    operations.add(new Operation.Builder(AddressTemplates.root(), READ_CHILDREN_RESOURCES_OPERATION).param(CHILD_TYPE, ROLE_MAPPING).param(RECURSIVE, true).build());
    dispatcher.execute(new Composite(operations), (CompositeResult result) -> {
        int step = 0;
        ModelNode attributes = result.step(step++).get(RESULT);
        AccessControlProvider accessControlProvider = ModelNodeHelper.asEnumValue(attributes, PROVIDER, AccessControlProvider::valueOf, SIMPLE);
        environment.setAccessControlProvider(accessControlProvider);
        attributes.get(STANDARD_ROLE_NAMES).asList().stream().map(node -> new Role(node.asString())).forEach(roles::add);
        if (!environment.isStandalone()) {
            result.step(step++).get(RESULT).asPropertyList().stream().map(property -> scopedRole(property, Role.Type.HOST, HOSTS)).forEach(roles::add);
            result.step(step++).get(RESULT).asPropertyList().stream().map(property -> scopedRole(property, Role.Type.SERVER_GROUP, SERVER_GROUPS)).forEach(roles::add);
        }
        // noinspection UnusedAssignment
        result.step(step++).get(RESULT).asPropertyList().forEach(p1 -> {
            Role role = roles.get(Ids.role(p1.getName()));
            if (role != null) {
                ModelNode assignmentNode = p1.getValue();
                if (assignmentNode.hasDefined(INCLUDE_ALL)) {
                    role.setIncludeAll(assignmentNode.get(INCLUDE_ALL).asBoolean());
                }
                if (assignmentNode.hasDefined(INCLUDE)) {
                    assignmentNode.get(INCLUDE).asPropertyList().forEach(p2 -> addAssignment(p2, role, true));
                }
                if (assignmentNode.hasDefined(EXCLUDE)) {
                    assignmentNode.get(EXCLUDE).asPropertyList().forEach(p2 -> addAssignment(p2, role, false));
                }
            } else {
                logger.error("Cannot add assignment for role {}: No matching role found!", p1.getName());
            }
        });
        // sync with current user
        String currentUserId = Ids.principal(Principal.Type.USER.name().toLowerCase(), currentUser.getName());
        Principal currentPrincipal = principals.get(currentUserId);
        if (currentPrincipal != null) {
            Set<Role> currentRoles = assignments.byPrincipal(currentPrincipal).map(Assignment::getRole).collect(toSet());
            currentUser.refreshRoles(currentRoles);
        }
        callback.execute();
    });
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) Environment(org.jboss.hal.config.Environment) MessageEvent(org.jboss.hal.spi.MessageEvent) AccessControlProvider(org.jboss.hal.config.AccessControlProvider) LoggerFactory(org.slf4j.LoggerFactory) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Property(org.jboss.hal.dmr.Property) Message(org.jboss.hal.spi.Message) User(org.jboss.hal.config.User) SIMPLE(org.jboss.hal.config.AccessControlProvider.SIMPLE) Collectors.toSet(java.util.stream.Collectors.toSet) Logger(org.slf4j.Logger) RBAC(org.jboss.hal.config.AccessControlProvider.RBAC) CompositeResult(org.jboss.hal.dmr.CompositeResult) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) Set(java.util.Set) EventBus(com.google.web.bindery.event.shared.EventBus) DialogFactory(org.jboss.hal.ballroom.dialog.DialogFactory) Roles(org.jboss.hal.config.Roles) Composite(org.jboss.hal.dmr.Composite) List(java.util.List) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Callback(org.jboss.hal.spi.Callback) Resources(org.jboss.hal.resources.Resources) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Role(org.jboss.hal.config.Role) ModelNodeHelper(org.jboss.hal.dmr.ModelNodeHelper) Composite(org.jboss.hal.dmr.Composite) CompositeResult(org.jboss.hal.dmr.CompositeResult) ArrayList(java.util.ArrayList) AccessControlProvider(org.jboss.hal.config.AccessControlProvider) Operation(org.jboss.hal.dmr.Operation) Role(org.jboss.hal.config.Role) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 15 with Property

use of org.jboss.hal.dmr.Property in project console by hal.

the class EjbView method flattenMethods.

// add method name to the model
private List<ModelNode> flattenMethods(List<Property> methods) {
    List<ModelNode> flatMethods = new ArrayList<>();
    for (Property method : methods) {
        ModelNode flatMethod = method.getValue();
        flatMethod.get(NAME).set(method.getName());
        flatMethods.add(flatMethod);
    }
    return flatMethods;
}
Also used : ArrayList(java.util.ArrayList) ModelNode(org.jboss.hal.dmr.ModelNode) Property(org.jboss.hal.dmr.Property)

Aggregations

Property (org.jboss.hal.dmr.Property)39 ModelNode (org.jboss.hal.dmr.ModelNode)26 Operation (org.jboss.hal.dmr.Operation)15 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)15 Ids (org.jboss.hal.resources.Ids)9 ArrayList (java.util.ArrayList)8 List (java.util.List)8 Inject (javax.inject.Inject)6 Composite (org.jboss.hal.dmr.Composite)6 ModelType (org.jboss.hal.dmr.ModelType)6 Metadata (org.jboss.hal.meta.Metadata)6 Resources (org.jboss.hal.resources.Resources)6 Map (java.util.Map)5 Form (org.jboss.hal.ballroom.form.Form)5 EventBus (com.google.web.bindery.event.shared.EventBus)4 HashMap (java.util.HashMap)4 Collectors.toList (java.util.stream.Collectors.toList)4 Collectors.toMap (java.util.stream.Collectors.toMap)4 PropertiesItem (org.jboss.hal.ballroom.form.PropertiesItem)4 Environment (org.jboss.hal.config.Environment)4