atg.commerce.catalog.custom
Class CatalogUpdateService

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.service.scheduler.SchedulableService
              extended by atg.service.scheduler.SingletonSchedulableService
                  extended by atg.commerce.catalog.CMSService
                      extended by atg.commerce.catalog.custom.CatalogUpdateService
All Implemented Interfaces:
atg.commerce.catalog.CMSConstants, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, Schedulable, java.util.EventListener
Direct Known Subclasses:
CatalogMigrationService

public class CatalogUpdateService
extends atg.commerce.catalog.CMSService

This service batch-computes the properties that are usually maintained by CatalogCompletionService. This can be used either as a migration tool, or if you want to disable CatalogCompletionService for performance reasons, and then batch-compute the properties with this service. Properties computed by this service: catalog.directAncestorCatalogsAndSelf catalog.allRootCategories catalog.indirectAncestorCatalogs catalog.ancestorCategories category.parentCategory category.parentCatalog

See Also:
CatalogCompletionService

Nested Class Summary
 
Nested classes/interfaces inherited from class atg.commerce.catalog.CMSService
atg.commerce.catalog.CMSService.BookkeepingForThread
 
Field Summary
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String PROCESS_NAME_PREFIX
           
static java.lang.String PUBLISHING_USER
           
 
Fields inherited from class atg.service.scheduler.SchedulableService
mJobId
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.commerce.catalog.CMSConstants
AGS_GENANCESTORS, AGS_GENCATALOGS, AGS_GENPARENTCATS, ANCESTORS_GENERATED, CATALOGS_UPDATED, CATALOGS_VERIFIED, CATEGORIES_VERIFIED, CUS_INVALID_PARENT_BRANCH, CUS_NAME_ALREADY_IN_USE, CUS_UNABLE_TO_GET_WS, CUS_UPDATECATALOGS, CUS_USING_CHECKED_IN_WS, CUS_VM_NOT_SET, CUS_WS_NOT_CREATED, CUS_WS_NOT_CREATED_INVALID_PARENT_BRANCH, CUS_WS_REQUIRED, CVS_VERIFYCATALOGS, CVS_VERIFYCATEGORIES, CVS_VERIFYPRODUCTS, CVS_VERIFYSKUS, DEFAULT_CATALOG_ITEM_TYPE, DEFAULT_MAP_SIZE, GENERATED_ANCESTORS, INFOS_GENERATED, IS_ANCESTORS_GENERATED, LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO, LEVEL_WARNING, MY_RESOURCE_NAME, NO_PATH, NOT_GENERATOR, sResourceBundle, TYPE_ANCESTOR, TYPE_CATALOGMAINTENANCE, TYPE_CUSTOM_MIGRATION, TYPE_MIGRATION, TYPE_UPDATE, TYPE_VERIFY, VALID_PATH
 
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
CatalogUpdateService()
           
 
Method Summary
 void catalogTreeStep(Repository pCatalogRepository, MutableRepositoryItem pBaseItem, MutableRepositoryItem pCurrentItem, MutableRepositoryItem pPreviousItem, boolean pDirect, java.util.Map pCompletedItems)
          This is a recursive method that traverses up the catalog tree, starting with a baseItem, and visiting all its parent categories and catalogs, compiling all the incrementally-computed properties
 void categoryTreeStep(Repository pCatalogRepository, MutableRepositoryItem pBaseItem, MutableRepositoryItem pCurrentItem, MutableRepositoryItem pPreviousItem, boolean pDirect, java.util.Map pCompletedItems)
          This is a recursive method that traverses up the catalog tree, starting with a baseItem, and visiting all its parent categories and catalogs, compiling all the incrementally-computed properties
 void clearProperties(Repository pCatalogRepository)
          This method sets all the properties calculated by this service in all catalog and category items to null
 CatalogProperties getCatalogProperties()
          A helper class that holds commonly accessed reposority property and item names
 CustomCatalogTools getCatalogTools()
          Returns property catalogTools
 int getMaxItemsPerTransaction()
          Returns property maxItemsPerTransaction
 java.lang.String getProjectWorkflow()
          retrieve the workflow
 java.lang.String getServiceName()
           
