Hyperic HQ Plugin API v. 4.4.0.2

org.hyperic.hq.authz.server.session
Class ResourceGroupManagerEJBImpl

java.lang.Object
  extended by org.hyperic.hq.authz.server.session.AuthzSession
      extended by org.hyperic.hq.authz.server.session.ResourceGroupManagerEJBImpl
All Implemented Interfaces:
java.io.Serializable, javax.ejb.EnterpriseBean, javax.ejb.SessionBean

public class ResourceGroupManagerEJBImpl
extends AuthzSession
implements javax.ejb.SessionBean

Use this session bean to manipulate ResourceGroups, All arguments and return values are value-objects.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.hyperic.hq.authz.server.session.AuthzSession
ctx, log
 
Constructor Summary
ResourceGroupManagerEJBImpl()
           
 
Method Summary
 void addResource(AuthzSubject whoami, Resource resource, java.util.Collection groups)
          Add a resource to a collection of groups
 ResourceGroup addResource(AuthzSubject whoami, ResourceGroup group, Resource resource)
          Add a resource to a group by resource id and resource type
 void addResources(AuthzSubject subj, ResourceGroup group, java.util.List resources)
           
 void changeGroupOwner(AuthzSubject subject, ResourceGroup group, AuthzSubject newOwner)
          Change owner of a group.
 ResourceGroup createResourceGroup(AuthzSubject whoami, ResourceGroup.ResourceGroupCreateInfo cInfo, java.util.Collection roles, java.util.Collection resources)
          Create a resource group.
 void ejbActivate()
           
 void ejbCreate()
           
 void ejbPassivate()
           
 void ejbRemove()
           
 java.util.Collection findDeletedGroups()
           
 PageList findGroupsContaining(AuthzSubject subject, Resource member, java.util.Collection excludeGroups, PageInfo pInfo)
          Get a list of ResourceGroups which are compatible with the specified prototype.
 PageList findGroupsNotContaining(AuthzSubject subject, Resource member, Resource prototype, java.util.Collection excGrps, PageInfo pInfo)
          Get a list of ResourceGroups which are compatable with the specified prototype.
 ResourceGroup findResourceGroupById(AuthzSubject whoami, java.lang.Integer id)
          Find the group that has the given ID.
 ResourceGroup findResourceGroupById(java.lang.Integer id)
          Find the group that has the given ID.
 ResourceGroup findResourceGroupByName(AuthzSubject whoami, java.lang.String name)
          Find the role that has the given name.
 java.util.Collection getAllResourceGroups()
          Get all ResourceGroups
 java.util.Collection getAllResourceGroups(AuthzSubject subject, boolean excludeRoot)
          Get all the resource groups excluding the root resource group.
 java.util.List getAllResourceGroups(AuthzSubject subject, PageControl pc)
          Get all the resource groups including the root resource group.
 AppdefResourceType getAppdefResourceType(AuthzSubject subject, ResourceGroup group)
           
 java.util.Collection getCompatibleResourceGroups(AuthzSubject subject, Resource resProto)
          Get all compatible resource groups of the given entity type and resource type.
 AppdefGroupValue getGroupConvert(AuthzSubject subj, ResourceGroup g)
          Temporary method to convert a ResourceGroup into an AppdefGroupValue
 java.lang.Number getGroupCount()
          Get the # of groups within HQ inventory
 java.util.Collection getGroups(Resource r)
          Get all the groups a resource belongs to
 long getMaxCollectionInterval(ResourceGroup g, java.lang.Integer templateId)
          Get the maximum collection interval for a scheduled metric within a compatible group of resources.
 java.util.Collection getMembers(ResourceGroup g)
          Get all the members of a group.
 java.util.Map getMemberTypes(ResourceGroup g)
          Get the member type counts of a group
 java.util.List getMetricsCollecting(ResourceGroup g, java.lang.Integer templateId)
          Return a List of Measurements that are collecting for the given template ID and group.
 int getNumMembers(ResourceGroup g)
          Get the # of members in a group
