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

java.lang.Object
  extended by info.aduna.gee.publication.servlets.cache.FileCache

public class FileCache
extends Object

Contrary to what the name suggests, FileCache will not cache files. Most of the files that are read are of a specific kind (e.g. a "zpad.conf"). Cacheing is done by its kind, not at the File level.


Field Summary
protected static HashMap _fileExistsMap
          Cache of filename/exists pairs.
static String BASEURL
          Symbolic representations of specific URLs.
static String BIN
           
static String CATEGORIES
           
static String CODEBASES
           
static String CONF
           
static String COVERS
           
static String DEFAULTS
           
static String DEFAULTSUBSCRIPTIONS
           
static String DOCUMENTROOT
          Vhost configuration directory-tree, e.g.
static String HOST
          Code internal substitutions patterns.
static String I18N
           
static String LOGS
          Vhost logging and reports, e.g.
static String MAILLOG
           
static String PPATH
           
static String PS
           
static String REPORTS
           
static String RESOURCES
          Symbolic representations of specific paths.
static String SERVERPATH
           
static String SHOPORDERS
           
static String SHOPROOT
          Vhost shop directories
static String SYSTEMCATEGORIES
           
static String SYSTEMSUBSCRIPTIONS
           
static String TEMPLATES
          Vhost templates, e.g.
static String USERFILES
           
static String USERNAME
           
static String USERPATH
           
static String USERPHYSURL
           
static String USERS
           
static String USERURL
           
static String VIRTUAL_HOST
          Base directory for a specific vhost, e.g.
 
Constructor Summary
FileCache()
           
 
Method Summary
protected static String _getPath(javax.servlet.http.HttpServletRequest request, String host, UserInfo userInfo, String fileDescription)
           
protected static Properties _getProperties(String fileName)
          Read a Properties from a file.
static String _getString(String fileName)
          Read a String from a file.
protected static String _internationalizePath(javax.servlet.http.HttpServletRequest request, String path)
          Substitute I18N code internal substitution patterns in a path.
protected static void _putProperties(Properties p, String fileName)
          Store a Properties in a file.
protected static void _putString(String s, String filePath)
          Store a String in a file.
static boolean checkFileExists(String filePath)
          Dynamically test whether a file exists.
static boolean fileExists(String filePath)
          Test whether a file exists and cache the result forever -- THEREFORE USE FOR "STATIC" FILES ONLY!
static String getFixedLanguagePath(String language, String path)
           
static Locale getLocale(javax.servlet.http.HttpServletRequest request, String fileDescription)
          For a particular file and the current request, find out what the Locale of the file is.
static String getPath(javax.servlet.http.HttpServletRequest request, String fileDescription)
          Substitute all code internal substitution patterns in a path.
static String getPath(javax.servlet.http.HttpServletRequest request, UserInfo userInfo, String fileDescription)
          Substitute all code internal substitution patterns in a path.
static String getPath(String host, String fileDescription)
          Substitute all code internal substitution patterns in a path.
static String getPath(String host, UserInfo userInfo, String fileDescription)
           
static Properties getProperties(javax.servlet.http.HttpServletRequest request, String fileDescription)
           
static Properties getProperties(javax.servlet.http.HttpServletRequest request, UserInfo userInfo, String fileDescription)
          Read a Properties from a file.
static Properties getProperties(String fileDescription)
           
static Properties getProperties(String host, String fileDescription)
          Read a Properties from a file.
static String getString(javax.servlet.http.HttpServletRequest request, String fileDescription)
           
static String getString(javax.servlet.http.HttpServletRequest request, UserInfo userInfo, String fileDescription)
          Read a String from a file.
static String getString(String fileDescription)
           
static String getString(String host, String fileDescription)
          Read a String from a file.
static void putProperties(javax.servlet.http.HttpServletRequest request, Properties p, String fileDescription)
           
static void putProperties(javax.servlet.http.HttpServletRequest request, UserInfo userInfo, Properties p, String fileDescription)
          Store a Properties in a file.
static void putProperties(Properties p, String fileDescription)
           
static void putProperties(String host, Properties p, String fileDescription)
          Store a Properties in a file.
static void putString(javax.servlet.http.HttpServletRequest request, String s, String fileDescription)
           
static void putString(javax.servlet.http.HttpServletRequest request, UserInfo userInfo, String s, String fileDescription)
          Store a String in a file.
static void putString(String s, String fileDescription)
           
static void putString(String host, String s, String fileDescription)
          Store a String in a file.
