use of org.jboss.hal.dmr.Property in project console by hal.
the class ThreadPoolPreview method update.
@Override
public void update(SubsystemMetadata item) {
ResourceAddress address = EJB3_SUBSYSTEM_TEMPLATE.resolve(statementContext);
Operation operation = new Operation.Builder(address, READ_RESOURCE_OPERATION).param(INCLUDE_RUNTIME, true).param(RECURSIVE, true).build();
dispatcher.execute(operation, result -> {
List<Property> properties = failSafePropertyList(result, THREAD_POOL);
if (!properties.isEmpty()) {
ModelNode threadPool = properties.get(0).getValue();
long active = threadPool.get(ACTIVE_COUNT).asLong();
long completed = threadPool.get(COMPLETED_TASK_COUNT).asLong();
long queue = threadPool.get(QUEUE_SIZE).asLong();
long rejected = threadPool.get(REJECTED_COUNT).asLong();
tasks.update(ImmutableMap.of(Ids.TASKS_ACTIVE, active, Ids.TASKS_COMPLETED, completed, Ids.TASKS_QUEUE, queue, Ids.TASKS_REJECTED, rejected));
int currentThreads = threadPool.get(CURRENT_THREAD_COUNT).asInt();
int maxThreads = threadPool.get(MAX_THREADS).asInt();
threads.update(currentThreads, maxThreads);
}
});
}
use of org.jboss.hal.dmr.Property in project console by hal.
the class ReadAuthentication method call.
@Override
public Completable call(FlowContext context) {
logger.debug("Read authentication");
ResourceAddress address = CORE_SERVICE_TEMPLATE.resolve(statementContext);
Operation opAuthorization = new Operation.Builder(address, READ_CHILDREN_RESOURCES_OPERATION).param(CHILD_TYPE, ACCESS).param(INCLUDE_RUNTIME, true).param(RECURSIVE_DEPTH, 1).build();
Operation opWhoami = new Operation.Builder(ResourceAddress.root(), WHOAMI).param(VERBOSE, true).build();
return dispatcher.execute(new Composite(opAuthorization, opWhoami)).doOnSuccess((CompositeResult compositeResult) -> {
ModelNode result = compositeResult.step(0).get(RESULT);
if (result.hasDefined(AUTHORIZATION)) {
result = result.get(AUTHORIZATION);
// provider
AccessControlProvider accessControlProvider = asEnumValue(result, PROVIDER, AccessControlProvider::valueOf, SIMPLE);
environment.setAccessControlProvider(accessControlProvider);
// standard roles
if (result.hasDefined(STANDARD_ROLE_NAMES)) {
result.get(STANDARD_ROLE_NAMES).asList().stream().map(node -> new Role(node.asString())).forEach(role -> environment.getRoles().add(role));
}
// scoped roles
if (!environment.isStandalone()) {
if (result.hasDefined(HOST_SCOPED_ROLE)) {
result.get(HOST_SCOPED_ROLE).asPropertyList().stream().map(property -> scopedRole(property, Role.Type.HOST, HOSTS)).forEach(role -> environment.getRoles().add(role));
}
if (result.hasDefined(SERVER_GROUP_SCOPED_ROLE)) {
result.get(SERVER_GROUP_SCOPED_ROLE).asPropertyList().stream().map(property -> scopedRole(property, Role.Type.SERVER_GROUP, SERVER_GROUPS)).forEach(role -> environment.getRoles().add(role));
}
}
} else {
logger.warn("Unable to read {} (insufficient rights?). Use :whoami values as fallback.", CORE_SERVICE_TEMPLATE.append("access=authorization"));
ModelNode resultWhoami = compositeResult.step(1).get(RESULT);
environment.setAccessControlProvider(RBAC);
environment.getRoles().clear();
if (resultWhoami.hasDefined(ROLES)) {
resultWhoami.get(ROLES).asList().stream().map(node -> new Role(node.asString())).forEach(role -> environment.getRoles().add(role));
} else if (resultWhoami.hasDefined(MAPPED_ROLES)) {
resultWhoami.get(MAPPED_ROLES).asList().stream().map(node -> new Role(node.asString())).forEach(role -> environment.getRoles().add(role));
}
}
}).onErrorResumeNext(throwable -> {
if (throwable instanceof DispatchFailure) {
logger.error("Unable to read {}. Use :whoami values as fallback.", CORE_SERVICE_TEMPLATE);
return Single.just(new CompositeResult(new ModelNode()));
} else {
return Single.error(throwable);
}
}).toCompletable();
}
use of org.jboss.hal.dmr.Property in project console by hal.
the class RemotingView method init.
@PostConstruct
void init() {
// remote connector
Metadata connectorMetadata = mbuiContext.metadataRegistry().lookup(CONNECTOR_TEMPLATE);
connectorForm = new ModelNodeForm.Builder<NamedNode>(Ids.REMOTING_CONNECTOR_FORM, connectorMetadata).unboundFormItem(new PropertiesItem(PROPERTY), 1).onSave((form, changedValues) -> presenter.saveConnector(form, changedValues)).prepareReset(form -> presenter.resetConnector(form)).build();
registerAttachable(connectorForm);
// remote connector security
Metadata connectorSecurityMetadata = mbuiContext.metadataRegistry().lookup(CONNECTOR_SECURITY_TEMPLATE);
connectorSecurityForm = new ModelNodeForm.Builder<>(Ids.REMOTING_CONNECTOR_SECURITY_FORM, connectorSecurityMetadata).unboundFormItem(new PropertiesItem(PROPERTY), 2).singleton(() -> new Operation.Builder(SELECTED_CONNECTOR_SECURITY_TEMPLATE.resolve(presenter.selectedConnectorContext), READ_RESOURCE_OPERATION).build(), () -> presenter.createConnectorSecurity()).onSave((form, changedValues) -> presenter.saveConnectorSecurity(form, changedValues)).prepareReset(form -> presenter.resetConnectorSecurity(form)).prepareRemove(form -> presenter.removeConnectorSecurity(form)).build();
registerAttachable(connectorSecurityForm);
// remote connector security policy
Metadata connectorSecurityPolicyMetadata = mbuiContext.metadataRegistry().lookup(CONNECTOR_SECURITY_POLICY_TEMPLATE);
connectorSecurityPolicyForm = new ModelNodeForm.Builder<>(Ids.REMOTING_CONNECTOR_SECURITY_POLICY_FORM, connectorSecurityPolicyMetadata).singleton(() -> new Operation.Builder(SELECTED_CONNECTOR_SECURITY_POLICY_TEMPLATE.resolve(presenter.selectedConnectorContext), READ_RESOURCE_OPERATION).build(), () -> presenter.createConnectorSecurityPolicy()).onSave((form, changedValues) -> presenter.saveConnectorSecurityPolicy(changedValues)).prepareReset(form -> presenter.resetConnectorSecurityPolicy(form)).prepareRemove(form -> presenter.removeConnectorSecurityPolicy(form)).build();
registerAttachable(connectorSecurityPolicyForm);
// remote connector tabs
Tabs connectorTabs = new Tabs(Ids.REMOTING_CONNECTOR_TAB_CONTAINER);
connectorTabs.add(Ids.REMOTING_CONNECTOR_TAB, mbuiContext.resources().constants().attributes(), connectorForm.element());
connectorTabs.add(Ids.REMOTING_CONNECTOR_SECURITY_TAB, Names.SECURITY, connectorSecurityForm.element());
connectorTabs.add(Ids.REMOTING_CONNECTOR_SECURITY_POLICY_TAB, Names.POLICY, connectorSecurityPolicyForm.element());
connectorTable.element().parentNode.appendChild(connectorTabs.element());
// http connector
Metadata httpConnectorMetadata = mbuiContext.metadataRegistry().lookup(HTTP_CONNECTOR_TEMPLATE);
httpConnectorForm = new ModelNodeForm.Builder<NamedNode>(Ids.REMOTING_HTTP_CONNECTOR_FORM, httpConnectorMetadata).unboundFormItem(new PropertiesItem(PROPERTY), 2).onSave((form, changedValues) -> presenter.saveHttpConnector(form, changedValues)).prepareReset(form -> presenter.resetHttpConnector(form)).build();
registerAttachable(httpConnectorForm);
// http connector security
Metadata httpConnectorSecurityMetadata = mbuiContext.metadataRegistry().lookup(HTTP_CONNECTOR_SECURITY_TEMPLATE);
httpConnectorSecurityForm = new ModelNodeForm.Builder<>(Ids.REMOTING_HTTP_CONNECTOR_SECURITY_FORM, httpConnectorSecurityMetadata).unboundFormItem(new PropertiesItem(PROPERTY), 2).singleton(() -> new Operation.Builder(SELECTED_HTTP_CONNECTOR_SECURITY_TEMPLATE.resolve(presenter.selectedHttpConnectorContext), READ_RESOURCE_OPERATION).build(), () -> presenter.createHttpConnectorSecurity()).onSave((form, changedValues) -> presenter.saveHttpConnectorSecurity(form, changedValues)).prepareReset(form -> presenter.resetHttpConnectorSecurity(form)).prepareRemove(form -> presenter.removeHttpConnectorSecurity(form)).build();
registerAttachable(httpConnectorSecurityForm);
// http connector security policy
Metadata httpConnectorSecurityPolicyMetadata = mbuiContext.metadataRegistry().lookup(HTTP_CONNECTOR_SECURITY_POLICY_TEMPLATE);
httpConnectorSecurityPolicyForm = new ModelNodeForm.Builder<>(Ids.REMOTING_HTTP_CONNECTOR_SECURITY_POLICY_FORM, httpConnectorSecurityPolicyMetadata).singleton(() -> new Operation.Builder(SELECTED_HTTP_CONNECTOR_SECURITY_POLICY_TEMPLATE.resolve(presenter.selectedHttpConnectorContext), READ_RESOURCE_OPERATION).build(), () -> presenter.createHttpConnectorSecurityPolicy()).onSave((form, changedValues) -> presenter.saveHttpConnectorSecurityPolicy(changedValues)).prepareReset(form -> presenter.resetHttpConnectorSecurityPolicy(form)).prepareRemove(form -> presenter.removeHttpConnectorSecurityPolicy(form)).build();
registerAttachable(httpConnectorSecurityPolicyForm);
// http connector tabs
Tabs httpConnectorTabs = new Tabs(Ids.REMOTING_HTTP_CONNECTOR_TAB_CONTAINER);
httpConnectorTabs.add(Ids.REMOTING_HTTP_CONNECTOR_TAB, mbuiContext.resources().constants().attributes(), httpConnectorForm.element());
httpConnectorTabs.add(Ids.REMOTING_HTTP_CONNECTOR_SECURITY_TAB, Names.SECURITY, httpConnectorSecurityForm.element());
httpConnectorTabs.add(Ids.REMOTING_HTTP_CONNECTOR_SECURITY_POLICY_TAB, Names.POLICY, httpConnectorSecurityPolicyForm.element());
httpConnectorTable.element().parentNode.appendChild(httpConnectorTabs.element());
}
use of org.jboss.hal.dmr.Property in project console by hal.
the class RemotingView method updateGenericConnector.
@SuppressWarnings("HardCodedStringLiteral")
private void updateGenericConnector(NamedNode node, Form<NamedNode> form, Form<ModelNode> securityForm, Form<ModelNode> policyForm) {
FormItem<Object> properties = form.getFormItem(PROPERTY);
FormItem<Object> securityProperties = securityForm.getFormItem(PROPERTY);
if (node != null) {
Map<String, String> p = failSafePropertyList(node, PROPERTY).stream().collect(toMap(Property::getName, property -> property.getValue().get(VALUE).asString()));
ModelNode security = failSafeGet(node, "security/sasl");
Map<String, String> sp = failSafePropertyList(node, "security/sasl/" + PROPERTY).stream().collect(toMap(Property::getName, property -> property.getValue().get(VALUE).asString()));
ModelNode policy = failSafeGet(node, "security/sasl/sasl-policy/policy");
form.view(node);
properties.setValue(p);
securityForm.view(security);
securityProperties.setValue(sp);
policyForm.view(policy);
} else {
form.clear();
properties.clearValue();
securityForm.clear();
securityProperties.clearValue();
policyForm.clear();
}
}
use of org.jboss.hal.dmr.Property in project console by hal.
the class ReadChildrenAutoComplete method operation.
private Operation operation(ResourceAddress address, int numberOfTemplates) {
Operation operation;
int wildcards = 0;
if (address.isDefined()) {
for (Property property : address.asPropertyList()) {
if ("*".equals(property.getValue().asString())) {
wildcards++;
}
}
}
if (numberOfTemplates == 1 && (wildcards == 0 || (wildcards == 1 && "*".equals(address.lastValue())))) {
ResourceAddress parent = address.getParent();
String childName = address.lastName();
operation = new Operation.Builder(parent, READ_CHILDREN_NAMES_OPERATION, true).param(CHILD_TYPE, childName).build();
} else {
// The address is something like /foo=*/bar=*
// Would be nice if we could use
// /foo=*:read-children-names(child-type=bar)
// but it returns an empty list, so we're using
// /foo=*/bar=*:read-resource
// which makes parsing the response more complicated
operation = new Operation.Builder(address, READ_RESOURCE_OPERATION, true).param(ATTRIBUTES_ONLY, true).param(INCLUDE_ALIASES, false).param(INCLUDE_DEFAULTS, false).param(INCLUDE_RUNTIME, false).param(PROXIES, false).build();
}
return operation;
}
Aggregations