Hyperic HQ Plugin API v. 4.4.0.2

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

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

public class ResourceManagerEJBImpl
extends AuthzSession
implements javax.ejb.SessionBean

Use this session bean to manipulate Resources, ResourceTypes and ResourceGroups. That is to say, Resources and their derivatives. Alteratively you can say, anything enity that starts with the word Resource. 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
 
Constructor Summary
ResourceManagerEJBImpl()
           
 
Method Summary
 void _removeResource(AuthzSubject subj, Resource r, boolean nullResourceType)
           
 Resource createResource(AuthzSubject owner, ResourceType rt, Resource prototype, java.lang.Integer instanceId, java.lang.String name, boolean system, Resource parent)
          Create a resource.
 void createResourceEdges(AuthzSubject subject, ResourceRelation relation, AppdefEntityID parent, AppdefEntityID[] children)
           
 void createResourceEdges(AuthzSubject subject, ResourceRelation relation, AppdefEntityID parent, AppdefEntityID[] children, boolean deleteExisting)
           
 void ejbActivate()
           
 void ejbCreate()
           
 void ejbPassivate()
           
 void ejbRemove()
           
 java.util.List findAllAppdefPrototypes()
          Get all resources which are prototypes of platforms, servers, and services.
 java.util.Map findAllViewableInstances(AuthzSubject subject)
          Get viewable resources either by "type" OR "resource name" OR "type AND resource name".
 java.util.Collection findAncestorResourceEdges(Resource resource, ResourceRelation relation)
           
 java.util.List findAppdefPrototypes()
          Get all resources which are prototypes of platforms, servers, and services and have a resource of that type in the inventory.
 java.util.Collection findChildResourceEdges(Resource resource, ResourceRelation relation)
           
 java.util.Collection findDescendantResourceEdges(Resource resource, ResourceRelation relation)
           
 Resource findResource(AppdefEntityID aeid)
           
 Resource findResourceById(java.lang.Integer id)
           
 Resource findResourceByInstanceId(java.lang.Integer typeId, java.lang.Integer instanceId)
           
 Resource findResourceByInstanceId(ResourceType type, java.lang.Integer instanceId)
          Find the Resource that has the given instance ID and ResourceType.
 java.util.Collection findResourceByOwner(AuthzSubject owner)
          Gets all the Resources owned by the given Subject.
 Resource findResourceByTypeAndInstanceId(java.lang.String type, java.lang.Integer instanceId)
          Find the Resource that has the given instance ID and ResourceType name.
 java.util.List findResourceEdges(ResourceRelation relation, java.lang.Integer resourceId, java.util.List platformTypeIds, java.lang.String platformName)
           
 java.util.Collection findResourceEdges(ResourceRelation relation, java.util.List parentList)
           
 java.util.Collection findResourceEdges(ResourceRelation relation, Resource parent)
           
 java.util.Collection findResourceEdgesByName(java.lang.String name, ResourceRelation relation)
           
 Resource findResourcePrototype(AppdefEntityTypeID id)
           
 Resource findResourcePrototypeByName(java.lang.String name)
          Find a resource, acting as a resource prototype.
 java.util.List findResourcesByParent(AuthzSubject subject, Resource res)
          Find all the resources which are descendents of the given resource
 java.util.List findResourcesOfPrototype(Resource proto, PageInfo pInfo)
          Find all the resources which have the specified prototype
 java.util.List findResourcesOfType(int resourceType, PageInfo pInfo)
          Find all the resources of an authz resource type
 ResourceType findResourceTypeByName(java.lang.String name)
          Find the type that has the given name.
 Resource findRootResource()
          Find's the root (id=0) resource
 java.util.List findViewableInstances(AuthzSubject subject, java.lang.String typeName, java.lang.String resName, java.lang.String appdefTypeStr, java.lang.Integer typeId, PageControl pc)
          Get viewable resources either by "type" OR "resource name" OR "type AND resource name".
 PageList findViewables(AuthzSubject subject, java.lang.String searchFor, PageControl pc)
          Get viewable resources by "type" OR "resource name"
 PageList findViewableSvcResources(AuthzSubject subject, java.lang.String nameFilter, PageControl pc)
          Get viewable service resources.
 java.util.List getAllResourceTypes(AuthzSubject subject, PageControl pc)
          Get all the resource types
 int getDescendantResourceEdgeCount(Resource resource, ResourceRelation relation)
           
