Skip to content

Commit

Permalink
HAL-1953: fix unmanaged deployment for server groups
Browse files Browse the repository at this point in the history
  • Loading branch information
michpetrov committed Jan 4, 2024
1 parent 4f77e0e commit 8ac5a7b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 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 @@ -250,7 +250,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 +282,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 (runtimeName != null) {
builder.param(RUNTIME_NAME, runtimeName);
}
Operation operation = builder.build();
return dispatcher.execute(operation).then(__ -> Promise.resolve(context));
}
}
Expand Down

0 comments on commit 8ac5a7b

Please sign in to comment.