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;
}
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);
}
}
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++;
}
}
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();
});
}
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;
}
Aggregations