protected  Workspace getWorkspace(java.lang.String pWorkspaceId)
          Creates and returns new workspace
 boolean isComputeSubCatalogs()
          Returns property computeSubCatalogs
 boolean performService(Repository pRepository, java.util.Collection pCatalogIds, java.util.List pServiceFunctions)
          Performs this services functions.
 void setCatalogProperties(CatalogProperties pCatalogProperties)
           
 void setCatalogTools(CustomCatalogTools pCatalogTools)
          Sets property catalogTools
 void setCompletedCatalogs(java.util.Map pCompletedCatalogs)
          Sets the catalogs that have been used as a starting point for a catalog tree walk
 void setComputeSubCatalogs(boolean pComputeSubCatalogs)
          Sets boolean indicating if the subCatalogs property of the catalog item should be computed.
 void setMaxItemsPerTransaction(int pMaxItemsPerTransaction)
          Sets the maximum number of repository items that will be handled within a single transaction
 void setProjectWorkflow(java.lang.String pProjectWorkflow)
          set the workflow
protected  java.lang.String stringIt(java.util.Collection pObject)
           
protected  java.lang.String stringIt(java.lang.Object[] pObject)
           
 void updateCatalog(Repository pCatalogRepository)
          The main method iterates through all the catalogs, sets the "directAncestorCatalogsAndSelf" property of the catalog to itself, calls the recursive "catalogTreeStep" method, which starts a walk up the catalog tree, and then adds the catalog to the "completed" list.
 
Methods inherited from class atg.commerce.catalog.CMSService
addErrorMessage, addInfoMessage, addWarningMessage, clearBookkeepingForThread, clearMessages, createCMSMessage, doScheduledTask, doService, getAvailableFunctions, getBookkeepingForThread, getCurrentMessages, getErrorMessages, getFunctionsToPerformByDefault, getInfoMessages, getServiceLock, getTotalNumberOfErrorMessages, getTotalNumberOfInfoMessages, getTotalNumberOfMessages, getTotalNumberOfWarningMessages, getTransactionManager, getWarningMessages, hasFunction, isSaveMessages, logDebug, logError, logInfo, logWarning, performService, postService, preService, removeServiceLock, setAvailableFunctions, setFunctionsToPerformByDefault, setSaveMessages, setTransactionManager
 
Methods inherited from class atg.service.scheduler.SingletonSchedulableService
acquireLock, getClientLockManager, getLockName, getLockTimeOut, performScheduledTask, releaseLock, setClientLockManager, setLockName, setLockTimeOut
 
Methods inherited from class atg.service.scheduler.SchedulableService
doStartService, doStopService, getJobDescription, getJobId, getJobName, getSchedule, getScheduler, getThreadMethod, isTransactional, setJobDescription, setJobName, setSchedule, setScheduler, setThreadMethod, setTransactional, startScheduledJob, stopScheduledJob
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logError, logError, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, 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 final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values

PROCESS_NAME_PREFIX

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

PUBLISHING_USER

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

CatalogUpdateService

public CatalogUpdateService()
Method Detail

setCatalogTools

public void setCatalogTools(CustomCatalogTools pCatalogTools)
Sets property catalogTools


getCatalogTools

public CustomCatalogTools getCatalogTools()
Returns property catalogTools


setCatalogProperties

public void setCatalogProperties(CatalogProperties pCatalogProperties)

getCatalogProperties

public CatalogProperties getCatalogProperties()
A helper class that holds commonly accessed reposority property and item names


setCompletedCatalogs

public void setCompletedCatalogs(java.util.Map pCompletedCatalogs)
Sets the catalogs that have been used as a starting point for a catalog tree walk


setComputeSubCatalogs

public void setComputeSubCatalogs(boolean pComputeSubCatalogs)
Sets boolean indicating if the subCatalogs property of the catalog item should be computed.


isComputeSubCatalogs

public boolean isComputeSubCatalogs()
Returns property computeSubCatalogs


setMaxItemsPerTransaction

public void setMaxItemsPerTransaction(int pMaxItemsPerTransaction)
Sets the maximum number of repository items that will be handled within a single transaction


getMaxItemsPerTransaction

public int getMaxItemsPerTransaction()
Returns property maxItemsPerTransaction


getProjectWorkflow

public java.lang.String getProjectWorkflow()
retrieve the workflow

Returns:
The publishing workflow name

setProjectWorkflow

public void setProjectWorkflow(java.lang.String pProjectWorkflow)
set the workflow

Parameters:
pWorkspaceId - - The publishing workflow name

getServiceName

