use of org.jboss.hal.core.deployment.Content in project console by hal.
the class ContentColumn method undeploy.
private void undeploy(Content content) {
if (!content.getServerGroupDeployments().isEmpty()) {
Set<String> serverGroupsWithContent = content.getServerGroupDeployments().stream().map(ServerGroupDeployment::getServerGroup).collect(toSet());
new DeployContentDialog1(content, serverGroupsWithContent, resources, (cnt, serverGroups) -> {
List<Operation> operations = serverGroups.stream().map(serverGroup -> {
ResourceAddress resourceAddress = new ResourceAddress().add(SERVER_GROUP, serverGroup).add(DEPLOYMENT, content.getName());
return new Operation.Builder(resourceAddress, REMOVE).build();
}).collect(toList());
dispatcher.execute(new Composite(operations), (CompositeResult cr) -> {
refresh(RESTORE_SELECTION);
MessageEvent.fire(eventBus, Message.success(resources.messages().contentUndeployed(content.getName())));
});
}).show();
} else {
MessageEvent.fire(eventBus, Message.warning(resources.messages().undeployedContent(content.getName())));
}
}
use of org.jboss.hal.core.deployment.Content in project console by hal.
the class ContentPreview method update.
@Override
public void update(Content content) {
attributes.refresh(content);
boolean undeployed = content.getServerGroupDeployments().isEmpty();
boolean unmanaged = !content.isManaged();
boolean exploded = content.isExploded();
Elements.setVisible(deploymentsDiv, !undeployed);
Elements.setVisible(undeployedContentDiv, undeployed);
Elements.setVisible(infoExplodedDiv, !unmanaged && exploded);
if (!undeployed) {
Elements.removeChildrenFrom(deploymentsUl);
content.getServerGroupDeployments().forEach(sgd -> {
String serverGroup = sgd.getServerGroup();
PlaceRequest serverGroupPlaceRequest = places.finderPlace(NameTokens.DEPLOYMENTS, new FinderPath().append(Ids.DEPLOYMENT_BROWSE_BY, Ids.asId(Names.SERVER_GROUPS)).append(Ids.DEPLOYMENT_SERVER_GROUP, Ids.serverGroup(serverGroup)).append(Ids.SERVER_GROUP_DEPLOYMENT, Ids.serverGroupDeployment(serverGroup, content.getName()))).build();
String serverGroupToken = places.historyToken(serverGroupPlaceRequest);
HTMLElement li = li().add(a(serverGroupToken).textContent(serverGroup)).element();
if (authorisationDecision.isAllowed(Constraint.executable(SERVER_GROUP_DEPLOYMENT_TEMPLATE, ADD))) {
li.appendChild(span().textContent(" (").element());
li.appendChild(a().css(clickable).on(click, event -> column.undeploy(content, serverGroup)).textContent(resources.constants().undeploy()).element());
li.appendChild(span().textContent(")").element());
}
deploymentsUl.appendChild(li);
});
}
}
use of org.jboss.hal.core.deployment.Content in project console by hal.
the class BrowseContentPresenter method reload.
@Override
protected void reload() {
if (ManagementModel.supportsReadContentFromDeployment(environment.getManagementVersion())) {
ResourceAddress address = new ResourceAddress().add(DEPLOYMENT, content);
Operation operation = new Operation.Builder(address, READ_RESOURCE_OPERATION).param(INCLUDE_RUNTIME, true).build();
dispatcher.execute(operation, result -> getView().setContent(new Content(result)));
} else {
// TODO Fallback when browse-content is not supported
}
}
use of org.jboss.hal.core.deployment.Content in project console by hal.
the class ContentColumn method uploadContent.
private void uploadContent() {
Metadata metadata = metadataRegistry.lookup(CONTENT_TEMPLATE);
Wizard<DeploymentContext, DeploymentState> wizard = new Wizard.Builder<DeploymentContext, DeploymentState>(resources.messages().addResourceTitle(resources.constants().content()), new DeploymentContext()).addStep(UPLOAD, new UploadContentStep(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().uploadInProgress(), resources.messages().uploadInProgress(name));
series(new FlowContext(progress.get()), new CheckDeployment(dispatcher, name), new UploadOrReplace(environment, dispatcher, name, runtimeName, context.file, false)).subscribe(new Outcome<FlowContext>() {
@Override
public void onError(FlowContext context, Throwable error) {
wzd.showError(resources.constants().uploadError(), resources.messages().uploadError(name), error.getMessage());
}
@Override
public void onSuccess(FlowContext context) {
refresh(Ids.content(name));
wzd.showSuccess(resources.constants().uploadSuccessful(), resources.messages().uploadSuccessful(name), resources.messages().view(resources.constants().content()), cxt -> {
/* nothing to do, content is already selected */
});
}
});
}).build();
wizard.show();
}
use of org.jboss.hal.core.deployment.Content in project console by hal.
the class ContentColumn method deploy.
void deploy(Content content) {
Operation operation = new Operation.Builder(ResourceAddress.root(), READ_CHILDREN_NAMES_OPERATION).param(CHILD_TYPE, SERVER_GROUP).build();
dispatcher.execute(operation, result -> {
Set<String> serverGroupsWithoutContent = result.asList().stream().map(ModelNode::asString).collect(toSet());
Set<String> serverGroupsWithContent = content.getServerGroupDeployments().stream().map(ServerGroupDeployment::getServerGroup).collect(toSet());
serverGroupsWithoutContent.removeAll(serverGroupsWithContent);
if (serverGroupsWithoutContent.isEmpty()) {
MessageEvent.fire(eventBus, Message.warning(resources.messages().contentAlreadyDeployedToAllServerGroups(content.getName())));
} else {
new DeployContentDialog1(content, serverGroupsWithoutContent, resources, (cnt, serverGroups, enable) -> {
List<Operation> operations = serverGroups.stream().map(serverGroup -> {
ResourceAddress resourceAddress = new ResourceAddress().add(SERVER_GROUP, serverGroup).add(DEPLOYMENT, content.getName());
return new Operation.Builder(resourceAddress, ADD).param(RUNTIME_NAME, content.getRuntimeName()).param(ENABLED, enable).build();
}).collect(toList());
if (enable) {
ItemMonitor.startProgress(Ids.content(cnt.getName()));
}
dispatcher.execute(new Composite(operations), (CompositeResult cr) -> {
if (enable) {
ItemMonitor.stopProgress(Ids.content(cnt.getName()));
}
refresh(RESTORE_SELECTION);
MessageEvent.fire(eventBus, Message.success(resources.messages().contentDeployed1(content.getName())));
});
}).show();
}
});
}
Aggregations