static void refresh(String host)
          Refresh, i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_fileExistsMap

protected static HashMap _fileExistsMap
Cache of filename/exists pairs. This is the only information that is cached selectively (since e.g. user files may appear and disappear). The key is a full path, the value a Boolean.


HOST

public static String HOST
Code internal substitutions patterns. These should not be confused with the Template substitution patterns. Code internal substitutions use 3 underscores, Template substitution patterns use 2 underscores.


I18N

public static String I18N

PPATH

public static String PPATH

USERNAME

public static String USERNAME

SERVERPATH

public static String SERVERPATH

PS

public static String PS

RESOURCES

public static String RESOURCES
Symbolic representations of specific paths. Use InitServlet.A12R_HOME and getRealPath("/") if you need document root. These representations contain substitutions patterns.


CODEBASES

public static String CODEBASES

VIRTUAL_HOST

public static String VIRTUAL_HOST
Base directory for a specific vhost, e.g. /opt/a12r/hosts/www.myhost.com/


DOCUMENTROOT

public static String DOCUMENTROOT
Vhost configuration directory-tree, e.g. /opt/a12r/hosts/www.myhost.com/conf/...


BIN

public static String BIN

CONF

public static String CONF

SYSTEMSUBSCRIPTIONS

public static String SYSTEMSUBSCRIPTIONS

SYSTEMCATEGORIES

public static String SYSTEMCATEGORIES

CATEGORIES

public static String CATEGORIES

DEFAULTS

public static String DEFAULTS

DEFAULTSUBSCRIPTIONS

public static String DEFAULTSUBSCRIPTIONS

TEMPLATES

public static String TEMPLATES
Vhost templates, e.g. /opt/a12r/hosts/www.myhost.com/templates//"


LOGS

public static String LOGS
Vhost logging and reports, e.g. /opt/a12r/hosts/www.myhost.com/logs/


REPORTS

public static String REPORTS

MAILLOG

public static String MAILLOG

COVERS

public static String COVERS

USERS

public static String USERS

USERPATH

public static String USERPATH

USERFILES

public static String USERFILES

SHOPROOT

public static String SHOPROOT
Vhost shop directories


SHOPORDERS

public static String SHOPORDERS

BASEURL

public static String BASEURL
Symbolic representations of specific URLs. Don't use PS here (it's always /).


USERURL

public static String USERURL

USERPHYSURL

public static String USERPHYSURL
Constructor Detail

FileCache

public FileCache()
Method Detail

getString

public static String getString(String fileDescription)
See Also:
getString(HttpServletRequest, UserInfo, String)

getString

public static String getString(javax.servlet.http.HttpServletRequest request,
                               String fileDescription)
See Also:
getString(HttpServletRequest, UserInfo, String)

getString

public static String getString(javax.servlet.http.HttpServletRequest request,
                               UserInfo userInfo,
                               String fileDescription)
Read a String from a file.

Parameters:
request - if not null, it contains fields for code internal substitutions
userInfo - if not null, it contains fields for code internal substitutions
fileDescription - the path, optionally containing code internal substitution patterns

getString

public static String getString(String host,
                               String fileDescription)
Read a String from a file.

Parameters:
host - if not null, it contains fields for code internal substitutions
fileDescription - the path, optionally containing code internal substitution patterns

_getString

public static String _getString(String fileName)
Read a String from a file.

Parameters:
fileName - the full path

putString

public static void putString(String s,
                             String fileDescription)
See Also:
putString(HttpServletRequest, UserInfo, String, String)

putString

public static void putString(javax.servlet.http.HttpServletRequest request,
                             String s,
                             String fileDescription)
See Also:
putString(HttpServletRequest, UserInfo, String, String)

putString

public static void putString(javax.servlet.http.HttpServletRequest request,
                             UserInfo userInfo,
                             String s,
                             String fileDescription)
Store a String in a file.

Parameters:
request - if not null, it contains fields for code internal substitutions
userInfo - if not null, it contains fields for code internal substitutions
s - the string to be stored
fileDescription - the path, optionally containing code internal substitution patterns

putString

public static void putString(String host,
                             String s,
                             String fileDescription)
Store a String in a file.

Parameters:
host - if not null, it contains fields for code internal substitutions
s - the string to be stored
fileDescription - the path, optionally containing code internal substitution patterns

_putString

protected static void _putString(String s,
                                 String filePath)
Store a String in a file.

Parameters:
s - the string to be stored
filePath - the full path of the file

getProperties

public static Properties getProperties(String fileDescription)
See Also:
getProperties(HttpServletRequest, UserInfo, String)

