info.aduna.gee.publication.servlets.cache
Class TemplateCache

java.lang.Object
  extended by info.aduna.gee.publication.servlets.cache.TemplateCache
All Implemented Interfaces:
ApiConstants, UserTypes

public class TemplateCache
extends Object
implements ApiConstants, UserTypes

Class TemplateCache


Field Summary
protected static String[] _publicTemplates
           
protected static HashMap _templateMap
           
protected static HashMap _templateTimeMap
           
static String API_RESULT_STUB
           
 
Fields inherited from interface info.aduna.gee.publication.servlets.ApiConstants
CREATE_EMAIL_KEY, CREATE_NAME_KEY, CREATE_PASSWORD_KEY, CREATE_TIMETOLIVE_KEY, MESSAGE_KEY, RESULT_KEY, RETURN_CODE_KEY
 
Fields inherited from interface info.aduna.gee.publication.UserTypes
API_BIT, COVER_BUILDER_BIT, ENGINE_BIT, GUEST_BITS, OWNER_BITS, PRO_BITS, PROUSER_BIT, SERVER_BIT, SHOP_BIT, SHOW_BIT, SHOW_BITS, VISITOR_BIT
 
Constructor Summary
TemplateCache()
           
 
Method Summary
protected static String _getTemplateString(javax.servlet.http.HttpServletRequest request, String fileName)
           
protected static String _getTypeFromRequest(javax.servlet.http.HttpServletRequest request)
           
protected static boolean _looksLikeStub(String stubCandidate)
           
static String convert(String templateString, HashMap stubsMap)
           
static String convert(String templateString, HashMap stubsMap, boolean removeStubs)
          Do the actual substitutions.
static String get(javax.servlet.http.HttpServletRequest request, String fileName, UserInfo userInfo, CoverInfo coverInfo, HashMap stubsMap)
           
static String get(javax.servlet.http.HttpServletRequest request, String fileName, UserInfo userInfo, CoverInfo coverInfo, HashMap stubsMap, boolean removeStubs)
          Get the appropriate template and substitute "stubs".
static int getDefaultType(javax.servlet.http.HttpServletRequest request)
          Get the (overall) default zpad-code-type on this host.
static int getDefaultType(javax.servlet.http.HttpServletRequest request, UserInfo userInfo)
          Get the default zpad-code-type for a user on this host.
static int getUserType(javax.servlet.http.HttpServletRequest request, UserInfo userInfo, HashMap stubsMap)
          Get the effective zpad-code-type for the user on this host.
static boolean isApiRequest(int userType)
          Is the current request a api request ?
static boolean isApiRequest(String userType)
          Is the current request a api request ?
static boolean isPublicTemplate(String name)
           
static long lastModified(String host)
           
static void refresh(String host)
           
static int versionToType(String version)
          Translate a symbolic version name to a numeric user type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

API_RESULT_STUB

public static final String API_RESULT_STUB
See Also:
Constant Field Values

_templateMap

protected static HashMap _templateMap

_templateTimeMap

protected static HashMap _templateTimeMap

_publicTemplates

protected static String[] _publicTemplates
Constructor Detail

TemplateCache

public TemplateCache()
Method Detail

isPublicTemplate

public static boolean isPublicTemplate(String name)

get

public static String get(javax.servlet.http.HttpServletRequest request,
                         String fileName,
                         UserInfo userInfo,
                         CoverInfo coverInfo,
                         HashMap stubsMap)

get

public static String get(javax.servlet.http.HttpServletRequest request,
                         String fileName,
                         UserInfo userInfo,
                         CoverInfo coverInfo,
                         HashMap stubsMap,
                         boolean removeStubs)
Get the appropriate template and substitute "stubs".

Parameters:
request - non-null
fileName - non-null, the name of the Template requested
userInfo - may be null
coverInfo - may be null
stubsMap - may be null, a set of stub/stubvalue pairs
removeStubs - whether or not to remove unknown stubs

_getTemplateString

protected static String _getTemplateString(javax.servlet.http.HttpServletRequest request,
                                           String fileName)

convert

public static String convert(String templateString,
                             HashMap stubsMap)

convert

public static String convert(String templateString,
                             HashMap stubsMap,
                             boolean removeStubs)
Do the actual substitutions.


_looksLikeStub

protected static boolean _looksLikeStub(String stubCandidate)

refresh

public static void refresh(String host)

getDefaultType

public static int getDefaultType(javax.servlet.http.HttpServletRequest request)
Get the (overall) default zpad-code-type on this host.


getDefaultType

public static int getDefaultType(javax.servlet.http.HttpServletRequest request,
                                 UserInfo userInfo)
Get the default zpad-code-type for a user on this host.

Parameters:
request - The request, e.g. to determine the host
userInfo - The userInfo or null.

getUserType

public static int getUserType(javax.servlet.http.HttpServletRequest request,
                              UserInfo userInfo,
                              HashMap stubsMap)
Get the effective zpad-code-type for the user on this host.


_getTypeFromRequest

protected static String _getTypeFromRequest(javax.servlet.http.HttpServletRequest request)

versionToType

public static int versionToType(String version)
Translate a symbolic version name to a numeric user type.

Returns:
either a positive number or -1

lastModified

public static long lastModified(String host)

isApiRequest

public static boolean isApiRequest(int userType)
Is the current request a api request ?

Parameters:
userType - the client's Zpad type

isApiRequest

public static boolean isApiRequest(String userType)
Is the current request a api request ?

Parameters:
userType - the client's Zpad type


Copyright © 1997-2008 Aduna. All Rights Reserved.