atg.multisite
Class ProfileRealmManager

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.multisite.ProfileRealmManager
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class ProfileRealmManager
extends GenericService

This class is the central location for dealing with profile realms. This class can be used to determine the current realm for a thread. It can also be used to set the realm to use for a thread. This class can handle creating, deleting and retrieving profile realms.


Nested Class Summary
 class ProfileRealmManager.ProfileRealmException
           
 
Field Summary
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String DEFAULT_REALM_ID
           
static java.lang.String PROFILE_ITEM_TYPE
           
static java.lang.String PROFILE_REALM_ITEM_TYPE
           
static java.lang.String PUSH_REALM_PARAM_NAME
           
static java.lang.String REALM_DESCRIPTION_PROPERTY_NAME
           
static java.lang.String REALM_ID_PROPERTY
           
static java.lang.String REALM_NAME_PROPERTY_NAME
           
static java.lang.String SITE_ITEM_TYPE
           
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
ProfileRealmManager()
          Constructs an instanceof ProfileRealmManager
 
Method Summary
 boolean canShareableJoinSiteGroup(java.lang.String pShareableId, SiteGroup pSiteGroup)
          check to see if a shareable type can be added to a site group, given the constraints on nucleus component sharing groups not spanning multiple realms
 boolean canShareableJoinSiteGroup(java.lang.String pShareableId, java.lang.String pSiteGroupId)
          check to see if a shareable type can be added to a site group, given the constraints on nucleus component sharing groups not spanning multiple realms
 boolean canShareableJoinSiteGroup(java.lang.String pShareableId, java.lang.String pSiteGroupId, java.util.HashSet<Site> pCurrentSiteGroupSites)
          check to see if a shareable type can be added to a site group, given the constraints on nucleus component sharing groups not spanning multiple realms
 boolean canSiteJoinRealm(java.lang.String pSiteId, java.lang.String pRealmId)
          check to see if a site can belong to a specified realm, given the constraints on nucleus component sharing groups not spanning multiple realms
 boolean canSiteJoinSiteGroup(java.lang.String pSiteId, SiteGroup pSiteGroup)
          check to see if a site can belong to a site group, given the constraints on nucleus component sharing groups not spanning multiple realms
 boolean canSiteJoinSiteGroup(java.lang.String pSiteId, java.lang.String pSiteGroupId)
          check to see if a site can belong to a site group, given the constraints on nucleus component sharing groups not spanning multiple realms
 boolean canSiteJoinSiteGroup(java.lang.String pSiteId, java.lang.String pSiteGroupId, java.util.Collection<Site> pExistedSites, java.util.HashSet<ShareableType> pShareableTypes)
          check to see if a site can belong to a site group, given the constraints on nucleus component sharing groups not spanning multiple realms
protected  boolean checkRequiredProperties()
          check to make sure all properties are set for this service.
protected  javax.servlet.Servlet createAdminServlet()
          create the admin servlet
 MutableRepositoryItem createRealm(java.lang.String pRealmId, java.lang.String pRealmName, java.lang.String pRealmDescription)
          create a new profileRealm item
 void deleteRealm(java.lang.String pRealmId)
          delete a profile realm if there are no sites in the realm.
 RepositoryItem[] getAllRealms()
          get an array of all profileRealm items
 RepositoryItem getCurrentRealm()
          get the profile realm for the current site
static java.lang.String getCurrentRealmId()
          get the profile realm id for the current site
 int getProfileCountForRealm(java.lang.String pRealmId)
          get the number of profiles associated with a given realm
 MutableRepository getProfileRepository()
          get ProfileRepository
 RepositoryItem getRealm(java.lang.String pRealmId)
          get a profile realm
 RepositoryItem getRealmForSite(java.lang.String pSiteId)
          get a profile realm
 java.lang.String getRealmIdForSite(java.lang.String pSiteId)
          get a profile realm id
 SiteGroupManager getSiteGroupManager()
          get SiteGroupManager
 Repository getSiteRepository()
          get SiteRepository
 RepositoryItem[] getSitesInRealm(java.lang.String pRealmId)
          get all the site repository items in a given realm
 atg.multisite.SiteStorageAdapter getSiteStorageAdapter()
          get SiteStorageAdapter
 javax.transaction.TransactionManager getTransactionManager()
          get TransactionManager
 boolean isCurrentlyDefaultRealm()
           
 boolean isProfileRealmsEnabled()
          get ProfileRealmsEnabled
