Hyperic HQ Plugin API v. 4.4.0.2

org.hyperic.hq.appdef.server.session
Class PlatformManagerEJBImpl

java.lang.Object
  extended by org.hyperic.hq.appdef.server.session.AppdefSessionUtil
      extended by org.hyperic.hq.appdef.server.session.AppdefSessionEJB
          extended by org.hyperic.hq.appdef.server.session.PlatformManagerEJBImpl
All Implemented Interfaces:
java.io.Serializable, javax.ejb.EnterpriseBean, javax.ejb.SessionBean

public class PlatformManagerEJBImpl
extends AppdefSessionEJB
implements javax.ejb.SessionBean

This class is responsible for managing Platform objects in appdef and their relationships

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.hyperic.hq.appdef.server.session.AppdefSessionEJB
_ctx, _ic, log
 
Constructor Summary
PlatformManagerEJBImpl()
           
 
Method Summary
 Ip addIp(Platform platform, java.lang.String address, java.lang.String netmask, java.lang.String macAddress)
          Add an IP to a platform
 Platform createPlatform(AuthzSubject subject, AIPlatformValue aipValue)
          Create a Platform from an AIPlatform
 Platform createPlatform(AuthzSubject subject, java.lang.Integer platformTypeId, PlatformValue pValue, java.lang.Integer agentPK)
          Create a Platform of a specified type
 void deletePlatformType(PlatformType pt)
          DevNote: This method was refactored out of updatePlatformTypes.
 void ejbActivate()
           
 void ejbCreate()
          Create a platform manager session bean.
 void ejbPassivate()
           
 void ejbRemove()
           
 java.util.Collection findAllPlatformTypes()
           
 java.util.Collection findDeletedPlatforms()
           
 java.util.List findParentPlatformPojosByNetworkRelation(AuthzSubject subj, java.util.List platformTypeIds, java.lang.String platformName, java.lang.Boolean hasChildren)
           
 Platform findPlatformByFqdn(AuthzSubject subject, java.lang.String fqdn)
          Get the Platform that has the specified Fqdn
 Platform findPlatformById(java.lang.Integer id)
          Find a Platform by Id.
 java.util.Collection findPlatformPojosByIpAddr(java.lang.String addr)
          Get the platforms that have an IP with the specified address.
 java.util.List findPlatformPojosByNoNetworkRelation(AuthzSubject subj, java.util.List platformTypeIds, java.lang.String platformName)
           
 java.util.List findPlatformPojosByTypeAndName(AuthzSubject subj, java.lang.Integer pType, java.lang.String regEx)
           
 PageList findPlatformsByIpAddr(AuthzSubject subject, java.lang.String addr, PageControl pc)
          Get the platforms that have an IP with the specified address.
 PlatformType findPlatformType(java.lang.Integer id)
          Find a PlatformType by id
 PlatformType findPlatformTypeByName(java.lang.String type)
          Find a platform type by name
 Resource findResource(PlatformType pt)
           
 java.util.Collection findSupportedPlatformTypes()
           
 java.util.Collection findUnsupportedPlatformTypes()
           
 PageList getAllPlatforms(AuthzSubject subject, PageControl pc)
          Get all platforms.
 PageList getAllPlatformTypes(AuthzSubject subject, PageControl pc)
          Find all platform types
 Platform getAssociatedPlatformByMacAddress(AuthzSubject subject, Resource r)
          Get the associated platform that has the same MAC address as the given resource
 java.lang.Number getCpuCount()
           
