edu.vt.middleware.registry.common
Class CommonRegistryFinder

java.lang.Object
  extended by edu.vt.middleware.registry.common.CommonRegistryFinder
Direct Known Subclasses:
RegistryFinder, RegistryFinder, RegistryFinder, RegistryFinder, RegistryFinder, RegistryFinder, RegistryFinder, RegistryFinder, RegistryFinder, RegistryFinder, RegistryFinder, RegistryFinder, RegistryFinder, RegistryFinder, RegistryUpdater, RegistryUpdater, RegistryUpdater, RegistryUpdater, RegistryUpdater, RegistryUpdater, RegistryUpdater, RegistryUpdater, RegistryUpdater, RegistryUpdater, RegistryUpdater, RegistryUpdater, RegistryUpdater

public class CommonRegistryFinder
extends Object

CommonRegistryFinder implements the details of finding common Registry beans and related data.

Version:
$Revision: 7986 $
Author:
Daniel Fisher

Field Summary
private  EntityManager entityManager
          Entity Manager for looking up beans
private static Log LOG
          Log for this class
 
Constructor Summary
CommonRegistryFinder(EntityManager em)
          Creates a new CommonRegistryFinder with the supplied entity manager.
 
Method Summary
 boolean emailAccountExists(Long uid)
          This returns whether the supplied email account uid exists.
 boolean entitlementExists(Long uid)
          This returns whether the supplied entitlement exists in the registry.
 void flushAndRefresh(DataObject o)
          Calls flush and refresh on the supplied data object.
private  Account getAccount(Long uid)
          This returns the account for the person with the supplied UID.
 AccountState getAccountState(Long uid)
          This returns the account state for the supplied UID.
<T extends DataType>
List<T>
getDataTypes(Class<T> dataTypeClass)
          This returns all data types in the registry.
 EntitlementData getEntitlementData(String entitlement)
          This returns the EntitlementData bean for the supplied entitlement string.
 EntityManager getEntityManager()
          Returns the EntityManager for this class.
 Group getGroup(String uugid)
          This returns the Group bean for the supplied UUGID.
 Group getGroup(String uugid, boolean throwIfNotFound)
          Gets a group from the registry for the given uugid.
private
<T extends NamedDataObject>
T
getNamedDataObject(Class<T> ndoClass, String uuid, boolean throwIfNotFound)
          Gets a named data object from the registry for the given uuid.
 Person getPerson(Long uid)
          This returns the Person bean for the supplied UID.
 Person getPerson(Long uid, boolean throwIfNotFound)
          Gets a person from the registry for the given uid.
 Long getPersonUid(String userid)
          This returns the sequence number of the person with the supplied userid.
 Service getService(String uusid)
          This returns the Service bean for the supplied UUSID.
 Service getService(String uusid, boolean throwIfNotFound)
          Gets a service from the registry for the given uusid.
 Ticket getTicket(String id)
          This returns the Ticket bean for the supplied ID.
 Ticket getTicket(String id, boolean throwIfNotFound)
           
 String getUserid(Long uid)
          This returns the userid for the person with the supplied UID.
 boolean groupExists(String uugid)
          This returns whether a group exists for the supplied UUGID in the registry.
 boolean guestIdExists(String guestId)
          This returns whether the supplied guest id exists.
 boolean personExists(Long uid)
          This returns whether the supplied person exists in the registry.
 boolean serviceExists(String uusid)
          This returns whether a service exists for the supplied UUSID in the registry.
 boolean ticketExists(String id)
          This returns whether a ticket exists for the supplied ID in the registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final Log LOG
Log for this class


entityManager

private EntityManager entityManager
Entity Manager for looking up beans

Constructor Detail

CommonRegistryFinder

public CommonRegistryFinder(EntityManager em)
Creates a new CommonRegistryFinder with the supplied entity manager.

Parameters:
em - EntityManager
Method Detail

getEntityManager

public EntityManager getEntityManager()
Returns the EntityManager for this class.

Returns:
EntityManager

flushAndRefresh

public void flushAndRefresh(DataObject o)
Calls flush and refresh on the supplied data object.

Parameters:
o - DataObject

getDataTypes

public <T extends DataType> List<T> getDataTypes(Class<T> dataTypeClass)
This returns all data types in the registry.

