atg.svc.repository.service
Class OrganizationValueService

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.svc.repository.service.BaseService
              extended by atg.svc.repository.service.KnowledgeBaseService
                  extended by atg.svc.repository.service.OrganizationValueService
All Implemented Interfaces:
atg.naming.NameContextBindingListener, atg.naming.NameContextElement, atg.naming.NameResolver, atg.nucleus.AdminableService, atg.nucleus.logging.ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, atg.nucleus.naming.ComponentNameResolver, atg.nucleus.PostStartupAction, atg.nucleus.Service, atg.nucleus.ServiceListener, atg.repository.PropertiesChangedListener, java.util.EventListener

@Service(requiredProperties={"segmentService","profileService","solutionSecurityUtils","serviceRepository"})
public class OrganizationValueService
extends KnowledgeBaseService
implements atg.repository.PropertiesChangedListener, atg.nucleus.PostStartupAction

OrganizationValueService Business API for OrganizationValue objects


Nested Class Summary
protected  class OrganizationValueService.ComparatorOrganizationValueByDisplayName
          Helper class comparator used to sort collection of OrganizationValues to return to UI
protected  class OrganizationValueService.ComparatorOrganizationValueByOrganizationId
          Helper class comparator used to sort collection of OrganizationValues to return to UI
 
Field Summary
static java.lang.String CLASS_VERSION
           
 
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
OrganizationValueService()
           
 
Method Summary
 void clearCachedAllInternalAudiences()
           
 void clearCachedAllOwningGroups()
           
 void deleteOrganizationValues(java.lang.String pOrgId)
          Deletes all organization values that wrap the given organization id.
 void doStartService()
           
protected  atg.svc.repository.beans.OrganizationValue findInternalAudienceByOrganizationId(java.lang.String pOrganizationId)
          Finds and returns internal audience by organizationId.
 atg.svc.repository.beans.OrganizationValue findOrganizationValue(atg.svc.repository.beans.OrganizationValueType pType, java.lang.String pOrgId)
          Finds an OrganizationValue given its type and organization id.
protected  atg.svc.repository.beans.OrganizationValue findOwningGroupByOrganizationId(java.lang.String pOrganizationId)
          Finds and returns owning group by organizationId.
 java.util.List<atg.svc.repository.beans.OrganizationValue> getAllInternalAudience()
          Gets all internal audience OrganizationValue objects.
 java.util.List<atg.svc.repository.beans.OrganizationValue> getAllInternalAudienceByDisplayName()
          Gets all owning group OrganizationValue items and sorts them by display name.
 java.util.List<atg.svc.repository.beans.OrganizationValue> getAllOrganizationValues()
          Gets all OrganizationValue objects.
 java.util.List<atg.svc.repository.beans.OrganizationValue> getAllOwningGroups()
          Gets all owning groups OrganizationValue objects.
 java.util.List<atg.svc.repository.beans.OrganizationValue> getAllOwningGroupsByDisplayName()
          } Gets all owning group OrganizationValue items and sorts them by display name.
protected  java.util.List<atg.svc.repository.beans.OrganizationValue> getCachedAllInternalAudiences()
          Caches the sorted list of all internal audiences in global scope so we don't have to build it over and over again.