static org.hyperic.hq.appdef.shared.PlatformManagerLocal getOne()
           
 Platform getPhysPlatformByAgentToken(java.lang.String agentToken)
           
 Platform getPlatformByAIPlatform(AuthzSubject subject, AIPlatformValue aiPlatform)
          Get the Platform object based on an AIPlatformValue.
 Platform getPlatformById(AuthzSubject subject, java.lang.Integer id)
          Get platform light value by id.
 java.util.Collection getPlatformByIpAddr(AuthzSubject subject, java.lang.String address)
          Get the Collection of platforms that have the specified Ip address
 java.util.Collection getPlatformByMacAddr(AuthzSubject subject, java.lang.String address)
          Get the Collection of platforms that have the specified MAC address
 PlatformValue getPlatformByName(AuthzSubject subject, java.lang.String name)
          Find a platform by name
 Platform getPlatformByName(java.lang.String name)
           
 PlatformValue getPlatformByServer(AuthzSubject subject, java.lang.Integer serverId)
          Get the platform for a server.
 PlatformValue getPlatformByService(AuthzSubject subject, java.lang.Integer serviceId)
          Get the platform that hosts the server that provides the specified service.
 java.lang.Number getPlatformCount()
           
 java.lang.Integer getPlatformIdByServer(java.lang.Integer serverId)
          Get the platform ID for a server.
 java.lang.Integer getPlatformIdByService(java.lang.Integer serviceId)
          Get the platform ID that hosts the server that provides the specified service.
 java.lang.Integer[] getPlatformIds(AuthzSubject subject, java.lang.Integer platTypeId)
          Get server IDs by server type and platform.
 java.util.Collection getPlatformPksByAgentToken(AuthzSubject subject, java.lang.String agentToken)
          Get the platform by agent token
 java.lang.String getPlatformPluginName(AppdefEntityID id)
          Get PlatformPluginName for an entity id.
 PageList getPlatformsByApplication(AuthzSubject subject, java.lang.Integer appId, PageControl pc)
          Get all platforms by application.
 PageList getPlatformsByServers(AuthzSubject subject, java.util.List sIDs)
          Get the platforms for a list of servers.
 java.util.List getPlatformsByType(AuthzSubject subject, java.lang.String type)
          Get server IDs by server type and platform.
 java.util.List getPlatformTypeCounts()
          Returns a list of 2 element arrays.
 PageList getRecentPlatforms(AuthzSubject subject, long range, int size)
          Get platforms created within a given time range.
 PageList getViewablePlatformTypes(AuthzSubject subject, PageControl pc)
          Find viewable platform types
 void handleResourceDelete(Resource resource)
           
 void removeIp(Platform platform, java.lang.String address, java.lang.String netmask, java.lang.String macAddress)
          Remove an IP on a platform
 void removePlatform(AuthzSubject subject, Platform platform)
          Delete a platform
 Ip updateIp(Platform platform, java.lang.String address, java.lang.String netmask, java.lang.String macAddress)
          Update an IP on a platform
 Platform updatePlatform(AuthzSubject subject, PlatformValue existing)
          Update an existing Platform.
 Platform updatePlatformImpl(AuthzSubject subject, PlatformValue existing)
          Update an existing Platform.
 void updatePlatformTypes(java.lang.String plugin, PlatformTypeInfo[] infos)
          Update platform types
 void updateWithAI(AIPlatformValue aiplatform, AuthzSubject subj)
          Update an existing appdef platform with data from an AI platform.
 
Methods inherited from class org.hyperic.hq.appdef.server.session.AppdefSessionEJB
changeOwner, checkAIScanPermission, checkAlertingPermission, checkAlertingScope, checkControlPermission, checkCreateChildPermission, checkCreatePlatformPermission, checkModifyPermission, checkMonitorPermission, checkPermission, checkPermission, checkRemovePermission, checkViewPermission, createAuthzResource, createAuthzResource, deleteCustomProperties, filterResourceTypes, filterViewableServers, getApplicationPrototypeResourceType, getApplicationResourceType, getAuthzResourceType, getGroupResourceType, getInitialContext, getOperationByName, getOverlord, getPlatformPrototypeResourceType, getPlatformResourceType, getResourcePermissions, getResourceType, getRootResourceType, getServerPrototypeResourceType, getServerResourceType, getServiceCluster, getServicePrototypeResourceType, getServiceResourceType, getSessionContext, getViewableApplications, getViewableGroups, getViewablePlatformPKs, getViewablePlatforms, getViewableServers, getViewableServiceInventory, getViewableServices, removeAuthzResource, rollback, setSessionContext
 
