use of org.jboss.hal.dmr.Operation in project console by hal.
the class StandaloneDeploymentColumn method enableDisable.
private void enableDisable(Deployment deployment, String operation, SafeHtml successMessage, SafeHtml errorMessage) {
String id = Ids.deployment(deployment.getName());
ResourceAddress address = new ResourceAddress().add(DEPLOYMENT, deployment.getName());
Operation op = new Operation.Builder(address, operation).build();
ItemMonitor.startProgress(id);
dispatcher.execute(op, result -> {
ItemMonitor.stopProgress(id);
refresh(RESTORE_SELECTION);
MessageEvent.fire(eventBus, Message.success(successMessage));
}, (o, failure) -> {
ItemMonitor.stopProgress(id);
MessageEvent.fire(eventBus, Message.error(errorMessage, failure));
}, (o, exception) -> {
ItemMonitor.stopProgress(id);
MessageEvent.fire(eventBus, Message.error(errorMessage, exception.getMessage()));
});
}
use of org.jboss.hal.dmr.Operation in project console by hal.
the class StandaloneDeploymentColumn method explodeSubs.
private void explodeSubs(Deployment deployment) {
ResourceAddress address = new ResourceAddress().add(DEPLOYMENT, deployment.getName());
Operation disable = new Operation.Builder(address, UNDEPLOY).build();
Composite op = new Composite(disable);
String id = Ids.deployment(deployment.getName());
ItemMonitor.startProgress(id);
deployment.getSubdeployments().forEach(subdeployment -> {
Operation explode = new Operation.Builder(address, EXPLODE).param(PATH, subdeployment.getName()).build();
op.add(explode);
});
dispatcher.execute(op, (Consumer<CompositeResult>) result -> {
enable(deployment);
MessageEvent.fire(eventBus, Message.success(resources.messages().deploymentExploded(deployment.getName())));
}, (operation, failure) -> {
ItemMonitor.stopProgress(id);
SafeHtml message = failure.contains("WFLYDR0015") ? resources.messages().deploymentSubAlreadyExploded() : resources.messages().lastOperationException();
MessageEvent.fire(eventBus, Message.error(message, failure));
});
}
use of org.jboss.hal.dmr.Operation in project console by hal.
the class ContentColumn method createEmpty.
private void createEmpty() {
CreateEmptyDialog dialog = new CreateEmptyDialog(resources, name -> {
ResourceAddress address = CONTENT_TEMPLATE.resolve(statementContext, name);
ModelNode contentNode = new ModelNode();
contentNode.get(EMPTY).set(true);
Operation operation = new Operation.Builder(address, ADD).param(CONTENT, new ModelNode().add(contentNode)).build();
dispatcher.execute(operation, result -> {
refresh(Ids.deployment(name));
MessageEvent.fire(eventBus, Message.success(resources.messages().deploymentEmptySuccess(name)));
});
});
dialog.addValidationHandlerForNameItem(createUniqueValidation());
dialog.show();
}
use of org.jboss.hal.dmr.Operation 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.dmr.Operation in project console by hal.
the class BrowseContentElement method addContent.
private void addContent() {
TextBoxItem targetPathItem = new TextBoxItem(TARGET_PATH);
targetPathItem.setRequired(true);
Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.CONTENT_NEW, Metadata.empty()).unboundFormItem(targetPathItem).addOnly().build();
AddResourceDialog dialog = new AddResourceDialog(resources.constants().newContent(), form, (name, model) -> {
String path = targetPathItem.getValue();
ResourceAddress address = new ResourceAddress().add(DEPLOYMENT, content.getName());
ModelNode contentNode = new ModelNode();
contentNode.get(INPUT_STREAM_INDEX).set(0);
contentNode.get(TARGET_PATH).set(path);
Operation operation = new Operation.Builder(address, ADD_CONTENT).param(CONTENT, new ModelNode().add(contentNode)).build();
dispatcher.upload(file(filename(path), ""), operation).toCompletable().andThen(browseContent()).andThen(awaitTreeReady()).subscribe(() -> {
MessageEvent.fire(eventBus, Message.success(resources.messages().newContentSuccess(content.getName(), path)));
tree.selectNode(NODE_ID.apply(path));
});
});
targetPathItem.setValue(selectedPath());
dialog.show();
}
Aggregations