atg.projects.store.droplet
Class StoreTextDroplet

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.TimedOperationService
              extended by atg.nucleus.servlet.ServletService
                  extended by atg.nucleus.servlet.HttpServletService
                      extended by atg.servlet.DynamoServlet
                          extended by atg.projects.store.droplet.StoreTextDroplet
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.Service, atg.nucleus.ServiceListener, atg.servlet.ParameterServlet, java.util.EventListener, javax.servlet.Servlet

public class StoreTextDroplet
extends atg.servlet.DynamoServlet

This droplet performs a look up in the repository to obtain localized resource text message templates either by matching on a specific key to obtain a single resource text message template or by matching on a tag to obtain zero or more resource text messages 'tagged' with this value. It is not possible to find a match on both key and tag values, if a key is supplied that is the value used to find a match. The ‘key’ property is a unique value in the repository so only a single message template will match on any particular key value. The ‘tag’ property is not a unique value across message templates but there can only be one tag per text resource. So a text message template can be tagged as ‘news’ but not as both ‘news’ and ‘latest-news’. When performing a key match we firstly try to find a site specific resource text message template by matching on a site version of the supplied key value or if no match is found we try to find a match on the supplied key value. If no match is found in the repository for either key versions then: if the default text input parameter is not empty then this is used as the message text if the default text input parameter is empty and the default text property is not empty then the default text property is used as the message text otherwise the message text is set as an empty string No default text is returned when performing a tag match. In this case an empty string array is returned. The message templates are then parsed to substitute any format pattern specifiers with the corresponding entry value obtained from either the 'args' input parameter map or from the request input parameters. The message template can consist of static text elements and zero or more format pattern specifiers. A format pattern specifier is defined as a region of text enclosed by '{' and '}' characters. This allows the page coder to create dynamic message content based on the message template and substituting values for the format pattern specifiers at runtime. For example, The quick {color} fox {action} over the {object}. with matching format pattern values as follows color=brown action=jumps object=lazy dog resolves as The quick brown fox jumps over the lazy dog. The message template can contain '\\', '\{', '\}' escape sequences. This allows '\', '{', and '}' characters to appear in the message and not be treated as format specifier pattern delimiters. If the message template was defined as The \{ quick {color} fox \} {action} over the {object}. this resolves as The { quick brown fox } jumps over the lazy dog. Unknown escape sequences ignore the '\' character, so The \q quick {color} fox {action} over the {object}. will resolve as The q quick brown fox jumps over the lazy dog. Text within the format pattern delimiters is taken literally and will ignore escape sequences, so The quick {c\qolor\} fox {action} over the {object}. will pick up 'c\qolor\' as a format pattern specifier. If multiple parameters matching the same format pattern specifier are passed to the droplet then it is the last parameter which will be used. So passing in a 'color' parameter twice with values 'brown' & 'black' will insert 'black' into the example above. Any parameter name/values or map entries passed into the droplet but which do not match on a format pattern specifier in the message template are ignored. Any format pattern specifiers present in the message template but which do not have a corresponding value passed into the droplet remain untouched in the resulting message. The droplet does not perform any strong verification on the message template form so The quick {color fox jumps over the lazy dog. is a valid template, there is no malformed exception for the unclosed format pattern. As there is no format pattern specifier sequence recognized in the template, the message resolves as The quick {color fox jumps over the lazy dog. The droplet takes the following input parameters: key (optional, required if ‘tag’ attribute not supplied) The key code to use when looking up the resource message text in the repository. tag (optional, required if ‘key’ attribute not supplied) The tag to use when looking up the resource message text in the repository.. args (optional) A map object consisting of a number of entries to use when populating the format pattern specifiers embedded in the message template text. The format pattern specifiers in the message template are used to match on the map key values and the corresponding map entry value is substituted for the format pattern in the resulting message text. arg name (optional) An arbitrary number of parameters to use when populating the format pattern specifiers embedded in the message template text. The actual 'arg' name is not defined; the format pattern specifiers in the message template are used as possible parameter names and the parameter value is substituted for the format pattern in the resulting message text. defaultText (optional) The default text to output when a message for the given key could not be found. The droplet renders the following open parameters: output message - the localized resource message text error message - error message if a problem occurred processing the request