protected  java.util.List<atg.svc.repository.beans.OrganizationValue> getCachedAllOwningGroups()
          Caches the sorted list of all owning groups in global scope so we don't have to build it over and over again.
 java.util.Collection getCurrentUserOtherOwningGroups()
          This method is implemented in Service.Agent.
 java.util.Collection getCurrentUserOwningGroups()
          This method is implemented in Service.Agent.
 atg.svc.repository.beans.OrganizationValue getDefaultOwningGroup()
          This method is implemented in Service.Agent.
 atg.svc.repository.beans.OrganizationValue getDefaultOwningGroup(atg.repository.RepositoryItem pUser)
          This method is implemented in Service.Agent.
 atg.repository.RepositoryItemDescriptor getOrganizationItemDescriptor()
           
 atg.svc.repository.beans.OrganizationValue getOrganizationValueById(java.lang.String pOrgValueId)
          Gets an OrgnizationValue given its repository id.
 java.lang.String getOrganizationValueDisplayName(atg.svc.repository.beans.OrganizationValue pOrganizationValue)
          Gets the display name of the OrganizationValue.
 atg.svc.repository.beans.OrganizationValue getOrganizationValueFromOrganization(atg.svc.repository.beans.OrganizationValueType pType, java.lang.String pOrgId, java.lang.String pOrgName)
          Gets an organization value given the type and organization id.
 atg.repository.RepositoryItemDescriptor getOrganizationValueItemDescriptor()
           
 java.util.List<atg.svc.repository.beans.OrganizationValue> getOrganizationValueListById(java.lang.String[] pOrgValueIds)
          Gets a list of OrgnizationValue objects given a list of repository ids.
 java.util.Collection getOrganizationValuesByOrganizationId(java.lang.String pOrgValueId)
          Gets collection of Organization Values by Organization id
 ProfileService getProfileService()
          Reference for Profile Service
 atg.svc.repository.service.SegmentService getSegmentService()
          Reference for Segment Service
 atg.repository.Repository getServiceRepository()
          The repository that we use to listen for solution property changes.
 atg.svc.repository.service.util.SolutionSecurityUtils getSolutionSecurityUtils()
          Reference for Solution Security Utils
 atg.userdirectory.UserDirectory getUserDirectory()
          Reference for Directory Service
 boolean isAgentModule()
          True if this is the Agent or admmin module, false if this is the SelfService module
 boolean isEnableMonitoring()
          Whether to monitor for organization changes so cache can be invalidated.
 boolean isOrganizationExistsForOrganizationValue(atg.svc.repository.beans.OrganizationValue pOrganizationValue)
          Method checks if Organization exists for provided OrganizationValue
 boolean isOrganizationValueVisibleForCurrentUser(atg.svc.repository.beans.OrganizationValue pOrganizationValue)
          Returns true if the OrganizationValue is visible for the current user.
 void performAction()
          Registers this class as a PostStartupAction so that the population of the organization and internal audience classes is safely deferred until after all other components start, especially the initialization of r2j which this code relies on.
 void propertiesChanged(atg.repository.PropertiesChangedEvent pEvent)
          Remove an organization from the OrganizationNameCache when an internal organization item is modified or deleted.
 void setAgentModule(boolean pAgentModule)
           
protected  void setCachedAllInternalAudiences(java.util.List<atg.svc.repository.beans.OrganizationValue> pCachedAllInternalAudiences)
           
protected  void setCachedAllOwningGroups(java.util.List<atg.svc.repository.beans.OrganizationValue> pCachedAllOwningGroups)
           
 void setEnableMonitoring(boolean pEnableMonitoring)
           
 void setProfileService(ProfileService pProfileService)
           
 void setSegmentService(atg.svc.repository.service.SegmentService pSegmentService)
           
 void setServiceRepository(atg.repository.Repository pServiceRepository)
           
 void setSolutionSecurityUtils(atg.svc.repository.service.util.SolutionSecurityUtils pSolutionSecurityUtils)
           
 void setUserDirectory(atg.userdirectory.UserDirectory pUserDirectory)
           
 void startMonitoring()
          Registers this class as a PropertiesChangedListener listening for property changes to solutions
 void validateOrganizationValueIsUnique(atg.svc.repository.beans.OrganizationValueType pType, java.lang.String pOrgId, java.lang.String pOrgName)
          This method is implemented in Service.admin.
 
Methods inherited from class atg.svc.repository.service.KnowledgeBaseService
getKnowledgeHomesFactory, getServiceSegmentBeanHomes, getServiceSegmentRepositoryHomes, getSolutionBeanHomes, getSolutionRepositoryHomes, setKnowledgeHomesFactory
 
Methods inherited from class atg.svc.repository.service.BaseService
getRepositoryService, getToday, setRepositoryService
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, 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
Constructor Detail

OrganizationValueService

public OrganizationValueService()
Method Detail

getUserDirectory

public atg.userdirectory.UserDirectory getUserDirectory()
Reference for Directory Service


setUserDirectory

public void setUserDirectory(atg.userdirectory.UserDirectory pUserDirectory)

getSegmentService

public atg.svc.repository.service.SegmentService getSegmentService()
Reference for Segment Service


setSegmentService

public void setSegmentService(atg.svc.repository.service.SegmentService pSegmentService)

getProfileService

public ProfileService getProfileService()
Reference for Profile Service


setProfileService

public void setProfileService(ProfileService pProfileService)

