atg.search.query.formhandlers
Class BaseSearchFormHandler

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.droplet.EmptyFormHandler
              extended by atg.droplet.GenericFormHandler
                  extended by atg.search.query.formhandlers.BaseSearchFormHandler
All Implemented Interfaces:
DropletFormHandler, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
BrowseFormHandler, CategorizeFormHandler, QueryFormHandler, SimilarDocsFormHandler, StructuredQueryFormHandler, ViewInContextFormHandler

public abstract class BaseSearchFormHandler
extends GenericFormHandler

This class provides the generic functionality for executing queries against the search server and retrieving results. Subclasses implement query specific functionality, in particular they provide implementations for the following abstract methods:

   protected ClientRequest createClientRequest( DynamoHttpServletRequest pRequest,
     DynamoHttpServletResponse pResponse ); *

   protected SearchMessage createSearchMessage( ClientRequest pClientRequest,
     DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse );
 
This class also provides support for the documentSets and parserOptions properties, these properties are common to all request types (though the ViewInContext tag doesn't use them directly.)


Field Summary
static java.lang.String CLASS_VERSION
           
protected static java.lang.String DEFAULT_ANONYMOUS_USERNAME
           
protected static java.lang.String DEFAULT_SITE_NAME
           
 
Fields inherited from class atg.droplet.GenericFormHandler
PARAM_DEFER_FORWARD_OR_REDIRECT, PARAM_USE_FORWARDS
 
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
BaseSearchFormHandler()
           
 
Method Summary
protected  Results afterSearch(ClientRequest pRequest, SearchContext pContext, SearchSession pSession, Results pResults)
          This method is called just after a search has been executed and is intended to allow subclasses an opportunity to update the search session or modify the search results object.
 void beforeGet(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Calls parent beforeGet() then calls buildClientRequest(pRequest,pResponse) to create the appropriate ClientRequest object.
protected  ClientRequest beforeSearch(ClientRequest pRequest, SearchContext pContext, SearchSession pSession)
          This method is called just before a search is executed and is intended to allow subclasses an opportunity to make last minute changes to the request object or to update the search context.
 boolean beforeSet(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Calls parent beforeSet() then calls buildClientRequest(pRequest,pResponse) to create the appropriate ClientRequest object.
protected  void buildClientRequest(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          If there is no current ClientRequest object, delegate to the subclass the creation of this object.
protected  java.lang.StringBuffer buildSimpleTag(java.lang.String pTagName, java.lang.String pTagValue, java.util.Map pAttributes)
          Build a simple tag
protected abstract  ClientRequest createClientRequest(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Called to create the subclass object of the client request
 java.util.Map createOptionSet(java.lang.String pOptionSetName)
          Return the named option set or null if no option set exists for the specified name.
protected abstract  SearchMessage createSearchMessage(ClientRequest pClientRequest, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Create a JMS message to send to listeners to notify them of the search and search results
 SearchSession createSearchSession(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Create the SearchSession by first calling createSessionConfig() to obtain a configuration, then by calling ESSearchService.createSession()
protected  SessionConfig createSessionConfig(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Create and initialize SessionConfig object
 java.util.Map decodeMapData(java.lang.String pData, java.lang.String pPairRegex, KeyValueSplitter pSpliter)
          Decode encoded key/value data from a string, return results in a map.
protected  void dumpMap(java.lang.String pMapPropertyName, java.util.Map pMap)
          For debugging, dump the contents of a map and print a string indicating what property of the request this map represents.
protected  void dumpRequestInfo(ClientRequest pRequest)
          Dump request information.
protected  java.lang.String encodeArrayData(java.lang.String[] pArray, java.lang.String pPrefix, java.lang.String pSuffix, java.lang.String pDelimiter)
          Translate an array into a string of encoded values using the specified delimiter and separator values.
protected  java.lang.String encodeCollectionData(java.util.Collection pCollection, java.lang.String pPrefix, java.lang.String pSuffix, java.lang.String pDelimiter)
          Translate a collection into a string of encoded values using the specified delimiter and separator values.
protected  java.lang.String encodeMapData(java.util.Map pMap, java.lang.String pPrefix, java.lang.String pSeparator, java.lang.String pSuffix, java.lang.String pDelimiter)
          Translate a map into a string of encoded key/value pairs using the specified delimiter and separator values
 java.lang.String getAnonymousUserName()
          Get the string to use for the anonymous user.
 boolean getAutoRedirect()
          If set to true then the form handler will check the search results for a redirect URL and if found redirect to it.
protected  java.lang.Boolean getBooleanRequestAttribute(java.lang.String pAttributeName)
          Get a request attribute value as a Boolean
protected  boolean getBoolRequestAttribute(java.lang.String pAttributeName, boolean pDefault)
          Get a request attribute value as an int
 java.lang.String getClearQueryURL()
          Get the optional URL to redirect to when handleClearQuery() is invoked
 ClientRequest getClientRequest()
          Get the client request object from the search context.
protected  DocumentSetConstraint getDocumentSets()
          Get the <documentSets> tag contents as DocumentSetConstraint object.
 XMLBuilder getDocumentSetsBuilder()
          Get the optional XMLBuilder object.
 java.lang.String getErrorURL()
          Get the optional url to redirect to when an error is encountered in handleSearch()
protected  java.lang.Integer getIntegerRequestAttribute(java.lang.String pAttributeName)
          Get a request attribute value as an Integer
protected  int getIntRequestAttribute(java.lang.String pAttributeName, int pDefault)
          Get a request attribute value as an int
 java.util.Map getOptionSet()
          Set the option set in use for this request.
 java.lang.String getOptionSetName()
          Get the option set name to use for this query, or null to use the default option set for this query type.
protected  ParserOptions getParserOptions()
          Returns a ParserOptions object.
 XMLBuilder getParserOptionsBuilder()
          Get the optional parser options builder object.
 java.lang.String getRequestAttribute(java.lang.String pAttributeName)
          Get a request attribute associated with specified attribute name.
 java.util.Map getRequestAttributes()
          Return the request attribute map
 Results getResults()
          Return the Results object.
 ResultsFetchingProxy getResultsFetcher()
          Get the results fetcher.
 SearchContext getSearchContext()
          Get the session scoped search context
protected  SearchMessageSource getSearchMessageSource()
          Get the message source for this component.
 ESSearchService getSearchService()
          Get the ESSearchService, the interface to the search service
 SearchSession getSearchSession()
          Return the search session from the search context or null if one does not yet exist.
 boolean getSessionBasedSearchRequest()
          Set to true to save search request in the SearchContext component, false otherwise.
 boolean getSessionBasedSearchResults()
          Set to true to save search Results object in SearchContext object, false otherwise.
 java.lang.String getSessionConfigLanguage()
          Get the value used to initialize the SessionConfig's language property.
protected  java.util.Map getSiteDefaultOptionSet(ClientRequest pRequest, SearchSession pSession)
          Get the default option set for this client request.
 java.lang.String getSiteName()
          Get the site name.
 java.lang.String[] getStringArrayRequestAttribute(java.lang.String pKey, java.lang.String pSeparator)
          Return a request attribute value, identified by the specified key, as a String array
 java.lang.String getSuccessURL()
          Get the optional url to redirect to on a successful search.
 RepositoryItem getUserProfile()
          Get the user profile repository item or null.
protected  boolean handleAutoRedirect(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse, Results pResults, boolean pResult)
          Method to handle a redirect url in the search results.
 boolean handleClearQuery(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Handle clear query
protected  boolean handleErrorCondition(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse, java.lang.Exception pException)
           
 boolean handleSearch(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Handle search request.
 boolean isRequestLogging()
          Get the loggingEnabled property of the client request.
protected  java.util.Map mergeMaps(java.util.Map pBase, java.util.Map pOverrides)
          Merge override map entries with base entries.
protected  void prepareClientRequest(DynamoHttpServletRequest pRequest)
          Called during handleSearch, sets the parser/parsing and constraints/documentSets values into the request object.
protected  void sendSearchMessage(ClientRequest pClientRequest, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Send a JMS Search message via configured SearchMessageSource.
 void setAnonymousUserName(java.lang.String pAnonymousUserName)
          Set the name of the user to use for anonymous searches.
 void setAutoRedirect(boolean pAutoRedirect)
          If set to true then the form handler will check the search results for a redirect URL and if found redirect to it.
protected  void setBooleanRequestAttribute(java.lang.String pAttributeName, java.lang.Boolean pAttributeValue)
          Convince method to set a request attribute using a Boolean value
 void setClearQueryURL(java.lang.String pClearQueryURL)
          Set the optional URL to go to when handleClearQuery() is invoked.
protected  void setClientRequest(ClientRequest pClientRequest)
          Set the client request object.
 void setDocumentSetsBuilder(XMLBuilder pDocumentSetsBuilder)
          Set an optional XMLBuilder object.
 void setErrorURL(java.lang.String pErrorURL)
          Set the optional url to redirect to when an error is encountered in handleSearch()
 void setOptionSet(java.util.Map pOptionSet)
          Set the option set in use for this request.
 void setOptionSetName(java.lang.String pOptionSetName)
          Set the option set name to use for this query.
 void setParserOptionsBuilder(XMLBuilder pParserOptionsBuilder)
          Set an optional parser options builder object.
 java.lang.String setRequestAttribute(java.lang.String pKey, java.lang.String pValue)
          Set a request attribute into the request attribute map.
 void setRequestAttributes(java.util.Map pRequestAttributes)
          Set request attribute map.
 void setRequestLogging(boolean pLogging)
          Set the loggingEnabled property of the ClientRequest object
protected  void setResults(Results pResults)
          Set the Results object returned from the search server.
 void setResultsFetcher(ResultsFetchingProxy pResultsFetcher)
          Set a results fetching proxy.
 void setSearchContext(SearchContext pSearchContext)
          Set the session scoped search context object
 void setSearchService(ESSearchService pSearchService)
          Set the ESSearchService instance, this is the connection to the search server
 void setSessionBasedSearchRequest(boolean pSession)
          Set to true to save search request in the SearchContext component, false otherwise.
 void setSessionBasedSearchResults(boolean pSession)
          Set to true to save search Results object in SearchContext object, false otherwise.
 void setSessionConfigLanguage(java.lang.String pSessionConfigLanguage)
          Set the language value used when creating the search session.
 void setSiteName(java.lang.String pSiteName)
          Set the siteName to be used in the SessionConfig
 void setSuccessURL(java.lang.String pSuccessURL)
          Set the optional url to redirect to on a successful search (a search which throws no exceptions)
 void setUserProfile(RepositoryItem pUserProfile)
          Set the user user profile for the user executing the search
 
Methods inherited from class atg.droplet.GenericFormHandler
addFormException, addUncheckedFormException, afterSet, checkFormRedirect, createFormSubmissionMessage, getCancelURL, getCheckForValidSession, getFormError, getFormExceptions, getFormName, getMessagePort, getMessageSource, getMessageType, getPropertyExceptions, getSendMessages, getUncheckedFormExceptions, handleCancel, handleFormException, handleUncheckedFormException, hasUncheckedFormExceptions, isDeferForwardsAndRedirects, isRestorableForm, isUseForwards, isValidSession, redirectOrForward, resetFormExceptions, setCancelURL, setCheckForValidSession, setDeferForwardsAndRedirects, setFormName, setMessagePort, setMessageSource, setMessageType, setRestorableForm, setSendMessages, setUseForwards
 
Methods inherited from class atg.droplet.EmptyFormHandler
afterGet
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, 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 java.lang.String CLASS_VERSION

DEFAULT_ANONYMOUS_USERNAME

protected static final java.lang.String DEFAULT_ANONYMOUS_USERNAME
See Also:
Constant Field Values

DEFAULT_SITE_NAME

protected static final java.lang.String DEFAULT_SITE_NAME
See Also:
Constant Field Values
Constructor Detail

BaseSearchFormHandler

public BaseSearchFormHandler()
Method Detail

setSessionBasedSearchRequest

public void setSessionBasedSearchRequest(boolean pSession)
Set to true to save search request in the SearchContext component, false otherwise.

Parameters:
pSession - true to save search request in the SearchContext, false otherwise
See Also:
SearchContext.getClientRequest()

getSessionBasedSearchRequest

public boolean getSessionBasedSearchRequest()
Set to true to save search request in the SearchContext component, false otherwise.

Returns:
true if saving search request in the SearchContext, false otherwise
See Also:
SearchContext.getClientRequest()

setSessionBasedSearchResults

public void setSessionBasedSearchResults(boolean pSession)
Set to true to save search Results object in SearchContext object, false otherwise.

Parameters:
pSession - true to save Results in SearchContext, false otherwise.
See Also:
SearchContext.getResults()

getSessionBasedSearchResults

public boolean getSessionBasedSearchResults()
Set to true to save search Results object in SearchContext object, false otherwise.

Returns:
true if saving Results in SearchContext, false otherwise.
See Also:
SearchContext.getResults()

setResultsFetcher

public void setResultsFetcher(ResultsFetchingProxy pResultsFetcher)
Set a results fetching proxy. If set, this object will be invoked to fetch the search results instead of the form handler.

Parameters:
pResultsFetcher - the results fetcher proxy
See Also:
ResultsFetchingProxy, CollectionFilterFetchingProxy

getResultsFetcher

public ResultsFetchingProxy getResultsFetcher()
Get the results fetcher. If set, this object will be invoked to fetch the search results.

Returns:
the custom results fetcher
See Also:
ResultsFetchingProxy, CollectionFilterFetchingProxy

getOptionSetName

public java.lang.String getOptionSetName()
Get the option set name to use for this query, or null to use the default option set for this query type.

Returns:
the option set name or null
See Also:
SearchSession#getOptionSet(String optionSetName)

setOptionSetName

public void setOptionSetName(java.lang.String pOptionSetName)
Set the option set name to use for this query. Use null to get the default option set for this query type.

Parameters:
the - option set name or null
See Also:
SearchSession#getOptionSet(String optionSetName)

createOptionSet

public java.util.Map createOptionSet(java.lang.String pOptionSetName)
Return the named option set or null if no option set exists for the specified name. The option set is retrieved from the searchSession.

Parameters:
pOptionSetName - the name of the option set
Returns:
the option set map or null
See Also:
SearchSession#getOptionSet(String optionSetName)

setOptionSet

public void setOptionSet(java.util.Map pOptionSet)
Set the option set in use for this request. This value is used in the prepareClientRequest() method to merge page values into current option set.

Parameters:
pOptionSet - the option set for this search request

getOptionSet

public java.util.Map getOptionSet()
Set the option set in use for this request. This value is used in the prepareClientRequest() method to merge page values into current option set.

Returns:
the option set in use for this request

setRequestLogging

public void setRequestLogging(boolean pLogging)
Set the loggingEnabled property of the ClientRequest object

Parameters:
pLogging - true or false
See Also:
ClientRequest#loggingEnabled(boolean loggingEnabled)

isRequestLogging

public boolean isRequestLogging()
Get the loggingEnabled property of the client request.

Returns:
true if logging is enabled, false otherwise
See Also:
ClientRequest#loggingEnabled(boolean loggingEnabled)

setDocumentSetsBuilder

public void setDocumentSetsBuilder(XMLBuilder pDocumentSetsBuilder)
Set an optional XMLBuilder object. If this build is not present, <documentSets> constraints can be set via the setDocumentSets method.

Parameters:
pDocumentSetsBuilder - the <documentSets> constraints builder or null
See Also:
XMLBuilder, MapXMLBuilder

getDocumentSetsBuilder

public XMLBuilder getDocumentSetsBuilder()
Get the optional XMLBuilder object. If this value is not explicitly set, this method creates and returns a MapXMLBuilder to build the parser options.

Returns:
the <documentSets> tag builder
See Also:
XMLBuilder, MapXMLBuilder

getDocumentSets

protected DocumentSetConstraint getDocumentSets()
Get the <documentSets> tag contents as DocumentSetConstraint object. Uses the value returned by getDocumentSetsBuilder() to create this value.

Returns:
the documetSets tag's contents or null
See Also:
getDocumentSetsBuilder(), XMLBuilder.buildXML(BaseSearchFormHandler pFormHandler, ClientRequest pClientRequest, String pTagName)

setParserOptionsBuilder

public void setParserOptionsBuilder(XMLBuilder pParserOptionsBuilder)
Set an optional parser options builder object.

Parameters:
pPar - the <prefAnswerConstr> XMLBuilder or null to use default MapXMLBuilder
See Also:
XMLBuilder, MapXMLBuilder

getParserOptionsBuilder

public XMLBuilder getParserOptionsBuilder()
Get the optional parser options builder object. If this value is not explicitly set, this method creates and returns a MapXMLBuilder to build the parser options.

Returns:
the <parserOptions> XMLBuilder
See Also:
XMLBuilder, MapXMLBuilder

getParserOptions

protected ParserOptions getParserOptions()
Returns a ParserOptions object. This object is generated with the parserOptionsBuilder object.

Returns:
the parser options
See Also:
getParserOptionsBuilder(), XMLBuilder.buildXML(BaseSearchFormHandler pFormHandler, ClientRequest pClientRequest, String pTagName)

getClientRequest

public ClientRequest getClientRequest()
Get the client request object from the search context.

Returns:
the client request object for the query type

getRequestAttributes

public java.util.Map getRequestAttributes()
Return the request attribute map

Returns:
the request's attribute map

setRequestAttributes

public void setRequestAttributes(java.util.Map pRequestAttributes)
Set request attribute map. If the client request has been created, adds the specified map entries to the client request. If the client request has not yet been created, saves the specified map and updates client request map map when it is created, in buildClientRequest().

Parameters:
pRequestAttributes - the request attribute map
See Also:
buildClientRequest(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)

getRequestAttribute

public java.lang.String getRequestAttribute(java.lang.String pAttributeName)
Get a request attribute associated with specified attribute name.

Parameters:
pAttributeName - the request attribute name
Returns:
the request attribute value or null

setRequestAttribute

public java.lang.String setRequestAttribute(java.lang.String pKey,
                                            java.lang.String pValue)
Set a request attribute into the request attribute map. If pValue is null or empty, remove any value associated with pKey instead.

Parameters:
pKey - the attribute key
pValue - the attribute value or null to remove existing pKey
Returns:
the previous value or null

getStringArrayRequestAttribute

public java.lang.String[] getStringArrayRequestAttribute(java.lang.String pKey,
                                                         java.lang.String pSeparator)
Return a request attribute value, identified by the specified key, as a String array

Parameters:
pKey - the attribute key
pSeparator - the string that separates elements of the array

setClearQueryURL

public void setClearQueryURL(java.lang.String pClearQueryURL)
Set the optional URL to go to when handleClearQuery() is invoked.

Parameters:
pClearQueryURL - the url or null
See Also:
handleClearQuery(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)

getClearQueryURL

public java.lang.String getClearQueryURL()
Get the optional URL to redirect to when handleClearQuery() is invoked

Returns:
the url or null

setErrorURL

public void setErrorURL(java.lang.String pErrorURL)
Set the optional url to redirect to when an error is encountered in handleSearch()

Parameters:
pErrorURL - the url or null

getErrorURL

public java.lang.String getErrorURL()
Get the optional url to redirect to when an error is encountered in handleSearch()

Returns:
the url or null

setSuccessURL

public void setSuccessURL(java.lang.String pSuccessURL)
Set the optional url to redirect to on a successful search (a search which throws no exceptions)

Parameters:
pSuccessURL - the success url or nul

getSuccessURL

public java.lang.String getSuccessURL()
Get the optional url to redirect to on a successful search. A successful search is one that throws no exceptions.

Returns:
the success url or null if not set

setAutoRedirect

public void setAutoRedirect(boolean pAutoRedirect)
If set to true then the form handler will check the search results for a redirect URL and if found redirect to it. This takes precedence over any successURL specified.

Parameters:
pAutoRedirect - boolean true to use redirect URL in search results

getAutoRedirect

public boolean getAutoRedirect()
If set to true then the form handler will check the search results for a redirect URL and if found redirect to it. This takes precedence over any successURL specified.

Returns:
boolean true to use redirect URL in search results

getAnonymousUserName

public java.lang.String getAnonymousUserName()
Get the string to use for the anonymous user. Default is "anonymous"

Returns:
the anonymous user name

setAnonymousUserName

public void setAnonymousUserName(java.lang.String pAnonymousUserName)
Set the name of the user to use for anonymous searches. Defaults to "anonymous".

Parameters:
pAnonymousUserName -

setSessionConfigLanguage

public void setSessionConfigLanguage(java.lang.String pSessionConfigLanguage)
Set the language value used when creating the search session. This value is set into the language property of the SessionConfig object.

Parameters:
pSessionConfigLanguage -

getSessionConfigLanguage

public java.lang.String getSessionConfigLanguage()
Get the value used to initialize the SessionConfig's language property.

Returns:
the SessionConfig's language
See Also:
SessionConfig.setLanguage(String)

setSiteName

public void setSiteName(java.lang.String pSiteName)
Set the siteName to be used in the SessionConfig

Parameters:
pSiteName - the site name or null to use default

getSiteName

public java.lang.String getSiteName()
Get the site name. Returns either "default" if not set, or the custom site name. This value is both set into the SessionConfig object used in the creation of the SearchSession, and sent in the JMS message for searches executed in that session.

Returns:
the site name

setSearchService

public void setSearchService(ESSearchService pSearchService)
Set the ESSearchService instance, this is the connection to the search server

Parameters:
pESSearchService - the search service

setSearchContext

public void setSearchContext(SearchContext pSearchContext)
Set the session scoped search context object

Parameters:
pSearchContext - the search context

getSearchContext

public SearchContext getSearchContext()
Get the session scoped search context

Returns:
the search context

getSearchSession

public SearchSession getSearchSession()
Return the search session from the search context or null if one does not yet exist.

Returns:
the search session or null

createSearchSession

public SearchSession createSearchSession(DynamoHttpServletRequest pRequest,
                                         DynamoHttpServletResponse pResponse)
Create the SearchSession by first calling createSessionConfig() to obtain a configuration, then by calling ESSearchService.createSession()

Parameters:
pRequest - the Dynamo http request
pResponse - the Dynamo http response
Returns:
the session or null on error
See Also:
createSessionConfig(atg.servlet.DynamoHttpServletRequest, atg.servlet.DynamoHttpServletResponse)

getSearchService

public ESSearchService getSearchService()
Get the ESSearchService, the interface to the search service

Returns:
the search service

setUserProfile

public void setUserProfile(RepositoryItem pUserProfile)
Set the user user profile for the user executing the search

Parameters:
pUserProfile - the user profile repository item or null

getUserProfile

public RepositoryItem getUserProfile()
Get the user profile repository item or null.

Returns:
the user profile repository item or null

prepareClientRequest

protected void prepareClientRequest(DynamoHttpServletRequest pRequest)
Called during handleSearch, sets the parser/parsing and constraints/documentSets values into the request object. Overriding subclasses can either invoke this method to set these values or handle them themselves. This method uses mergeMaps() to merge the siteDefaultOpitonSet map with the requestAttributes set on the page.

Parameters:
pRequest - DynamoHttpServletRequest

createClientRequest

protected abstract ClientRequest createClientRequest(DynamoHttpServletRequest pRequest,
                                                     DynamoHttpServletResponse pResponse)
Called to create the subclass object of the client request

Parameters:
pRequest - the dynamo request
pResponse - the dynamo response

createSearchMessage

protected abstract SearchMessage createSearchMessage(ClientRequest pClientRequest,
                                                     DynamoHttpServletRequest pRequest,
                                                     DynamoHttpServletResponse pResponse)
Create a JMS message to send to listeners to notify them of the search and search results

Parameters:
pClientRequest - the search server request object
pRequest - the dynamo request
pResponse - the dynamo response
Returns:
the JMS message to send or null

getResults

public Results getResults()
Return the Results object.

Returns:
the results object

buildClientRequest

protected void buildClientRequest(DynamoHttpServletRequest pRequest,
                                  DynamoHttpServletResponse pResponse)
If there is no current ClientRequest object, delegate to the subclass the creation of this object.

Parameters:
pRequest - the dynamo request
pResponse - the dynamo response

beforeSet

public boolean beforeSet(DynamoHttpServletRequest pRequest,
                         DynamoHttpServletResponse pResponse)
                  throws DropletFormException
Calls parent beforeSet() then calls buildClientRequest(pRequest,pResponse) to create the appropriate ClientRequest object.

Specified by:
beforeSet in interface DropletFormHandler
Overrides:
beforeSet in class GenericFormHandler
Parameters:
pRequest - the dynamo request
pResponse - the dynamo response
Returns:
the result of calling the parent
Throws:
DropletFormException
See Also:
buildClientRequest(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)

beforeGet

public void beforeGet(DynamoHttpServletRequest pRequest,
                      DynamoHttpServletResponse pResponse)
Calls parent beforeGet() then calls buildClientRequest(pRequest,pResponse) to create the appropriate ClientRequest object.

Specified by:
beforeGet in interface DropletFormHandler
Overrides:
beforeGet in class EmptyFormHandler
Parameters:
pRequest - the dynamo request
pResponse - the dynamo response
See Also:
buildClientRequest(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)

handleSearch

public boolean handleSearch(DynamoHttpServletRequest pRequest,
                            DynamoHttpServletResponse pResponse)
                     throws java.io.IOException,
                            javax.servlet.ServletException
Handle search request. This method handles all search requests by delegating to subclasses the creation of the actual request type, the population of that request type with the appropriate information, and the sending of the JMS search notification method.

Parameters:
pRequest - the dynamo request
pResponse - the dynamo response
Returns:
true to continue processing, false otherwise
Throws:
javax.servlet.ServletException
java.io.IOException

handleAutoRedirect

protected boolean handleAutoRedirect(DynamoHttpServletRequest pRequest,
                                     DynamoHttpServletResponse pResponse,
                                     Results pResults,
                                     boolean pResult)
                              throws java.io.IOException
Method to handle a redirect url in the search results. If auto redirect is switched on and the search results contain a redirect action then it will redirect to that url.

Parameters:
pResults - Search Results object.
pResult - Whether to continue processing.
Returns:
boolean whether to continue processing. Set to false if redirect found.
Throws:
java.io.IOException - for redirect problems

sendSearchMessage

protected void sendSearchMessage(ClientRequest pClientRequest,
                                 DynamoHttpServletRequest pRequest,
                                 DynamoHttpServletResponse pResponse)
Send a JMS Search message via configured SearchMessageSource. Calls subclass to create JMS message for this search type.

Parameters:
pClientRequest - the Primus ClientRequest type
pRequest - the dynamo request
pResponse - the dynamo response
See Also:
createSearchMessage(ClientRequest pClientRequest, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse), SearchMessageSource.fireSearchMessage(SearchMessage pSearchMessage)

handleErrorCondition

protected boolean handleErrorCondition(DynamoHttpServletRequest pRequest,
                                       DynamoHttpServletResponse pResponse,
                                       java.lang.Exception pException)
                                throws java.io.IOException,
                                       javax.servlet.ServletException
Returns:
true to stay on page
Throws:
java.io.IOException
javax.servlet.ServletException

handleClearQuery

public boolean handleClearQuery(DynamoHttpServletRequest pRequest,
                                DynamoHttpServletResponse pResponse)
                         throws javax.servlet.ServletException,
                                java.io.IOException
Handle clear query

Parameters:
pRequest - the dynamo request
pResponse - the dynamo response
Throws:
javax.servlet.ServletException
java.io.IOException
See Also:
setClearQueryURL(String pClearQueryURL)

getIntegerRequestAttribute

protected java.lang.Integer getIntegerRequestAttribute(java.lang.String pAttributeName)
Get a request attribute value as an Integer

Parameters:
pAttributeName - the name of the attribute
Returns:
an Integer representing the value of the attribute or null if that value has not been set.

encodeMapData

protected java.lang.String encodeMapData(java.util.Map pMap,
                                         java.lang.String pPrefix,
                                         java.lang.String pSeparator,
                                         java.lang.String pSuffix,
                                         java.lang.String pDelimiter)
Translate a map into a string of encoded key/value pairs using the specified delimiter and separator values

Parameters:
pMap - the map to translate into an encoded string
pPrefix - a value to insert before each key, or null if not used
pSeparator - the value used to separate key and value, or null if not used
pSuffix - a value to insert after each value, including the last. Null if not used
pDelimiter - the value used to delimit key/value pairs in the string. Null if not used.
Returns:
the encoded map data or null if map is null or empty

encodeArrayData

protected java.lang.String encodeArrayData(java.lang.String[] pArray,
                                           java.lang.String pPrefix,
                                           java.lang.String pSuffix,
                                           java.lang.String pDelimiter)
Translate an array into a string of encoded values using the specified delimiter and separator values.

Parameters:
pCollection - the Collection to translate into an encoded string
pPrefix - a value to insert before each value, or null if not used
pSuffix - a value to insert after each value, including the last. Null if not used
pDelimiter - the value used to delimit values in the string. Null if not used.
Returns:
the encoded collection data or null if collection is null or empty

encodeCollectionData

protected java.lang.String encodeCollectionData(java.util.Collection pCollection,
                                                java.lang.String pPrefix,
                                                java.lang.String pSuffix,
                                                java.lang.String pDelimiter)
Translate a collection into a string of encoded values using the specified delimiter and separator values.

Parameters:
pCollection - the Collection to translate into an encoded string
pPrefix - a value to insert before each value, or null if not used
pSuffix - a value to insert after each value, including the last. Null if not used
pDelimiter - the value used to delimit values in the string. Null if not used.
Returns:
the encoded collection data or null if collection is null or empty

decodeMapData

public java.util.Map decodeMapData(java.lang.String pData,
                                   java.lang.String pPairRegex,
                                   KeyValueSplitter pSpliter)
Decode encoded key/value data from a string, return results in a map.

Parameters:
pData - the encoded key/value pairs
pPairRegex - the regular expression to identify key/value pairs. For example, a "," would identify comma-delimited key/value pairs.
pSpliter - a class that splits a single encoded key/value pair into component values.

getIntRequestAttribute

protected int getIntRequestAttribute(java.lang.String pAttributeName,
                                     int pDefault)
Get a request attribute value as an int

Parameters:
pAttributeName - the attribute name
pDefault - the default value to use if the attribute has not been set
Returns:
the value representing the request attribute

setBooleanRequestAttribute

protected void setBooleanRequestAttribute(java.lang.String pAttributeName,
                                          java.lang.Boolean pAttributeValue)
Convince method to set a request attribute using a Boolean value

Parameters:
pAttributeName - the name of the request attribute
pAttributeValue - the attribute value or null to remove the attribute

getBooleanRequestAttribute

protected java.lang.Boolean getBooleanRequestAttribute(java.lang.String pAttributeName)
Get a request attribute value as a Boolean

Parameters:
pAttributeName - the name of the attribute
Returns:
a Boolean representing the value of the attribute or null if that value has not been set.

getBoolRequestAttribute

protected boolean getBoolRequestAttribute(java.lang.String pAttributeName,
                                          boolean pDefault)
Get a request attribute value as an int

Parameters:
pAttributeName - the attribute name
pDefault - the default value to use if the attribute has not been set
Returns:
the value representing the request attribute

setClientRequest

protected void setClientRequest(ClientRequest pClientRequest)
Set the client request object. The type of object will vary depending upon the type of search being executed.

Parameters:
pClientRequest - the client requested object

setResults

protected void setResults(Results pResults)
Set the Results object returned from the search server.

Parameters:
pResults - the results object or null

createSessionConfig

protected SessionConfig createSessionConfig(DynamoHttpServletRequest pRequest,
                                            DynamoHttpServletResponse pResponse)
Create and initialize SessionConfig object

Parameters:
pRequest - the Dynamo request
pSessionConfig - the search session configuration
pRequest - the Dynamo http request object
Returns:
the updated session configuration

buildSimpleTag

protected java.lang.StringBuffer buildSimpleTag(java.lang.String pTagName,
                                                java.lang.String pTagValue,
                                                java.util.Map pAttributes)
Build a simple tag

Parameters:
pTagName - <pTagName>
pTagValue - <>tagvalue</>
pAttributes - an optionally empty or null map of tag attributes

dumpRequestInfo

protected void dumpRequestInfo(ClientRequest pRequest)
Dump request information. Called before query submit if logging debug is enabled.

Parameters:
pRequest - the request

dumpMap

protected void dumpMap(java.lang.String pMapPropertyName,
                       java.util.Map pMap)
For debugging, dump the contents of a map and print a string indicating what property of the request this map represents.

Parameters:
pMapPropertyName - the property name for information
pMap - the map to dump

getSearchMessageSource

protected SearchMessageSource getSearchMessageSource()
Get the message source for this component.

Returns:
the message source or null

getSiteDefaultOptionSet

protected java.util.Map getSiteDefaultOptionSet(ClientRequest pRequest,
                                                SearchSession pSession)
Get the default option set for this client request. This method just calls getSearchService().getOpitonSet( pRequest ), but subclasses could modify this behavior.

Returns:
the default option set or null

mergeMaps

protected java.util.Map mergeMaps(java.util.Map pBase,
                                  java.util.Map pOverrides)
Merge override map entries with base entries. Any override data with a value which is non-null and is not an empty string is merged into the base. Other base attributes are unaffected.

Parameters:
pBase - the base attribute map (typically the site defaults)
pOverrides - the overriding attributes, typically set on the page.
Returns:
the base map

beforeSearch

protected ClientRequest beforeSearch(ClientRequest pRequest,
                                     SearchContext pContext,
                                     SearchSession pSession)
This method is called just before a search is executed and is intended to allow subclasses an opportunity to make last minute changes to the request object or to update the search context. Subclasses may abort the search by returning a null client request. This default implementation returns the unmodified request object.

Parameters:
pRequest - the client query request
pContext - the search context, which holds session scoped information for the current search user
pSession - the search session
Returns:
the client request or null to abort the search request

afterSearch

protected Results afterSearch(ClientRequest pRequest,
                              SearchContext pContext,
                              SearchSession pSession,
                              Results pResults)
This method is called just after a search has been executed and is intended to allow subclasses an opportunity to update the search session or modify the search results object. This default implementation returns the result object unmodified.

Parameters:
pRequest - the client query request
pContext - the search context, which holds session scoped information for the current search user
pSession - the search session
pResults - the search results
Returns:
the potentially modified search results