Examples of ResourceGroup


Examples of org.rhq.core.domain.resource.group.ResourceGroup

    }

    @Override
    public PageList<OperationDefinition> getOperationDefinitions() {
        Subject subject = EnterpriseFacesContextUtility.getSubject();
        ResourceGroup resourceGroup = EnterpriseFacesContextUtility.getResourceGroup();

        // only name and definition are displayed in the "Supported Operations" section of the Operation>New sub-tab
        List<OperationDefinition> definitions = operationManager.findSupportedGroupOperations(subject, resourceGroup
            .getId(), false);

        return new PageList<OperationDefinition>(definitions, new PageControl(0, definitions.size()));
    }
View Full Code Here

Examples of org.rhq.core.domain.resource.group.ResourceGroup

    @EJB
    private SubjectManagerLocal subjectManager;

    public ResourceGroup createAutoClusterBackingGroup(Subject subject, ClusterKey clusterKey, boolean addResources) {
        ResourceGroup autoClusterBackingGroup = null;

        Query query = entityManager.createNamedQuery(ResourceGroup.QUERY_FIND_BY_CLUSTER_KEY);
        query.setParameter("clusterKey", clusterKey.toString());

        ResourceType resourceType = entityManager.find(ResourceType.class, ClusterKey.getResourceType(clusterKey));
        ResourceGroup resourceGroup = entityManager.find(ResourceGroup.class, clusterKey.getClusterGroupId());

        if (!authorizationManager.canViewGroup(subject, clusterKey.getClusterGroupId())) {
            throw new PermissionException("You do not have permission to view child cluster groups of the group ["
                + resourceGroup.getName() + "]");
        }

        // [BZ 817604] In unusual circumstances this clusterKey may be stale. Ensure the cluster group
        // is still a compat group before creating a backing group.
        if (GroupCategory.COMPATIBLE != resourceGroup.getGroupCategory()) {
            throw new IllegalStateException("The root group has changed. Please refresh your group before continuing.");
        }

        List<Resource> resources = null;
        try {
            autoClusterBackingGroup = (ResourceGroup) query.getSingleResult();
        } catch (NoResultException nre) {
            try {
                resources = getAutoClusterResources(subject, clusterKey);
                String name = null;
                if (resources.isEmpty()) {
                    name = "Group of " + resourceType.getName();
                } else {
                    for (Resource res : resources) {
                        if (name == null) {
                            name = res.getName();
                        } else {
                            if (!name.equals(res.getName())) {
                                name = "Group of " + resourceType.getName();
                            }
                        }
                    }
                }

                // Note, group names do not need to be unique for non-visible groups, like autocluster backing groups
                autoClusterBackingGroup = new ResourceGroup(name, resourceType);
                autoClusterBackingGroup.setClusterKey(clusterKey.toString());
                autoClusterBackingGroup.setClusterResourceGroup(resourceGroup);
                autoClusterBackingGroup.setVisible(false);

                // You are allowed to cause the creation of an auto cluster backing group as long as you can
View Full Code Here

Examples of org.rhq.core.domain.resource.group.ResourceGroup

        return autoClusterBackingGroup;
    }

    public ResourceGroup getAutoClusterBackingGroup(Subject subject, ClusterKey clusterKey) {
        ResourceGroup result = null;

        Query query = entityManager.createNamedQuery(ResourceGroup.QUERY_FIND_BY_CLUSTER_KEY);
        query.setParameter("clusterKey", clusterKey.toString());
        try {
            result = (ResourceGroup) query.getSingleResult();
View Full Code Here

Examples of org.rhq.core.domain.resource.group.ResourceGroup

    @Override
    @SuppressWarnings("unchecked")
    public Set<Permission> getExplicitGroupPermissions(Subject subject, int groupId) {
        Set<Permission> result = new HashSet<Permission>();

        ResourceGroup group = entityManager.find(ResourceGroup.class, groupId);
        Subject owner = group.getSubject();

        if (null == owner) {
            // role-owned group
            Query query = entityManager.createNamedQuery(Subject.QUERY_GET_PERMISSIONS_BY_GROUP_ID);
            query.setParameter("subject", subject);
View Full Code Here

Examples of org.rhq.core.domain.resource.group.ResourceGroup

    public boolean hasGroupPermission(Subject subject, Permission permission, int groupId) {
        if (isInventoryManager(subject)) {
            return true;
        }

        ResourceGroup group = entityManager.find(ResourceGroup.class, groupId);
        Subject owner = group.getSubject();

        if (null == owner) {
            // role-owned group
            Query query = entityManager.createNamedQuery(Subject.QUERY_HAS_GROUP_PERMISSION);
            query.setParameter("subject", subject);
View Full Code Here

Examples of org.rhq.core.domain.resource.group.ResourceGroup

        if (!authorizationManager.hasGroupPermission(subject, Permission.MODIFY_RESOURCE, resourceGroupId)) {
            throw new PermissionException("You do not have permission to modify group");
        }

        Set<Tag> definedTags = addTags(subject, tags);
        ResourceGroup group = entityManager.find(ResourceGroup.class, resourceGroupId);

        Set<Tag> previousTags = new HashSet<Tag>(group.getTags());
        previousTags.removeAll(definedTags);
        for (Tag tag : previousTags) {
            tag.removeResourceGroup(group);
        }
View Full Code Here

Examples of org.rhq.core.domain.resource.group.ResourceGroup

            for (ResourceGroup resourceGroup : currentResourceGroups) {
                attachedRole.removeResourceGroup(resourceGroup);
            }

            for (ResourceGroup resourceGroup : newResourceGroups) {
                ResourceGroup attachedResourceGroup = entityManager.find(ResourceGroup.class, resourceGroup.getId());
                attachedRole.addResourceGroup(attachedResourceGroup);
            }
        }

        Set<LdapGroup> newLdapGroups = role.getLdapGroups();
View Full Code Here

Examples of org.rhq.core.domain.resource.group.ResourceGroup

                throw new IllegalArgumentException("Could not find role[" + roleId + "] to add resourceGroups to");
            }
            role.getResourceGroups().size(); // load them in

            for (Integer groupId : groupIds) {
                ResourceGroup group = entityManager.find(ResourceGroup.class, groupId);
                if (group == null) {
                    throw new IllegalArgumentException("Tried to add resourceGroup[" + groupId + "] to role[" + roleId
                        + "], but resourceGroup was not found.");
                }
                role.addResourceGroup(group);
View Full Code Here

Examples of org.rhq.core.domain.resource.group.ResourceGroup

                throw new IllegalArgumentException("Could not find role[" + roleId + "] to remove resourceGroups from");
            }
            role.getResourceGroups().size(); // load them in

            for (Integer groupId : groupIds) {
                ResourceGroup doomedGroup = entityManager.find(ResourceGroup.class, groupId);
                if (doomedGroup == null) {
                    throw new IllegalArgumentException("Tried to remove doomedGroup[" + groupId + "] from role["
                        + roleId + "], but subject was not found");
                }
                role.removeResourceGroup(doomedGroup);
View Full Code Here

Examples of org.rhq.core.domain.resource.group.ResourceGroup

    @Override
    @RequiredPermission(Permission.MANAGE_SECURITY)
    public void removeRolesFromResourceGroup(Subject subject, int groupId, int[] roleIds) {
        if ((roleIds != null) && (roleIds.length > 0)) {
            ResourceGroup group = entityManager.find(ResourceGroup.class, groupId);
            if (group == null) {
                throw new IllegalArgumentException("Could not find resourceGroup[" + groupId + "] to remove roles from");
            }
            group.getRoles().size(); // load them in

            for (Integer roleId : roleIds) {
                Role doomedRole = entityManager.find(Role.class, roleId);
                if (doomedRole == null) {
                    throw new IllegalArgumentException("Tried to remove role[" + roleId + "] from resourceGroup["
                        + groupId + "], but role was not found");
                }
                group.removeRole(doomedRole);
            }
        }

        return;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.