Skip to content

Commit

Permalink
Merge pull request #1045 from michpetrov/hal-1953
Browse files Browse the repository at this point in the history
HAL-1953: fix unmanaged deployment for server groups
  • Loading branch information
hpehl authored Jan 5, 2024
2 parents 92a492c + 0d8ea3f commit b08cd94
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,11 @@ public AbstractDeploymentColumn(Builder<T> 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<T>(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,
Expand Down Expand Up @@ -607,11 +610,11 @@ private String extractDataSources(List<DataSource> 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<Task<FlowContext>> tasks = new ArrayList<>();
tasks.add(new DeploymentTasks.AddUnmanagedDeployment(dispatcher, name, model));
if (columnProps.columnType == ColumnType.SERVER_GROUP) {
Expand All @@ -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;
});
}
});
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -250,7 +251,7 @@ public Promise<FlowContext> 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<FlowContext> {

private final Environment environment;
Expand Down Expand Up @@ -282,10 +283,12 @@ public Promise<FlowContext> 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));
}
}
Expand Down Expand Up @@ -465,15 +468,16 @@ public Promise<FlowContext> 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

Expand Down

0 comments on commit b08cd94

Please sign in to comment.