Search in sources :

Example 11 with Outcome

use of org.jboss.hal.flow.Outcome 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();
}
Also used : Dialog(org.jboss.hal.ballroom.dialog.Dialog) Provider(javax.inject.Provider) Environment(org.jboss.hal.config.Environment) Deployment(org.jboss.hal.core.deployment.Deployment) Constraint(org.jboss.hal.meta.security.Constraint) ItemActionFactory(org.jboss.hal.core.finder.ItemActionFactory) StatementContext(org.jboss.hal.meta.StatementContext) ItemDisplay(org.jboss.hal.core.finder.ItemDisplay) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) ManagementModel(org.jboss.hal.meta.ManagementModel) CheckDeployment(org.jboss.hal.client.deployment.DeploymentTasks.CheckDeployment) CreateEmptyDialog(org.jboss.hal.client.deployment.dialog.CreateEmptyDialog) UploadDeploymentStep(org.jboss.hal.client.deployment.wizard.UploadDeploymentStep) UploadOrReplace(org.jboss.hal.client.deployment.DeploymentTasks.UploadOrReplace) Column(org.jboss.hal.spi.Column) HTMLElement(elemental2.dom.HTMLElement) Message(org.jboss.hal.spi.Message) Server(org.jboss.hal.core.runtime.server.Server) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) DEPLOYMENT_ADDRESS(org.jboss.hal.client.deployment.StandaloneDeploymentColumn.DEPLOYMENT_ADDRESS) DeploymentState(org.jboss.hal.client.deployment.wizard.DeploymentState) ServerActions(org.jboss.hal.core.runtime.server.ServerActions) DeploymentContext(org.jboss.hal.client.deployment.wizard.DeploymentContext) CrudOperations(org.jboss.hal.core.CrudOperations) AddUnmanagedDialog(org.jboss.hal.client.deployment.dialog.AddUnmanagedDialog) NAMES(org.jboss.hal.client.deployment.wizard.DeploymentState.NAMES) List(java.util.List) Status(org.jboss.hal.core.deployment.Deployment.Status) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) CLEAR_SELECTION(org.jboss.hal.core.finder.FinderColumn.RefreshMode.CLEAR_SELECTION) Flow.series(org.jboss.hal.flow.Flow.series) Finder(org.jboss.hal.core.finder.Finder) Footer(org.jboss.hal.spi.Footer) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) ModelNode(org.jboss.hal.dmr.ModelNode) MessageEvent(org.jboss.hal.spi.MessageEvent) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) ColumnAction(org.jboss.hal.core.finder.ColumnAction) ItemAction(org.jboss.hal.core.finder.ItemAction) FlowContext(org.jboss.hal.flow.FlowContext) Outcome(org.jboss.hal.flow.Outcome) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) JsHelper(org.jboss.hal.js.JsHelper) Progress(org.jboss.hal.flow.Progress) AddressTemplate(org.jboss.hal.meta.AddressTemplate) AddUnmanagedDeployment(org.jboss.hal.client.deployment.DeploymentTasks.AddUnmanagedDeployment) UPLOAD(org.jboss.hal.client.deployment.wizard.DeploymentState.UPLOAD) RESTORE_SELECTION(org.jboss.hal.core.finder.FinderColumn.RefreshMode.RESTORE_SELECTION) FinderColumn(org.jboss.hal.core.finder.FinderColumn) ColumnActionFactory(org.jboss.hal.core.finder.ColumnActionFactory) Requires(org.jboss.hal.spi.Requires) CompositeResult(org.jboss.hal.dmr.CompositeResult) Operation(org.jboss.hal.dmr.Operation) NamesStep(org.jboss.hal.client.deployment.wizard.NamesStep) Ids(org.jboss.hal.resources.Ids) Wizard(org.jboss.hal.ballroom.wizard.Wizard) EventBus(com.google.web.bindery.event.shared.EventBus) CSS.pfIcon(org.jboss.hal.resources.CSS.pfIcon) ItemMonitor(org.jboss.hal.core.finder.ItemMonitor) Consumer(java.util.function.Consumer) Composite(org.jboss.hal.dmr.Composite) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Collectors.toList(java.util.stream.Collectors.toList) NameTokens(org.jboss.hal.meta.token.NameTokens) Resources(org.jboss.hal.resources.Resources) Strings(org.jboss.hal.resources.Strings) UploadElement(org.jboss.hal.client.shared.uploadwizard.UploadElement) Elements.span(org.jboss.gwt.elemento.core.Elements.span) DeploymentState(org.jboss.hal.client.deployment.wizard.DeploymentState) CheckDeployment(org.jboss.hal.client.deployment.DeploymentTasks.CheckDeployment) Metadata(org.jboss.hal.meta.Metadata) FlowContext(org.jboss.hal.flow.FlowContext) DeploymentContext(org.jboss.hal.client.deployment.wizard.DeploymentContext) UploadOrReplace(org.jboss.hal.client.deployment.DeploymentTasks.UploadOrReplace) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) Outcome(org.jboss.hal.flow.Outcome) UploadDeploymentStep(org.jboss.hal.client.deployment.wizard.UploadDeploymentStep) NamesStep(org.jboss.hal.client.deployment.wizard.NamesStep) Wizard(org.jboss.hal.ballroom.wizard.Wizard)

