use of org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete in project console by hal.
the class OtherSettingsPresenter method addSecurityDomain.
// -------------------------------------------- Security Domain
void addSecurityDomain() {
Metadata metadata = metadataRegistry.lookup(SECURITY_DOMAIN_TEMPLATE);
// emulate capability-reference on default-realm
String capabilityReference = metadata.getDescription().findAttribute(ATTRIBUTES + "/" + REALMS + "/" + VALUE_TYPE, REALM).getValue().get(CAPABILITY_REFERENCE).asString();
String id = Ids.build(Ids.ELYTRON_SECURITY_DOMAIN, Ids.ADD);
NameItem nameItem = new NameItem();
ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).addOnly().unboundFormItem(nameItem, 0).include(DEFAULT_REALM).unsorted().build();
form.getFormItem(DEFAULT_REALM).setRequired(true);
form.getFormItem(DEFAULT_REALM).registerSuggestHandler(new SuggestCapabilitiesAutoComplete(dispatcher, statementContext, capabilityReference, metadata.getTemplate()));
new AddResourceDialog(resources.messages().addResourceTitle(Names.SECURITY_DOMAIN), form, (name, model) -> {
if (model != null) {
// add the default-realm in the list of realms
ModelNode realm = new ModelNode();
realm.get(REALM).set(model.get(DEFAULT_REALM).asString());
model.get(REALMS).add(realm);
}
ResourceAddress address = SECURITY_DOMAIN_TEMPLATE.resolve(statementContext, nameItem.getValue());
crud.add(Names.SECURITY_DOMAIN, name, address, model, (n, a) -> reload(SECURITY_DOMAIN, nodes -> getView().updateResourceElement(SECURITY_DOMAIN, nodes)));
}).show();
}
use of org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete in project console by hal.
the class DefaultFormItemProvider method checkCapabilityReference.
private void checkCapabilityReference(ModelNode attributeDescription, FormItem<?> formItem) {
SuggestHandler suggestHandler = null;
if (attributeDescription.hasDefined(CAPABILITY_REFERENCE)) {
Dispatcher dispatcher = Core.INSTANCE.dispatcher();
StatementContext statementContext = Core.INSTANCE.statementContext();
String reference = attributeDescription.get(CAPABILITY_REFERENCE).asString();
Capabilities capabilities = metadata.getCapabilities();
if (capabilities.supportsSuggestions()) {
suggestHandler = new SuggestCapabilitiesAutoComplete(dispatcher, statementContext, reference, metadata.getTemplate());
} else if (capabilities.contains(reference)) {
suggestHandler = new ReadChildrenAutoComplete(dispatcher, statementContext, capabilities.lookup(reference));
}
}
if (suggestHandler != null) {
formItem.registerSuggestHandler(suggestHandler);
}
}
use of org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete in project console by hal.
the class StoresPresenter method obtainCertificate.
void obtainCertificate(Metadata metadata, String name) {
metadata = metadata.forOperation(OBTAIN_CERTIFICATE);
String id = Ids.build(KEY_STORE, OBTAIN_CERTIFICATE, FORM);
String title = new LabelBuilder().label(OBTAIN_CERTIFICATE);
Form<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).build();
form.setSaveCallback((form1, changedValues) -> {
ResourceAddress address = KEY_STORE_TEMPLATE.resolve(statementContext, name);
Operation operation = new Operation.Builder(address, OBTAIN_CERTIFICATE).payload(form.getModel()).build();
String alias = form.getModel().get(ALIAS).asString();
dispatcher.execute(operation, result -> MessageEvent.fire(getEventBus(), Message.success(resources.messages().obtainCertificateSuccess(alias, name))), (operation1, failure) -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().obtainCertificateError(alias, name, failure))), (operation1, ex) -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().obtainCertificateError(alias, name, ex.getMessage()))));
});
Dialog dialog = new Dialog.Builder(title).add(p().textContent(metadata.getDescription().getDescription()).element()).add(form.element()).primary(resources.constants().obtain(), form::save).size(Dialog.Size.MEDIUM).closeOnEsc(true).cancel().build();
dialog.registerAttachable(form);
if (!environment.isStandalone()) {
// the capability reference the /profile=* resource and the template attached to the metadata
// points to the {selected.host}/{selected.server}, so we need to register the template to the profile
String capability = metadata.getDescription().get(ATTRIBUTES).get(CERTIFICATE_AUTHORITY_ACCOUNT).get(CAPABILITY_REFERENCE).asString();
form.getFormItem(CERTIFICATE_AUTHORITY_ACCOUNT).registerSuggestHandler(new SuggestCapabilitiesAutoComplete(dispatcher, statementContext, capability, ELYTRON_PROFILE_TEMPLATE));
}
dialog.show();
form.edit(new ModelNode());
}
use of org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete in project console by hal.
the class StoresPresenter method revokeCertificate.
void revokeCertificate(Metadata metadata, String name, String alias) {
metadata = metadata.forOperation(REVOKE_CERTIFICATE);
String id = Ids.build(KEY_STORE, REVOKE_CERTIFICATE, FORM);
String title = new LabelBuilder().label(CERTIFICATE_AUTHORITY_ACCOUNT);
Form<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).build();
form.setSaveCallback((form1, changedValues) -> {
ResourceAddress address = KEY_STORE_TEMPLATE.resolve(statementContext, name);
Operation operation = new Operation.Builder(address, REVOKE_CERTIFICATE).payload(form.getModel()).build();
dispatcher.execute(operation, result -> MessageEvent.fire(getEventBus(), Message.success(resources.messages().revokeCertificateSuccess(alias, name))), (operation1, failure) -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().revokeCertificateError(alias, name, failure))), (operation1, ex) -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().revokeCertificateError(alias, name, ex.getMessage()))));
});
Dialog dialog = new Dialog.Builder(title).add(p().textContent(metadata.getDescription().getDescription()).element()).add(form.element()).primary(resources.constants().revoke(), form::save).size(Dialog.Size.MEDIUM).closeOnEsc(true).cancel().build();
dialog.registerAttachable(form);
ModelNode model = new ModelNode();
model.get(ALIAS).set(alias);
form.getFormItem(ALIAS).setEnabled(false);
if (!environment.isStandalone()) {
// the capability reference the /profile=* resource and the template attached to the metadata
// points to the {selected.host}/{selected.server}, so we need to register the template to the profile
String capability = metadata.getDescription().get(ATTRIBUTES).get(CERTIFICATE_AUTHORITY_ACCOUNT).get(CAPABILITY_REFERENCE).asString();
form.getFormItem(CERTIFICATE_AUTHORITY_ACCOUNT).registerSuggestHandler(new SuggestCapabilitiesAutoComplete(dispatcher, statementContext, capability, ELYTRON_PROFILE_TEMPLATE));
}
dialog.show();
form.edit(model);
}
Aggregations