static org.hyperic.hq.authz.shared.ResourceGroupManagerLocal getOne()
           
 ResourceGroup getResourceGroupByResource(Resource resource)
           
 AuthzSubject getResourceGroupOwner(java.lang.Integer gid)
          Get a ResourceGroup owner's AuthzSubjectValue
 PageList getResourceGroupsById(AuthzSubject whoami, java.lang.Integer[] ids, PageControl pc)
          Get the resource groups with the specified ids
 java.util.Collection getResources(AuthzSubject whoami, java.lang.Integer id)
          List the resources in this group that the caller is authorized to see.
 boolean isMember(ResourceGroup group, Resource resource)
          Returns true if the passed resource is a member of the given group.
 void removeGroupsCompatibleWith(Resource proto)
          Remove all groups compatable with the specified resource prototype.
 void removeResource(AuthzSubject whoami, Resource resource, java.util.Collection groups)
          Remove a resource from a collection of groups
 void removeResourceGroup(AuthzSubject whoami, ResourceGroup group)
          Delete the specified ResourceGroup.
 void removeResources(AuthzSubject whoami, ResourceGroup group, java.util.Collection resources)
          RemoveResources from a group.
 void setCriteria(AuthzSubject whoami, ResourceGroup group, CritterList critters)
          Sets the criteria list for this group.
 void setGroupModifiedBy(AuthzSubject whoami, java.lang.Integer id)
          Set a ResourceGroup modifiedBy attribute
 void setResources(AuthzSubject whoami, ResourceGroup group, java.util.Collection resources)
          Change the resource contents of a group to the specified list of resources.
 void updateGroup(AuthzSubject whoami, ResourceGroup group, java.lang.String name, java.lang.String description, java.lang.String location)
          Update some of the fundamentals of groups (name, description, location).
 void updateGroupType(AuthzSubject subject, ResourceGroup g, int groupType, int groupEntType, int groupEntResType)
           
 
Methods inherited from class org.hyperic.hq.authz.server.session.AuthzSession
findPrototype, findSubjectByAuth, getContainmentRelation, getInitialContext, getNetworkRelation, getOperationDAO, getResourceDAO, getResourceGroupDAO, getResourceTypeDAO, getRoleDAO, getRootResourceType, getSessionContext, getSubjectDAO, getVirtualRelation, lookupSubject, setSessionContext, toPojos
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.ejb.SessionBean
setSessionContext
 

Constructor Detail

ResourceGroupManagerEJBImpl

public ResourceGroupManagerEJBImpl()
Method Detail

createResourceGroup

public ResourceGroup createResourceGroup(AuthzSubject whoami,
                                         ResourceGroup.ResourceGroupCreateInfo cInfo,
                                         java.util.Collection roles,
                                         java.util.Collection resources)
                                  throws GroupCreationException,
                                         GroupDuplicateNameException
Create a resource group. Currently no permission checking.

Parameters:
roles - List of Roles
resources - List of Resources
Throws:
GroupCreationException
GroupDuplicateNameException

findResourceGroupById

public ResourceGroup findResourceGroupById(AuthzSubject whoami,
                                           java.lang.Integer id)
                                    throws PermissionException
Find the group that has the given ID. Performs authz checking

Parameters:
whoami - user requesting to find the group
Returns:
ResourceGroup or null if it does not exist XXX scottmf, why is this method called find() but calls dao.get()???
Throws:
PermissionException

findResourceGroupById

public ResourceGroup findResourceGroupById(java.lang.Integer id)
Find the group that has the given ID. Does not do any authz checking


findResourceGroupByName

public ResourceGroup findResourceGroupByName(AuthzSubject whoami,
                                             java.lang.String name)
                                      throws PermissionException
Find the role that has the given name.

Parameters:
whoami - user requesting to find the group
name - The name of the role you're looking for.
Returns:
The value-object of the role of the given name.
Throws:
PermissionException - whoami does not have viewResourceGroup on the requested group

findDeletedGroups

public java.util.Collection findDeletedGroups()

updateGroup

public void updateGroup(AuthzSubject whoami,
                        ResourceGroup group,
                        java.lang.String name,
                        java.lang.String description,
                        java.lang.String location)
                 throws PermissionException,
                        GroupDuplicateNameException
Update some of the fundamentals of groups (name, description, location). If name, description or location are null, the associated properties of the passed group will not change.

Throws:
DuplicateObjectException - if an attempt to rename the group would result in a group with the same name.
PermissionException
GroupDuplicateNameException

removeGroupsCompatibleWith

public void removeGroupsCompatibleWith(Resource proto)
                                throws VetoException