static org.hyperic.hq.authz.shared.ResourceManagerLocal getOne()
           
 ResourceEdge getParentResourceEdge(Resource resource, ResourceRelation relation)
           
 int getPlatformCountMinusVsphereVmPlatforms()
           
 java.lang.Number getResourceCount()
          Get the # of resources within HQ inventory
 java.lang.Number getResourceTypeCount()
          Get the # of resource types within HQ inventory
 Resource getResourceTypeResource(java.lang.Integer typeId)
          Get the Resource entity associated with this ResourceType.
 boolean hasChildResourceEdges(Resource resource, ResourceRelation relation)
           
 boolean hasResourceRelation(Resource resource, ResourceRelation relation)
           
 boolean isResourceChildOf(Resource parent, Resource child)
           
 void moveResource(AuthzSubject owner, Resource target, Resource destination)
          Move a resource.
 void removeResource(AuthzSubject subject, Resource r)
           
 void removeResourceEdges(AuthzSubject subject, ResourceRelation relation, AppdefEntityID parent, AppdefEntityID[] children)
           
 void removeResourceEdges(AuthzSubject subject, ResourceRelation relation, Resource parent)
           
 AppdefEntityID[] removeResourcePerms(AuthzSubject subj, Resource r, boolean nullResourceType)
          Removes the specified resource by nulling out its resourceType.
 void resourceHierarchyUpdated(AuthzSubject subj, java.util.Collection resources)
           
 boolean resourcesExistOfType(java.lang.String typeName)
          Check if there are any resources of a given type
 void setResourceOwner(AuthzSubject whoami, Resource resource, AuthzSubject newOwner)
           
 
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

ResourceManagerEJBImpl

public ResourceManagerEJBImpl()
Method Detail

findResourceTypeByName

public ResourceType findResourceTypeByName(java.lang.String name)
                                    throws javax.ejb.FinderException
Find the type that has the given name.

Parameters:
name - The name of the type you're looking for.
Returns:
The value-object of the type of the given name.
Throws:
javax.ejb.FinderException - Unable to find a given or dependent entities.

findResourcePrototypeByName

public Resource findResourcePrototypeByName(java.lang.String name)
Find a resource, acting as a resource prototype.


resourcesExistOfType

public boolean resourcesExistOfType(java.lang.String typeName)
Check if there are any resources of a given type


createResource

public Resource createResource(AuthzSubject owner,
                               ResourceType rt,
                               Resource prototype,
                               java.lang.Integer instanceId,
                               java.lang.String name,
                               boolean system,
                               Resource parent)
Create a resource.


moveResource

public void moveResource(AuthzSubject owner,
                         Resource target,
                         Resource destination)
Move a resource. It is the responsibility of the caller (AppdefManager) to ensure that this resource can be moved to the destination. It's also of note that this method only deals with relinking resource edges to the ancestors of the destination resource. This means that in the case of Server moves, it's up to the caller to re-link dependent chilren.


getResourceCount

public java.lang.Number getResourceCount()
Get the # of resources within HQ inventory


getResourceTypeCount

public java.lang.Number getResourceTypeCount()
Get the # of resource types within HQ inventory


getResourceTypeResource

public Resource getResourceTypeResource(java.lang.Integer typeId)
Get the Resource entity associated with this ResourceType.

Parameters:
type - This ResourceType.

findResourceByInstanceId

public Resource findResourceByInstanceId(ResourceType type,
                                         java.lang.Integer instanceId)
Find the Resource that has the given instance ID and ResourceType.