Methods inherited from class org.hyperic.hq.appdef.server.session.AppdefSessionUtil
findResourceType, findResourceType, getAgentDAO, getAIQManagerLocal, getApplicationDAO, getApplicationManager, getConfigManager, getConfigResponseDAO, getCPropManager, getPlatformDAO, getPlatformManager, getPlatformTypeDAO, getResourceManager, getServerDAO, getServerManager, getServerTypeDAO, getServiceDAO, getServiceManager, getServiceTypeDAO
 
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

PlatformManagerEJBImpl

public PlatformManagerEJBImpl()
Method Detail

findPlatformType

public PlatformType findPlatformType(java.lang.Integer id)
                              throws org.hibernate.ObjectNotFoundException
Find a PlatformType by id

Throws:
org.hibernate.ObjectNotFoundException

findPlatformTypeByName

public PlatformType findPlatformTypeByName(java.lang.String type)
                                    throws PlatformNotFoundException
Find a platform type by name

Parameters:
type - - name of the platform type
Returns:
platformTypeValue
Throws:
PlatformNotFoundException

findAllPlatformTypes

public java.util.Collection findAllPlatformTypes()
Returns:
PlatformTypes

findSupportedPlatformTypes

public java.util.Collection findSupportedPlatformTypes()
Returns:
PlatformTypes

findUnsupportedPlatformTypes

public java.util.Collection findUnsupportedPlatformTypes()
Returns:
PlatformTypes

findResource

public Resource findResource(PlatformType pt)

getAllPlatformTypes

public PageList getAllPlatformTypes(AuthzSubject subject,
                                    PageControl pc)
Find all platform types

Returns:
List of PlatformTypeValues

getViewablePlatformTypes

public PageList getViewablePlatformTypes(AuthzSubject subject,
                                         PageControl pc)
                                  throws javax.ejb.FinderException,
                                         PermissionException
Find viewable platform types

Returns:
List of PlatformTypeValues
Throws:
javax.ejb.FinderException
PermissionException

getPlatformPluginName

public java.lang.String getPlatformPluginName(AppdefEntityID id)
                                       throws AppdefEntityNotFoundException
Get PlatformPluginName for an entity id. There is no authz in this method because it is not needed.

Returns:
name of the plugin for the entity's platform such as "Apache 2.0 Linux". It is used as to look up plugins via a generic plugin manager.
Throws:
AppdefEntityNotFoundException

removePlatform

public void removePlatform(AuthzSubject subject,
                           Platform platform)
                    throws javax.ejb.RemoveException,
                           PlatformNotFoundException,
                           PermissionException,
                           VetoException
Delete a platform

Parameters:
subject - The user performing the delete operation.
id - - The id of the Platform
Throws:
javax.ejb.RemoveException
PlatformNotFoundException
PermissionException
VetoException

handleResourceDelete

public void handleResourceDelete(Resource resource)

createPlatform

public Platform createPlatform(AuthzSubject subject,
                               java.lang.Integer platformTypeId,
                               PlatformValue pValue,
                               java.lang.Integer agentPK)
                        throws javax.ejb.CreateException,
                               ValidationException,
                               PermissionException,
                               AppdefDuplicateNameException,
                               AppdefDuplicateFQDNException,
                               ApplicationException
Create a Platform of a specified type

Throws:
javax.ejb.CreateException
ValidationException
PermissionException
AppdefDuplicateNameException
AppdefDuplicateFQDNException
ApplicationException

createPlatform

public Platform createPlatform(AuthzSubject subject,
                               AIPlatformValue aipValue)
                        throws ApplicationException,
                               javax.ejb.CreateException
Create a Platform from an AIPlatform

Parameters:
aipValue - the AIPlatform to create as a regular appdef platform.
Throws:
ApplicationException
javax.ejb.CreateException

getAllPlatforms