Example:

  

  
  

  
    
    

    
      
      
    
    
      
      
    
  


  

  
    

    
      
      
      
        
      
      
    
    
      
      
    
  
 


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.servlet.DynamoServlet
mAllowCleanupRequest, mParameters
 
Fields inherited from class atg.nucleus.servlet.ServletService
SERVLET_INFO_KEY
 
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
StoreTextDroplet()
           
 
Method Summary
 java.lang.String getDefaultText(java.lang.String pKey)
           
 java.lang.String getDefaultTextTemplate()
           
 java.lang.String getItemDescriptorName()
           
 atg.repository.Repository getRepository()
           
 java.lang.String getSiteKey(java.lang.String pKey)
           
 java.lang.String getSiteKeyTemplate()
           
 java.lang.String getSiteTag(java.lang.String pTag)
           
 java.lang.String getSiteTagTemplate()
           
 void service(atg.servlet.DynamoHttpServletRequest pRequest, atg.servlet.DynamoHttpServletResponse pResponse)
          Receives and validates the request input parameters.
 void setDefaultTextTemplate(java.lang.String pDefaultTextTemplate)
           
 void setItemDescriptorName(java.lang.String pItemDescriptorName)
           
 void setRepository(atg.repository.Repository pRepository)
           
 void setSiteKeyTemplate(java.lang.String pSiteKeyTemplate)
           
 void setSiteTagTemplate(java.lang.String pSiteTagTemplate)
           
 
Methods inherited from class atg.servlet.DynamoServlet
doDelete, doGet, doPost, doPut, getParameter, getParameters, getServletContext, service, service, setParameter
 
Methods inherited from class atg.nucleus.servlet.ServletService
destroy, getServletConfig, getServletInfo, init, setServletInfo
 
Methods inherited from class atg.nucleus.TimedOperationService
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
 
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, reResolveThis, 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
Class version string

Constructor Detail

StoreTextDroplet

public StoreTextDroplet()
Method Detail

setDefaultTextTemplate

public void setDefaultTextTemplate(java.lang.String pDefaultTextTemplate)

getDefaultTextTemplate

public java.lang.String getDefaultTextTemplate()

getDefaultText

public java.lang.String getDefaultText(java.lang.String pKey)

setSiteKeyTemplate

public void setSiteKeyTemplate(java.lang.String pSiteKeyTemplate)

getSiteKeyTemplate

public java.lang.String getSiteKeyTemplate()

getSiteKey

public java.lang.String getSiteKey(java.lang.String pKey)

setSiteTagTemplate

public void setSiteTagTemplate(java.lang.String pSiteTagTemplate)

getSiteTagTemplate

public java.lang.String getSiteTagTemplate()

getSiteTag

public java.lang.String getSiteTag(java.lang.String pTag)

setRepository

public void setRepository(atg.repository.Repository pRepository)

getRepository

public atg.repository.Repository getRepository()

setItemDescriptorName

public void setItemDescriptorName(java.lang.String pItemDescriptorName)

getItemDescriptorName

public java.lang.String getItemDescriptorName()

service

public void service(atg.servlet.DynamoHttpServletRequest pRequest,
                    atg.servlet.DynamoHttpServletResponse pResponse)
             throws javax.servlet.ServletException,
                    java.io.IOException
Receives and validates the request input parameters. Performs a look up in the repository based on the supplied 'key' parameter value to obtain localized resource text message template. If a match is found the message template is parsed to substitute any format pattern specifiers with the corresponding entry value obtained from either the 'args' input parameter map or the request input parameters. If no match is found for the 'key' in the repository then: if the default text input parameter is not empty then this is used as the message text if the default text input parameter is empty and the default text property is not empty then the default text property is used as the message text otherwise the message text is set as an empty string

Overrides:
service in class atg.servlet.DynamoServlet
Parameters:
pRequest - - HTTP request
pResponse - - HTTP response
Throws:
javax.servlet.ServletException - if an error occurs
java.io.IOException - if an error occurs