getSolutionSecurityUtils

public atg.svc.repository.service.util.SolutionSecurityUtils getSolutionSecurityUtils()
Reference for Solution Security Utils


setSolutionSecurityUtils

public void setSolutionSecurityUtils(atg.svc.repository.service.util.SolutionSecurityUtils pSolutionSecurityUtils)

getServiceRepository

public atg.repository.Repository getServiceRepository()
The repository that we use to listen for solution property changes. We use ServiceRepository_production to listen for changes to the unversioned self-service solutions. To listen for versioned solutions internally, we should use ServiceRepository.


setServiceRepository

public void setServiceRepository(atg.repository.Repository pServiceRepository)

isAgentModule

public boolean isAgentModule()
True if this is the Agent or admmin module, false if this is the SelfService module


setAgentModule

public void setAgentModule(boolean pAgentModule)

isEnableMonitoring

public boolean isEnableMonitoring()
Whether to monitor for organization changes so cache can be invalidated. This is provided for completeness, but there really is no reason this should be disabled.


setEnableMonitoring

public void setEnableMonitoring(boolean pEnableMonitoring)

getCachedAllOwningGroups

protected java.util.List<atg.svc.repository.beans.OrganizationValue> getCachedAllOwningGroups()
Caches the sorted list of all owning groups in global scope so we don't have to build it over and over again. Invalidated when an OrganizationValue or Organization changes.


setCachedAllOwningGroups

protected void setCachedAllOwningGroups(java.util.List<atg.svc.repository.beans.OrganizationValue> pCachedAllOwningGroups)

clearCachedAllOwningGroups

public void clearCachedAllOwningGroups()

getCachedAllInternalAudiences

protected java.util.List<atg.svc.repository.beans.OrganizationValue> getCachedAllInternalAudiences()
Caches the sorted list of all internal audiences in global scope so we don't have to build it over and over again. Invalidated when an OrganizationValue or Organization changes.


setCachedAllInternalAudiences

protected void setCachedAllInternalAudiences(java.util.List<atg.svc.repository.beans.OrganizationValue> pCachedAllInternalAudiences)

clearCachedAllInternalAudiences

public void clearCachedAllInternalAudiences()

findOwningGroupByOrganizationId

protected atg.svc.repository.beans.OrganizationValue findOwningGroupByOrganizationId(java.lang.String pOrganizationId)
                                                                              throws SvcException
Finds and returns owning group by organizationId. The method uses cached list of all owning groups. List is sorted by organization id and method uses comparator and pseudo OrganizationValue to quickly locate owning group

Parameters:
pOrganizationId - repository item to process
Returns:
owning group or null if not found
Throws:
SvcException

findInternalAudienceByOrganizationId

protected atg.svc.repository.beans.OrganizationValue findInternalAudienceByOrganizationId(java.lang.String pOrganizationId)
                                                                                   throws SvcException
Finds and returns internal audience by organizationId. The method uses cached list of all internal audiences. List is sorted by organization id and method uses comparator and pseudo OrganizationValue to quickly locate owning group

Parameters:
pOrganizationId - repository item to process
Returns:
internal audience or null if not found
Throws:
SvcException

getOrganizationItemDescriptor

public atg.repository.RepositoryItemDescriptor getOrganizationItemDescriptor()
                                                                      throws atg.repository.RepositoryException
Returns:
repository item descriptor for Organization item
Throws:
atg.repository.RepositoryException - if Organization item isn't defined

getOrganizationValueItemDescriptor

public atg.repository.RepositoryItemDescriptor getOrganizationValueItemDescriptor()
                                                                           throws atg.repository.RepositoryException
Returns:
repository item descriptor for OrganizationValue item
Throws:
atg.repository.RepositoryException - if OrganizationValue item isn't defined

getOrganizationValueById

public atg.svc.repository.beans.OrganizationValue getOrganizationValueById(java.lang.String pOrgValueId)
                                                                    throws ObjectNotFoundException,
                                                                           SvcException
Gets an OrgnizationValue given its repository id.

Parameters:
pOrgValueId - The id of the OrganizationValue.
Returns:
The OrganizationValue object.
Throws:
ObjectNotFoundException
SvcException

getOrganizationValuesByOrganizationId

public java.util.Collection getOrganizationValuesByOrganizationId(java.lang.String pOrgValueId)
                                                           throws javax.ejb.FinderException