public PageList getAllPlatforms(AuthzSubject subject,
                                PageControl pc)
                         throws javax.ejb.FinderException,
                                PermissionException
Get all platforms.

Parameters:
subject - The subject trying to list platforms.
pc - a PageControl object which determines the size of the page and the sorting, if any.
Returns:
A List of PlatformValue objects representing all of the platforms that the given subject is allowed to view.
Throws:
javax.ejb.FinderException
PermissionException

getRecentPlatforms

public PageList getRecentPlatforms(AuthzSubject subject,
                                   long range,
                                   int size)
                            throws javax.ejb.FinderException,
                                   PermissionException
Get platforms created within a given time range.

Parameters:
subject - The subject trying to list platforms.
range - The range in milliseconds.
size - The number of platforms to return.
Returns:
A List of PlatformValue objects representing all of the platforms that the given subject is allowed to view that were created within the given range.
Throws:
javax.ejb.FinderException
PermissionException

getPlatformById

public Platform getPlatformById(AuthzSubject subject,
                                java.lang.Integer id)
                         throws PlatformNotFoundException,
                                PermissionException
Get platform light value by id. Does not check permission.

Throws:
PlatformNotFoundException
PermissionException

findPlatformById

public Platform findPlatformById(java.lang.Integer id)
                          throws PlatformNotFoundException
Find a Platform by Id.

Parameters:
id - The id to look up.
Returns:
A Platform object representing this Platform.
Throws:
PlatformNotFoundException - If the given Platform is not found.

getPlatformByAIPlatform

public Platform getPlatformByAIPlatform(AuthzSubject subject,
                                        AIPlatformValue aiPlatform)
                                 throws PermissionException
Get the Platform object based on an AIPlatformValue. Checks against FQDN, CertDN, then checks to see if all IP addresses match. If all of these checks fail null is returned.

Throws:
PermissionException

getPhysPlatformByAgentToken

public Platform getPhysPlatformByAgentToken(java.lang.String agentToken)
Returns:
non-virtual, physical, Platform associated with the agentToken or null if one does not exist.

getPlatformByName

public PlatformValue getPlatformByName(AuthzSubject subject,
                                       java.lang.String name)
                                throws PlatformNotFoundException,
                                       PermissionException
Find a platform by name

Parameters:
subject - - who is trying this
name - - the name of the platform
Throws:
PlatformNotFoundException
PermissionException

getPlatformByName

public Platform getPlatformByName(java.lang.String name)

findPlatformByFqdn

public Platform findPlatformByFqdn(AuthzSubject subject,
                                   java.lang.String fqdn)
                            throws PlatformNotFoundException,
                                   PermissionException
Get the Platform that has the specified Fqdn

Throws:
PlatformNotFoundException
PermissionException

getPlatformByIpAddr

public java.util.Collection getPlatformByIpAddr(AuthzSubject subject,
                                                java.lang.String address)
                                         throws PermissionException
Get the Collection of platforms that have the specified Ip address

Throws:
PermissionException

getPlatformByMacAddr

public java.util.Collection getPlatformByMacAddr(AuthzSubject subject,
                                                 java.lang.String address)
                                          throws PermissionException
Get the Collection of platforms that have the specified MAC address

Throws:
PermissionException

getAssociatedPlatformByMacAddress

public Platform getAssociatedPlatformByMacAddress(AuthzSubject subject,
                                                  Resource r)
                                           throws PermissionException,
                                                  PlatformNotFoundException
Get the associated platform that has the same MAC address as the given resource

Throws:
PermissionException
PlatformNotFoundException

getPlatformPksByAgentToken

public java.util.Collection getPlatformPksByAgentToken(AuthzSubject subject,
                                                       java.lang.String agentToken)
                                                throws PlatformNotFoundException
Get the platform by agent token

Throws:
PlatformNotFoundException

getPlatformByService

public PlatformValue getPlatformByService(AuthzSubject subject,
                                          java.lang.Integer serviceId)
                                   throws PlatformNotFoundException,
                                          PermissionException
