Search in sources :

Example 1 with Messages

use of org.jboss.hal.resources.Messages in project console by hal.

the class TopologyTasks method reloadBlocking.

// ------------------------------------------------------ topology
/**
 * Show a blocking verification dialog and executes the specified operation.
 */
public static void reloadBlocking(Dispatcher dispatcher, EventBus eventBus, Operation operation, String type, String name, String urlConsole, Resources resources) {
    Messages messages = resources.messages();
    String title = messages.restart(name);
    dispatcher.execute(operation, result -> DialogFactory.buildBlocking(title, Dialog.Size.MEDIUM, messages.reloadConsoleRedirect(urlConsole)).show(), (operation1, failure) -> MessageEvent.fire(eventBus, Message.error(messages.reloadErrorCause(type, name, failure))), (operation1, exception) -> MessageEvent.fire(eventBus, Message.error(messages.reloadErrorCause(type, name, exception.getMessage()))));
}
Also used : Messages(org.jboss.hal.resources.Messages)

Example 2 with Messages

use of org.jboss.hal.resources.Messages in project console by hal.

the class ApplyPatchWizard method show.

public void show() {
    Messages messages = resources.messages();
    Wizard.Builder<PatchContext, PatchState> wb = new Wizard.Builder<>(messages.addResourceTitle(Names.PATCH), new PatchContext());
    checkServersState(servers -> {
        if (servers != null) {
            wb.addStep(CHECK_SERVERS, new CheckRunningServersStep(resources, servers, statementContext.selectedHost()));
        }
        wb.addStep(UPLOAD, new UploadPatchStep(resources)).addStep(CONFIGURE, new ConfigurationStep(metadata, resources)).onBack((context, currentState) -> {
            PatchState previous = null;
            switch(currentState) {
                case CHECK_SERVERS:
                    break;
                case UPLOAD:
                    previous = CHECK_SERVERS;
                    break;
                case CONFIGURE:
                    previous = UPLOAD;
                    break;
                default:
                    break;
            }
            return previous;
        }).onNext((context, currentState) -> {
            PatchState next = null;
            switch(currentState) {
                case CHECK_SERVERS:
                    next = UPLOAD;
                    break;
                case UPLOAD:
                    next = CONFIGURE;
                    break;
                case CONFIGURE:
                    break;
                default:
                    break;
            }
            return next;
        }).stayOpenAfterFinish().onFinish((wzd, context) -> {
            String name = context.file.name;
            wzd.showProgress(resources.constants().patchInProgress(), messages.patchInProgress(name));
            series(new FlowContext(progress.get()), new UploadPatch(statementContext, dispatcher, serverActions, context)).subscribe(new Outcome<FlowContext>() {

                @Override
                public void onError(FlowContext flowContext, Throwable error) {
                    wzd.showError(resources.constants().patchError(), messages.patchAddError(name, error.getMessage()), error.getMessage());
                }

                @Override
                public void onSuccess(FlowContext context) {
                    callback.execute();
                    wzd.showSuccess(resources.constants().patchSuccessful(), messages.patchSucessfullyApplied(name), messages.view(Names.PATCH), cxt -> {
                    /* nothing to do, content is already selected */
                    });
                }
            });
        });
        Wizard<PatchContext, PatchState> wizard = wb.build();
        wizard.show();
    });
}
Also used : Completable(rx.Completable) Provider(javax.inject.Provider) Environment(org.jboss.hal.config.Environment) StatementContext(org.jboss.hal.meta.StatementContext) Messages(org.jboss.hal.resources.Messages) UPLOAD(org.jboss.hal.client.patching.wizard.PatchState.UPLOAD) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) FlowContext(org.jboss.hal.flow.FlowContext) Outcome(org.jboss.hal.flow.Outcome) Property(org.jboss.hal.dmr.Property) Task(org.jboss.hal.flow.Task) Progress(org.jboss.hal.flow.Progress) PATCHING_TEMPLATE(org.jboss.hal.client.patching.PatchesColumn.PATCHING_TEMPLATE) Server(org.jboss.hal.core.runtime.server.Server) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) ServerActions(org.jboss.hal.core.runtime.server.ServerActions) Operation(org.jboss.hal.dmr.Operation) CONFIGURE(org.jboss.hal.client.patching.wizard.PatchState.CONFIGURE) Wizard(org.jboss.hal.ballroom.wizard.Wizard) CHECK_SERVERS(org.jboss.hal.client.patching.wizard.PatchState.CHECK_SERVERS) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Callback(org.jboss.hal.spi.Callback) Resources(org.jboss.hal.resources.Resources) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Flow.series(org.jboss.hal.flow.Flow.series) Messages(org.jboss.hal.resources.Messages) FlowContext(org.jboss.hal.flow.FlowContext) Wizard(org.jboss.hal.ballroom.wizard.Wizard)