protected  void logPropertyNotSetErrorNoRepeat(java.lang.String pErrorKey)
          display an error related to a required property setting
 java.lang.String popRealmId(java.lang.String pRealmId)
          pop a profile realm id off the stack
 boolean pushRealmId(java.lang.String pRealmId)
          push a profile realm id on the stack
 void setForceEnabled()
          set the force enabled thread local
 void setProfileRealmsEnabled(boolean pProfileRealmsEnabled)
          set ProfileRealmsEnabled
 void setProfileRepository(MutableRepository pProfileRepository)
          set ProfileRepository
 void setSiteGroupManager(SiteGroupManager pSiteGroupManager)
          set SiteGroupManager
 void setSiteRepository(Repository pSiteRepository)
          set SiteRepository
 void setSiteStorageAdapter(atg.multisite.SiteStorageAdapter pSiteStorageAdapter)
          set SiteStorageAdapter
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
          set TransactionManager
 void unsetForceEnabled()
          unset the force enabled thread local
 void updateRealm(java.lang.String pRealmId, java.lang.String pRealmName, java.lang.String pRealmDescription)
          update a profileRealm item
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


DEFAULT_REALM_ID

public static final java.lang.String DEFAULT_REALM_ID
See Also:
Constant Field Values

PROFILE_REALM_ITEM_TYPE

public static final java.lang.String PROFILE_REALM_ITEM_TYPE
See Also:
Constant Field Values

SITE_ITEM_TYPE

public static final java.lang.String SITE_ITEM_TYPE
See Also:
Constant Field Values

PROFILE_ITEM_TYPE

public static final java.lang.String PROFILE_ITEM_TYPE
See Also:
Constant Field Values

REALM_ID_PROPERTY

public static final java.lang.String REALM_ID_PROPERTY
See Also:
Constant Field Values

REALM_NAME_PROPERTY_NAME

public static final java.lang.String REALM_NAME_PROPERTY_NAME
See Also:
Constant Field Values

REALM_DESCRIPTION_PROPERTY_NAME

public static final java.lang.String REALM_DESCRIPTION_PROPERTY_NAME
See Also:
Constant Field Values

PUSH_REALM_PARAM_NAME

public static final java.lang.String PUSH_REALM_PARAM_NAME
See Also:
Constant Field Values
Constructor Detail

ProfileRealmManager

public ProfileRealmManager()
Constructs an instanceof ProfileRealmManager

Method Detail

setProfileRealmsEnabled

public void setProfileRealmsEnabled(boolean pProfileRealmsEnabled)
set ProfileRealmsEnabled

Parameters:
pProfileRealmsEnabled - the ProfileRealmsEnabled

isProfileRealmsEnabled

public boolean isProfileRealmsEnabled()
get ProfileRealmsEnabled

Returns:
the ProfileRealmsEnabled

setProfileRepository

public void setProfileRepository(MutableRepository pProfileRepository)
set ProfileRepository

Parameters:
pProfileRepository - the ProfileRepository

getProfileRepository

public MutableRepository getProfileRepository()
get ProfileRepository

Returns:
the ProfileRepository

setSiteRepository

public void setSiteRepository(Repository pSiteRepository)
set SiteRepository

Parameters:
pSiteRepository - the SiteRepository

getSiteRepository

public Repository getSiteRepository()
get SiteRepository

Returns:
the SiteRepository

setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
set TransactionManager

Parameters:
pTransactionManager - the TransactionManager

getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
get TransactionManager

Returns:
the TransactionManager

setSiteStorageAdapter

public void setSiteStorageAdapter(atg.multisite.SiteStorageAdapter pSiteStorageAdapter)
set SiteStorageAdapter

Parameters:
pSiteStorageAdapter - the SiteStorageAdapter

getSiteStorageAdapter

public atg.multisite.SiteStorageAdapter getSiteStorageAdapter()
get SiteStorageAdapter

Returns:
the SiteStorageAdapter

setSiteGroupManager

