Search in sources :

Example 1 with CHECK_SERVERS

use of org.jboss.hal.client.patching.wizard.PatchState.CHECK_SERVERS 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 2 with CHECK_SERVERS

use of org.jboss.hal.client.patching.wizard.PatchState.CHECK_SERVERS 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

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 Operation (org.jboss.hal.dmr.Operation)2 Property (org.jboss.hal.dmr.Property)2 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)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 Messages (org.jboss.hal.resources.Messages)2