Parameters:
type - The ResourceType of the Resource you're looking for.
instanceId - Your ID for the resource you're looking for.
Returns:
The value-object of the Resource of the given ID.

findResourceByInstanceId

public Resource findResourceByInstanceId(java.lang.Integer typeId,
                                         java.lang.Integer instanceId)

findRootResource

public Resource findRootResource()
Find's the root (id=0) resource


findResourceById

public Resource findResourceById(java.lang.Integer id)

findResourceByTypeAndInstanceId

public Resource findResourceByTypeAndInstanceId(java.lang.String type,
                                                java.lang.Integer instanceId)
Find the Resource that has the given instance ID and ResourceType name.

Parameters:
type - The ResourceType of the Resource you're looking for.
instanceId - Your ID for the resource you're looking for.
Returns:
The value-object of the Resource of the given ID.

findResource

public Resource findResource(AppdefEntityID aeid)

findResourcePrototype

public Resource findResourcePrototype(AppdefEntityTypeID id)

removeResourcePerms

public AppdefEntityID[] removeResourcePerms(AuthzSubject subj,
                                            Resource r,
                                            boolean nullResourceType)
                                     throws VetoException,
                                            PermissionException
Removes the specified resource by nulling out its resourceType. Will not null the resourceType of the resource which is passed in. These resources need to be cleaned up eventually by AppdefBossEJBImpl.removeDeletedResources. This may be done in the background via zevent by issuing a ResourcesCleanupZevent.

Parameters:
r - Resource resource to be removed.
nullResourceType - tells the method to null out the resourceType
Returns:
AppdefEntityID[] - an array of the resources (including children) deleted
Throws:
VetoException
PermissionException
See Also:
AppdefBossEJBImpl.removeDeletedResources}, ResourcesCleanupZevent}

_removeResource

public void _removeResource(AuthzSubject subj,
                            Resource r,
                            boolean nullResourceType)

removeResource

public void removeResource(AuthzSubject subject,
                           Resource r)
                    throws VetoException
Throws:
VetoException

setResourceOwner

public void setResourceOwner(AuthzSubject whoami,
                             Resource resource,
                             AuthzSubject newOwner)
                      throws PermissionException
Throws:
PermissionException

getAllResourceTypes

public java.util.List getAllResourceTypes(AuthzSubject subject,
                                          PageControl pc)
Get all the resource types

Parameters:
subject -
pc - Paging information for the request

findViewableInstances

public java.util.List findViewableInstances(AuthzSubject subject,
                                            java.lang.String typeName,
                                            java.lang.String resName,
                                            java.lang.String appdefTypeStr,
                                            java.lang.Integer typeId,
                                            PageControl pc)
Get viewable resources either by "type" OR "resource name" OR "type AND resource name".

Parameters:
subject -
Returns:
Map of resource values

findViewables

public PageList findViewables(AuthzSubject subject,
                              java.lang.String searchFor,
                              PageControl pc)
Get viewable resources by "type" OR "resource name"

Parameters:
subject -
Returns:
Map of resource values

findAllViewableInstances

public java.util.Map findAllViewableInstances(AuthzSubject subject)
Get viewable resources either by "type" OR "resource name" OR "type AND resource name".

Parameters:
subject -
Returns:
Map of resource values

findResourcesByParent

public java.util.List findResourcesByParent(AuthzSubject subject,
                                            Resource res)
Find all the resources which are descendents of the given resource


findResourcesOfType

public java.util.List findResourcesOfType(int resourceType,
                                          PageInfo pInfo)
Find all the resources of an authz resource type

Parameters:
resourceType - 301 for platforms, etc.
pInfo - A pager, using a sort field of ResourceSortField
Returns:
a list of Resources

findResourcesOfPrototype

public java.util.List findResourcesOfPrototype(Resource proto,
                                               PageInfo pInfo)
Find all the resources which have the specified prototype

Returns:
a list of Resources

findAppdefPrototypes

public java.util.List findAppdefPrototypes()
Get all resources which are prototypes of platforms, servers, and services and have a resource of that type in the inventory.