Get the platform that hosts the server that provides the specified service.

Parameters:
subject - The subject trying to list services.
serviceId - service ID.
Returns:
the Platform
Throws:
PlatformNotFoundException
PermissionException

getPlatformIdByService

public java.lang.Integer getPlatformIdByService(java.lang.Integer serviceId)
                                         throws PlatformNotFoundException
Get the platform ID that hosts the server that provides the specified service.

Parameters:
serviceId - service ID.
Returns:
the Platform
Throws:
PlatformNotFoundException

getPlatformByServer

public PlatformValue getPlatformByServer(AuthzSubject subject,
                                         java.lang.Integer serverId)
                                  throws PlatformNotFoundException,
                                         PermissionException
Get the platform for a server.

Parameters:
subject - The subject trying to list services.
serverId - Server ID.
Throws:
PlatformNotFoundException
PermissionException

getPlatformIdByServer

public java.lang.Integer getPlatformIdByServer(java.lang.Integer serverId)
                                        throws PlatformNotFoundException
Get the platform ID for a server.

Parameters:
serverId - Server ID.
Throws:
PlatformNotFoundException

getPlatformsByServers

public PageList getPlatformsByServers(AuthzSubject subject,
                                      java.util.List sIDs)
                               throws PlatformNotFoundException,
                                      PermissionException
Get the platforms for a list of servers.

Parameters:
subject - The subject trying to list services.
Throws:
PlatformNotFoundException
PermissionException

getPlatformsByApplication

public PageList getPlatformsByApplication(AuthzSubject subject,
                                          java.lang.Integer appId,
                                          PageControl pc)
                                   throws ApplicationNotFoundException,
                                          PlatformNotFoundException,
                                          PermissionException
Get all platforms by application.

Parameters:
subject - The subject trying to list services.
appId - Application ID. but when they are, they should live somewhere in appdef/shared so that clients can use them too.
Returns:
A List of ApplicationValue objects representing all of the services that the given subject is allowed to view.
Throws:
ApplicationNotFoundException
PlatformNotFoundException
PermissionException

getPlatformIds

public java.lang.Integer[] getPlatformIds(AuthzSubject subject,
                                          java.lang.Integer platTypeId)
                                   throws PermissionException
Get server IDs by server type and platform.

Parameters:
subject - The subject trying to list servers.
Returns:
A PageList of ServerValue objects representing servers on the specified platform that the subject is allowed to view.
Throws:
PermissionException

getPlatformsByType

public java.util.List getPlatformsByType(AuthzSubject subject,
                                         java.lang.String type)
                                  throws PermissionException,
                                         InvalidAppdefTypeException
Get server IDs by server type and platform.

Parameters:
subject - The subject trying to list servers.
pc - The page control.
Returns:
A PageList of ServerValue objects representing servers on the specified platform that the subject is allowed to view.
Throws:
PermissionException
InvalidAppdefTypeException

findPlatformsByIpAddr

public PageList findPlatformsByIpAddr(AuthzSubject subject,
                                      java.lang.String addr,
                                      PageControl pc)
                               throws PermissionException
Get the platforms that have an IP with the specified address. If no matches are found, this method DOES NOT throw a PlatformNotFoundException, rather it returns an empty PageList.

Throws:
PermissionException

findPlatformPojosByTypeAndName

public java.util.List findPlatformPojosByTypeAndName(AuthzSubject subj,
                                                     java.lang.Integer pType,
                                                     java.lang.String regEx)
Parameters:
subj -
pType - platform type
nameRegEx - regex which matches either the platform fqdn or the resource sortname XXX scottmf need to add permission checking

findParentPlatformPojosByNetworkRelation

public java.util.List findParentPlatformPojosByNetworkRelation(AuthzSubject subj,
                                                               java.util.List platformTypeIds,
                                                               java.lang.String platformName,
                                                               java.lang.Boolean hasChildren)
Parameters:
subj -
platformTypeIds - List of platform type ids
hasChildren - indicates whether the platform is the parent of a network hierarchy
Returns:
a list of Platforms