getProperties

public static Properties getProperties(javax.servlet.http.HttpServletRequest request,
                                       String fileDescription)
See Also:
getProperties(HttpServletRequest, UserInfo, String)

getProperties

public static Properties getProperties(javax.servlet.http.HttpServletRequest request,
                                       UserInfo userInfo,
                                       String fileDescription)
Read a Properties from a file.

Parameters:
request - if not null, it contains fields for code internal substitutions
userInfo - if not null, it contains fields for code internal substitutions
fileDescription - the path, optionally containing code internal substitution patterns

getProperties

public static Properties getProperties(String host,
                                       String fileDescription)
Read a Properties from a file.

Parameters:
host - if not null, it contains fields for code internal substitutions
fileDescription - the path, optionally containing code internal substitution patterns

_getProperties

protected static Properties _getProperties(String fileName)
Read a Properties from a file.

Parameters:
fileName - the full path of the file

putProperties

public static void putProperties(Properties p,
                                 String fileDescription)
See Also:
putProperties(HttpServletRequest, UserInfo, Properties, String)

putProperties

public static void putProperties(javax.servlet.http.HttpServletRequest request,
                                 Properties p,
                                 String fileDescription)
See Also:
putProperties(HttpServletRequest, UserInfo, Properties, String)

putProperties

public static void putProperties(javax.servlet.http.HttpServletRequest request,
                                 UserInfo userInfo,
                                 Properties p,
                                 String fileDescription)
Store a Properties in a file.

Parameters:
request - if not null, it contains fields for code internal substitutions
userInfo - if not null, it contains fields for code internal substitutions
p - the Properties to be stored
fileDescription - the path, optionally containing code internal substitution patterns

putProperties

public static void putProperties(String host,
                                 Properties p,
                                 String fileDescription)
Store a Properties in a file.

Parameters:
host - if not null, it contains fields for code internal substitutions
p - the Properties to be stored
fileDescription - the path, optionally containing code internal substitution patterns

_putProperties

protected static void _putProperties(Properties p,
                                     String fileName)
Store a Properties in a file.

Parameters:
p - the Properties
fileName - the full path of the file

getPath

public static String getPath(javax.servlet.http.HttpServletRequest request,
                             String fileDescription)
Substitute all code internal substitution patterns in a path.

Parameters:
request - if not null, it contains fields for code internal substitutions
fileDescription - the path, optionally containing code internal substitution patterns

getPath

public static String getPath(javax.servlet.http.HttpServletRequest request,
                             UserInfo userInfo,
                             String fileDescription)
Substitute all code internal substitution patterns in a path.

Parameters:
request - if not null, it contains fields for code internal substitutions
userInfo - if not null, it contains fields for code internal substitutions
fileDescription - the path, optionally containing code internal substitution patterns

getPath

public static String getPath(String host,
                             String fileDescription)
Substitute all code internal substitution patterns in a path.

Parameters:
host - if not null, it contains the host's name
fileDescription - the path, optionally containing code internal substitution patterns

getPath

public static String getPath(String host,
                             UserInfo userInfo,
                             String fileDescription)

_getPath

protected static String _getPath(javax.servlet.http.HttpServletRequest request,
                                 String host,
                                 UserInfo userInfo,
                                 String fileDescription)

_internationalizePath

protected static String _internationalizePath(javax.servlet.http.HttpServletRequest request,
                                              String path)
Substitute I18N code internal substitution patterns in a path. Find the best (according to language preferences in the request) language dependent variant of a file.

Parameters:
request - if not null, it contains fields for I18N code internal substitutions
path - the path, optionally containing I18N code internal substitution patterns

getLocale

public static Locale getLocale(javax.servlet.http.HttpServletRequest request,
                               String fileDescription)
For a particular file and the current request, find out what the Locale of the file is. This is used when substitutions must be applied to the file (e.g. in case of a Template).


refresh

public static void refresh(String host)
Refresh, i.e. remove a cacheing for a particular host.

Parameters:
host - the host

fileExists

public static boolean fileExists(String filePath)
Test whether a file exists and cache the result forever -- THEREFORE USE FOR "STATIC" FILES ONLY!

Parameters:
filePath - the full path of the file

getFixedLanguagePath

public static String getFixedLanguagePath(String language,
                                          String path)

checkFileExists

public static boolean checkFileExists(String filePath)
Dynamically test whether a file exists.

Parameters:
filePath - the full path of the file


Copyright © 1997-2008 Aduna. All Rights Reserved.