use of org.jboss.hal.dmr.ModelNode in project console by hal.
the class ClusteringPresenter method addBridge.
void addBridge(ServerSubResource ssr) {
Metadata metadata = metadataRegistry.lookup(ssr.template);
NameItem nameItem = new NameItem();
Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(ssr.baseId, Ids.ADD), metadata).unboundFormItem(nameItem, 0).fromRequestProperties().include(QUEUE_NAME, DISCOVERY_GROUP, STATIC_CONNECTORS).unsorted().build();
List<AddressTemplate> templates = asList(SELECTED_SERVER_TEMPLATE.append(CONNECTOR + EQ_WILDCARD), SELECTED_SERVER_TEMPLATE.append(IN_VM_CONNECTOR + EQ_WILDCARD), SELECTED_SERVER_TEMPLATE.append(HTTP_CONNECTOR + EQ_WILDCARD), SELECTED_SERVER_TEMPLATE.append(REMOTE_CONNECTOR + EQ_WILDCARD));
form.getFormItem(DISCOVERY_GROUP).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, SELECTED_SERVER_TEMPLATE.append(DISCOVERY_GROUP + EQ_WILDCARD)));
form.getFormItem(STATIC_CONNECTORS).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, templates));
new AddResourceDialog(resources.messages().addResourceTitle(ssr.type), form, (name, model) -> {
name = nameItem.getValue();
ResourceAddress address = SELECTED_SERVER_TEMPLATE.append(ssr.resource + "=" + name).resolve(statementContext);
crud.add(ssr.type, name, address, model, (n, a) -> reload());
}).show();
}
use of org.jboss.hal.dmr.ModelNode in project console by hal.
the class ConnectionPresenter method addHttpConnector.
void addHttpConnector() {
ServerSubResource ssr = ServerSubResource.HTTP_CONNECTOR;
Metadata metadata = metadataRegistry.lookup(ssr.template);
Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(ssr.baseId, Ids.ADD), metadata).unboundFormItem(new NameItem(), 0).fromRequestProperties().requiredOnly().build();
form.getFormItem(SOCKET_BINDING).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, AddressTemplate.of("/socket-binding-group=*/socket-binding=*")));
form.getFormItem(ENDPOINT).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, AddressTemplate.of("/{selected.profile}/subsystem=messaging-activemq/server=*/http-acceptor=*")));
new AddResourceDialog(ssr.type, form, (name, model) -> {
ResourceAddress address = SELECTED_SERVER_TEMPLATE.append(ssr.resource + EQ + name).resolve(statementContext);
crud.add(ssr.type, name, address, model, (n, a) -> reload());
}).show();
}
use of org.jboss.hal.dmr.ModelNode in project console by hal.
the class ConnectionPresenter method addPooledConnectionFactory.
void addPooledConnectionFactory(ServerSubResource ssr) {
Metadata metadata = metadataRegistry.lookup(ssr.template);
NameItem nameItem = new NameItem();
Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(ssr.baseId, Ids.ADD), metadata).unboundFormItem(nameItem, 0).fromRequestProperties().include("entries", DISCOVERY_GROUP, CONNECTORS).unsorted().build();
List<AddressTemplate> templates = asList(SELECTED_SERVER_TEMPLATE.append(CONNECTOR + EQ_WILDCARD), SELECTED_SERVER_TEMPLATE.append(IN_VM_CONNECTOR + EQ_WILDCARD), SELECTED_SERVER_TEMPLATE.append(HTTP_CONNECTOR + EQ_WILDCARD), SELECTED_SERVER_TEMPLATE.append(REMOTE_CONNECTOR + EQ_WILDCARD));
form.getFormItem(DISCOVERY_GROUP).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, SELECTED_SERVER_TEMPLATE.append(DISCOVERY_GROUP + EQ_WILDCARD)));
form.getFormItem(CONNECTORS).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, templates));
new AddResourceDialog(resources.messages().addResourceTitle(ssr.type), form, (name, model) -> {
name = nameItem.getValue();
ResourceAddress address = SELECTED_SERVER_TEMPLATE.append(ssr.resource + EQ + name).resolve(statementContext);
crud.add(ssr.type, name, address, model, (n, a) -> reload());
}).show();
}
use of org.jboss.hal.dmr.ModelNode in project console by hal.
the class MailSessionPresenter method launchAddServer.
void launchAddServer() {
SortedSet<String> availableServers = new TreeSet<>(asList(SMTP.toUpperCase(), IMAP.toUpperCase(), POP3.toUpperCase()));
ResourceAddress selectedSessionAddress = SELECTED_MAIL_SESSION_TEMPLATE.resolve(statementContext);
Operation serverNamesOp = new Operation.Builder(selectedSessionAddress, READ_CHILDREN_NAMES_OPERATION).param(CHILD_TYPE, SERVER).build();
dispatcher.execute(serverNamesOp, serversResult -> {
Set<String> existingServers = serversResult.asList().stream().map(node -> node.asString().toUpperCase()).collect(toSet());
availableServers.removeAll(existingServers);
if (availableServers.isEmpty()) {
MessageEvent.fire(getEventBus(), Message.error(resources.messages().allMailServersExist()));
} else {
FormItem<String> serverTypeItem;
if (availableServers.size() == 1) {
serverTypeItem = new TextBoxItem(ModelDescriptionConstants.SERVER_TYPE, resources.constants().type());
serverTypeItem.setValue(availableServers.first());
serverTypeItem.setEnabled(false);
} else {
serverTypeItem = new SingleSelectBoxItem(ModelDescriptionConstants.SERVER_TYPE, resources.constants().type(), new ArrayList<>(availableServers), false);
serverTypeItem.setRequired(true);
}
Metadata metadata = metadataRegistry.lookup(AddressTemplates.SERVER_TEMPLATE);
Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.MAIL_SERVER_DIALOG, metadata).unboundFormItem(serverTypeItem, 0).include(OUTBOUND_SOCKET_BINDING_REF, USERNAME, PASSWORD, "ssl", "tls").fromRequestProperties().requiredOnly().unsorted().build();
form.getFormItem(OUTBOUND_SOCKET_BINDING_REF).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, AddressTemplates.SOCKET_BINDING_TEMPLATE));
AddResourceDialog dialog = new AddResourceDialog(resources.messages().addResourceTitle(Names.SERVER), form, (name, modelNode) -> {
String serverType = serverTypeItem.getValue().toLowerCase();
ResourceAddress address = SELECTED_MAIL_SESSION_TEMPLATE.append(SERVER + EQUALS + serverType).resolve(statementContext);
Operation operation = new Operation.Builder(address, ModelDescriptionConstants.ADD).payload(modelNode).build();
dispatcher.execute(operation, result -> {
MessageEvent.fire(getEventBus(), Message.success(resources.messages().addResourceSuccess(Names.SERVER, serverType)));
reload();
});
});
dialog.show();
}
});
}
use of org.jboss.hal.dmr.ModelNode in project console by hal.
the class RemoteCacheContainerPresenter method resetRemoteCacheContainer.
void resetRemoteCacheContainer(Form<ModelNode> form) {
ResourceAddress address = SELECTED_REMOTE_CACHE_CONTAINER_TEMPLATE.resolve(statementContext);
Metadata metadata = metadataRegistry.lookup(REMOTE_CACHE_CONTAINER_TEMPLATE);
crud.reset(Names.REMOTE_CACHE_CONTAINER, remoteCacheContainer, address, form, metadata, new FinishReset<ModelNode>(form) {
@Override
public void afterReset(Form<ModelNode> form) {
reload();
}
});
}
Aggregations