org.rhq.enterprise.server.resource.group
Class ResourceGroupManagerBean

java.lang.Object
  extended by org.rhq.enterprise.server.resource.group.ResourceGroupManagerBean
All Implemented Interfaces:
ResourceGroupManagerLocal, ResourceGroupManagerRemote

public class ResourceGroupManagerBean
extends Object
implements ResourceGroupManagerLocal, ResourceGroupManagerRemote

A manager that provides methods for creating, updating, deleting, and querying ResourceGroups.

Author:
Ian Springer, Joseph Marques

Constructor Summary
ResourceGroupManagerBean()
           
 
Method Summary
 void addResourcesToGroup(org.rhq.core.domain.auth.Subject subject, int groupId, int[] resourceIds)
           
 org.rhq.core.domain.resource.group.ResourceGroup createPrivateResourceGroup(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.resource.group.ResourceGroup group)
          NOTE: This is only used to support AutoGroups currently but the idea may be expanded in the future.
 org.rhq.core.domain.resource.group.ResourceGroup createResourceGroup(org.rhq.core.domain.auth.Subject user, org.rhq.core.domain.resource.group.ResourceGroup group)
           
 void deleteResourceGroup(org.rhq.core.domain.auth.Subject subject, int groupId)
           
 void deleteResourceGroups(org.rhq.core.domain.auth.Subject subject, int[] groupIds)
           
 void enableRecursivityForGroup(org.rhq.core.domain.auth.Subject subject, int groupId)
           
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.resource.group.ResourceGroup> findAvailableResourceGroupsForRole(org.rhq.core.domain.auth.Subject subject, int roleId, int[] excludeIds, org.rhq.core.domain.util.PageControl pageControl)
           
 int[] findDefinitionsForAutoGroup(org.rhq.core.domain.auth.Subject subject, int autoGroupParentResourceId, int autoGroupChildResourceTypeId, boolean displayTypeSummaryOnly)
          Get the MeasurementDefinitions for the passed autogroup
 int[] findDefinitionsForCompatibleGroup(org.rhq.core.domain.auth.Subject subject, int groupId, boolean displayTypeSummaryOnly)
          Return the MeasurementDefinitions for the passed comatible group
 List<Integer> findDeletedResourceGroupIds(int[] possibleGroupIds)
           
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.resource.group.ResourceGroup> findResourceGroupByIds(org.rhq.core.domain.auth.Subject subject, int[] resourceGroupIds, org.rhq.core.domain.util.PageControl pageControl)
           
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.resource.group.composite.ResourceGroupComposite> findResourceGroupComposites(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.resource.group.GroupCategory groupCategory, org.rhq.core.domain.resource.ResourceCategory resourceCategory, String resourceTypeName, String pluginName, String nameFilter, Integer resourceId, Integer groupId, org.rhq.core.domain.util.PageControl pc)
           
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.resource.group.composite.ResourceGroupComposite> findResourceGroupCompositesByCriteria(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.criteria.ResourceGroupCriteria criteria)
          This method adheres to all of the regular semantics of Criteria-based queries.
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.resource.group.ResourceGroup> findResourceGroupsByCriteria(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.criteria.ResourceGroupCriteria criteria)
           
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.resource.group.ResourceGroup> findResourceGroupsForRole(org.rhq.core.domain.auth.Subject subject, int roleId, org.rhq.core.domain.util.PageControl pc)
           
 List<org.rhq.core.domain.resource.Resource> findResourcesForAutoGroup(org.rhq.core.domain.auth.Subject subject, int autoGroupParentResourceId, int autoGroupChildResourceTypeId)
           
 List<org.rhq.core.domain.resource.Resource> findResourcesForResourceGroup(org.rhq.core.domain.auth.Subject subject, int groupId, org.rhq.core.domain.resource.group.GroupCategory category)
           
 org.rhq.core.domain.resource.group.ResourceGroup getByGroupDefinitionAndGroupByClause(int groupDefinitionId, String groupByClause)
           
 int getExplicitGroupMemberCount(int resourceGroupId)
           
 int getImplicitGroupMemberCount(int resourceGroupId)
           
 org.rhq.core.domain.resource.group.ResourceGroup getResourceGroup(org.rhq.core.domain.auth.Subject subject, int groupId)
           
 org.rhq.core.domain.resource.group.ResourceGroup getResourceGroupById(org.rhq.core.domain.auth.Subject user, int id, org.rhq.core.domain.resource.group.GroupCategory category)
           
 org.rhq.core.domain.resource.group.composite.ResourceGroupComposite getResourceGroupComposite(org.rhq.core.domain.auth.Subject subject, int groupId)
           
 int[] getResourceGroupCountSummary(org.rhq.core.domain.auth.Subject user)
          Get a summary of counts, by category, of the user's assigned, visible groups.
 void init()
           
 void removeAllResourcesFromGroup(org.rhq.core.domain.auth.Subject subject, int groupId)
           
 void removeResourcesFromGroup(org.rhq.core.domain.auth.Subject subject, int groupId, int[] resourceIds)
           
 void setAssignedResourceGroupsForResource(org.rhq.core.domain.auth.Subject subject, int resourceId, int[] resourceGroupIds, boolean setType)
          This method ensures that the resource will have exactly the specified set of explicit group membership.
 void setAssignedResources(org.rhq.core.domain.auth.Subject subject, int groupId, int[] resourceIds, boolean setType)
          This method ensures that the explicit group membership is set to the specified resources.
 void setRecursive(org.rhq.core.domain.auth.Subject subject, int groupId, boolean isRecursive)
           
 void setResourceType(int resourceGroupId)
           
 void uninventoryMembers(org.rhq.core.domain.auth.Subject subject, int groupId)
           
 void updateImplicitGroupMembership(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.resource.Resource resource)
           
 org.rhq.core.domain.resource.group.ResourceGroup updateResourceGroup(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.resource.group.ResourceGroup group)
           
 org.rhq.core.domain.resource.group.ResourceGroup updateResourceGroup(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.resource.group.ResourceGroup group, RecursivityChangeType changeType)
           
 org.rhq.core.domain.resource.group.ResourceGroup updateResourceGroup(org.rhq.core.domain.auth.Subject user, org.rhq.core.domain.resource.group.ResourceGroup group, RecursivityChangeType changeType, boolean updateMembership)
           
 void updateResourceGroupDescription(org.rhq.core.domain.auth.Subject subject, int groupId, String description)
           
 void updateResourceGroupLocation(org.rhq.core.domain.auth.Subject subject, int groupId, String location)
           
 void updateResourceGroupName(org.rhq.core.domain.auth.Subject subject, int groupId, String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceGroupManagerBean

public ResourceGroupManagerBean()
Method Detail

init

@PostConstruct
public void init()

createPrivateResourceGroup

public org.rhq.core.domain.resource.group.ResourceGroup createPrivateResourceGroup(org.rhq.core.domain.auth.Subject subject,
                                                                                   org.rhq.core.domain.resource.group.ResourceGroup group)
Description copied from interface: ResourceGroupManagerLocal
NOTE: This is only used to support AutoGroups currently but the idea may be expanded in the future. Creates a private, "user-owned" (aka "subject-owned") resource group. This group differs from a role-owned group in that it can not be assigned to a role, instead it is owned by the user that creates it. It comprises only a set of resources for which the user has, minimally, view permission. Since a user's view permissions can change, membership and authz checking must be performed as needed when taking any action on the group.

A user does not need MANAGE_INVENTORY to create a sub-group because it is private to his view.

This call does not populate the group with members, it only creates the group. The group is automatically set to be non-recursive.

All user-owned groups are deleted if the the user is deleted.

Specified by:
createPrivateResourceGroup in interface ResourceGroupManagerLocal
Parameters:
subject - The user for which the group will be created.
group - The group characteristics. Any membership defined here is ignored. The recursivity setting is ignored.
Returns:
The new group.

createResourceGroup

public org.rhq.core.domain.resource.group.ResourceGroup createResourceGroup(org.rhq.core.domain.auth.Subject user,
                                                                            org.rhq.core.domain.resource.group.ResourceGroup group)
Specified by:
createResourceGroup in interface ResourceGroupManagerLocal
Specified by:
createResourceGroup in interface ResourceGroupManagerRemote

updateResourceGroup

public org.rhq.core.domain.resource.group.ResourceGroup updateResourceGroup(org.rhq.core.domain.auth.Subject subject,
                                                                            org.rhq.core.domain.resource.group.ResourceGroup group)
                                                                     throws ResourceGroupUpdateException
Specified by:
updateResourceGroup in interface ResourceGroupManagerLocal
Specified by:
updateResourceGroup in interface ResourceGroupManagerRemote
Throws:
ResourceGroupUpdateException

updateResourceGroup

public org.rhq.core.domain.resource.group.ResourceGroup updateResourceGroup(org.rhq.core.domain.auth.Subject subject,
                                                                            org.rhq.core.domain.resource.group.ResourceGroup group,
                                                                            RecursivityChangeType changeType)
                                                                     throws ResourceGroupUpdateException
Specified by:
updateResourceGroup in interface ResourceGroupManagerLocal
Throws:
ResourceGroupUpdateException

updateResourceGroup

public org.rhq.core.domain.resource.group.ResourceGroup updateResourceGroup(org.rhq.core.domain.auth.Subject user,
                                                                            org.rhq.core.domain.resource.group.ResourceGroup group,
                                                                            RecursivityChangeType changeType,
                                                                            boolean updateMembership)
                                                                     throws ResourceGroupUpdateException
Specified by:
updateResourceGroup in interface ResourceGroupManagerLocal
Throws:
ResourceGroupUpdateException

deleteResourceGroup

public void deleteResourceGroup(org.rhq.core.domain.auth.Subject subject,
                                int groupId)
                         throws ResourceGroupNotFoundException,
                                ResourceGroupDeleteException
Specified by:
deleteResourceGroup in interface ResourceGroupManagerLocal
Specified by:
deleteResourceGroup in interface ResourceGroupManagerRemote
Throws:
ResourceGroupNotFoundException
ResourceGroupDeleteException

deleteResourceGroups

public void deleteResourceGroups(org.rhq.core.domain.auth.Subject subject,
                                 int[] groupIds)
                          throws ResourceGroupNotFoundException,
                                 ResourceGroupDeleteException
Specified by:
deleteResourceGroups in interface ResourceGroupManagerLocal
Specified by:
deleteResourceGroups in interface ResourceGroupManagerRemote
Throws:
ResourceGroupNotFoundException
ResourceGroupDeleteException

getResourceGroupById

public org.rhq.core.domain.resource.group.ResourceGroup getResourceGroupById(org.rhq.core.domain.auth.Subject user,
                                                                             int id,
                                                                             org.rhq.core.domain.resource.group.GroupCategory category)
                                                                      throws ResourceGroupNotFoundException
Specified by:
getResourceGroupById in interface ResourceGroupManagerLocal
Throws:
ResourceGroupNotFoundException

getResourceGroupCountSummary

public int[] getResourceGroupCountSummary(org.rhq.core.domain.auth.Subject user)
Description copied from interface: ResourceGroupManagerLocal
Get a summary of counts, by category, of the user's assigned, visible groups.

Specified by:
getResourceGroupCountSummary in interface ResourceGroupManagerLocal
Returns:
A 2 element int array with counts for mixed, compatible as a[0], a[1] respectively.

enableRecursivityForGroup

public void enableRecursivityForGroup(org.rhq.core.domain.auth.Subject subject,
                                      int groupId)
                               throws ResourceGroupNotFoundException,
                                      ResourceGroupUpdateException
Specified by:
enableRecursivityForGroup in interface ResourceGroupManagerLocal
Throws:
ResourceGroupNotFoundException
ResourceGroupUpdateException

addResourcesToGroup

public void addResourcesToGroup(org.rhq.core.domain.auth.Subject subject,
                                int groupId,
                                int[] resourceIds)
Specified by:
addResourcesToGroup in interface ResourceGroupManagerLocal
Specified by:
addResourcesToGroup in interface ResourceGroupManagerRemote

removeResourcesFromGroup

public void removeResourcesFromGroup(org.rhq.core.domain.auth.Subject subject,
                                     int groupId,
                                     int[] resourceIds)
Specified by:
removeResourcesFromGroup in interface ResourceGroupManagerLocal
Specified by:
removeResourcesFromGroup in interface ResourceGroupManagerRemote

removeAllResourcesFromGroup

public void removeAllResourcesFromGroup(org.rhq.core.domain.auth.Subject subject,
                                        int groupId)
                                 throws ResourceGroupDeleteException
Specified by:
removeAllResourcesFromGroup in interface ResourceGroupManagerLocal
Throws:
ResourceGroupDeleteException

findAvailableResourceGroupsForRole

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.resource.group.ResourceGroup> findAvailableResourceGroupsForRole(org.rhq.core.domain.auth.Subject subject,
                                                                                                                              int roleId,
                                                                                                                              int[] excludeIds,
                                                                                                                              org.rhq.core.domain.util.PageControl pageControl)
Specified by:
findAvailableResourceGroupsForRole in interface ResourceGroupManagerLocal

findResourceGroupByIds

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.resource.group.ResourceGroup> findResourceGroupByIds(org.rhq.core.domain.auth.Subject subject,
                                                                                                                  int[] resourceGroupIds,
                                                                                                                  org.rhq.core.domain.util.PageControl pageControl)
Specified by:
findResourceGroupByIds in interface ResourceGroupManagerLocal

updateImplicitGroupMembership

public void updateImplicitGroupMembership(org.rhq.core.domain.auth.Subject subject,
                                          org.rhq.core.domain.resource.Resource resource)
Specified by:
updateImplicitGroupMembership in interface ResourceGroupManagerLocal

findResourcesForAutoGroup

public List<org.rhq.core.domain.resource.Resource> findResourcesForAutoGroup(org.rhq.core.domain.auth.Subject subject,
                                                                             int autoGroupParentResourceId,
                                                                             int autoGroupChildResourceTypeId)
Specified by:
findResourcesForAutoGroup in interface ResourceGroupManagerLocal

findResourcesForResourceGroup

public List<org.rhq.core.domain.resource.Resource> findResourcesForResourceGroup(org.rhq.core.domain.auth.Subject subject,
                                                                                 int groupId,
                                                                                 org.rhq.core.domain.resource.group.GroupCategory category)
Specified by:
findResourcesForResourceGroup in interface ResourceGroupManagerLocal

findDefinitionsForAutoGroup

public int[] findDefinitionsForAutoGroup(org.rhq.core.domain.auth.Subject subject,
                                         int autoGroupParentResourceId,
                                         int autoGroupChildResourceTypeId,
                                         boolean displayTypeSummaryOnly)
Description copied from interface: ResourceGroupManagerLocal
Get the MeasurementDefinitions for the passed autogroup

Specified by:
findDefinitionsForAutoGroup in interface ResourceGroupManagerLocal
Parameters:
subject - Subject of the calling user
autoGroupParentResourceId - id of the parent resource
autoGroupChildResourceTypeId - Id of the ResourceType of the children
displayTypeSummaryOnly - TODO
Returns:
a set of Definitions which is empty for an invalid autoGroupChildResourceType

findDefinitionsForCompatibleGroup

public int[] findDefinitionsForCompatibleGroup(org.rhq.core.domain.auth.Subject subject,
                                               int groupId,
                                               boolean displayTypeSummaryOnly)
Description copied from interface: ResourceGroupManagerLocal
Return the MeasurementDefinitions for the passed comatible group

Specified by:
findDefinitionsForCompatibleGroup in interface ResourceGroupManagerLocal
Parameters:
subject - Subject of the calling user
groupId - id of the group
displayTypeSummaryOnly - TODO
Returns:
a set of Definitions, which is empty for an invalid groupId

getByGroupDefinitionAndGroupByClause

public org.rhq.core.domain.resource.group.ResourceGroup getByGroupDefinitionAndGroupByClause(int groupDefinitionId,
                                                                                             String groupByClause)
Specified by:
getByGroupDefinitionAndGroupByClause in interface ResourceGroupManagerLocal

setResourceType

public void setResourceType(int resourceGroupId)
                     throws ResourceGroupDeleteException
Specified by:
setResourceType in interface ResourceGroupManagerLocal
Throws:
ResourceGroupDeleteException

getExplicitGroupMemberCount

public int getExplicitGroupMemberCount(int resourceGroupId)
Specified by:
getExplicitGroupMemberCount in interface ResourceGroupManagerLocal

getImplicitGroupMemberCount

public int getImplicitGroupMemberCount(int resourceGroupId)
Specified by:
getImplicitGroupMemberCount in interface ResourceGroupManagerLocal

findResourceGroupComposites

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.resource.group.composite.ResourceGroupComposite> findResourceGroupComposites(org.rhq.core.domain.auth.Subject subject,
                                                                                                                                          org.rhq.core.domain.resource.group.GroupCategory groupCategory,
                                                                                                                                          org.rhq.core.domain.resource.ResourceCategory resourceCategory,
                                                                                                                                          String resourceTypeName,
                                                                                                                                          String pluginName,
                                                                                                                                          String nameFilter,
                                                                                                                                          Integer resourceId,
                                                                                                                                          Integer groupId,
                                                                                                                                          org.rhq.core.domain.util.PageControl pc)
Specified by:
findResourceGroupComposites in interface ResourceGroupManagerLocal

findDeletedResourceGroupIds

public List<Integer> findDeletedResourceGroupIds(int[] possibleGroupIds)
Specified by:
findDeletedResourceGroupIds in interface ResourceGroupManagerLocal

setAssignedResources

public void setAssignedResources(org.rhq.core.domain.auth.Subject subject,
                                 int groupId,
                                 int[] resourceIds,
                                 boolean setType)
                          throws ResourceGroupDeleteException
Description copied from interface: ResourceGroupManagerLocal
This method ensures that the explicit group membership is set to the specified resources. Members will be added or removed as necessary. Make sure you pass the correct value for the parameter.

For global groups requires MANAGE_INVENTORY. For private groups requires VIEW permission on all specified resources.

Specified by:
setAssignedResources in interface ResourceGroupManagerLocal
setType - Set to false if the specified resourceIds will not alter the group type (compatible or mixed). Set true to have the group type (re)set automatically, based on the new group membership.
Throws:
ResourceGroupDeleteException

setAssignedResourceGroupsForResource

public void setAssignedResourceGroupsForResource(org.rhq.core.domain.auth.Subject subject,
                                                 int resourceId,
                                                 int[] resourceGroupIds,
                                                 boolean setType)
                                          throws ResourceGroupDeleteException
Description copied from interface: ResourceGroupManagerLocal
This method ensures that the resource will have exactly the specified set of explicit group membership. Make sure you pass the correct value for the parameter.

Specified by:
setAssignedResourceGroupsForResource in interface ResourceGroupManagerLocal
setType - Set to false if addition or removal of the specified resourceId will not alter the group type for the specified resource groups (compatible or mixed). Set true to have the group type (re)set automatically, based on the new group membership.
Throws:
ResourceGroupDeleteException

getResourceGroup

public org.rhq.core.domain.resource.group.ResourceGroup getResourceGroup(org.rhq.core.domain.auth.Subject subject,
                                                                         int groupId)
Specified by:
getResourceGroup in interface ResourceGroupManagerLocal
Specified by:
getResourceGroup in interface ResourceGroupManagerRemote

getResourceGroupComposite

public org.rhq.core.domain.resource.group.composite.ResourceGroupComposite getResourceGroupComposite(org.rhq.core.domain.auth.Subject subject,
                                                                                                     int groupId)
Specified by:
getResourceGroupComposite in interface ResourceGroupManagerLocal
Specified by:
getResourceGroupComposite in interface ResourceGroupManagerRemote

findResourceGroupsForRole

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.resource.group.ResourceGroup> findResourceGroupsForRole(org.rhq.core.domain.auth.Subject subject,
                                                                                                                     int roleId,
                                                                                                                     org.rhq.core.domain.util.PageControl pc)
Specified by:
findResourceGroupsForRole in interface ResourceGroupManagerLocal
Specified by:
findResourceGroupsForRole in interface ResourceGroupManagerRemote

setRecursive

public void setRecursive(org.rhq.core.domain.auth.Subject subject,
                         int groupId,
                         boolean isRecursive)
Specified by:
setRecursive in interface ResourceGroupManagerLocal
Specified by:
setRecursive in interface ResourceGroupManagerRemote

findResourceGroupsByCriteria

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.resource.group.ResourceGroup> findResourceGroupsByCriteria(org.rhq.core.domain.auth.Subject subject,
                                                                                                                        org.rhq.core.domain.criteria.ResourceGroupCriteria criteria)
Specified by:
findResourceGroupsByCriteria in interface ResourceGroupManagerLocal
Specified by:
findResourceGroupsByCriteria in interface ResourceGroupManagerRemote

findResourceGroupCompositesByCriteria

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.resource.group.composite.ResourceGroupComposite> findResourceGroupCompositesByCriteria(org.rhq.core.domain.auth.Subject subject,
                                                                                                                                                    org.rhq.core.domain.criteria.ResourceGroupCriteria criteria)
This method adheres to all of the regular semantics of Criteria-based queries. In other words, all of the methods on the Criteria object - including paging, sorting, filtering, fetching - will work with this method. The only thing that differs is the ResultSet which, instead of being a collection of ResourceGroup objects is a collection of ResourceGroupComposite objects. The extended data in the composite object, however, is treated differently: 1) It is always fetched 2) It can not be a candidate for filtering 3) It must be sorted by using the zero-based positional ordinal within the projection This method offers 4 new aggregates that you can sort on. The explicitCount (ordinal 0) - the count of the number of children in the group explicitAvail (ordinal 1) - decimal percentage representing the number of UP children relative to the total number of children in the group implicitCount (ordinal 2) - the count of the number of descendents in the group implicitAvail (ordinal 3) - decimal percentage representing the number of UP descendents relative to the total number of descendents in the group

Specified by:
findResourceGroupCompositesByCriteria in interface ResourceGroupManagerLocal

uninventoryMembers

public void uninventoryMembers(org.rhq.core.domain.auth.Subject subject,
                               int groupId)
Specified by:
uninventoryMembers in interface ResourceGroupManagerLocal

updateResourceGroupName

public void updateResourceGroupName(org.rhq.core.domain.auth.Subject subject,
                                    int groupId,
                                    String name)

updateResourceGroupDescription

public void updateResourceGroupDescription(org.rhq.core.domain.auth.Subject subject,
                                           int groupId,
                                           String description)

updateResourceGroupLocation

public void updateResourceGroupLocation(org.rhq.core.domain.auth.Subject subject,
                                        int groupId,
                                        String location)


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.