Search in sources :

Example 1 with SERVER_MANAGEMENT

use of org.kie.workbench.common.services.shared.resources.PerspectiveIds.SERVER_MANAGEMENT in project kie-wb-common by kiegroup.

the class AbstractBuildAndDeployExecutor method saveContainerSpecAndMaybeStartContainer.

protected void saveContainerSpecAndMaybeStartContainer(final BuildExecutionContext context, final ContainerSpec containerSpec) {
    specManagementService.call(ignore -> {
        if (!context.isStartContainer()) {
            notificationEvent.fire(new NotificationEvent(CONSTANTS.DeploySuccessful(), NotificationEvent.NotificationType.SUCCESS).setAutoHide(false).setNavigation(CONSTANTS.ViewDeploymentDetails(), new DefaultPlaceRequest(SERVER_MANAGEMENT)));
            finish();
            return;
        }
        specManagementService.call(ignore2 -> {
            notificationEvent.fire(new NotificationEvent(CONSTANTS.DeploySuccessfulAndContainerStarted(), NotificationEvent.NotificationType.SUCCESS).setAutoHide(false).setNavigation(CONSTANTS.ViewDeploymentDetails(), new DefaultPlaceRequest(SERVER_MANAGEMENT)));
            finish();
        }, (o, throwable) -> {
            notificationEvent.fire(new NotificationEvent(CONSTANTS.DeploySuccessfulButContainerFailedToStart(), NotificationEvent.NotificationType.WARNING).setAutoHide(false).setNavigation(CONSTANTS.ViewDeploymentDetails(), new DefaultPlaceRequest(SERVER_MANAGEMENT)));
            finish();
            return false;
        }).startContainer(containerSpec);
    }, (o, throwable) -> {
        notificationEvent.fire(new NotificationEvent(CONSTANTS.DeployFailed(), NotificationEvent.NotificationType.ERROR).setAutoHide(false).setNavigation(CONSTANTS.ViewDeploymentDetails(), new DefaultPlaceRequest(SERVER_MANAGEMENT)));
        finish();
        return false;
    }).saveContainerSpec(context.getServerTemplate().getId(), containerSpec);
}
Also used : ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) BuildDialog(org.kie.workbench.common.screens.projecteditor.client.build.exec.dialog.BuildDialog) KieServerMode(org.kie.server.api.model.KieServerMode) ServerTemplateList(org.kie.server.controller.api.model.spec.ServerTemplateList) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) CONSTANTS(org.kie.workbench.common.screens.projecteditor.client.resources.ProjectEditorResources.CONSTANTS) BuildExecutionContext(org.kie.workbench.common.screens.projecteditor.client.build.exec.BuildExecutionContext) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest) DeploymentPopup(org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentPopup) ERROR(org.uberfire.workbench.events.NotificationEvent.NotificationType.ERROR) SpecManagementService(org.kie.workbench.common.screens.server.management.service.SpecManagementService) BuildService(org.guvnor.common.services.project.builder.service.BuildService) SERVER_MANAGEMENT(org.kie.workbench.common.services.shared.resources.PerspectiveIds.SERVER_MANAGEMENT) Event(javax.enterprise.event.Event) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) AbstractExecutor(org.kie.workbench.common.screens.projecteditor.client.build.exec.impl.executors.AbstractExecutor) Predicate(java.util.function.Predicate) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) Collectors(java.util.stream.Collectors) List(java.util.List) DeploymentMode(org.guvnor.common.services.project.service.DeploymentMode) Message(org.jboss.errai.bus.client.api.messaging.Message) Stream(java.util.stream.Stream) BuildUtils(org.kie.workbench.common.screens.projecteditor.client.build.exec.impl.executors.utils.BuildUtils) SUCCESS(org.uberfire.workbench.events.NotificationEvent.NotificationType.SUCCESS) Caller(org.jboss.errai.common.client.api.Caller) Optional(java.util.Optional) ContextValidator(org.kie.workbench.common.screens.projecteditor.client.build.exec.impl.executors.ContextValidator) Collections(java.util.Collections) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest)

Example 2 with SERVER_MANAGEMENT

use of org.kie.workbench.common.services.shared.resources.PerspectiveIds.SERVER_MANAGEMENT in project kie-wb-common by kiegroup.

