use of org.jboss.hal.dmr.dispatch.Dispatcher in project console by hal.
the class ServerGroupDeploymentColumn method uploadAndDeploy.
private void uploadAndDeploy() {
Metadata metadata = metadataRegistry.lookup(SERVER_GROUP_DEPLOYMENT_TEMPLATE);
Wizard<DeploymentContext, DeploymentState> wizard = new Wizard.Builder<DeploymentContext, DeploymentState>(resources.messages().addResourceTitle(resources.constants().content()), new DeploymentContext()).addStep(UPLOAD, new UploadDeploymentStep(resources)).addStep(NAMES, new NamesStep(environment, metadata, resources)).onBack((context, currentState) -> currentState == NAMES ? UPLOAD : null).onNext((context, currentState) -> currentState == UPLOAD ? NAMES : null).stayOpenAfterFinish().onFinish((wzd, context) -> {
String name = context.name;
String runtimeName = context.runtimeName;
wzd.showProgress(resources.constants().deploymentInProgress(), resources.messages().deploymentInProgress(name));
series(new FlowContext(progress.get()), new CheckDeployment(dispatcher, name), new UploadOrReplace(environment, dispatcher, name, runtimeName, context.file, false), new AddServerGroupDeployment(environment, dispatcher, name, runtimeName, statementContext.selectedServerGroup())).subscribe(new Outcome<FlowContext>() {
@Override
public void onError(FlowContext context, Throwable error) {
wzd.showError(resources.constants().deploymentError(), resources.messages().deploymentError(name), error.getMessage());
}
@Override
public void onSuccess(FlowContext context) {
refresh(Ids.serverGroupDeployment(statementContext.selectedServerGroup(), name));
wzd.showSuccess(resources.constants().deploymentSuccessful(), resources.messages().deploymentSuccessful(name), resources.messages().view(Names.DEPLOYMENT), cxt -> {
/* nothing to do, content is already selected */
});
}
});
}).build();
wizard.show();
}
use of org.jboss.hal.dmr.dispatch.Dispatcher in project console by hal.
the class StandaloneDeploymentColumn method uploadDeployment.
private void uploadDeployment() {
Metadata metadata = metadataRegistry.lookup(DEPLOYMENT_TEMPLATE);
Wizard<DeploymentContext, DeploymentState> wizard = new Wizard.Builder<DeploymentContext, DeploymentState>(resources.messages().addResourceTitle(Names.DEPLOYMENT), new DeploymentContext()).addStep(UPLOAD, new UploadDeploymentStep(resources)).addStep(NAMES, new NamesStep(environment, metadata, resources)).onBack((context, currentState) -> currentState == NAMES ? UPLOAD : null).onNext((context, currentState) -> currentState == UPLOAD ? NAMES : null).stayOpenAfterFinish().onFinish((wzd, context) -> {
String name = context.name;
String runtimeName = context.runtimeName;
wzd.showProgress(resources.constants().deploymentInProgress(), resources.messages().deploymentInProgress(name));
series(new FlowContext(progress.get()), new CheckDeployment(dispatcher, name), new UploadOrReplace(environment, dispatcher, name, runtimeName, context.file, context.enabled)).subscribe(new Outcome<FlowContext>() {
@Override
public void onError(FlowContext context, Throwable error) {
wzd.showError(resources.constants().deploymentError(), resources.messages().deploymentError(name), error.getMessage());
}
@Override
public void onSuccess(FlowContext context) {
refresh(Ids.deployment(name));
wzd.showSuccess(resources.constants().uploadSuccessful(), resources.messages().uploadSuccessful(name), resources.messages().view(Names.DEPLOYMENT), cxt -> {
/* nothing to do, deployment is already selected */
});
}
});
}).build();
wizard.show();
}
use of org.jboss.hal.dmr.dispatch.Dispatcher in project console by hal.
the class TestStep method testConnection.
private void testConnection() {
Context context = wizard().getContext();
List<Task<FlowContext>> tasks = new ArrayList<>();
if (!context.isCreated()) {
// add data source
tasks.add(flowContext -> dispatcher.execute(addOperation(context, statementContext)).doOnSuccess((CompositeResult result) -> context.setCreated(true)).doOnError(throwable -> {
flowContext.set(WIZARD_TITLE, resources.constants().testConnectionError());
flowContext.set(WIZARD_TEXT, resources.messages().dataSourceAddError());
}).toCompletable());
}
// check running server(s)
tasks.addAll(runningServers(environment, dispatcher, properties(PROFILE_NAME, statementContext.selectedProfile())));
// test connection
tasks.add(flowContext -> {
List<Server> servers = flowContext.get(TopologyTasks.SERVERS);
ResourceAddress address;
if (!servers.isEmpty()) {
Server server = servers.get(0);
address = server.getServerAddress();
} else if (environment.isStandalone()) {
address = ResourceAddress.root();
} else {
flowContext.set(WIZARD_TITLE, resources.constants().testConnectionError());
flowContext.set(WIZARD_TEXT, SafeHtmlUtils.fromString(resources.constants().noRunningServers()));
return Completable.error(new FlowException(resources.messages().testConnectionErrorDomain(), flowContext));
}
address.add(SUBSYSTEM, DATASOURCES).add(context.dataSource.isXa() ? XA_DATA_SOURCE : DATA_SOURCE, context.dataSource.getName());
Operation operation = new Operation.Builder(address, TEST_CONNECTION_IN_POOL).build();
return dispatcher.execute(operation).doOnError(throwable -> {
flowContext.set(WIZARD_TITLE, resources.constants().testConnectionError());
flowContext.set(WIZARD_TEXT, resources.messages().testConnectionError(context.dataSource.getName()));
}).toCompletable();
});
series(new FlowContext(progress.get()), tasks).subscribe(new Outcome<FlowContext>() {
@Override
public void onError(FlowContext flowContext, Throwable error) {
String title;
SafeHtml text;
if (flowContext == null) {
title = resources.constants().unknownError();
text = resources.messages().unknownError();
} else {
title = flowContext.get(WIZARD_TITLE);
text = flowContext.get(WIZARD_TEXT);
}
wizard().showError(title, text, error.getMessage(), false);
}
@Override
public void onSuccess(FlowContext flowContext) {
wizard().showSuccess(resources.constants().testConnectionSuccess(), resources.messages().testConnectionSuccess(context.dataSource.getName()), false);
}
});
}
use of org.jboss.hal.dmr.dispatch.Dispatcher in project console by hal.
the class EjbView method init.
@PostConstruct
void init() {
StatementContext statementContext = mbuiContext.statementContext();
if (ManagementModel.supportsEjbApplicationSecurityDomain(environment().getManagementVersion())) {
AddressTemplate template = AddressTemplate.of("/{selected.profile}/subsystem=ejb3/application-security-domain=*");
Metadata metadata = mbuiContext.metadataRegistry().lookup(template);
appSecurityDomainTable = new ModelNodeTable.Builder<NamedNode>(Ids.EJB3_APPLICATION_SECURITY_DOMAIN_TABLE, metadata).button(mbuiContext.tableButtonFactory().add(Ids.EJB3_APPLICATION_SECURITY_DOMAIN_ADD, Names.APPLICATION_SECURITY_DOMAIN, template, (name, address) -> presenter.reload())).button(mbuiContext.tableButtonFactory().remove(Names.APPLICATION_SECURITY_DOMAIN, template, (api) -> api.selectedRow().getName(), () -> presenter.reload())).column(NAME, (cell, type, row, meta) -> row.getName()).build();
appSecurityDomainForm = new ModelNodeForm.Builder<NamedNode>(Ids.EJB3_APPLICATION_SECURITY_DOMAIN_FORM, metadata).onSave((form, changedValues) -> {
String name = form.getModel().getName();
saveForm(Names.APPLICATION_SECURITY_DOMAIN, name, template.resolve(statementContext, name), changedValues, metadata);
}).prepareReset(form -> {
String name = form.getModel().getName();
resetForm(Names.APPLICATION_SECURITY_DOMAIN, name, template.resolve(statementContext, name), form, metadata);
}).build();
HTMLElement section = section().add(h(1).textContent(Names.APPLICATION_SECURITY_DOMAIN)).add(p().textContent(metadata.getDescription().getDescription())).add(appSecurityDomainTable).add(appSecurityDomainForm).element();
navigation.insertPrimary(Ids.EJB3_APPLICATION_SECURITY_DOMAIN_ITEM, null, Names.SECURITY_DOMAIN, fontAwesome("link"), section);
}
Dispatcher dispatcher = mbuiContext.dispatcher();
configurationForm.getFormItem(DEFAULT_SFSB_CACHE).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, CACHE_TEMPLATE));
configurationForm.getFormItem(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, CACHE_TEMPLATE));
configurationForm.getFormItem(DEFAULT_SLSB_INSTANCE_POOL).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, BEAN_POOL_TEMPLATE));
configurationForm.getFormItem(DEFAULT_SECURITY_DOMAIN).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, SECURITY_DOMAIN_TEMPLATE));
cacheForm.getFormItem(PASSIVATION_STORE).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, PASSIVATION_TEMPLATE));
}
use of org.jboss.hal.dmr.dispatch.Dispatcher in project console by hal.
the class RollbackWizard method show.
public void show() {
Messages messages = resources.messages();
Wizard.Builder<PatchContext, PatchState> wb = new Wizard.Builder<>(resources.constants().rollback(), new PatchContext());
checkServersState(servers -> {
if (servers != null) {
wb.addStep(CHECK_SERVERS, new CheckRunningServersStep(resources, servers, statementContext.selectedHost()));
}
wb.addStep(ROLLBACK, new org.jboss.hal.client.patching.wizard.RollbackStep(metadata, resources, statementContext.selectedHost(), patchId)).onBack((context, currentState) -> {
PatchState previous = null;
switch(currentState) {
case CHECK_SERVERS:
break;
case ROLLBACK:
previous = CHECK_SERVERS;
break;
default:
break;
}
return previous;
}).onNext((context, currentState) -> {
PatchState next = null;
switch(currentState) {
case CHECK_SERVERS:
next = ROLLBACK;
break;
case ROLLBACK:
break;
default:
break;
}
return next;
}).stayOpenAfterFinish().onFinish((wzd, context) -> {
String name = context.patchId;
wzd.showProgress(resources.constants().rollbackInProgress(), messages.rollbackInProgress(name));
series(new FlowContext(progress.get()), new RollbackTask(statementContext, dispatcher, serverActions, context)).subscribe(new Outcome<FlowContext>() {
@Override
public void onError(FlowContext context, Throwable error) {
wzd.showError(resources.constants().rollbackError(), messages.rollbackError(error.getMessage()), error.getMessage());
}
@Override
public void onSuccess(FlowContext context) {
callback.execute();
wzd.showSuccess(resources.constants().rollbackSuccessful(), messages.rollbackSucessful(name));
}
});
});
Wizard<PatchContext, PatchState> wizard = wb.build();
wizard.show();
});
}
Aggregations