findPlatformPojosByNoNetworkRelation

public java.util.List findPlatformPojosByNoNetworkRelation(AuthzSubject subj,
                                                           java.util.List platformTypeIds,
                                                           java.lang.String platformName)
Parameters:
subj -
platformTypeIds - List of platform type ids
Returns:
a list of Platforms

findPlatformPojosByIpAddr

public java.util.Collection findPlatformPojosByIpAddr(java.lang.String addr)
Get the platforms that have an IP with the specified address.

Returns:
a list of Platforms

findDeletedPlatforms

public java.util.Collection findDeletedPlatforms()

updatePlatformImpl

public Platform updatePlatformImpl(AuthzSubject subject,
                                   PlatformValue existing)
                            throws UpdateException,
                                   PermissionException,
                                   AppdefDuplicateNameException,
                                   PlatformNotFoundException,
                                   AppdefDuplicateFQDNException,
                                   ApplicationException
Update an existing Platform. Requires all Ip's to have been re-added via the platformValue.addIpValue(IpValue) method due to bug 4924

Parameters:
existing - - the value object for the platform you want to save
Throws:
UpdateException
PermissionException
AppdefDuplicateNameException
PlatformNotFoundException
AppdefDuplicateFQDNException
ApplicationException

updatePlatform

public Platform updatePlatform(AuthzSubject subject,
                               PlatformValue existing)
                        throws UpdateException,
                               PermissionException,
                               AppdefDuplicateNameException,
                               PlatformNotFoundException,
                               AppdefDuplicateFQDNException,
                               ApplicationException
Update an existing Platform. Requires all Ip's to have been re-added via the platformValue.addIpValue(IpValue) method due to bug 4924

Parameters:
existing - - the value object for the platform you want to save
Throws:
UpdateException
PermissionException
AppdefDuplicateNameException
PlatformNotFoundException
AppdefDuplicateFQDNException
ApplicationException

deletePlatformType

public void deletePlatformType(PlatformType pt)
                        throws VetoException,
                               javax.ejb.RemoveException
DevNote: This method was refactored out of updatePlatformTypes. It does not work.

Throws:
VetoException
javax.ejb.RemoveException

updatePlatformTypes

public void updatePlatformTypes(java.lang.String plugin,
                                PlatformTypeInfo[] infos)
                         throws javax.ejb.CreateException,
                                javax.ejb.FinderException,
                                javax.ejb.RemoveException,
                                VetoException
Update platform types

Throws:
javax.ejb.CreateException
javax.ejb.FinderException
javax.ejb.RemoveException
VetoException

updateWithAI

public void updateWithAI(AIPlatformValue aiplatform,
                         AuthzSubject subj)
                  throws PlatformNotFoundException,
                         ApplicationException
Update an existing appdef platform with data from an AI platform.

Parameters:
aiplatform - the AI platform object to use for data
Throws:
PlatformNotFoundException
ApplicationException

addIp

public Ip addIp(Platform platform,
                java.lang.String address,
                java.lang.String netmask,
                java.lang.String macAddress)
Add an IP to a platform


updateIp

public Ip updateIp(Platform platform,
                   java.lang.String address,
                   java.lang.String netmask,
                   java.lang.String macAddress)
Update an IP on a platform


removeIp

public void removeIp(Platform platform,
                     java.lang.String address,
                     java.lang.String netmask,
                     java.lang.String macAddress)
Remove an IP on a platform


getPlatformTypeCounts

public java.util.List getPlatformTypeCounts()
Returns a list of 2 element arrays. The first element is the name of the platform type, the second element is the # of platforms of that type in the inventory.


getPlatformCount

public java.lang.Number getPlatformCount()

getCpuCount

public java.lang.Number getCpuCount()

getOne

public static org.hyperic.hq.appdef.shared.PlatformManagerLocal getOne()

ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException
Create a platform manager session bean.

Throws:
javax.ejb.CreateException - If an error occurs creating the pager for the bean.

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.