Example 3 with Messages

use of org.jboss.hal.resources.Messages in project console by hal.

the class PatchesColumn method checkHostState.

/**
 * Checks if the host or standalone server is in restart mode, if yes then asks user to restart host/server, as it must be
 * restarted before a patch can be installed or to call a rollback on an installed patch.
 */
private void checkHostState(Callback callback) {
    Messages messages = resources.messages();
    if (environment.isStandalone()) {
        Operation operation = new Operation.Builder(ResourceAddress.root(), READ_RESOURCE_OPERATION).param(INCLUDE_RUNTIME, true).param(ATTRIBUTES_ONLY, true).build();
        dispatcher.execute(operation, result -> {
            Server.STANDALONE.addServerAttributes(result);
            if (Server.STANDALONE.needsRestart()) {
                serverActions.restartStandalone(Server.STANDALONE, messages.patchRestartStandaloneQuestion());
            } else {
                callback.execute();
            }
        });
    } else {
        ResourceAddress address = new ResourceAddress().add(HOST, statementContext.selectedHost());
        Operation operation = new Operation.Builder(address, READ_RESOURCE_OPERATION).param(INCLUDE_RUNTIME, true).param(ATTRIBUTES_ONLY, true).build();
        dispatcher.execute(operation, result -> {
            Property prop = new Property(statementContext.selectedHost(), result);
            Host host = new Host(prop);
            if (host.needsRestart()) {
                SafeHtml question = host.isDomainController() ? messages.patchRestartDomainControllerQuestion(host.getName()) : messages.patchRestartHostControllerQuestion(host.getName());
                hostActions.restart(host, question);
            } else {
                callback.execute();
            }
        });
    }
}
Also used : Messages(org.jboss.hal.resources.Messages) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Host(org.jboss.hal.core.runtime.host.Host) Operation(org.jboss.hal.dmr.Operation) Property(org.jboss.hal.dmr.Property)

Example 4 with Messages

use of org.jboss.hal.resources.Messages 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();
    });
}
Also used : Completable(rx.Completable) ServerActions(org.jboss.hal.core.runtime.server.ServerActions) Provider(javax.inject.Provider) Environment(org.jboss.hal.config.Environment) Operation(org.jboss.hal.dmr.Operation) StatementContext(org.jboss.hal.meta.StatementContext) Messages(org.jboss.hal.resources.Messages) Wizard(org.jboss.hal.ballroom.wizard.Wizard) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) FlowContext(org.jboss.hal.flow.FlowContext) Outcome(org.jboss.hal.flow.Outcome) ROLLBACK(org.jboss.hal.client.patching.wizard.PatchState.ROLLBACK) CHECK_SERVERS(org.jboss.hal.client.patching.wizard.PatchState.CHECK_SERVERS) Property(org.jboss.hal.dmr.Property) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Task(org.jboss.hal.flow.Task) Progress(org.jboss.hal.flow.Progress) Callback(org.jboss.hal.spi.Callback) Resources(org.jboss.hal.resources.Resources) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) PATCHING_TEMPLATE(org.jboss.hal.client.patching.PatchesColumn.PATCHING_TEMPLATE) Flow.series(org.jboss.hal.flow.Flow.series) Server(org.jboss.hal.core.runtime.server.Server) Metadata(org.jboss.hal.meta.Metadata) Messages(org.jboss.hal.resources.Messages) FlowContext(org.jboss.hal.flow.FlowContext) Wizard(org.jboss.hal.ballroom.wizard.Wizard)

Aggregations

Messages (org.jboss.hal.resources.Messages)4 Operation (org.jboss.hal.dmr.Operation)3 Property (org.jboss.hal.dmr.Property)3 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)3 Provider (javax.inject.Provider)2 Wizard (org.jboss.hal.ballroom.wizard.Wizard)2 PATCHING_TEMPLATE (org.jboss.hal.client.patching.PatchesColumn.PATCHING_TEMPLATE)2 CHECK_SERVERS (org.jboss.hal.client.patching.wizard.PatchState.CHECK_SERVERS)2 Environment (org.jboss.hal.config.Environment)2 Server (org.jboss.hal.core.runtime.server.Server)2 ServerActions (org.jboss.hal.core.runtime.server.ServerActions)2 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)2 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)2 Flow.series (org.jboss.hal.flow.Flow.series)2 FlowContext (org.jboss.hal.flow.FlowContext)2 Outcome (org.jboss.hal.flow.Outcome)2 Progress (org.jboss.hal.flow.Progress)2 Task (org.jboss.hal.flow.Task)2 Metadata (org.jboss.hal.meta.Metadata)2 StatementContext (org.jboss.hal.meta.StatementContext)2