atg.endeca.index
Class LocaledExporter

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.endeca.index.LocaledExporter
All Implemented Interfaces:
Indexable, 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
Direct Known Subclasses:
RepositoryTypeHierarchyExporter, SchemaExporter

public abstract class LocaledExporter
extends GenericService
implements Indexable

A base class that needs to export items by locale. Handles most of the setup/teardown of the submitter session. Appropriate for exporters that generate a relatively small number of records to be exported, since it assumes that a single Records object will hold all records comfortably in memory.

Created: November 16 2011


Nested Class Summary
static class LocaledExporter.MinimalBulkLoaderResults
          Extends BulkLoaderResults with a minimal implemental that accepts a boolean "successful" flag..
static class LocaledExporter.MinimalIncrementalLoaderResults
          Extends IncrementalLoaderResults with a minimal implementation.
 
Field Summary
static java.lang.String CLASS_VERSION
          Class version string from source code control system.
 
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
LocaledExporter()
           
 
Method Summary
 boolean cancel(IndexingTask pTask, boolean pBaseline)
          Cancel the currently in-process performBulkLoad or processQueuedIncrementalUpdates.
protected  javax.servlet.Servlet createAdminServlet()
          Creates and returns a new Servlet that will administer this service.
protected  EndecaContext createContext()
          Create the context to use.
protected abstract  Records createExportRecords(EndecaContext pContext, java.util.Locale pLocale)
          Create the export records for the specified locale.
 java.lang.String createExportRecordsAsXML()
          Return the set of export records for the default Locale in XML form.
protected  Records createExportRecordsForLocale(java.util.Locale pLocale)
          Create the set of export records for the default Locale.
 void doStartService()
          This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values.
protected  void export(IndexingTask pTask)
          Generate and export the schema via our DocumentSubmitter.
 void export(IndexingTask pTask, java.util.Locale pLocale, atg.repository.search.indexing.DocumentSubmitterSession pSession)
          Export the schema using the specified DocumentSubmitterSession.
 void exportRecords(Records pRecords, IndexingTask pTask, java.util.Locale pLocale, atg.repository.search.indexing.DocumentSubmitterSession pSession)
          Export the schema using the specified DocumentSubmitterSession.
 java.lang.String getDefaultLanguageForRecordStores()
          Returns property mDefaultLanguageForRecordStores.
 atg.repository.search.indexing.DocumentSubmitter getDocumentSubmitter()
          Returns property documentSubmitter.
 Records getExportRecordsForDefaultLocale()
          Return the export records for the default Locale.
 EndecaIndexingOutputConfig getIndexingOutputConfig()
          Returns property indexingOutputConfig.
 java.util.Set<java.lang.String> getIndexingOutputConfigPaths()
          Return the set of IndexingOutputConfigs associated with this Indexable.
 java.util.Locale[] getLocales()
          Returns property locales.
