Package org.rhq.core.domain.resource.composite

Examples of org.rhq.core.domain.resource.composite.ResourcePermission


            getTitleBar().setResource(this.resourceComposite, isRefresh);

            // wipe the canvas views for the current set of subtabs.
            this.getTabSet().destroyViews();

            ResourcePermission resourcePermissions = this.resourceComposite.getResourcePermission();
            Set<ResourceTypeFacet> facets = this.resourceComposite.getResourceFacets().getFacets();

            updateSummaryTabContent();
            updateInventoryTabContent(resourceComposite, resource, facets);
            updateAlertsTabContent(resourceComposite);
View Full Code Here


    }

    protected boolean hasControlPermission() {
        if (null == this.hasControlPermission) {
            Set<Permission> globalPerm = this.getPortletWindow().getGlobalPermissions();
            ResourcePermission resPerm = this.getPortletWindow().getResourcePermissions();

            this.hasControlPermission = (globalPerm.contains(Permission.MANAGE_INVENTORY) || (null != resPerm && resPerm
                .isControl()));
        }

        return this.hasControlPermission;
    }
View Full Code Here

            ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
            Resource resource = resourceManager.getResourceById(user, getResource());

            Set<Permission> permissions = LookupUtil.getAuthorizationManager().getImplicitResourcePermissions(user,
                resource.getId());
            ResourcePermission resourcePermission = null;
            if (LookupUtil.getAuthorizationManager().isInventoryManager(user)) {
                resourcePermission = new ResourcePermission(Permission.RESOURCE_ALL);
            } else {
                resourcePermission = new ResourcePermission(permissions);
            }

            request.setAttribute("resourcePermissions", resourcePermission);

            //have a debug option to output the values as html.
View Full Code Here

    @Override
    protected void setupTableInteractions(boolean hasWriteAccess) {
        if (!hasWriteAccess) {
            Set<Permission> globalPerm = this.getPortletWindow().getGlobalPermissions();
            ResourcePermission resPerm = this.getPortletWindow().getResourcePermissions();
            hasWriteAccess = (globalPerm.contains(Permission.MANAGE_INVENTORY) || (null != resPerm && resPerm.isAlert()));
        }
        super.setupTableInteractions(hasWriteAccess);
    }
View Full Code Here

    @Override
    protected void setupTableInteractions(boolean hasWriteAccess) {
        if (!hasWriteAccess) {
            Set<Permission> globalPerm = this.getPortletWindow().getGlobalPermissions();
            ResourcePermission resPerm = this.getPortletWindow().getResourcePermissions();
            hasWriteAccess = (globalPerm.contains(Permission.MANAGE_INVENTORY) || (null != resPerm && resPerm.isDrift()));
        }
        super.setupTableInteractions(hasWriteAccess);
    }