Type Parameters:
T - data type to find
Parameters:
dataTypeClass - Class to get data for
Returns:
List - of all academic levels

personExists

public boolean personExists(Long uid)
This returns whether the supplied person exists in the registry.

Parameters:
uid - Long
Returns:
boolean

getPerson

public Person getPerson(Long uid)
                 throws ApplicationServerException
This returns the Person bean for the supplied UID.

Parameters:
uid - Long
Returns:
Person
Throws:
ApplicationServerException - if the method fails
NoResultFoundException - if the group cannot be found
NonUniqueResultFoundException - if multiple groups are found

getPerson

public Person getPerson(Long uid,
                        boolean throwIfNotFound)
                 throws ApplicationServerException
Gets a person from the registry for the given uid. The boolean flag controls the behavior when no results are found.

Parameters:
uid - The UID of the person to find.
throwIfNotFound - Indicates whether or not a NoResultFoundException should be thrown if no matching person is found.
Returns:
Person whose UID matches the given value. If the boolean flag parameter is set and no match is found, will raise a NoResultFoundException, otherwise it will return null when no match is found.
Throws:
ApplicationServerException - if the method fails
NoResultFoundException - If the person cannot be found. This only occurs if the boolean parameter is true.

getPersonUid

public Long getPersonUid(String userid)
                  throws ApplicationServerException
This returns the sequence number of the person with the supplied userid. Returns null if the userid cannot be found.

Parameters:
userid - String
Returns:
Long - sequence number
Throws:
ApplicationServerException - if the method fails
FinderFailedException - if multiple userids are found

getUserid

public String getUserid(Long uid)
                 throws ApplicationServerException
This returns the userid for the person with the supplied UID. Returns null if the userid cannot be found.

Parameters:
uid - Long
Returns:
String - userid
Throws:
ApplicationServerException - if the method fails
FinderFailedException - if multiple userids are found

getAccountState

public AccountState getAccountState(Long uid)
                             throws ApplicationServerException
This returns the account state for the supplied UID. Returns null if the userid cannot be found.

Parameters:
uid - Long
Returns:
AccountState
Throws:
ApplicationServerException - if the method fails
FinderFailedException - if multiple userids are found

guestIdExists

public boolean guestIdExists(String guestId)
                      throws ApplicationServerException
This returns whether the supplied guest id exists.

Parameters:
guestId - String to check
Returns:
boolean
Throws:
ApplicationServerException - if the method fails
FinderFailedException - if multiple userids are found

emailAccountExists

public boolean emailAccountExists(Long uid)
This returns whether the supplied email account uid exists.

Parameters:
uid - Long to check
Returns:
boolean

groupExists

public boolean groupExists(String uugid)
                    throws ApplicationServerException
This returns whether a group exists for the supplied UUGID in the registry.

Parameters:
uugid - String
Returns:
boolean
Throws:
ApplicationServerException - if the method fails
NonUniqueResultFoundException - if multiple groups are found

getGroup

public Group getGroup(String uugid)
               throws ApplicationServerException
This returns the Group bean for the supplied UUGID.

Parameters:
uugid - String
Returns:
Group
Throws:
ApplicationServerException - if the method fails
NoResultFoundException - if the group cannot be found
NonUniqueResultFoundException - if multiple groups are found

getGroup

public Group getGroup(String uugid,
                      boolean throwIfNotFound)
               throws ApplicationServerException
Gets a group from the registry for the given uugid. The boolean flag controls the behavior when no results are found.

Parameters:
uugid - The UUGID of the group to find.
throwIfNotFound - Indicates whether or not a NoResultFoundException should be thrown if no matching group is found.
Returns:
Group whose UUGID matches the given value. If the boolean flag parameter is set and no match is found, will raise a NoResultFoundException, otherwise it will return null when no match is found.
Throws:
ApplicationServerException - if the method fails
NoResultFoundException - If the group cannot be found. This only occurs if the boolean parameter is true.
NonUniqueResultFoundException - if multiple groups are found

serviceExists

public boolean serviceExists(String uusid)
                      throws ApplicationServerException
This returns whether a service exists for the supplied UUSID in the registry.