Remove all groups compatable with the specified resource prototype.

Throws:
VetoException - if another subsystem cannot allow it (for constraint reasons)

removeResourceGroup

public void removeResourceGroup(AuthzSubject whoami,
                                ResourceGroup group)
                         throws PermissionException,
                                VetoException
Delete the specified ResourceGroup.

Parameters:
whoami - The current running user.
group - The group to delete.
Throws:
PermissionException
VetoException

addResources

public void addResources(AuthzSubject subj,
                         ResourceGroup group,
                         java.util.List resources)
                  throws PermissionException,
                         VetoException
Throws:
PermissionException
VetoException

addResource

public ResourceGroup addResource(AuthzSubject whoami,
                                 ResourceGroup group,
                                 Resource resource)
                          throws PermissionException,
                                 VetoException
Add a resource to a group by resource id and resource type

Throws:
PermissionException
VetoException

addResource

public void addResource(AuthzSubject whoami,
                        Resource resource,
                        java.util.Collection groups)
                 throws PermissionException,
                        VetoException
Add a resource to a collection of groups

Parameters:
whoami - The current running user.
resource - The resource
groups - The groups to add to.
Throws:
PermissionException
VetoException

removeResource

public void removeResource(AuthzSubject whoami,
                           Resource resource,
                           java.util.Collection groups)
                    throws PermissionException,
                           VetoException
Remove a resource from a collection of groups

Parameters:
whoami - The current running user.
resource - The resource
groups - The groups to remove from.
Throws:
PermissionException
VetoException

removeResources

public void removeResources(AuthzSubject whoami,
                            ResourceGroup group,
                            java.util.Collection resources)
                     throws PermissionException,
                            VetoException
RemoveResources from a group.

Parameters:
whoami - The current running user.
group - The group .
Throws:
PermissionException
VetoException

setCriteria

public void setCriteria(AuthzSubject whoami,
                        ResourceGroup group,
                        CritterList critters)
                 throws PermissionException,
                        GroupException
Sets the criteria list for this group.

Parameters:
whoami - The current running user.
group - This group.
critters - List of critters to associate with this resource group.
Throws:
PermissionException - whoami does not own the resource.
GroupException - critters is not a valid list of criteria.

setResources

public void setResources(AuthzSubject whoami,
                         ResourceGroup group,
                         java.util.Collection resources)
                  throws PermissionException,
                         VetoException
Change the resource contents of a group to the specified list of resources.

Parameters:
resources - A list of Resources to be in the group
Throws:
PermissionException
VetoException

getResources

public java.util.Collection getResources(AuthzSubject whoami,
                                         java.lang.Integer id)
List the resources in this group that the caller is authorized to see.

Parameters:
whoami - The current running user.
groupValue - This group.
pc - Paging information for the request
Returns:
list of authorized resources in this group.

getAllResourceGroups

public java.util.List getAllResourceGroups(AuthzSubject subject,
                                           PageControl pc)
                                    throws PermissionException,
                                           javax.ejb.FinderException
Get all the resource groups including the root resource group.

Throws:
PermissionException
javax.ejb.FinderException

getMembers

public java.util.Collection getMembers(ResourceGroup g)
Get all the members of a group.

Returns:
Resources

getMemberTypes

public java.util.Map getMemberTypes(ResourceGroup g)
Get the member type counts of a group


getGroups

public java.util.Collection getGroups(Resource r)
Get all the groups a resource belongs to

Returns:
ResourceGroups

getGroupCount

public java.lang.Number getGroupCount()
Get the # of groups within HQ inventory


isMember

public boolean isMember(ResourceGroup group,
                        Resource resource)
Returns true if the passed resource is a member of the given group.


getNumMembers

public int getNumMembers(ResourceGroup g)
Get the # of members in a group


getGroupConvert

public AppdefGroupValue getGroupConvert(AuthzSubject subj,
                                        ResourceGroup g)
Temporary method to convert a ResourceGroup into an AppdefGroupValue


getAppdefResourceType

public AppdefResourceType getAppdefResourceType(AuthzSubject subject,
                                                ResourceGroup group)

findGroupsNotContaining

public PageList findGroupsNotContaining(AuthzSubject subject,
                                        Resource member,
                                        Resource prototype,
                                        java.util.Collection excGrps,
                                        PageInfo pInfo)