Gets collection of Organization Values by Organization id

Parameters:
pOrgValueId - id of physical organization
Returns:
collection
Throws:
javax.ejb.FinderException

getOrganizationValueListById

public java.util.List<atg.svc.repository.beans.OrganizationValue> getOrganizationValueListById(java.lang.String[] pOrgValueIds)
                                                                                        throws ObjectNotFoundException,
                                                                                               SvcException
Gets a list of OrgnizationValue objects given a list of repository ids.

Parameters:
pOrgValueIds - The array of OrganizationValue ids.
Returns:
The List of OrganizationValue objects.
Throws:
ObjectNotFoundException - If an OrganizationValue is not found.
SvcException

getAllOrganizationValues

public java.util.List<atg.svc.repository.beans.OrganizationValue> getAllOrganizationValues()
                                                                                    throws SvcException
Gets all OrganizationValue objects. The returned list is sorted by displayName. The sort is done in memory because the displayName value is a runtime computed property.

Returns:
A Collection of OrganizationValue objects.
Throws:
SvcException

getOrganizationValueFromOrganization

public atg.svc.repository.beans.OrganizationValue getOrganizationValueFromOrganization(atg.svc.repository.beans.OrganizationValueType pType,
                                                                                       java.lang.String pOrgId,
                                                                                       java.lang.String pOrgName)
                                                                                throws SvcException,
                                                                                       DuplicateRecordException
Gets an organization value given the type and organization id. If the OrganizationValue does not exist it will be created using the given organization name and id, saved and returned.

Parameters:
pType - The organization value type to get or create
pOrgId - The repository id of the organization the organization value is wrapping.
pOrgName - The name of the organization.
Returns:
The found OrganizationValue or the new one if it's created.
Throws:
PersistenceException - If a PersistenceException is thrown on the save if a new OrganizationValue is created.
DuplicateRecordException - Thrown if the organization value exists in an active project that has not been completed. See getOrganizationValueFromOrganization(OrganizationValueType, String, String)
SvcException

findOrganizationValue

public atg.svc.repository.beans.OrganizationValue findOrganizationValue(atg.svc.repository.beans.OrganizationValueType pType,
                                                                        java.lang.String pOrgId)
                                                                 throws ObjectNotFoundException,
                                                                        SvcException
Finds an OrganizationValue given its type and organization id.

Parameters:
pType - The OrganizationValueType
pOrgId - The organization id
Returns:
The OrganizationValue that matches the input parameters
Throws:
ObjectNotFoundException - If the OrganizationValue was not found.
SvcException

validateOrganizationValueIsUnique

public void validateOrganizationValueIsUnique(atg.svc.repository.beans.OrganizationValueType pType,
                                              java.lang.String pOrgId,
                                              java.lang.String pOrgName)
                                       throws SvcException
This method is implemented in Service.admin. OrganizationValueService is used in common/OrganizationValueService component Attempt to call method from Self Service will result in exception.

Throws:
SvcException
See Also:
atg.svc.repository.service.AgentOrganizationValueService.

getDefaultOwningGroup

public atg.svc.repository.beans.OrganizationValue getDefaultOwningGroup()
                                                                 throws SvcException,
                                                                        javax.ejb.FinderException
This method is implemented in Service.Agent. OrganizationValueService is used in common/OrganizationValueService component Attempt to call method from Self Service will result in exception.

Throws:
SvcException
javax.ejb.FinderException
See Also:
atg.svc.repository.service.AgentOrganizationValueService.

getDefaultOwningGroup

public atg.svc.repository.beans.OrganizationValue getDefaultOwningGroup(atg.repository.RepositoryItem pUser)
                                                                 throws SvcException,
                                                                        javax.ejb.FinderException
This method is implemented in Service.Agent. OrganizationValueService is used in common/OrganizationValueService component Attempt to call method from Self Service will result in exception.

Throws:
SvcException
javax.ejb.FinderException
See Also:
atg.svc.repository.service.AgentOrganizationValueService.

getCurrentUserOwningGroups

public java.util.Collection getCurrentUserOwningGroups()
                                                throws SvcException
This method is implemented in Service.Agent. OrganizationValueService is used in common/OrganizationValueService component Attempt to call method from Self Service will result in exception.