Example 12 with Outcome

use of org.jboss.hal.flow.Outcome 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);
        }
    });
}
Also used : StatementContext(org.jboss.hal.meta.StatementContext) FlowContext(org.jboss.hal.flow.FlowContext) Completable(rx.Completable) DataSourceWizard.addOperation(org.jboss.hal.client.configuration.subsystem.datasource.wizard.DataSourceWizard.addOperation) CSS.blankSlatePf(org.jboss.hal.resources.CSS.blankSlatePf) Elements.div(org.jboss.gwt.elemento.core.Elements.div) Provider(javax.inject.Provider) Environment(org.jboss.hal.config.Environment) StatementContext(org.jboss.hal.meta.StatementContext) CSS.btnLg(org.jboss.hal.resources.CSS.btnLg) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) FlowContext(org.jboss.hal.flow.FlowContext) Outcome(org.jboss.hal.flow.Outcome) ArrayList(java.util.ArrayList) CSS.btnPrimary(org.jboss.hal.resources.CSS.btnPrimary) Task(org.jboss.hal.flow.Task) TopologyTasks(org.jboss.hal.core.runtime.TopologyTasks) Progress(org.jboss.hal.flow.Progress) HTMLElement(elemental2.dom.HTMLElement) TopologyTasks.runningServers(org.jboss.hal.core.runtime.TopologyTasks.runningServers) Server(org.jboss.hal.core.runtime.server.Server) ModelNodeHelper.properties(org.jboss.hal.dmr.ModelNodeHelper.properties) SafeHtmlUtils(com.google.gwt.safehtml.shared.SafeHtmlUtils) Elements.button(org.jboss.gwt.elemento.core.Elements.button) CompositeResult(org.jboss.hal.dmr.CompositeResult) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) EventType.click(org.jboss.gwt.elemento.core.EventType.click) CSS.btn(org.jboss.hal.resources.CSS.btn) List(java.util.List) WizardStep(org.jboss.hal.ballroom.wizard.WizardStep) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Resources(org.jboss.hal.resources.Resources) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) FlowException(org.jboss.hal.flow.FlowException) Flow.series(org.jboss.hal.flow.Flow.series) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Task(org.jboss.hal.flow.Task) Server(org.jboss.hal.core.runtime.server.Server) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CompositeResult(org.jboss.hal.dmr.CompositeResult) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ArrayList(java.util.ArrayList) DataSourceWizard.addOperation(org.jboss.hal.client.configuration.subsystem.datasource.wizard.DataSourceWizard.addOperation) Operation(org.jboss.hal.dmr.Operation) FlowContext(org.jboss.hal.flow.FlowContext) FlowException(org.jboss.hal.flow.FlowException)