View Full Code Here

    }

    private void buildAndShowResourceContextMenu(final ResourceTreeNode node,
        final ResourceComposite resourceComposite, final ResourceType resourceType) {
        final Resource resource = resourceComposite.getResource();
        final ResourcePermission resourcePermission = resourceComposite.getResourcePermission();

        // resource name
        resourceContextMenu.setItems(new MenuItem(resource.getName()));

        // resource type name
        resourceContextMenu.addItem(new MenuItem(MSG.view_tree_common_contextMenu_type_name_label(resourceType
            .getName())));

        // separator
        resourceContextMenu.addItem(new MenuItemSeparator());

        // refresh node
        MenuItem refresh = new MenuItem(MSG.common_button_refresh());
        refresh.addClickHandler(new ClickHandler() {

            public void onClick(MenuItemClickEvent event) {
                contextMenuRefresh(treeGrid, node, false);
            }
        });
        resourceContextMenu.addItem(refresh);




        // separator
        resourceContextMenu.addItem(new MenuItemSeparator());

        // child resources
        MenuItem childResources = new MenuItem(MSG.view_tabs_common_child_resources());
        boolean childResourcesEnabled = resourceType.getChildResourceTypes() != null
            && !resourceType.getChildResourceTypes().isEmpty();
        childResources.setEnabled(childResourcesEnabled);
        if (childResourcesEnabled) {
            childResources.addClickHandler(new ClickHandler() {
                public void onClick(MenuItemClickEvent event) {
                    CoreGUI.goToView(LinkManager.getResourceTabLink(resource.getId(), "Inventory", "Children"));
                }
            });
        }
        resourceContextMenu.addItem(childResources);

        // plugin config
        MenuItem pluginConfiguration = new MenuItem(MSG.view_tabs_common_connectionSettings());
        boolean pluginConfigEnabled = resourceType.getPluginConfigurationDefinition() != null;
        pluginConfiguration.setEnabled(pluginConfigEnabled);
        if (pluginConfigEnabled) {
            pluginConfiguration.addClickHandler(new ClickHandler() {

                public void onClick(MenuItemClickEvent event) {
                    CoreGUI.goToView(LinkManager.getResourceTabLink(resource.getId(), "Inventory", "ConnectionSettings"));
                }
            });
        }
        resourceContextMenu.addItem(pluginConfiguration);

        // resource config
        MenuItem resourceConfiguration = new MenuItem(MSG.view_tree_common_contextMenu_resourceConfiguration());
        boolean resourceConfigEnabled = resourcePermission.isConfigureRead()
            && resourceType.getResourceConfigurationDefinition() != null;
        resourceConfiguration.setEnabled(resourceConfigEnabled);
        if (resourceConfigEnabled) {
            resourceConfiguration.addClickHandler(new ClickHandler() {

                public void onClick(MenuItemClickEvent event) {
                    CoreGUI.goToView(LinkManager.getResourceTabLink(resource.getId(), "Configuration", "Current"));
                }
            });
        }
        resourceContextMenu.addItem(resourceConfiguration);

        // separator
        resourceContextMenu.addItem(new MenuItemSeparator());

        // Operations Menu
        MenuItem operations = new MenuItem(MSG.common_title_operations());
        boolean operationsEnabled = (resourcePermission.isControl() && (resourceType.getOperationDefinitions() != null) && !resourceType
            .getOperationDefinitions().isEmpty());
        operations.setEnabled(operationsEnabled);
        if (operationsEnabled) {
            Menu opSubMenu = new Menu();

            //sort the display items alphabetically
            TreeSet<String> ordered = new TreeSet<String>();
            Map<String, OperationDefinition> definitionMap = new HashMap<String, OperationDefinition>();
            for (OperationDefinition o : resourceType.getOperationDefinitions()) {
                ordered.add(o.getDisplayName());
                definitionMap.put(o.getDisplayName(), o);
            }
            for (String displayName : ordered) {
                final OperationDefinition operationDefinition = definitionMap.get(displayName);

                MenuItem operationItem = new MenuItem(operationDefinition.getDisplayName());
                operationItem.addClickHandler(new ClickHandler() {

                    public void onClick(MenuItemClickEvent event) {
                        String viewPath = LinkManager.getResourceTabLink(resource.getId(),
                            ResourceDetailView.Tab.Operations.NAME, "Schedules") + "/0/" + operationDefinition.getId();
                        CoreGUI.goToView(viewPath);
                    }
                });
                opSubMenu.addItem(operationItem);
            }
            operations.setSubmenu(opSubMenu);
        }
        resourceContextMenu.addItem(operations);

        // this menu item will be the last one
        final OpenSupportCaseMenuItem openSupportCase = new OpenSupportCaseMenuItem(resourceComposite);

        // Create Child Menu and Manual Import Menu
        final Set<ResourceType> creatableChildTypes = getCreatableChildTypes(resourceType);
        final Set<ResourceType> importableChildTypes = getImportableChildTypes(resourceType);
        final boolean hasCreatableTypes = !creatableChildTypes.isEmpty();
        final boolean hasImportableTypes = !importableChildTypes.isEmpty();
        boolean canCreate = resourcePermission.isCreateChildResources();

        Integer[] singletonChildTypes = getSingletonChildTypes(resourceType);

        // To properly filter Create Child and Import menus we need existing singleton child resources. If the
        // user has created permission and the parent type has singleton child types and creatable or importable child
View Full Code Here

        return dashboardView.getGlobalPermissions();
    }

    public ResourcePermission getResourcePermissions() {

        ResourcePermission result = null;

        if (null != dashboardView.getResourceComposite()) {
            result = dashboardView.getResourceComposite().getResourcePermission();
        } else if (null != dashboardView.getGroupComposite()) {
            result = dashboardView.getGroupComposite().getResourcePermission();
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.resource.composite.ResourcePermission

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.