protected  void initContext(EndecaContext pContext, IndexingTask pTask, atg.repository.search.indexing.DocumentSubmitterSession pSession, java.util.Locale pLocale)
          Initialize the specified context object.
 boolean isNeededForIncremental()
          Whether this Indexable is needed for an incremental update.
 boolean isSupportsStatusCounts()
          Whether this object supports returning/updating status counts.
 boolean mayNeedCleanup()
          Whether this task may need cleanup.
 atg.repository.search.indexing.BulkLoaderResults performBaselineUpdate(IndexingTask pTask)
          Do a full/bulk load.
 atg.repository.search.indexing.LoaderResults performPartialUpdate(IndexingTask pTask)
          Do an incremental load (that is, process any Queued incremental updates.
 void postIndexingCleanup(IndexingTask pTask, boolean pSuccess, atg.repository.search.indexing.LoaderResults pResults)
          Perform any post indexing cleanup.
protected  void restoreDynamoRequestLocale(java.lang.Object pRestoreValue)
          Restore the current dynamo request locale.
 void setDefaultLanguageForRecordStores(java.lang.String pDefaultLanguageForRecordStores)
          Sets property mDefaultLanguageForRecordStores.
 void setDocumentSubmitter(atg.repository.search.indexing.DocumentSubmitter pDocumentSubmitter)
          Sets property documentSubmitter.
protected  java.lang.Object setDynamoRequestLocale(java.util.Locale pLocale)
          Set the current dynamo request locale, possibly setting a fake current local request.
 void setIndexingOutputConfig(EndecaIndexingOutputConfig pIndexingOutputConfig)
          Sets property indexingOutputConfig.
 void setLocales(java.util.Locale[] pLocales)
          Sets property locales.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, 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 final java.lang.String CLASS_VERSION
Class version string from source code control system.

See Also:
Constant Field Values
Constructor Detail

LocaledExporter

public LocaledExporter()
Method Detail

setLocales

public void setLocales(java.util.Locale[] pLocales)
Sets property locales. List of locales to generate the schema in.


getLocales

public java.util.Locale[] getLocales()
Returns property locales. List of locales to generate the schema in.


setDefaultLanguageForRecordStores

public void setDefaultLanguageForRecordStores(java.lang.String pDefaultLanguageForRecordStores)
Sets property mDefaultLanguageForRecordStores. If set, everything is exported to a single record store for all locales


getDefaultLanguageForRecordStores

public java.lang.String getDefaultLanguageForRecordStores()
Returns property mDefaultLanguageForRecordStores. If set, everything is exported to a single record store for all locales


setDocumentSubmitter

public void setDocumentSubmitter(atg.repository.search.indexing.DocumentSubmitter pDocumentSubmitter)
Sets property documentSubmitter. The document submitter to use for exporting the schema.


getDocumentSubmitter

public atg.repository.search.indexing.DocumentSubmitter getDocumentSubmitter()
Returns property documentSubmitter. The document submitter to use for exporting the schema.


setIndexingOutputConfig

public void setIndexingOutputConfig(EndecaIndexingOutputConfig pIndexingOutputConfig)
Sets property indexingOutputConfig. The indexing output config whose schema should be exported.


getIndexingOutputConfig

public EndecaIndexingOutputConfig getIndexingOutputConfig()
Returns property indexingOutputConfig. The indexing output config whose schema should be exported.


export

protected void export(IndexingTask pTask)
               throws atg.repository.search.indexing.IndexingException
Generate and export the schema via our DocumentSubmitter.

Parameters:
pTask - the current indexing task. May be null if there is no current IndexingTask.
Throws:
atg.repository.search.indexing.IndexingException

createContext

protected EndecaContext createContext()
Create the context to use.


initContext

protected void initContext(EndecaContext pContext,
                           IndexingTask pTask,
                           atg.repository.search.indexing.DocumentSubmitterSession pSession,
                           java.util.Locale pLocale)
Initialize the specified context object.


export

public void export(IndexingTask pTask,
                   java.util.Locale pLocale,
                   atg.repository.search.indexing.DocumentSubmitterSession pSession)
            throws atg.repository.search.indexing.IndexingException
Export the schema using the specified DocumentSubmitterSession.

Parameters:
pTask - the current indexing task. May be null if called outside of an IndexingPhase.
pLocale - the locale in which to export the schema.
pSession - the document submitter session to use.
Throws:
atg.repository.search.indexing.IndexingException

exportRecords

public void exportRecords(Records pRecords,
                          IndexingTask pTask,
                          java.util.Locale pLocale,
                          atg.repository.search.indexing.DocumentSubmitterSession pSession)
                   throws atg.repository.search.indexing.IndexingException
Export the schema using the specified DocumentSubmitterSession.

Parameters:
pRecords - the records to export. If null, will generate records using createExportRecords().
pTask - the current indexing task. May be null if called outside of an IndexingPhase.
pLocale - the locale in which to export the schema.
pSession - the document submitter session to use.
Throws:
atg.repository.search.indexing.IndexingException

createExportRecords

protected abstract Records createExportRecords(EndecaContext pContext,
                                               java.util.Locale pLocale)
                                        throws atg.repository.search.indexing.IndexingException
Create the export records for the specified locale.

Parameters:
pContext - the current indexing context.
pLocale - to locale for which to generate records.
Returns:
the generated set of records.
Throws:
atg.repository.search.indexing.IndexingException

performPartialUpdate

public atg.repository.search.indexing.LoaderResults performPartialUpdate(IndexingTask pTask)
                                                                  throws atg.repository.search.indexing.IndexingException
Description copied from interface: Indexable
Do an incremental load (that is, process any Queued incremental updates. Note that the any results property but "successful" may not be filled except by IndexingOutputConfigs.

Specified by:
performPartialUpdate in interface Indexable
Parameters:
pTask - the indexing task invoking the update. May be null if called via another means.
Throws:
atg.repository.search.indexing.IndexingException

performBaselineUpdate

public atg.repository.search.indexing.BulkLoaderResults performBaselineUpdate(IndexingTask pTask)
                                                                       throws atg.repository.search.indexing.IndexingException
Description copied from interface: Indexable
Do a full/bulk load. Note that the any results property but "successful" may not be filled except by IndexingOutputConfigs.

This is called "performBulkLoad" rather than "bulkLoad" so that MultiConfigLoader could implement it.

Specified by:
performBaselineUpdate in interface Indexable
Parameters:
pTask - the indexing task invoking the update. May be null if called via another means.
Throws:
atg.repository.search.indexing.IndexingException

isNeededForIncremental

public boolean isNeededForIncremental()
Description copied from interface: Indexable
Whether this Indexable is needed for an incremental update.

Specified by:
isNeededForIncremental in interface Indexable
Returns:
true if this Indexable should be invoked for an incremental update, false if this Indexable should not be involved at an incremental update.

postIndexingCleanup

public void postIndexingCleanup(IndexingTask pTask,
                                boolean pSuccess,
                                atg.repository.search.indexing.LoaderResults pResults)
Description copied from interface: Indexable
Perform any post indexing cleanup.

Specified by:
postIndexingCleanup in interface Indexable
Parameters:
pTask - the current indexing task, if any.
pSuccess - true if we are cleaning up from a successful index, false otherwise.
pResults - the loader results (if any) returns from performBaselineUpdate and performPartialUpdate.

mayNeedCleanup

public boolean mayNeedCleanup()
Description copied from interface: Indexable
Whether this task may need cleanup. If true is returned, postIndexingCleanup will be called at some point after performPartialUpdate or performBaselineUpdate.

Specified by:
mayNeedCleanup in interface Indexable

cancel

public boolean cancel(IndexingTask pTask,
                      boolean pBaseline)
               throws atg.repository.search.indexing.IndexingException
Description copied from interface: Indexable
Cancel the currently in-process performBulkLoad or processQueuedIncrementalUpdates. Quick running indexables may not support cancel.

Specified by:
cancel in interface Indexable
pBaseline - true if this is a baseline/full index, false if this is an incremental/partial index.
Returns:
true if current task was found to cancel, false otherwise.
Throws:
atg.repository.search.indexing.IndexingException

isSupportsStatusCounts

public boolean isSupportsStatusCounts()
Description copied from interface: Indexable
Whether this object supports returning/updating status counts. This is mostly so the admin will not display meaningless "0" even though work may be progressing.

Specified by:
isSupportsStatusCounts in interface Indexable

doStartService

public void doStartService()
                    throws ServiceException
Description copied from class: GenericService
This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values. The Service should override this method to start any processes it requires.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up

setDynamoRequestLocale

protected java.lang.Object setDynamoRequestLocale(java.util.Locale pLocale)
Set the current dynamo request locale, possibly setting a fake current local request. Invokers should always call restoreDynamoRequestLocale in a finally block after invoking this method.

Parameters:
pLocale - the locale to set.

restoreDynamoRequestLocale

protected void restoreDynamoRequestLocale(java.lang.Object pRestoreValue)
Restore the current dynamo request locale. This method should be called in a finally block by any code that called setDynamoRequestLocale.

Parameters:
pRestoreValue - the restore value returned by setDynamoRequestLocale.

getExportRecordsForDefaultLocale

public Records getExportRecordsForDefaultLocale()
                                         throws atg.repository.search.indexing.IndexingException
Return the export records for the default Locale. Useful mostly for debugging.

Throws:
atg.repository.search.indexing.IndexingException

createExportRecordsForLocale

protected Records createExportRecordsForLocale(java.util.Locale pLocale)
                                        throws atg.repository.search.indexing.IndexingException
Create the set of export records for the default Locale.

Throws:
atg.repository.search.indexing.IndexingException

createExportRecordsAsXML

public java.lang.String createExportRecordsAsXML()
                                          throws atg.repository.search.indexing.IndexingException
Return the set of export records for the default Locale in XML form.

Throws:
atg.repository.search.indexing.IndexingException

getIndexingOutputConfigPaths

public java.util.Set<java.lang.String> getIndexingOutputConfigPaths()
Description copied from interface: Indexable
Return the set of IndexingOutputConfigs associated with this Indexable. May return an empty set, but should always return non-null.

Specified by:
getIndexingOutputConfigPaths in interface Indexable

createAdminServlet

protected javax.servlet.Servlet createAdminServlet()
Description copied from class: GenericService
Creates and returns a new Servlet that will administer this service. By default, this creates a ServiceAdminServlet, but subclasses may create their own servlets.

Overrides:
createAdminServlet in class GenericService