Example 13 with Outcome

use of org.jboss.hal.flow.Outcome in project console by hal.

the class ManagementOperationsPresenter method reload.

@Override
protected void reload() {
    if (environment.isStandalone()) {
        ResourceAddress addressFindNP = MANAGEMENT_OPERATIONS_TEMPLATE.resolve(statementContext);
        Operation operationFindNP = new Operation.Builder(addressFindNP, FIND_NON_PROGRESSING_OPERATION).build();
        ResourceAddress addressMO = MANAGEMENT_OPERATIONS_TEMPLATE.resolve(statementContext);
        Operation operationMO = new Operation.Builder(addressMO, READ_CHILDREN_RESOURCES_OPERATION).param(CHILD_TYPE, ACTIVE_OPERATION).build();
        dispatcher.execute(new Composite(operationFindNP, operationMO), (CompositeResult result) -> {
            ModelNode resultNP = result.step(0).get(RESULT);
            ModelNode resultOperations = result.step(1).get(RESULT);
            final String nonProgressingId = resultNP.isDefined() ? resultNP.asString() : null;
            List<ManagementOperations> activeOps = asNamedNodes(resultOperations.asPropertyList()).stream().map(ManagementOperations::new).peek(activeOp -> {
                if (nonProgressingId != null && nonProgressingId.equals(activeOp.getName())) {
                    activeOp.setAsNonProgressing();
                }
            }).collect(toList());
            getView().update(activeOps);
        });
    } else {
        // return available hosts, to later call a find-non-progressing-operation on each host
        Task<FlowContext> hostsTask = context -> {
            ResourceAddress address = new ResourceAddress();
            Operation operation = new Operation.Builder(address, READ_CHILDREN_NAMES_OPERATION).param(CHILD_TYPE, HOST).build();
            return dispatcher.execute(operation).doOnSuccess(result -> {
                List<String> hosts = result.asList().stream().map(ModelNode::asString).collect(toList());
                context.set(HOSTS, hosts);
            }).toCompletable();
        };
        // return running servers, to later call a find-non-progressing-operation on each runtime server
        Task<FlowContext> serversTask = context -> {
            // /host=*/server=*:query(select=[host,name],where={server-state=running})
            ResourceAddress address = new ResourceAddress().add(HOST, WILDCARD).add(SERVER, WILDCARD);
            Operation operation = new Operation.Builder(address, QUERY).param(SELECT, new ModelNode().add(HOST).add(NAME)).param(WHERE, new ModelNode().set(SERVER_STATE, "running")).build();
            return dispatcher.execute(operation).doOnSuccess(result -> {
                List<String> servers = Collections.emptyList();
                if (result != null && result.isDefined()) {
                    servers = result.asList().stream().map(r -> hostServerAddress(r.get(RESULT))).collect(toList());
                }
                context.set("servers", servers);
            }).toCompletable();
        };
        // call find-non-progressing-operation and read-resource of active operations
        // on each host and server
        Task<FlowContext> findNonProgressingTask = context -> {
            List<String> hosts = context.get(HOSTS);
            List<String> servers = context.get("servers");
            Composite composite = new Composite();
            for (String host : hosts) {
                ResourceAddress address = new ResourceAddress().add(HOST, host).add(CORE_SERVICE, MANAGEMENT).add(SERVICE, MANAGEMENT_OPERATIONS);
                Operation operation = new Operation.Builder(address, FIND_NON_PROGRESSING_OPERATION).build();
                composite.add(operation);
                ResourceAddress ad = new ResourceAddress(address.clone()).add(ACTIVE_OPERATION, WILDCARD);
                Operation operationMO = new Operation.Builder(ad, READ_RESOURCE_OPERATION).build();
                composite.add(operationMO);
            }
            if (!servers.isEmpty()) {
                for (String server : servers) {
                    ResourceAddress address = AddressTemplate.of(server).append(MANAGEMENT_OPERATIONS_TEMPLATE).resolve(statementContext);
                    Operation findOp = new Operation.Builder(address, FIND_NON_PROGRESSING_OPERATION).build();
                    composite.add(findOp);
                    ResourceAddress ad = new ResourceAddress(address.clone()).add(ACTIVE_OPERATION, WILDCARD);
                    Operation operation = new Operation.Builder(ad, READ_RESOURCE_OPERATION).build();
                    composite.add(operation);
                }
            }
            return dispatcher.execute(composite).doOnSuccess(response -> {
                List<String> nonProgressingOps = new ArrayList<>();
                List<ManagementOperations> ops = new ArrayList<>();
                for (ModelNode r : response) {
                    ModelNode result = r.get(RESULT);
                    if (result != null && result.isDefined()) {
                        ModelType type = result.getType();
                        // if model is LIST it is the list of active operations
                        if (ModelType.LIST.equals(type)) {
                            for (ModelNode op : result.asList()) {
                                ModelNode opResult = op.get(RESULT);
                                // the result has two addresses
                                // 1) the active-operation address itself, example
                                // /host=master/server=server-three/core-service=management/service=management-operations/active-operation=1940701884
                                // 2) the resource address
                                // /host=master/server=server-three/subsystem=elytron/filesystem-realm=file1
                                // the active-operation address should be store to later use it to cancel, if needed
                                // the resource address is displayed to the user
                                ModelNode activeOpAddress = op.get(ADDRESS);
                                opResult.get(HAL_ACTIVE_OP_ADDRESS).set(activeOpAddress);
                                String opId = null;
                                List<Property> activeOperationAddressList = activeOpAddress.asPropertyList();
                                for (Property p : activeOperationAddressList) {
                                    if (p.getName().equals(ACTIVE_OPERATION)) {
                                        opId = p.getValue().asString();
                                    }
                                    // store the host and server to later show in the view
                                    if (p.getName().equals(HOST)) {
                                        opResult.get(HAL_ACTIVE_ADDRESS_HOST).set(p.getValue().asString());
                                    }
                                    if (p.getName().equals(SERVER)) {
                                        opResult.get(HAL_ACTIVE_ADDRESS_SERVER).set(p.getValue().asString());
                                    }
                                }
                                NamedNode node = new NamedNode(opId, opResult);
                                ManagementOperations activeOp = new ManagementOperations(node);
                                ops.add(activeOp);
                            }
                        } else {
                            nonProgressingOps.add(result.asString());
                        }
                    }
                }
                // if there are non progressing operations, mark them in the list
                if (!nonProgressingOps.isEmpty()) {
                    Collections.sort(nonProgressingOps);
                    for (ManagementOperations mop : ops) {
                        if (nonProgressingOps.indexOf(mop.getName()) > -1) {
                            mop.setAsNonProgressing();
                        }
                    }
                }
                context.set("active-operations", ops);
            }).toCompletable();
        };
        series(new FlowContext(progress.get()), hostsTask, serversTask, findNonProgressingTask).subscribe(new Outcome<FlowContext>() {

            @Override
            public void onError(FlowContext context, Throwable error) {
                MessageEvent.fire(getEventBus(), Message.error(SafeHtmlUtils.fromString("Error loading management operations: " + error.getMessage())));
            }

            @Override
            public void onSuccess(FlowContext context) {
                List<ManagementOperations> ops = context.get("active-operations");
                getView().update(ops);
            }
        });
    }
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) Completable(rx.Completable) Provider(javax.inject.Provider) Environment(org.jboss.hal.config.Environment) StatementContext(org.jboss.hal.meta.StatementContext) MessageEvent(org.jboss.hal.spi.MessageEvent) ProxyPlace(com.gwtplatform.mvp.client.proxy.ProxyPlace) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) FlowContext(org.jboss.hal.flow.FlowContext) Outcome(org.jboss.hal.flow.Outcome) ArrayList(java.util.ArrayList) ModelType(org.jboss.hal.dmr.ModelType) Inject(javax.inject.Inject) Property(org.jboss.hal.dmr.Property) Task(org.jboss.hal.flow.Task) Single(rx.Single) Progress(org.jboss.hal.flow.Progress) AddressTemplate(org.jboss.hal.meta.AddressTemplate) Message(org.jboss.hal.spi.Message) HasPresenter(org.jboss.hal.core.mvp.HasPresenter) Names(org.jboss.hal.resources.Names) ApplicationFinderPresenter(org.jboss.hal.core.mvp.ApplicationFinderPresenter) SafeHtmlUtils(com.google.gwt.safehtml.shared.SafeHtmlUtils) ModelNodeHelper.asNamedNodes(org.jboss.hal.dmr.ModelNodeHelper.asNamedNodes) Requires(org.jboss.hal.spi.Requires) CompositeResult(org.jboss.hal.dmr.CompositeResult) ProxyCodeSplit(com.gwtplatform.mvp.client.annotations.ProxyCodeSplit) Operation(org.jboss.hal.dmr.Operation) NameToken(com.gwtplatform.mvp.client.annotations.NameToken) Ids(org.jboss.hal.resources.Ids) FinderPathFactory(org.jboss.hal.core.finder.FinderPathFactory) EventBus(com.google.web.bindery.event.shared.EventBus) FinderPath(org.jboss.hal.core.finder.FinderPath) DialogFactory(org.jboss.hal.ballroom.dialog.DialogFactory) MANAGEMENT_OPERATIONS(org.jboss.hal.meta.token.NameTokens.MANAGEMENT_OPERATIONS) Composite(org.jboss.hal.dmr.Composite) List(java.util.List) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Collectors.toList(java.util.stream.Collectors.toList) Resources(org.jboss.hal.resources.Resources) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) HalView(org.jboss.hal.core.mvp.HalView) Flow.series(org.jboss.hal.flow.Flow.series) Finder(org.jboss.hal.core.finder.Finder) Footer(org.jboss.hal.spi.Footer) NamedNode(org.jboss.hal.dmr.NamedNode) Collections(java.util.Collections) Joiner(com.google.common.base.Joiner) Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CompositeResult(org.jboss.hal.dmr.CompositeResult) ArrayList(java.util.ArrayList) NamedNode(org.jboss.hal.dmr.NamedNode) Operation(org.jboss.hal.dmr.Operation) FlowContext(org.jboss.hal.flow.FlowContext) ModelType(org.jboss.hal.dmr.ModelType) ArrayList(java.util.ArrayList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) ModelNode(org.jboss.hal.dmr.ModelNode) Property(org.jboss.hal.dmr.Property)

Example 14 with Outcome

use of org.jboss.hal.flow.Outcome 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

FlowContext (org.jboss.hal.flow.FlowContext)14 Outcome (org.jboss.hal.flow.Outcome)14 Provider (javax.inject.Provider)12 Environment (org.jboss.hal.config.Environment)12 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)12 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)12 Flow.series (org.jboss.hal.flow.Flow.series)12 Progress (org.jboss.hal.flow.Progress)12 Operation (org.jboss.hal.dmr.Operation)11 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)11 StatementContext (org.jboss.hal.meta.StatementContext)11 Resources (org.jboss.hal.resources.Resources)11 List (java.util.List)10 EventBus (com.google.web.bindery.event.shared.EventBus)9 ArrayList (java.util.ArrayList)9 Collectors.toList (java.util.stream.Collectors.toList)9 Task (org.jboss.hal.flow.Task)9 Ids (org.jboss.hal.resources.Ids)9 Names (org.jboss.hal.resources.Names)9 Composite (org.jboss.hal.dmr.Composite)8