Search in sources :

Example 16 with Operation

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()));
    });
}
Also used : ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Operation(org.jboss.hal.dmr.Operation)

Example 17 with Operation

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));
    });
}
Also used : Dialog(org.jboss.hal.ballroom.dialog.Dialog) Provider(javax.inject.Provider) Environment(org.jboss.hal.config.Environment) Deployment(org.jboss.hal.core.deployment.Deployment) Constraint(org.jboss.hal.meta.security.Constraint) ItemActionFactory(org.jboss.hal.core.finder.ItemActionFactory) StatementContext(org.jboss.hal.meta.StatementContext) ItemDisplay(org.jboss.hal.core.finder.ItemDisplay) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) ManagementModel(org.jboss.hal.meta.ManagementModel) CheckDeployment(org.jboss.hal.client.deployment.DeploymentTasks.CheckDeployment) CreateEmptyDialog(org.jboss.hal.client.deployment.dialog.CreateEmptyDialog) UploadDeploymentStep(org.jboss.hal.client.deployment.wizard.UploadDeploymentStep) UploadOrReplace(org.jboss.hal.client.deployment.DeploymentTasks.UploadOrReplace) Column(org.jboss.hal.spi.Column) HTMLElement(elemental2.dom.HTMLElement) Message(org.jboss.hal.spi.Message) Server(org.jboss.hal.core.runtime.server.Server) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) DEPLOYMENT_ADDRESS(org.jboss.hal.client.deployment.StandaloneDeploymentColumn.DEPLOYMENT_ADDRESS) DeploymentState(org.jboss.hal.client.deployment.wizard.DeploymentState) ServerActions(org.jboss.hal.core.runtime.server.ServerActions) DeploymentContext(org.jboss.hal.client.deployment.wizard.DeploymentContext) CrudOperations(org.jboss.hal.core.CrudOperations) AddUnmanagedDialog(org.jboss.hal.client.deployment.dialog.AddUnmanagedDialog) NAMES(org.jboss.hal.client.deployment.wizard.DeploymentState.NAMES) List(java.util.List) Status(org.jboss.hal.core.deployment.Deployment.Status) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) CLEAR_SELECTION(org.jboss.hal.core.finder.FinderColumn.RefreshMode.CLEAR_SELECTION) Flow.series(org.jboss.hal.flow.Flow.series) Finder(org.jboss.hal.core.finder.Finder) Footer(org.jboss.hal.spi.Footer) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) ModelNode(org.jboss.hal.dmr.ModelNode) MessageEvent(org.jboss.hal.spi.MessageEvent) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) ColumnAction(org.jboss.hal.core.finder.ColumnAction) ItemAction(org.jboss.hal.core.finder.ItemAction) FlowContext(org.jboss.hal.flow.FlowContext) Outcome(org.jboss.hal.flow.Outcome) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) JsHelper(org.jboss.hal.js.JsHelper) Progress(org.jboss.hal.flow.Progress) AddressTemplate(org.jboss.hal.meta.AddressTemplate) AddUnmanagedDeployment(org.jboss.hal.client.deployment.DeploymentTasks.AddUnmanagedDeployment) UPLOAD(org.jboss.hal.client.deployment.wizard.DeploymentState.UPLOAD) RESTORE_SELECTION(org.jboss.hal.core.finder.FinderColumn.RefreshMode.RESTORE_SELECTION) FinderColumn(org.jboss.hal.core.finder.FinderColumn) ColumnActionFactory(org.jboss.hal.core.finder.ColumnActionFactory) Requires(org.jboss.hal.spi.Requires) CompositeResult(org.jboss.hal.dmr.CompositeResult) Operation(org.jboss.hal.dmr.Operation) NamesStep(org.jboss.hal.client.deployment.wizard.NamesStep) Ids(org.jboss.hal.resources.Ids) Wizard(org.jboss.hal.ballroom.wizard.Wizard) EventBus(com.google.web.bindery.event.shared.EventBus) CSS.pfIcon(org.jboss.hal.resources.CSS.pfIcon) ItemMonitor(org.jboss.hal.core.finder.ItemMonitor) Consumer(java.util.function.Consumer) Composite(org.jboss.hal.dmr.Composite) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Collectors.toList(java.util.stream.Collectors.toList) NameTokens(org.jboss.hal.meta.token.NameTokens) Resources(org.jboss.hal.resources.Resources) Strings(org.jboss.hal.resources.Strings) UploadElement(org.jboss.hal.client.shared.uploadwizard.UploadElement) Elements.span(org.jboss.gwt.elemento.core.Elements.span) Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CompositeResult(org.jboss.hal.dmr.CompositeResult) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Operation(org.jboss.hal.dmr.Operation)