public void setSiteGroupManager(SiteGroupManager pSiteGroupManager)
set SiteGroupManager

Parameters:
pSiteGroupManager - the SiteGroupManager

getSiteGroupManager

public SiteGroupManager getSiteGroupManager()
get SiteGroupManager

Returns:
the SiteGroupManager

getRealm

public RepositoryItem getRealm(java.lang.String pRealmId)
get a profile realm

Parameters:
pRealmId - the id of the realm we're trying to get
Returns:
the profileRealm repository item, or null if there was none for the given realm id

getRealmForSite

public RepositoryItem getRealmForSite(java.lang.String pSiteId)
get a profile realm

Parameters:
pSiteId - the id of the site whose realm we are getting
Returns:
the profileRealm repository item, or null if there was none for the given site id

getRealmIdForSite

public java.lang.String getRealmIdForSite(java.lang.String pSiteId)
get a profile realm id

Parameters:
pSiteId - the id of the site whose realm we are getting
Returns:
the id of the profile realm, or null if there was none for the given site id

getCurrentRealm

public RepositoryItem getCurrentRealm()
get the profile realm for the current site

Returns:
the realm corresponding to the current site, corresponding to the current request

getCurrentRealmId

public static java.lang.String getCurrentRealmId()
get the profile realm id for the current site

Returns:
the id of the realm corresponding to the current site, corresponding to the current request

isCurrentlyDefaultRealm

public boolean isCurrentlyDefaultRealm()
Returns:
true if the current profile realm is the default realm

pushRealmId

public boolean pushRealmId(java.lang.String pRealmId)
push a profile realm id on the stack

Parameters:
pRealmId - the realm id to push on to the top of the stack. If value is null, then the default realm id constant will be pushed on to the stack.
Returns:
true if the push was successful, false if not. the push will not be successful if the realm id does not correspond to null, the default realm constant, or an Id for an existing realm item.

popRealmId

public java.lang.String popRealmId(java.lang.String pRealmId)
pop a profile realm id off the stack

Parameters:
pRealmId - the realm id that is expected to be popped off of the top of the stack.
Returns:
the value that was popped off of the stack if the pop was successful. if pRealmId does not match the value on the top of the stack, then the pop fails, and the value on the top of the stack is not popped off.

createRealm

public MutableRepositoryItem createRealm(java.lang.String pRealmId,
                                         java.lang.String pRealmName,
                                         java.lang.String pRealmDescription)
                                  throws RepositoryException
create a new profileRealm item

Parameters:
pRealmId - the id of the new realm
pRealmName - the name of the new realm
pRealmDescription - the description text for the new realm
Returns:
the newly created item if the creation was successful.
Throws:
RepositoryException - if there was a repository error creating the new profileRealm

updateRealm

public void updateRealm(java.lang.String pRealmId,
                        java.lang.String pRealmName,
                        java.lang.String pRealmDescription)
                 throws RepositoryException
update a profileRealm item

Parameters:
pRealmId - the id of the existing realm
pRealmName - the possibly updated realm name value
pRealmDescription - the possibly updated realm description value
Throws:
RepositoryException - if there was a repository error updating the profileRealm item

deleteRealm

public void deleteRealm(java.lang.String pRealmId)
                 throws RepositoryException
delete a profile realm if there are no sites in the realm.

Parameters:
pRealmId - the id of the realm to delete
Throws:
RepositoryException - if there are still sites in the realm

getAllRealms

public RepositoryItem[] getAllRealms()
get an array of all profileRealm items

Returns:
an array containing all the profileRealm items in the repository

getSitesInRealm

public RepositoryItem[] getSitesInRealm(java.lang.String pRealmId)
get all the site repository items in a given realm

Parameters:
pRealmId - the id of the realm for which to get all the sites
Returns:
an array of RepositoryItems corresponding to all the sites whose realmId property is equal to pRealmId

getProfileCountForRealm

public int getProfileCountForRealm(java.lang.String pRealmId)
get the number of profiles associated with a given realm

Parameters:
pRealmId -
Returns:
the number of profiles associated with the given realm

canSiteJoinRealm

public boolean canSiteJoinRealm(java.lang.String pSiteId,
                                java.lang.String pRealmId)