Parameters:
uusid - String
Returns:
boolean
Throws:
ApplicationServerException - if the method fails
NonUniqueResultFoundException - if multiple services are found

getService

public Service getService(String uusid)
                   throws ApplicationServerException
This returns the Service bean for the supplied UUSID.

Parameters:
uusid - String
Returns:
Service
Throws:
ApplicationServerException - if the method fails
NoResultFoundException - if the service cannot be found
NonUniqueResultFoundException - if multiple services are found

getService

public Service getService(String uusid,
                          boolean throwIfNotFound)
                   throws ApplicationServerException
Gets a service from the registry for the given uusid. The boolean flag controls the behavior when no results are found.

Parameters:
uusid - The UUSID of the service to find.
throwIfNotFound - Indicates whether or not a NoResultFoundException should be thrown if no matching service is found.
Returns:
Service whose UUSID matches the given value. If the boolean flag parameter is set and no match is found, will raise a NoResultFoundException, otherwise it will return null when no match is found.
Throws:
ApplicationServerException - if the method fails
NoResultFoundException - If the service cannot be found. This only occurs if the boolean parameter is true.
NonUniqueResultFoundException - if multiple services are found

ticketExists

public boolean ticketExists(String id)
                     throws ApplicationServerException
This returns whether a ticket exists for the supplied ID in the registry.

Parameters:
id - String
Returns:
boolean
Throws:
ApplicationServerException - if the method fails
NonUniqueResultFoundException - if multiple tickets are found

getTicket

public Ticket getTicket(String id)
                 throws ApplicationServerException
This returns the Ticket bean for the supplied ID.

Parameters:
id - String
Returns:
Ticket
Throws:
ApplicationServerException - if the method fails
NoResultFoundException - if the ticket cannot be found
NonUniqueResultFoundException - if multiple tickets are found

getTicket

public Ticket getTicket(String id,
                        boolean throwIfNotFound)
                 throws ApplicationServerException
Parameters:
id - The ID of the ticket to find.
throwIfNotFound - Indicates whether or not a NoResultFoundException should be thrown if no matching ticket is found.
Returns:
Ticket whose ID matches the given value. If the boolean flag parameter is set and no match is found, will raise a NoResultFoundException, otherwise it will return null when no match is found.
Throws:
ApplicationServerException - if the method fails
NoResultFoundException - If the ticket cannot be found. This only occurs if the boolean parameter is true.
NonUniqueResultFoundException - if multiple tickets are found
See Also:
getNamedDataObject(Class, String, boolean)

entitlementExists

public boolean entitlementExists(Long uid)
This returns whether the supplied entitlement exists in the registry.

Parameters:
uid - Long
Returns:
boolean

getEntitlementData

public EntitlementData getEntitlementData(String entitlement)
                                   throws ApplicationServerException
This returns the EntitlementData bean for the supplied entitlement string.

Parameters:
entitlement - String
Returns:
EntitlementData
Throws:
ApplicationServerException - if the method fails
FinderFailedException - if multiple entitlements are found

getAccount

private Account getAccount(Long uid)
                    throws ApplicationServerException
This returns the account for the person with the supplied UID. Returns null if the userid cannot be found.

Parameters:
uid - Long
Returns:
Account
Throws:
ApplicationServerException - if the method fails
FinderFailedException - if multiple userids are found

getNamedDataObject

private <T extends NamedDataObject> T getNamedDataObject(Class<T> ndoClass,
                                                         String uuid,
                                                         boolean throwIfNotFound)
                                              throws ApplicationServerException
Gets a named data object from the registry for the given uuid. The boolean flag controls the behavior when no results are found.

Type Parameters:
T - type of named data object
Parameters:
ndoClass - of named data object
uuid - The UUID of the named data object to find.
throwIfNotFound - Indicates whether or not a NoResultFoundException should be thrown if no matching NDO is found.
Returns:
named data object whose UUID matches the given value. If the boolean flag parameter is set and no match is found, will raise a NoResultFoundException, otherwise it will return null when no match is found.
Throws:
ApplicationServerException - if the method fails
NoResultFoundException - If the NDO cannot be found. This only occurs if the boolean parameter is true.
NonUniqueResultFoundException - if multiple NDOs are found


Copyright © 2008 Virginia Tech. All Rights Reserved.