public java.lang.String getServiceName()
Specified by:
getServiceName in class atg.commerce.catalog.CMSService

performService

public boolean performService(Repository pRepository,
                              java.util.Collection pCatalogIds,
                              java.util.List pServiceFunctions)
Performs this services functions. pRepository and pCatalogIds are parameters only for compliance with CMSService. These parameters are not used - the repository is defined by the catalogRepository property, and we do not support processing of individual catalogs - the entire repository will be processed.

Specified by:
performService in class atg.commerce.catalog.CMSService
Parameters:
pRepository - - Not used. Repository is defined in catalogRepositoryProperty
pCatalogIds - - Not used. Entire repository is always processed
pServiceFunctions - - a list of strings that identify service functions. used to conditionally executed specific functions of a service
Returns:
boolean - service success or failure

updateCatalog

public void updateCatalog(Repository pCatalogRepository)
                   throws CatalogLoopException
The main method iterates through all the catalogs, sets the "directAncestorCatalogsAndSelf" property of the catalog to itself, calls the recursive "catalogTreeStep" method, which starts a walk up the catalog tree, and then adds the catalog to the "completed" list. When running in versioned environment, in addition to the above functionality, it creates a project using configured workflow and make the associated workspace current development line before making any changes to the catalog.

Throws:
CatalogLoopException - if there is a catalog that is an ancestor of itself

catalogTreeStep

public void catalogTreeStep(Repository pCatalogRepository,
                            MutableRepositoryItem pBaseItem,
                            MutableRepositoryItem pCurrentItem,
                            MutableRepositoryItem pPreviousItem,
                            boolean pDirect,
                            java.util.Map pCompletedItems)
                     throws RepositoryException,
                            TransactionDemarcationException,
                            CatalogLoopException
This is a recursive method that traverses up the catalog tree, starting with a baseItem, and visiting all its parent categories and catalogs, compiling all the incrementally-computed properties

Parameters:
pBaseItem - - The repository item that was the starting point of the current walk up the catalog tree.
pCurrentItem - - The repository item that represents the current point of the tree walk
pPreviousItem - - The repository item that represents the most recent point of the tree walk
pDirect - - Boolean indicating if, to this point in the tree walk, we have seen only directly-connect catalog items (i.e., we have not reached a category item yet)
pCompletedItems - - A map of all repository items that we have already seen on this tree walk, this is used to check for loops in the structure.
Throws:
RepositoryException
TransactionDemarcationException
CatalogLoopException

categoryTreeStep

public void categoryTreeStep(Repository pCatalogRepository,
                             MutableRepositoryItem pBaseItem,
                             MutableRepositoryItem pCurrentItem,
                             MutableRepositoryItem pPreviousItem,
                             boolean pDirect,
                             java.util.Map pCompletedItems)
                      throws RepositoryException,
                             TransactionDemarcationException,
                             CatalogLoopException
This is a recursive method that traverses up the catalog tree, starting with a baseItem, and visiting all its parent categories and catalogs, compiling all the incrementally-computed properties

Parameters:
pBaseItem - - The repository item that was the starting point of the current walk up the catalog tree.
pCurrentItem - - The repository item that represents the current point of the tree walk
pPreviousItem - - The repository item that represents the most recent point of the tree walk
pDirect - - Boolean indicating if, to this point in the tree walk, we have seen only directly-connect catalog items (i.e., we have not reached a category item yet)
pCompletedItems - - A map of all repository items that we have already seen on this tree walk, this is used to check for loops in the structure.
Throws:
RepositoryException
TransactionDemarcationException
CatalogLoopException

clearProperties

public void clearProperties(Repository pCatalogRepository)
This method sets all the properties calculated by this service in all catalog and category items to null


stringIt

protected java.lang.String stringIt(java.util.Collection pObject)
Overrides:
stringIt in class atg.commerce.catalog.CMSService

stringIt

protected java.lang.String stringIt(java.lang.Object[] pObject)
Overrides:
stringIt in class atg.commerce.catalog.CMSService

getWorkspace

protected Workspace getWorkspace(java.lang.String pWorkspaceId)
                          throws RepositoryException
Creates and returns new workspace

Parameters:
pWorkspaceId- - Id used to create the workspace.
Returns:
returns object of type Workspace
Throws:
RepositoryException - if unable to retrieve the workspace corresponding to pWorkspaceId