Example 18 with Operation

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();
}
Also used : CreateEmptyDialog(org.jboss.hal.client.deployment.dialog.CreateEmptyDialog) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Operation(org.jboss.hal.dmr.Operation) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 19 with Operation

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())));
    }
}
Also used : Dialog(org.jboss.hal.ballroom.dialog.Dialog) LoadContent(org.jboss.hal.client.deployment.DeploymentTasks.LoadContent) Provider(javax.inject.Provider) Environment(org.jboss.hal.config.Environment) Constraint(org.jboss.hal.meta.security.Constraint) ItemActionFactory(org.jboss.hal.core.finder.ItemActionFactory) StatementContext(org.jboss.hal.meta.StatementContext) ItemDisplay(org.jboss.hal.core.finder.ItemDisplay) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) ManagementModel(org.jboss.hal.meta.ManagementModel) CheckDeployment(org.jboss.hal.client.deployment.DeploymentTasks.CheckDeployment) CreateEmptyDialog(org.jboss.hal.client.deployment.dialog.CreateEmptyDialog) AuthorisationDecision(org.jboss.hal.meta.security.AuthorisationDecision) UploadOrReplace(org.jboss.hal.client.deployment.DeploymentTasks.UploadOrReplace) DeployContentDialog1(org.jboss.hal.client.deployment.dialog.DeployContentDialog1) Column(org.jboss.hal.spi.Column) HTMLElement(elemental2.dom.HTMLElement) Message(org.jboss.hal.spi.Message) Metadata(org.jboss.hal.meta.Metadata) Places(org.jboss.hal.core.mvp.Places) Names(org.jboss.hal.resources.Names) Collectors.toSet(java.util.stream.Collectors.toSet) UploadContentStep(org.jboss.hal.client.deployment.wizard.UploadContentStep) DeploymentState(org.jboss.hal.client.deployment.wizard.DeploymentState) DeploymentContext(org.jboss.hal.client.deployment.wizard.DeploymentContext) AddUnmanagedDialog(org.jboss.hal.client.deployment.dialog.AddUnmanagedDialog) Set(java.util.Set) Collectors.joining(java.util.stream.Collectors.joining) NAMES(org.jboss.hal.client.deployment.wizard.DeploymentState.NAMES) List(java.util.List) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) ROOT_ADDRESS(org.jboss.hal.client.deployment.ContentColumn.ROOT_ADDRESS) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) SecurityContextRegistry(org.jboss.hal.meta.security.SecurityContextRegistry) CLEAR_SELECTION(org.jboss.hal.core.finder.FinderColumn.RefreshMode.CLEAR_SELECTION) Flow.series(org.jboss.hal.flow.Flow.series) Finder(org.jboss.hal.core.finder.Finder) Footer(org.jboss.hal.spi.Footer) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) ServerGroupDeployment(org.jboss.hal.core.deployment.ServerGroupDeployment) ModelNode(org.jboss.hal.dmr.ModelNode) MessageEvent.fire(org.jboss.hal.spi.MessageEvent.fire) MessageEvent(org.jboss.hal.spi.MessageEvent) Constraints(org.jboss.hal.meta.security.Constraints) ColumnAction(org.jboss.hal.core.finder.ColumnAction) ItemAction(org.jboss.hal.core.finder.ItemAction) FlowContext(org.jboss.hal.flow.FlowContext) Outcome(org.jboss.hal.flow.Outcome) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) JsHelper(org.jboss.hal.js.JsHelper) Progress(org.jboss.hal.flow.Progress) AddressTemplate(org.jboss.hal.meta.AddressTemplate) CONTENT_ADDRESS(org.jboss.hal.client.deployment.ContentColumn.CONTENT_ADDRESS) AddUnmanagedDeployment(org.jboss.hal.client.deployment.DeploymentTasks.AddUnmanagedDeployment) UPLOAD(org.jboss.hal.client.deployment.wizard.DeploymentState.UPLOAD) SERVER_GROUP_DEPLOYMENT_ADDRESS(org.jboss.hal.client.deployment.ContentColumn.SERVER_GROUP_DEPLOYMENT_ADDRESS) RESTORE_SELECTION(org.jboss.hal.core.finder.FinderColumn.RefreshMode.RESTORE_SELECTION) FinderColumn(org.jboss.hal.core.finder.FinderColumn) ColumnActionFactory(org.jboss.hal.core.finder.ColumnActionFactory) Requires(org.jboss.hal.spi.Requires) CompositeResult(org.jboss.hal.dmr.CompositeResult) Operation(org.jboss.hal.dmr.Operation) NamesStep(org.jboss.hal.client.deployment.wizard.NamesStep) Ids(org.jboss.hal.resources.Ids) Wizard(org.jboss.hal.ballroom.wizard.Wizard) EventBus(com.google.web.bindery.event.shared.EventBus) CSS.pfIcon(org.jboss.hal.resources.CSS.pfIcon) PlaceRequest(com.gwtplatform.mvp.shared.proxy.PlaceRequest) ItemMonitor(org.jboss.hal.core.finder.ItemMonitor) DialogFactory(org.jboss.hal.ballroom.dialog.DialogFactory) Content(org.jboss.hal.core.deployment.Content) Composite(org.jboss.hal.dmr.Composite) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Collectors.toList(java.util.stream.Collectors.toList) NameTokens(org.jboss.hal.meta.token.NameTokens) Resources(org.jboss.hal.resources.Resources) Strings(org.jboss.hal.resources.Strings) UploadElement(org.jboss.hal.client.shared.uploadwizard.UploadElement) Elements.span(org.jboss.gwt.elemento.core.Elements.span) Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CompositeResult(org.jboss.hal.dmr.CompositeResult) DeployContentDialog1(org.jboss.hal.client.deployment.dialog.DeployContentDialog1) List(java.util.List) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) Operation(org.jboss.hal.dmr.Operation)

Example 20 with Operation

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();
}
Also used : AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Operation(org.jboss.hal.dmr.Operation) ModelNode(org.jboss.hal.dmr.ModelNode) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm)

Aggregations

Operation (org.jboss.hal.dmr.Operation)246 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)162 ModelNode (org.jboss.hal.dmr.ModelNode)106 Composite (org.jboss.hal.dmr.Composite)63 CompositeResult (org.jboss.hal.dmr.CompositeResult)54 Metadata (org.jboss.hal.meta.Metadata)51 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)49 AddressTemplate (org.jboss.hal.meta.AddressTemplate)48 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)46 ArrayList (java.util.ArrayList)44 List (java.util.List)44 Resources (org.jboss.hal.resources.Resources)44 EventBus (com.google.web.bindery.event.shared.EventBus)42 AddResourceDialog (org.jboss.hal.core.mbui.dialog.AddResourceDialog)42 StatementContext (org.jboss.hal.meta.StatementContext)42 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)41 LabelBuilder (org.jboss.hal.ballroom.LabelBuilder)40 Inject (javax.inject.Inject)39 Ids (org.jboss.hal.resources.Ids)39 Message (org.jboss.hal.spi.Message)37