use of org.jboss.hal.meta.Metadata 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.meta.Metadata in project console by hal.
the class RemoteCacheContainerPresenter method addRemoteCluster.
// ------------------------------------------------------ remote cluster
void addRemoteCluster() {
Metadata metadata = metadataRegistry.lookup(REMOTE_CLUSTER_TEMPLATE);
AddResourceDialog dialog = new AddResourceDialog(Ids.REMOTE_CLUSTER_ADD, resources.messages().addResourceTitle(Names.REMOTE_CLUSTER), metadata, (name, model) -> crud.add(Names.REMOTE_CLUSTER, name, remoteClusterAddress(name), model, (n, a) -> reload()));
dialog.show();
}
use of org.jboss.hal.meta.Metadata in project console by hal.
the class RemoteCacheContainerPresenter method resetInvalidationNearCache.
void resetInvalidationNearCache(Form<ModelNode> form) {
Metadata metadata = metadataRegistry.lookup(REMOTE_CACHE_CONTAINER_TEMPLATE.append("near-cache=invalidation"));
crud.resetSingleton(Names.INVALIDATION, nearCacheAddress(INVALIDATION), form, metadata, this::reload);
}
use of org.jboss.hal.meta.Metadata 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();
}
});
}
use of org.jboss.hal.meta.Metadata in project console by hal.
the class RemoteCacheContainerPresenter method saveRemoteCluster.
void saveRemoteCluster(String name, Map<String, Object> changedValues) {
Metadata metadata = metadataRegistry.lookup(REMOTE_CLUSTER_TEMPLATE);
crud.save(Names.REMOTE_CLUSTER, name, remoteClusterAddress(name), changedValues, metadata, this::reload);
}
Aggregations