the class AbstractBuildAndDeployExecutor method updateContainerSpec.

protected void updateContainerSpec(final BuildExecutionContext context, final ContainerSpec containerSpec) {
    ServerTemplate serverTemplate = context.getServerTemplate();
    if (serverTemplate.getMode().equals(KieServerMode.DEVELOPMENT)) {
        containerSpec.setStatus(serverTemplate.getContainerSpec(containerSpec.getId()).getStatus());
        specManagementService.call(ignore -> {
            notifyUpdateSuccess();
        }, (o, throwable) -> {
            notifyUpdateError();
            return false;
        }).updateContainerSpec(context.getServerTemplate().getId(), containerSpec);
    } else {
        notificationEvent.fire(new NotificationEvent(CONSTANTS.DeploymentSkippedCannotUpdateDeploymentsOnProduction(), ERROR).setAutoHide(false).setNavigation(CONSTANTS.ViewDeploymentDetails(), new DefaultPlaceRequest(SERVER_MANAGEMENT)));
        finish();
    }
}
Also used : ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) BuildDialog(org.kie.workbench.common.screens.projecteditor.client.build.exec.dialog.BuildDialog) KieServerMode(org.kie.server.api.model.KieServerMode) ServerTemplateList(org.kie.server.controller.api.model.spec.ServerTemplateList) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) CONSTANTS(org.kie.workbench.common.screens.projecteditor.client.resources.ProjectEditorResources.CONSTANTS) BuildExecutionContext(org.kie.workbench.common.screens.projecteditor.client.build.exec.BuildExecutionContext) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest) DeploymentPopup(org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentPopup) ERROR(org.uberfire.workbench.events.NotificationEvent.NotificationType.ERROR) SpecManagementService(org.kie.workbench.common.screens.server.management.service.SpecManagementService) BuildService(org.guvnor.common.services.project.builder.service.BuildService) SERVER_MANAGEMENT(org.kie.workbench.common.services.shared.resources.PerspectiveIds.SERVER_MANAGEMENT) Event(javax.enterprise.event.Event) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) AbstractExecutor(org.kie.workbench.common.screens.projecteditor.client.build.exec.impl.executors.AbstractExecutor) Predicate(java.util.function.Predicate) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) Collectors(java.util.stream.Collectors) List(java.util.List) DeploymentMode(org.guvnor.common.services.project.service.DeploymentMode) Message(org.jboss.errai.bus.client.api.messaging.Message) Stream(java.util.stream.Stream) BuildUtils(org.kie.workbench.common.screens.projecteditor.client.build.exec.impl.executors.utils.BuildUtils) SUCCESS(org.uberfire.workbench.events.NotificationEvent.NotificationType.SUCCESS) Caller(org.jboss.errai.common.client.api.Caller) Optional(java.util.Optional) ContextValidator(org.kie.workbench.common.screens.projecteditor.client.build.exec.impl.executors.ContextValidator) Collections(java.util.Collections) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest)

Aggregations

Collections (java.util.Collections)2 List (java.util.List)2 Optional (java.util.Optional)2 Predicate (java.util.function.Predicate)2 Collectors (java.util.stream.Collectors)2 Stream (java.util.stream.Stream)2 Event (javax.enterprise.event.Event)2 BuildResults (org.guvnor.common.services.project.builder.model.BuildResults)2 BuildService (org.guvnor.common.services.project.builder.service.BuildService)2 DeploymentMode (org.guvnor.common.services.project.service.DeploymentMode)2 Message (org.jboss.errai.bus.client.api.messaging.Message)2 Caller (org.jboss.errai.common.client.api.Caller)2 ErrorCallback (org.jboss.errai.common.client.api.ErrorCallback)2 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)2 KieServerMode (org.kie.server.api.model.KieServerMode)2 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)2 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)2 ServerTemplateList (org.kie.server.controller.api.model.spec.ServerTemplateList)2 BuildExecutionContext (org.kie.workbench.common.screens.projecteditor.client.build.exec.BuildExecutionContext)2 BuildDialog (org.kie.workbench.common.screens.projecteditor.client.build.exec.dialog.BuildDialog)2