check to see if a site can belong to a specified realm, given the constraints on nucleus component sharing groups not spanning multiple realms

Parameters:
pSiteId - the id of the site to add to the realm
pRealmId - the id of the realm that the site will be added to
Returns:
true if the site is allowed to join the realm, false if not

canSiteJoinSiteGroup

public boolean canSiteJoinSiteGroup(java.lang.String pSiteId,
                                    java.lang.String pSiteGroupId)
check to see if a site can belong to a site group, given the constraints on nucleus component sharing groups not spanning multiple realms

Parameters:
pSiteId - the id of the site to add to the realm
pSiteGroupId - the id of the site group that the site will be added to
Returns:
true if the site is allowed to join the group, false if not

canSiteJoinSiteGroup

public boolean canSiteJoinSiteGroup(java.lang.String pSiteId,
                                    SiteGroup pSiteGroup)
check to see if a site can belong to a site group, given the constraints on nucleus component sharing groups not spanning multiple realms

Parameters:
pSiteId - the id of the site to add to the realm
pSiteGroup - the site group that the site will be added to
Returns:
true if the site is allowed to join the group, false if not

canSiteJoinSiteGroup

public boolean canSiteJoinSiteGroup(java.lang.String pSiteId,
                                    java.lang.String pSiteGroupId,
                                    java.util.Collection<Site> pExistedSites,
                                    java.util.HashSet<ShareableType> pShareableTypes)
check to see if a site can belong to a site group, given the constraints on nucleus component sharing groups not spanning multiple realms

Parameters:
pSiteId - the id of the site to add to the realm
pSiteGroupId - the id of the site group that the site will be added to
pExistedSites - the current sites of site group, both persisted and not persisted Null value means that sites should be retrieved from the siteGroup itself, empty value is the value of the current editor condition with no site.
pShareableTypes - the current condition of shareable types
Returns:
true if the site is allowed to join the group, false if not

canShareableJoinSiteGroup

public boolean canShareableJoinSiteGroup(java.lang.String pShareableId,
                                         java.lang.String pSiteGroupId)
check to see if a shareable type can be added to a site group, given the constraints on nucleus component sharing groups not spanning multiple realms

Parameters:
pShareableId - the id of the shareable type to add to the realm
pSiteGroupId - the id of the site group that the shareable type will be added to
Returns:
true if the shareable type is allowed to join the group, false if not

canShareableJoinSiteGroup

public boolean canShareableJoinSiteGroup(java.lang.String pShareableId,
                                         java.lang.String pSiteGroupId,
                                         java.util.HashSet<Site> pCurrentSiteGroupSites)
check to see if a shareable type can be added to a site group, given the constraints on nucleus component sharing groups not spanning multiple realms

Parameters:
pShareableId - the id of the shareable type to add to the realm
pSiteGroupId - the id of the site group that the shareable type will be added to
pCurrentSiteGroupSites - the current sites of site group, both persisted and not persisted Null value means that sites should be retrieved from the siteGroup itself, empty value is the value of the current editor condition with no site.
Returns:
true if the shareable type is allowed to join the group, false if not

canShareableJoinSiteGroup

public boolean canShareableJoinSiteGroup(java.lang.String pShareableId,
                                         SiteGroup pSiteGroup)
check to see if a shareable type can be added to a site group, given the constraints on nucleus component sharing groups not spanning multiple realms

Parameters:
pShareableId - the id of the shareable type to add to the realm
pSiteGroup - the site group that the shareable type will be added to
Returns:
true if the shareable type is allowed to join the group, false if not

logPropertyNotSetErrorNoRepeat

protected void logPropertyNotSetErrorNoRepeat(java.lang.String pErrorKey)
display an error related to a required property setting

Parameters:
pErrorKey - the resource key for the error message

checkRequiredProperties

protected boolean checkRequiredProperties()
check to make sure all properties are set for this service. log errors for any missing properties

Returns:
true if everything is set, return false if not

createAdminServlet

protected javax.servlet.Servlet createAdminServlet()
create the admin servlet

Overrides:
createAdminServlet in class GenericService

setForceEnabled

public void setForceEnabled()
set the force enabled thread local


unsetForceEnabled

public void unsetForceEnabled()
unset the force enabled thread local