Throws:
SvcException
See Also:
atg.svc.repository.service.AgentOrganizationValueService.

getCurrentUserOtherOwningGroups

public java.util.Collection getCurrentUserOtherOwningGroups()
                                                     throws SvcException
This method is implemented in Service.Agent. OrganizationValueService is used in common/OrganizationValueService component Attempt to call method from Self Service will result in exception.

Throws:
SvcException
See Also:
atg.svc.repository.service.AgentOrganizationValueService.

getAllOwningGroupsByDisplayName

public java.util.List<atg.svc.repository.beans.OrganizationValue> getAllOwningGroupsByDisplayName()
                                                                                           throws SvcException
} Gets all owning group OrganizationValue items and sorts them by display name.

Returns:
A collection of OrganizationValue items.
Throws:
SvcException

getAllOwningGroups

public java.util.List<atg.svc.repository.beans.OrganizationValue> getAllOwningGroups()
                                                                              throws SvcException
Gets all owning groups OrganizationValue objects. The returned list is sorted by organizationId. The sort is done in memory because the displayName value is a runtime computed property.

Returns:
A Collection of OrganizationValue objects.
Throws:
SvcException

getAllInternalAudience

public java.util.List<atg.svc.repository.beans.OrganizationValue> getAllInternalAudience()
                                                                                  throws SvcException
Gets all internal audience OrganizationValue objects. The returned list is sorted by organizationId. The sort is done in memory because the displayName value is a runtime computed property.

Returns:
A Collection of OrganizationValue objects.
Throws:
SvcException

getAllInternalAudienceByDisplayName

public java.util.List<atg.svc.repository.beans.OrganizationValue> getAllInternalAudienceByDisplayName()
                                                                                               throws SvcException
Gets all owning group OrganizationValue items and sorts them by display name.

Returns:
A collection of OrganizationValue items.
Throws:
SvcException

deleteOrganizationValues

public void deleteOrganizationValues(java.lang.String pOrgId)
                              throws ObjectNotFoundException,
                                     PersistenceException
Deletes all organization values that wrap the given organization id.

Parameters:
pOrgId - The organizationId to find the OrganizationValue objects by.
Throws:
ObjectNotFoundException - If an underlying method throws ObjectNotFoundException
PersistenceException - If the delete fails.

isOrganizationValueVisibleForCurrentUser

public boolean isOrganizationValueVisibleForCurrentUser(atg.svc.repository.beans.OrganizationValue pOrganizationValue)
Returns true if the OrganizationValue is visible for the current user.

Parameters:
pOrganizationValue - The OrganizationValue to check.
Returns:
True if the OrganizationValue is visible for the current user.

getOrganizationValueDisplayName

public java.lang.String getOrganizationValueDisplayName(atg.svc.repository.beans.OrganizationValue pOrganizationValue)
Gets the display name of the OrganizationValue. The display name is calculated by first trying to lookup the organization in the profile repository to get its name and if it exists return it. Otherwise, the organizationName property is returned.

Parameters:
pOrganizationValue - The OrganizationValue to compute the display name for.
Returns:
The display name String.

isOrganizationExistsForOrganizationValue

public boolean isOrganizationExistsForOrganizationValue(atg.svc.repository.beans.OrganizationValue pOrganizationValue)
Method checks if Organization exists for provided OrganizationValue

Parameters:
pOrganizationValue - organization value to test
Returns:
true if Organization for provided OrganizationValue is exists.

propertiesChanged

public void propertiesChanged(atg.repository.PropertiesChangedEvent pEvent)
Remove an organization from the OrganizationNameCache when an internal organization item is modified or deleted.

Specified by:
propertiesChanged in interface atg.repository.PropertiesChangedListener
See Also:
PropertiesChangedListener.propertiesChanged(atg.repository.PropertiesChangedEvent)

startMonitoring

public void startMonitoring()
Registers this class as a PropertiesChangedListener listening for property changes to solutions


performAction

public void performAction()
Registers this class as a PostStartupAction so that the population of the organization and internal audience classes is safely deferred until after all other components start, especially the initialization of r2j which this code relies on.

Specified by:
performAction in interface atg.nucleus.PostStartupAction

doStartService

public void doStartService()
                    throws atg.nucleus.ServiceException
Overrides:
doStartService in class atg.nucleus.GenericService
Throws:
atg.nucleus.ServiceException