Get a list of ResourceGroups which are compatable with the specified prototype. Do not return any groups contained within 'excludeGroups' (a list of ResourceGroups

Parameters:
prototype - If specified, the resulting groups must be compatable with the prototype.
pInfo - Pageinfo with a sort field of type ResourceGroupSortField

findGroupsContaining

public PageList findGroupsContaining(AuthzSubject subject,
                                     Resource member,
                                     java.util.Collection excludeGroups,
                                     PageInfo pInfo)
Get a list of ResourceGroups which are compatible with the specified prototype. Do not return any groups contained within 'excludeGroups' (a list of ResourceGroups

Parameters:
prototype - If specified, the resulting groups must be compatible with the prototype.
pInfo - Pageinfo with a sort field of type ResourceGroupSortField

getAllResourceGroups

public java.util.Collection getAllResourceGroups(AuthzSubject subject,
                                                 boolean excludeRoot)
                                          throws PermissionException
Get all the resource groups excluding the root resource group.

Throws:
PermissionException

getAllResourceGroups

public java.util.Collection getAllResourceGroups()
Get all ResourceGroups


getCompatibleResourceGroups

public java.util.Collection getCompatibleResourceGroups(AuthzSubject subject,
                                                        Resource resProto)
                                                 throws javax.ejb.FinderException,
                                                        PermissionException
Get all compatible resource groups of the given entity type and resource type.

Throws:
javax.ejb.FinderException
PermissionException

getResourceGroupsById

public PageList getResourceGroupsById(AuthzSubject whoami,
                                      java.lang.Integer[] ids,
                                      PageControl pc)
                               throws PermissionException,
                                      javax.ejb.FinderException
Get the resource groups with the specified ids

Parameters:
ids - the resource group ids
pc - Paging information for the request
Throws:
PermissionException
javax.ejb.FinderException

changeGroupOwner

public void changeGroupOwner(AuthzSubject subject,
                             ResourceGroup group,
                             AuthzSubject newOwner)
                      throws PermissionException
Change owner of a group.

Throws:
PermissionException

getResourceGroupOwner

public AuthzSubject getResourceGroupOwner(java.lang.Integer gid)
                                   throws javax.ejb.FinderException
Get a ResourceGroup owner's AuthzSubjectValue

Parameters:
gid - The group id
Throws:
javax.ejb.FinderException - Unable to find a group by id

getResourceGroupByResource

public ResourceGroup getResourceGroupByResource(Resource resource)

setGroupModifiedBy

public void setGroupModifiedBy(AuthzSubject whoami,
                               java.lang.Integer id)
Set a ResourceGroup modifiedBy attribute

Parameters:
whoami - user requesting to find the group
id - The ID of the role you're looking for.

updateGroupType

public void updateGroupType(AuthzSubject subject,
                            ResourceGroup g,
                            int groupType,
                            int groupEntType,
                            int groupEntResType)
                     throws PermissionException
Throws:
PermissionException

getMaxCollectionInterval

public long getMaxCollectionInterval(ResourceGroup g,
                                     java.lang.Integer templateId)
Get the maximum collection interval for a scheduled metric within a compatible group of resources.

Returns:
The maximum collection time in milliseconds. TODO: This does not belong here. Evict, evict! -- JMT 04/01/08

getMetricsCollecting

public java.util.List getMetricsCollecting(ResourceGroup g,
                                           java.lang.Integer templateId)
Return a List of Measurements that are collecting for the given template ID and group.

Parameters:
g - The group in question.
templateId - The measurement template to query.
Returns:
templateId A list of Measurement objects with the given template id in the group that are set to be collected. TODO: This does not belong here. Evict, evict! -- JMT 04/01/08

getOne

public static org.hyperic.hq.authz.shared.ResourceGroupManagerLocal getOne()

ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException
Throws:
javax.ejb.CreateException

ejbRemove

public void ejbRemove()
Specified by:
ejbRemove in interface javax.ejb.SessionBean

ejbActivate

public void ejbActivate()
Specified by:
ejbActivate in interface javax.ejb.SessionBean

ejbPassivate

public void ejbPassivate()
Specified by:
ejbPassivate in interface javax.ejb.SessionBean

Hyperic HQ Plugin API v. 4.4.0.2

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.