findAllAppdefPrototypes

public java.util.List findAllAppdefPrototypes()
Get all resources which are prototypes of platforms, servers, and services.


findViewableSvcResources

public PageList findViewableSvcResources(AuthzSubject subject,
                                         java.lang.String nameFilter,
                                         PageControl pc)
Get viewable service resources. Service resources include individual cluster unassigned services as well as service clusters.

Parameters:
subject -
pc - control
Returns:
PageList of resource values

findResourceByOwner

public java.util.Collection findResourceByOwner(AuthzSubject owner)
Gets all the Resources owned by the given Subject.

Parameters:
subject - The owner.
Returns:
Array of resources owned by the given subject.

findResourceEdges

public java.util.Collection findResourceEdges(ResourceRelation relation,
                                              java.util.List parentList)
Parameters:
parentList - List of Resources
Returns:
Collection of ResourceEdges

findResourceEdges

public java.util.Collection findResourceEdges(ResourceRelation relation,
                                              Resource parent)
Returns:
Collection of ResourceEdges

isResourceChildOf

public boolean isResourceChildOf(Resource parent,
                                 Resource child)

hasChildResourceEdges

public boolean hasChildResourceEdges(Resource resource,
                                     ResourceRelation relation)

getDescendantResourceEdgeCount

public int getDescendantResourceEdgeCount(Resource resource,
                                          ResourceRelation relation)

findChildResourceEdges

public java.util.Collection findChildResourceEdges(Resource resource,
                                                   ResourceRelation relation)

findDescendantResourceEdges

public java.util.Collection findDescendantResourceEdges(Resource resource,
                                                        ResourceRelation relation)

findAncestorResourceEdges

public java.util.Collection findAncestorResourceEdges(Resource resource,
                                                      ResourceRelation relation)

findResourceEdgesByName

public java.util.Collection findResourceEdgesByName(java.lang.String name,
                                                    ResourceRelation relation)

getParentResourceEdge

public ResourceEdge getParentResourceEdge(Resource resource,
                                          ResourceRelation relation)

hasResourceRelation

public boolean hasResourceRelation(Resource resource,
                                   ResourceRelation relation)

findResourceEdges

public java.util.List findResourceEdges(ResourceRelation relation,
                                        java.lang.Integer resourceId,
                                        java.util.List platformTypeIds,
                                        java.lang.String platformName)

createResourceEdges

public void createResourceEdges(AuthzSubject subject,
                                ResourceRelation relation,
                                AppdefEntityID parent,
                                AppdefEntityID[] children)
                         throws PermissionException,
                                ResourceEdgeCreateException
Throws:
PermissionException
ResourceEdgeCreateException

createResourceEdges

public void createResourceEdges(AuthzSubject subject,
                                ResourceRelation relation,
                                AppdefEntityID parent,
                                AppdefEntityID[] children,
                                boolean deleteExisting)
                         throws PermissionException,
                                ResourceEdgeCreateException
Throws:
PermissionException
ResourceEdgeCreateException

removeResourceEdges

public void removeResourceEdges(AuthzSubject subject,
                                ResourceRelation relation,
                                AppdefEntityID parent,
                                AppdefEntityID[] children)
                         throws PermissionException
Throws:
PermissionException

removeResourceEdges

public void removeResourceEdges(AuthzSubject subject,
                                ResourceRelation relation,
                                Resource parent)
                         throws PermissionException
Throws:
PermissionException

resourceHierarchyUpdated

public void resourceHierarchyUpdated(AuthzSubject subj,
                                     java.util.Collection resources)
Parameters:
{@link - Collection} of Resources

getPlatformCountMinusVsphereVmPlatforms

public int getPlatformCountMinusVsphereVmPlatforms()
Returns:
the resource count with prototype of AuthzConstants.authzPlatform minus resources with the prototype of AuthConstants.platformPrototypeVmwareVsphereVm

getOne

public static org.hyperic.hq.authz.shared.ResourceManagerLocal 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.