diff --git a/app/src/main/java/org/jboss/hal/client/deployment/AbstractDeploymentColumn.java b/app/src/main/java/org/jboss/hal/client/deployment/AbstractDeploymentColumn.java index 184e4294cb..321b1e02c2 100644 --- a/app/src/main/java/org/jboss/hal/client/deployment/AbstractDeploymentColumn.java +++ b/app/src/main/java/org/jboss/hal/client/deployment/AbstractDeploymentColumn.java @@ -251,8 +251,11 @@ public AbstractDeploymentColumn(Builder builder, ColumnActionFactory columnAc COLUMN_UPLOAD_ACTION = createColumnAction(columnProps.actionDeploymentId, columnProps.actionDeploymentTitle, column -> uploadDeployment()); - COLUMN_ADD_UNMANAGED_ACTION = createColumnAction(columnProps.actionUnmanagedId, - resources.messages().addResourceTitle(Names.UNMANAGED_DEPLOYMENT), column -> addUnmanaged()); + COLUMN_ADD_UNMANAGED_ACTION = new ColumnAction.Builder(columnProps.actionUnmanagedId) + .title(Names.UNMANAGED_DEPLOYMENT) + .handler(column -> addUnmanaged()) + .constraint(Constraint.executable(DEPLOYMENT_TEMPLATE, ADD)) + .build(); COLUMN_ADD_EMPTY_ACTION = createColumnAction(Ids.DEPLOYMENT_EMPTY_CREATE, resources.constants().deploymentEmptyCreate(), column -> createEmpty()); COLUMN_ADD_FROM_REPOSITORY_ACTION = createColumnAction(Ids.SERVER_GROUP_DEPLOYMENT_ADD, @@ -607,11 +610,11 @@ private String extractDataSources(List dataSourceList) { /* unmanaged deployment */ protected void addUnmanaged() { - Metadata metadata = metadataRegistry.lookup(columnProps.template); + Metadata metadata = metadataRegistry.lookup(DEPLOYMENT_TEMPLATE); AddUnmanagedDialog dialog = new AddUnmanagedDialog(metadata, resources, (name, model) -> { if (model != null) { - String runtimeName = model.get(RUNTIME_NAME).asString(); + String runtimeName = model.hasDefined(RUNTIME_NAME) ? model.get(RUNTIME_NAME).asString() : null; List> tasks = new ArrayList<>(); tasks.add(new DeploymentTasks.AddUnmanagedDeployment(dispatcher, name, model)); if (columnProps.columnType == ColumnType.SERVER_GROUP) { @@ -623,6 +626,12 @@ protected void addUnmanaged() { MessageEvent.fire(eventBus, Message.success(resources.messages() .addResourceSuccess(Names.UNMANAGED_DEPLOYMENT, name))); return null; + }) + .catch_(error -> { + MessageEvent.fire(eventBus, + Message.error(columnProps.getDeploymentErrorText.apply(name), + String.valueOf(error))); + return null; }); } }); @@ -857,6 +866,12 @@ void deploy(Content content) { refresh(CLEAR_SELECTION); MessageEvent.fire(eventBus, Message.success(resources.messages().contentDeployed1(content.getName()))); + }, (__, error) -> { + if (enable) { + ItemMonitor.stopProgress(Ids.content(cnt.getName())); + } + MessageEvent.fire(eventBus, + Message.error(columnProps.getDeploymentErrorText.apply(content.getName()), error)); }); }).show(); } diff --git a/app/src/main/java/org/jboss/hal/client/deployment/DeploymentTasks.java b/app/src/main/java/org/jboss/hal/client/deployment/DeploymentTasks.java index 786e4cdff8..0053e67b2c 100644 --- a/app/src/main/java/org/jboss/hal/client/deployment/DeploymentTasks.java +++ b/app/src/main/java/org/jboss/hal/client/deployment/DeploymentTasks.java @@ -47,6 +47,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.base.Strings; import com.google.common.collect.Lists; import com.google.gwt.safehtml.shared.SafeHtml; import com.google.web.bindery.event.shared.EventBus; @@ -250,7 +251,7 @@ public Promise apply(final FlowContext context) { } } - /** Deploys the specified content to the specified server group. The deployment is not enable on the server group. */ + /** Deploys the specified content to the specified server group. The deployment will be enabled on the server group. */ static final class AddServerGroupDeployment implements Task { private final Environment environment; @@ -282,10 +283,12 @@ public Promise apply(final FlowContext context) { ResourceAddress address = new ResourceAddress() .add(SERVER_GROUP, serverGroup) .add(DEPLOYMENT, name); - Operation operation = new Operation.Builder(address, ADD) - .param(RUNTIME_NAME, runtimeName) - .param(ENABLED, true) - .build(); + Operation.Builder builder = new Operation.Builder(address, ADD) + .param(ENABLED, true); + if (!Strings.isNullOrEmpty(runtimeName)) { + builder.param(RUNTIME_NAME, runtimeName); + } + Operation operation = builder.build(); return dispatcher.execute(operation).then(__ -> Promise.resolve(context)); } } @@ -465,15 +468,16 @@ public Promise apply(final FlowContext context) { if (replace) { builder = new Operation.Builder(ResourceAddress.root(), FULL_REPLACE_DEPLOYMENT) // NON-NLS - .param(NAME, name) - .param(RUNTIME_NAME, runtimeName); + .param(NAME, name); // leave "enabled" as undefined to indicate that the state of the existing deployment should be retained } else { builder = new Operation.Builder(new ResourceAddress().add(DEPLOYMENT, name), ADD) - .param(RUNTIME_NAME, runtimeName) .param(ENABLED, enabled); } + if (!Strings.isNullOrEmpty(runtimeName)) { + builder.param(RUNTIME_NAME, runtimeName); + } Operation operation = builder.build(); operation.get(CONTENT).add().get(INPUT_STREAM_INDEX).set(0); // NON-NLS