Search in sources :

Example 1 with RemoveScopedRole

use of org.jboss.hal.client.accesscontrol.AccessControlTasks.RemoveScopedRole in project console by hal.

the class RoleColumn method removeScopedRole.

// ------------------------------------------------------ remove roles
private void removeScopedRole(Role role, String type) {
    List<Task<FlowContext>> tasks = new ArrayList<>();
    List<Assignment> assignments = accessControl.assignments().byRole(role).collect(toList());
    if (!assignments.isEmpty()) {
        tasks.add(new RemoveAssignments(dispatcher, assignments));
    }
    tasks.add(new CheckRoleMapping(dispatcher, role));
    tasks.add(new RemoveRoleMapping(dispatcher, role, status -> status == 200));
    tasks.add(new RemoveScopedRole(dispatcher, role));
    series(new FlowContext(progress.get()), tasks).subscribe(new SuccessfulOutcome<FlowContext>(eventBus, resources) {

        @Override
        public void onSuccess(FlowContext context) {
            MessageEvent.fire(eventBus, Message.success(resources.messages().removeResourceSuccess(type, role.getName())));
            accessControl.reload(() -> {
                refresh(RefreshMode.CLEAR_SELECTION);
                eventBus.fireEvent(new RolesChangedEvent());
            });
        }
    });
}
Also used : Provider(javax.inject.Provider) Environment(org.jboss.hal.config.Environment) StatementContext(org.jboss.hal.meta.StatementContext) AddScopedRole(org.jboss.hal.client.accesscontrol.AccessControlTasks.AddScopedRole) ItemDisplay(org.jboss.hal.core.finder.ItemDisplay) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) HTMLElement(elemental2.dom.HTMLElement) Message(org.jboss.hal.spi.Message) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Metadata(org.jboss.hal.meta.Metadata) CheckRoleMapping(org.jboss.hal.client.accesscontrol.AccessControlTasks.CheckRoleMapping) Settings(org.jboss.hal.config.Settings) SingleSelectBoxItem(org.jboss.hal.ballroom.form.SingleSelectBoxItem) ModifyResourceDialog(org.jboss.hal.core.mbui.dialog.ModifyResourceDialog) RemoveAssignments(org.jboss.hal.client.accesscontrol.AccessControlTasks.RemoveAssignments) List(java.util.List) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) SwitchItem(org.jboss.hal.ballroom.form.SwitchItem) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Flow.series(org.jboss.hal.flow.Flow.series) Role(org.jboss.hal.config.Role) Finder(org.jboss.hal.core.finder.Finder) Footer(org.jboss.hal.spi.Footer) Elements.small(org.jboss.gwt.elemento.core.Elements.small) CSS.subtitle(org.jboss.hal.resources.CSS.subtitle) ModelNode(org.jboss.hal.dmr.ModelNode) RemoveScopedRole(org.jboss.hal.client.accesscontrol.AccessControlTasks.RemoveScopedRole) AsyncColumn(org.jboss.hal.spi.AsyncColumn) 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) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) AddRoleMapping(org.jboss.hal.client.accesscontrol.AccessControlTasks.AddRoleMapping) Task(org.jboss.hal.flow.Task) ModifyIncludeAll(org.jboss.hal.client.accesscontrol.AccessControlTasks.ModifyIncludeAll) Progress(org.jboss.hal.flow.Progress) AddressTemplate(org.jboss.hal.meta.AddressTemplate) RemoveRoleMapping(org.jboss.hal.client.accesscontrol.AccessControlTasks.RemoveRoleMapping) FinderColumn(org.jboss.hal.core.finder.FinderColumn) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) Comparator.comparing(java.util.Comparator.comparing) ModifyScopedRole(org.jboss.hal.client.accesscontrol.AccessControlTasks.ModifyScopedRole) RolesChangedEvent(org.jboss.hal.config.RolesChangedEvent) AddressTemplates(org.jboss.hal.client.accesscontrol.AddressTemplates) ColumnActionFactory(org.jboss.hal.core.finder.ColumnActionFactory) Requires(org.jboss.hal.spi.Requires) CSS.itemText(org.jboss.hal.resources.CSS.itemText) Ids(org.jboss.hal.resources.Ids) EventBus(com.google.web.bindery.event.shared.EventBus) CSS.pfIcon(org.jboss.hal.resources.CSS.pfIcon) ReadChildrenAutoComplete(org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete) DialogFactory(org.jboss.hal.ballroom.dialog.DialogFactory) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Collectors.toList(java.util.stream.Collectors.toList) Resources(org.jboss.hal.resources.Resources) RUN_AS(org.jboss.hal.config.Settings.Key.RUN_AS) Elements.span(org.jboss.gwt.elemento.core.Elements.span) Form(org.jboss.hal.ballroom.form.Form) Task(org.jboss.hal.flow.Task) RemoveScopedRole(org.jboss.hal.client.accesscontrol.AccessControlTasks.RemoveScopedRole) ArrayList(java.util.ArrayList) FlowContext(org.jboss.hal.flow.FlowContext) RolesChangedEvent(org.jboss.hal.config.RolesChangedEvent) RemoveRoleMapping(org.jboss.hal.client.accesscontrol.AccessControlTasks.RemoveRoleMapping) RemoveAssignments(org.jboss.hal.client.accesscontrol.AccessControlTasks.RemoveAssignments) CheckRoleMapping(org.jboss.hal.client.accesscontrol.AccessControlTasks.CheckRoleMapping)

Aggregations

SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 EventBus (com.google.web.bindery.event.shared.EventBus)1 HTMLElement (elemental2.dom.HTMLElement)1 ArrayList (java.util.ArrayList)1 Comparator.comparing (java.util.Comparator.comparing)1 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)1 Inject (javax.inject.Inject)1 Provider (javax.inject.Provider)1 Elements.small (org.jboss.gwt.elemento.core.Elements.small)1 Elements.span (org.jboss.gwt.elemento.core.Elements.span)1 LabelBuilder (org.jboss.hal.ballroom.LabelBuilder)1 ReadChildrenAutoComplete (org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete)1 DialogFactory (org.jboss.hal.ballroom.dialog.DialogFactory)1 Form (org.jboss.hal.ballroom.form.Form)1 SingleSelectBoxItem (org.jboss.hal.ballroom.form.SingleSelectBoxItem)1 SwitchItem (org.jboss.hal.ballroom.form.SwitchItem)1 AddRoleMapping (org.jboss.hal.client.accesscontrol.AccessControlTasks.AddRoleMapping)1 AddScopedRole (org.jboss.hal.client.accesscontrol.AccessControlTasks.AddScopedRole)1 CheckRoleMapping (org.jboss.hal.client.accesscontrol.AccessControlTasks.CheckRoleMapping)1