no.feide.moria.servlet
Class RequestUtil

java.lang.Object
  extended by no.feide.moria.servlet.RequestUtil

public final class RequestUtil
extends java.lang.Object

This class is a toolkit for the servlets. Its main functionality is to retrieve resource bundles.

Version:
$Revision: 1.56 $
Author:
Lars Preben S. Arnesen <lars.preben.arnesen@conduct.no>

Field Summary
static java.lang.String ATTR_BASE_URL
          Base URL attribute in request object.
static java.lang.String ATTR_BUNDLE
          Attribute in request object: Language bundle.
static java.lang.String ATTR_CLIENT_NAME
          Attribute in request object: Name of client/service.
static java.lang.String ATTR_CLIENT_URL
          Attribute in request object: Link to associate with service name.
static java.lang.String ATTR_ERROR_TYPE
          Attribute in request object: Error type.
static java.lang.String ATTR_LANGUAGES
          Attribute in request object: Available languages.
static java.lang.String ATTR_ORGANIZATIONS
          Attribute in request object: Available organizations.
static java.lang.String ATTR_REQUESTED_ATTRIBUTES
          Attribute in request object: Requested attributes.
static java.lang.String ATTR_SEC_LEVEL
          Attribute in request object: Security level.
static java.lang.String ATTR_SELECTED_DENYSSO
          Attribute in request object: Denial of SSO.
static java.lang.String ATTR_SELECTED_LANG
          Attribute in request object: Preselected lanugage.
static java.lang.String ATTR_SELECTED_ORG
          Attribute in request object: Preselected organization.
static java.lang.String BUNDLE_ERROR
          Bundle for the error page.
static java.lang.String BUNDLE_FAQ
          Bundle for the faq page.
static java.lang.String BUNDLE_INFOABOUT
          Bundle for the information page about the information servlet.
static java.lang.String BUNDLE_INFORMATIONSERVLET
          Bundle for the Information servlet's attribute descriptions.
static java.lang.String BUNDLE_INFOWELCOME
          Bundle for the Welcome page for the Information Service.
static java.lang.String BUNDLE_LOGIN
          The name of the resource bundle for the login page.
static java.lang.String BUNDLE_STATISTICSSERVLET
          Bundle for the Statistics page.
static java.lang.String BUNDLE_STATUSSERVLET
          Bundle for the status servlet.
static java.lang.String CONFIG_DISPLAY_NAME
          From Authorization config: Service name.
static java.lang.String CONFIG_HOME
          From Authorization config Home organization of service.
static java.lang.String CONFIG_LANG
          Name of property from authorization module giving the default language for a given service.
static java.lang.String CONFIG_SERVICE_PRINCIPAL
          From Authorization configuration; service principal.
static java.lang.String CONFIG_URL
          From Authorization config: Service URL.
static java.lang.String ERROR_AUTHENTICATION_FAILED
          Error type: Authentication failed.
static java.lang.String ERROR_AUTHORIZATION_FAILED
          Error type: Authorization failed.
static java.lang.String ERROR_DIRECTORY_DOWN
          Error type: The directory is down.
static java.lang.String ERROR_INVALID_ORG
          Error type: Invalid organization selected.
static java.lang.String ERROR_MORIA_DOWN
          Error type: Moria is unavailable.
static java.lang.String ERROR_NO_CREDENTIALS
          Error type: User must supply username and password.
static java.lang.String ERROR_NO_ORG
          Error type: No organization selected.
static java.lang.String ERROR_UNKNOWN_TICKET
          Error type: Unknown ticket.
static java.lang.String FAQ_LINK
          Link to faq, shown on the login page.
(package private) static no.feide.moria.log.MessageLogger log
          Used for logging.
static java.lang.String PARAM_DENYSSO
          Parameter in request object: Deny SSO.
static java.lang.String PARAM_LANG
          Language URL parameter, used when overriding current language settings.
static java.lang.String PARAM_OLD_STATISTICS
          Attribute URL parameter, used to show statistics from the previous year.
static java.lang.String PARAM_ORG
          Organization URL parameter, used when overriding default organization in the URL redirecting a user from a service to Moria.
static java.lang.String PARAM_PASSWORD
          Parameter in request object: Password.
static java.lang.String PARAM_SHOW_ATTRS
          Attribute URL parameter, used when attributes are shown on the login page.
static java.lang.String PARAM_USERNAME
          Parameter in request object: Username.
private static java.lang.String PATH_PREFIX
          Prefix for all web module properties.
static java.lang.String PIC_LINK
          Link to pictures from the information service.
static java.lang.String PROP_BACKENDSTATUS_IGNORE
          Configuration property for the StatisticsServlet's ignored services
static java.lang.String PROP_BACKENDSTATUS_STATISTICS_XML
          Configuration property for the StatusServlet statistics.xml file path.
static java.lang.String PROP_BACKENDSTATUS_STATISTICS2_BASENAME_XML
          Configuration property for the StatusServlet statistics2 basename file path.
static java.lang.String PROP_BACKENDSTATUS_STATISTICS2_XML
          Configuration property for the StatusServlet statistics2.xml file path.
static java.lang.String PROP_BACKENDSTATUS_STATUS_XML
          Configuration property for the StatusServlet status.xml file path.
static java.lang.String PROP_COMMON
          Configuration property sub-string giving the abbreviations and names for all available languages.
static java.lang.String PROP_CONFIG
          Property name for web module configuration.
static java.lang.String PROP_COOKIE_DENYSSO
          Configuration property giving the name of the cookie used to deny SSO (when using Moria on public computers, for example).
static java.lang.String PROP_COOKIE_DENYSSO_TTL
          Configuration property giving the lifetime, in hours, for the cookie used to deny SSO (named by PROP_COOKIE_DENYSSO).
static java.lang.String PROP_COOKIE_LANG
          Configuration property giving the name of the cookie used to set user's desired language.
static java.lang.String PROP_COOKIE_LANG_TTL
          Configuration property giving the lifetime, in hours, for the cookie used to set user's desired language.
static java.lang.String PROP_COOKIE_ORG
          Configuration property giving the name of the cookie used to remember the user's previously selected organization.
static java.lang.String PROP_COOKIE_ORG_TTL
          Configuration property giving the lifetime, in hours, for the cookie used to remember the user's previously selected organization.
static java.lang.String PROP_COOKIE_SSO
          Configuration property giving the name of the cookie used to carry SSO sessions (that is, a Moria ticket ID belonging to a SSO session).
static java.lang.String PROP_COOKIE_SSO_TTL
          Configuration property giving the lifetime, in hours, for the cookie used to carry SSO sessions (named by PROP_COOKIE_SSO).
static java.lang.String PROP_FAQ_OWNER
          Organization name of the Moria owner, as shown on the FAQ page.
static java.lang.String PROP_FAQ_STATUS
          URL to the Status servlet, as shown on the FAQ page.
static java.lang.String PROP_INFORMATION_DESCRIPTIONS
          Configuration property for the Information service's attribute description XML file.
static java.lang.String PROP_INFORMATION_URL_PREFIX
          Configuration property giving the URL of the information servlet.
static java.lang.String PROP_LANGUAGE
          Property name for Language.
static java.lang.String PROP_LOGIN_DEFAULT_LANGUAGE
          Configuration property giving the default Moria language, to be used if no other preferences (user or service) are available.
static java.lang.String PROP_LOGIN_TICKET_PARAM
          Configuration property giving the name of the URL parameter containing the Moria ticket ID.
static java.lang.String PROP_LOGIN_URL_PREFIX
          Configuration property giving the URL of the login servlet.
static java.lang.String PROP_LOGOUT_URL_PARAM
          Property name for Logout URL.
static java.lang.String PROP_ORG
          Property name for Organization.
static java.lang.String PROP_STATISTICS_URL
          URL to the Statistics servlet, used for language selection.
static java.lang.String RESOURCE_DATE
          TODO: Add JavaDoc.
static java.lang.String RESOURCE_LINK
          TODO: Add JavaDoc.
static java.lang.String RESOURCE_MAIL
          TODO: Add JavaDoc.
 
Constructor Summary
private RequestUtil()
          Default private constructor.
 
Method Summary
static javax.servlet.http.Cookie createCookie(java.lang.String cookieName, java.lang.String cookieValue, int validHours)
          Creates a cookie.
static java.util.ResourceBundle getBundle(java.lang.String bundleName, java.lang.String requestParamLang, java.lang.String langFromCookie, java.lang.String serviceLang, java.lang.String browserLang, java.lang.String moriaLang)
          Generates a resource bundle.
(package private) static java.util.Properties getConfig(javax.servlet.ServletContext context)
          Get the config from the context.
static java.lang.String getCookieValue(java.lang.String cookieName, javax.servlet.http.Cookie[] cookies)
          Returns a requested cookie value from the HTTP request.
static java.lang.String insertLink(java.lang.String token, java.lang.String data, java.lang.String name, java.lang.String url)
          Replaces a given token with hyperlinks.
private static java.util.ResourceBundle locateBundle(java.lang.String bundleName, java.lang.String lang)
          Locates a bundle in a given language.
(package private) static java.util.TreeMap parseConfig(java.util.Properties config, java.lang.String element, java.lang.String language)
          Reads institution names from the servlet configuration and generates a TreeMap with the result, using the correct language.
(package private) static java.lang.String[] sortedAcceptLang(java.lang.String acceptLang)
          Parses an Accept-Language header sent from a browser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

static no.feide.moria.log.MessageLogger log
Used for logging.


PATH_PREFIX

private static final java.lang.String PATH_PREFIX
Prefix for all web module properties.

Current value is "no.feide.moria.web.".

See Also:
Constant Field Values

PROP_CONFIG

public static final java.lang.String PROP_CONFIG
Property name for web module configuration.

Current value is PATH_PREFIX + "config".

See Also:
Constant Field Values

PROP_LOGIN_TICKET_PARAM

public static final java.lang.String PROP_LOGIN_TICKET_PARAM
Configuration property giving the name of the URL parameter containing the Moria ticket ID. This property is required.

Current value is PATH_PREFIX + "login.ticket_param".

See Also:
Constant Field Values

PROP_ORG

public static final java.lang.String PROP_ORG
Property name for Organization.

See Also:
Constant Field Values

PROP_LOGIN_DEFAULT_LANGUAGE

public static final java.lang.String PROP_LOGIN_DEFAULT_LANGUAGE
Configuration property giving the default Moria language, to be used if no other preferences (user or service) are available. This property is required.

Current value is PATH_PREFIX + "login.default_language".

See Also:
Constant Field Values

PROP_LANGUAGE

public static final java.lang.String PROP_LANGUAGE
Property name for Language.

See Also:
Constant Field Values

PROP_LOGIN_URL_PREFIX

public static final java.lang.String PROP_LOGIN_URL_PREFIX
Configuration property giving the URL of the login servlet. This property is required.

Current value is PATH_PREFIX + "login.url_prefix".

See Also:
Constant Field Values

PROP_INFORMATION_URL_PREFIX

public static final java.lang.String PROP_INFORMATION_URL_PREFIX
Configuration property giving the URL of the information servlet. This property is required.

Current value is PATH_PREFIX + "information.url_prefix".

See Also:
Constant Field Values

PROP_COMMON

public static final java.lang.String PROP_COMMON
Configuration property sub-string giving the abbreviations and names for all available languages. The property name is on the form PROP_LANGUAGE + "_" + PROP_COMMON.

The actual values are a comma separated list of elements on the form EN:English, that is, a two-letter language abbreviation and a ':' character followed by its display name.

This property is required

Current value is "common".

See Also:
Constant Field Values

PROP_COOKIE_ORG

public static final java.lang.String PROP_COOKIE_ORG
Configuration property giving the name of the cookie used to remember the user's previously selected organization. This property is required.

Current value is PATH_PREFIX + "cookie.org.name".

See Also:
Constant Field Values

PROP_COOKIE_ORG_TTL

public static final java.lang.String PROP_COOKIE_ORG_TTL
Configuration property giving the lifetime, in hours, for the cookie used to remember the user's previously selected organization. This property is required.

Current value is PATH_PREFIX + "cookie.org.ttl".

See Also:
PROP_COOKIE_ORG, Constant Field Values

PROP_COOKIE_LANG

public static final java.lang.String PROP_COOKIE_LANG
Configuration property giving the name of the cookie used to set user's desired language. This property is required.

Current value is PATH_PREFIX + "cookie.lang.name".

See Also:
Constant Field Values

PROP_COOKIE_LANG_TTL

public static final java.lang.String PROP_COOKIE_LANG_TTL
Configuration property giving the lifetime, in hours, for the cookie used to set user's desired language. This property is required.

Current value is PATH_PREFIX + "cookie.lang.ttl".

See Also:
Constant Field Values

PROP_COOKIE_SSO

public static final java.lang.String PROP_COOKIE_SSO
Configuration property giving the name of the cookie used to carry SSO sessions (that is, a Moria ticket ID belonging to a SSO session). This property is required.

Current value is PATH_PREFIX + "cookie.sso.name".

See Also:
Constant Field Values

PROP_COOKIE_SSO_TTL

public static final java.lang.String PROP_COOKIE_SSO_TTL
Configuration property giving the lifetime, in hours, for the cookie used to carry SSO sessions (named by PROP_COOKIE_SSO). This property is required.

Current value is PATH_PREFIX + "cookie.sso.ttl".

See Also:
Constant Field Values

PROP_COOKIE_DENYSSO

public static final java.lang.String PROP_COOKIE_DENYSSO
Configuration property giving the name of the cookie used to deny SSO (when using Moria on public computers, for example). This property is required..

Current value is PATH_PREFIX + "cookie.denysso.name".

See Also:
Constant Field Values

PROP_COOKIE_DENYSSO_TTL

public static final java.lang.String PROP_COOKIE_DENYSSO_TTL
Configuration property giving the lifetime, in hours, for the cookie used to deny SSO (named by PROP_COOKIE_DENYSSO). This property is required

Current value is PATH_PREFIX + "cookie.denysso.ttl".

See Also:
PROP_COOKIE_DENYSSO, Constant Field Values

PROP_LOGOUT_URL_PARAM

public static final java.lang.String PROP_LOGOUT_URL_PARAM
Property name for Logout URL.

See Also:
Constant Field Values

BUNDLE_LOGIN

public static final java.lang.String BUNDLE_LOGIN
The name of the resource bundle for the login page.

Current value is "login".

See Also:
Constant Field Values

BUNDLE_INFOWELCOME

public static final java.lang.String BUNDLE_INFOWELCOME
Bundle for the Welcome page for the Information Service.

See Also:
Constant Field Values

BUNDLE_STATISTICSSERVLET

public static final java.lang.String BUNDLE_STATISTICSSERVLET
Bundle for the Statistics page.

See Also:
Constant Field Values

PROP_INFORMATION_DESCRIPTIONS

public static final java.lang.String PROP_INFORMATION_DESCRIPTIONS
Configuration property for the Information service's attribute description XML file.

See Also:
Constant Field Values

PROP_BACKENDSTATUS_STATUS_XML

public static final java.lang.String PROP_BACKENDSTATUS_STATUS_XML
Configuration property for the StatusServlet status.xml file path.

See Also:
Constant Field Values

PROP_BACKENDSTATUS_STATISTICS_XML

public static final java.lang.String PROP_BACKENDSTATUS_STATISTICS_XML
Configuration property for the StatusServlet statistics.xml file path.

See Also:
Constant Field Values

PROP_BACKENDSTATUS_STATISTICS2_BASENAME_XML

public static final java.lang.String PROP_BACKENDSTATUS_STATISTICS2_BASENAME_XML
Configuration property for the StatusServlet statistics2 basename file path.

See Also:
Constant Field Values

PROP_BACKENDSTATUS_STATISTICS2_XML

public static final java.lang.String PROP_BACKENDSTATUS_STATISTICS2_XML
Configuration property for the StatusServlet statistics2.xml file path.

See Also:
Constant Field Values

PROP_BACKENDSTATUS_IGNORE

public static final java.lang.String PROP_BACKENDSTATUS_IGNORE
Configuration property for the StatisticsServlet's ignored services

See Also:
Constant Field Values

BUNDLE_INFORMATIONSERVLET

public static final java.lang.String BUNDLE_INFORMATIONSERVLET
Bundle for the Information servlet's attribute descriptions.

See Also:
Constant Field Values

BUNDLE_INFOABOUT

public static final java.lang.String BUNDLE_INFOABOUT
Bundle for the information page about the information servlet.

See Also:
Constant Field Values

BUNDLE_STATUSSERVLET

public static final java.lang.String BUNDLE_STATUSSERVLET
Bundle for the status servlet.

See Also:
Constant Field Values

BUNDLE_FAQ

public static final java.lang.String BUNDLE_FAQ
Bundle for the faq page.

See Also:
Constant Field Values

BUNDLE_ERROR

public static final java.lang.String BUNDLE_ERROR
Bundle for the error page.

See Also:
Constant Field Values

FAQ_LINK

public static final java.lang.String FAQ_LINK
Link to faq, shown on the login page.

See Also:
Constant Field Values

PROP_FAQ_STATUS

public static final java.lang.String PROP_FAQ_STATUS
URL to the Status servlet, as shown on the FAQ page.
This property is required.
Current value is PATH_PREFIX + "faq.status".

See Also:
Constant Field Values

PROP_STATISTICS_URL

public static final java.lang.String PROP_STATISTICS_URL
URL to the Statistics servlet, used for language selection.

See Also:
Constant Field Values

PROP_FAQ_OWNER

public static final java.lang.String PROP_FAQ_OWNER
Organization name of the Moria owner, as shown on the FAQ page.

Current value is PATH_PREFIX + "faq.owner".

See Also:
Constant Field Values

PIC_LINK

public static final java.lang.String PIC_LINK
Link to pictures from the information service.

See Also:
Constant Field Values

RESOURCE_MAIL

public static final java.lang.String RESOURCE_MAIL
TODO: Add JavaDoc. Is this in use?

See Also:
Constant Field Values

RESOURCE_DATE

public static final java.lang.String RESOURCE_DATE
TODO: Add JavaDoc. Is this in use?

See Also:
Constant Field Values

RESOURCE_LINK

public static final java.lang.String RESOURCE_LINK
TODO: Add JavaDoc. Is this in use?

See Also:
Constant Field Values

CONFIG_LANG

public static final java.lang.String CONFIG_LANG
Name of property from authorization module giving the default language for a given service. This property is required.

Current value is "language".

See Also:
Constant Field Values

CONFIG_HOME

public static final java.lang.String CONFIG_HOME
From Authorization config Home organization of service.

See Also:
Constant Field Values

CONFIG_DISPLAY_NAME

public static final java.lang.String CONFIG_DISPLAY_NAME
From Authorization config: Service name.

See Also:
Constant Field Values

CONFIG_SERVICE_PRINCIPAL

public static final java.lang.String CONFIG_SERVICE_PRINCIPAL
From Authorization configuration; service principal.

See Also:
Constant Field Values

CONFIG_URL

public static final java.lang.String CONFIG_URL
From Authorization config: Service URL.

See Also:
Constant Field Values

PARAM_USERNAME

public static final java.lang.String PARAM_USERNAME
Parameter in request object: Username.

See Also:
Constant Field Values

PARAM_PASSWORD

public static final java.lang.String PARAM_PASSWORD
Parameter in request object: Password.

See Also:
Constant Field Values

PARAM_ORG

public static final java.lang.String PARAM_ORG
Organization URL parameter, used when overriding default organization in the URL redirecting a user from a service to Moria. Useful for services that wish to dynamically force use of a certain organization irrespective of the user's previous selections or the service defaults.

Current value is "org".

See Also:
Constant Field Values

PARAM_LANG

public static final java.lang.String PARAM_LANG
Language URL parameter, used when overriding current language settings.

Current value is "language".

See Also:
Constant Field Values

PARAM_SHOW_ATTRS

public static final java.lang.String PARAM_SHOW_ATTRS
Attribute URL parameter, used when attributes are shown on the login page.

See Also:
Constant Field Values

PARAM_OLD_STATISTICS

public static final java.lang.String PARAM_OLD_STATISTICS
Attribute URL parameter, used to show statistics from the previous year.

See Also:
Constant Field Values

PARAM_DENYSSO

public static final java.lang.String PARAM_DENYSSO
Parameter in request object: Deny SSO.

See Also:
Constant Field Values

ATTR_BASE_URL

public static final java.lang.String ATTR_BASE_URL
Base URL attribute in request object. Used to fill in the URL to the authentication web page.

Current value is "baseURL".

See Also:
Constant Field Values

ATTR_SEC_LEVEL

public static final java.lang.String ATTR_SEC_LEVEL
Attribute in request object: Security level.

See Also:
Constant Field Values

ATTR_ERROR_TYPE

public static final java.lang.String ATTR_ERROR_TYPE
Attribute in request object: Error type.

See Also:
Constant Field Values

ATTR_LANGUAGES

public static final java.lang.String ATTR_LANGUAGES
Attribute in request object: Available languages.

See Also:
Constant Field Values

ATTR_ORGANIZATIONS

public static final java.lang.String ATTR_ORGANIZATIONS
Attribute in request object: Available organizations.

See Also:
Constant Field Values

ATTR_SELECTED_ORG

public static final java.lang.String ATTR_SELECTED_ORG
Attribute in request object: Preselected organization.

See Also:
Constant Field Values

ATTR_SELECTED_DENYSSO

public static final java.lang.String ATTR_SELECTED_DENYSSO
Attribute in request object: Denial of SSO.

See Also:
Constant Field Values

ATTR_SELECTED_LANG

public static final java.lang.String ATTR_SELECTED_LANG
Attribute in request object: Preselected lanugage.

See Also:
Constant Field Values

ATTR_CLIENT_NAME

public static final java.lang.String ATTR_CLIENT_NAME
Attribute in request object: Name of client/service.

See Also:
Constant Field Values

ATTR_CLIENT_URL

public static final java.lang.String ATTR_CLIENT_URL
Attribute in request object: Link to associate with service name.

See Also:
Constant Field Values

ATTR_BUNDLE

public static final java.lang.String ATTR_BUNDLE
Attribute in request object: Language bundle.

See Also:
Constant Field Values

ATTR_REQUESTED_ATTRIBUTES

public static final java.lang.String ATTR_REQUESTED_ATTRIBUTES
Attribute in request object: Requested attributes.

See Also:
Constant Field Values

ERROR_NO_ORG

public static final java.lang.String ERROR_NO_ORG
Error type: No organization selected.

See Also:
Constant Field Values

ERROR_INVALID_ORG

public static final java.lang.String ERROR_INVALID_ORG
Error type: Invalid organization selected.

See Also:
Constant Field Values

ERROR_AUTHENTICATION_FAILED

public static final java.lang.String ERROR_AUTHENTICATION_FAILED
Error type: Authentication failed.

See Also:
Constant Field Values

ERROR_AUTHORIZATION_FAILED

public static final java.lang.String ERROR_AUTHORIZATION_FAILED
Error type: Authorization failed.

See Also:
Constant Field Values

ERROR_UNKNOWN_TICKET

public static final java.lang.String ERROR_UNKNOWN_TICKET
Error type: Unknown ticket.

See Also:
Constant Field Values

ERROR_DIRECTORY_DOWN

public static final java.lang.String ERROR_DIRECTORY_DOWN
Error type: The directory is down.

See Also:
Constant Field Values

ERROR_MORIA_DOWN

public static final java.lang.String ERROR_MORIA_DOWN
Error type: Moria is unavailable.

See Also:
Constant Field Values

ERROR_NO_CREDENTIALS

public static final java.lang.String ERROR_NO_CREDENTIALS
Error type: User must supply username and password.

See Also:
Constant Field Values
Constructor Detail

RequestUtil

private RequestUtil()
Default private constructor.

Method Detail

getBundle

public static java.util.ResourceBundle getBundle(java.lang.String bundleName,
                                                 java.lang.String requestParamLang,
                                                 java.lang.String langFromCookie,
                                                 java.lang.String serviceLang,
                                                 java.lang.String browserLang,
                                                 java.lang.String moriaLang)
Generates a resource bundle. The language of the resource bundle is selected from the following priority list:
  1. URL parameter (requestParamLang)
  2. User's cookie (langFromCookie)
  3. Default service language (serviceLang)
  4. User's browser settings (browserLang)
  5. Moria default setting (moriaLang)

Parameters:
bundleName - Name of the resource bundle to retrieve. Cannot be null.
requestParamLang - Language specified from URL parameter. Can be null.
langFromCookie - Language specified from user's cookie. Can be null.
serviceLang - Default language as specified by configuration for the service. Can be null.
browserLang - Language as requested by the users browser. Can be null.
moriaLang - Default language for Moria. Cannot be null.
Returns:
The requested resource bundle.
Throws:
java.lang.IllegalArgumentException - If bundleName or moriaLang is null or an empty string.
java.util.MissingResourceException - If the resource bundle cannot be found.

locateBundle

private static java.util.ResourceBundle locateBundle(java.lang.String bundleName,
                                                     java.lang.String lang)
Locates a bundle in a given language.

Parameters:
bundleName - Name of the bundle, cannot be null or "".
lang - The bundle's langauge.
Returns:
The resourceBundle for the selected language, null if it is not found.
Throws:
java.lang.IllegalArgumentException - If bundleName or lang is null or an empty string.

getCookieValue

public static java.lang.String getCookieValue(java.lang.String cookieName,
                                              javax.servlet.http.Cookie[] cookies)
Returns a requested cookie value from the HTTP request.

Parameters:
cookieName - Name of the cookie.
cookies - The cookies from the HTTP request.
Returns:
Requested value, empty string if not found.
Throws:
java.lang.IllegalArgumentException - If cookieName is null or an empty string.

createCookie

public static javax.servlet.http.Cookie createCookie(java.lang.String cookieName,
                                                     java.lang.String cookieValue,
                                                     int validHours)
Creates a cookie.

Parameters:
cookieName - Name of the cookie. Cannot be null.
cookieValue - Value to set in cookie. Cannot be null.
validHours - Number of hours before the cookie expires. Must be 0 or greater.
Returns:
A Cookie with the specified name and value, with the given expiry time.
Throws:
java.lang.IllegalArgumentException - If cookieName or cookieValue is null or an empty string.

sortedAcceptLang

static java.lang.String[] sortedAcceptLang(java.lang.String acceptLang)
Parses an Accept-Language header sent from a browser. The language entries in the string can be weighted and the parser generates a list of the languages sorted by the weight value.

Parameters:
acceptLang - The accept language header, cannot be null or "".
Returns:
A string array of language names, sorted by the browser's weight preferences.
Throws:
java.lang.IllegalArgumentException - If acceptLang is null or an empty string.

parseConfig

static java.util.TreeMap parseConfig(java.util.Properties config,
                                     java.lang.String element,
                                     java.lang.String language)
Reads institution names from the servlet configuration and generates a TreeMap with the result, using the correct language.

The configuration must contain properties on the form element + "_" + language.

Parameters:
config - The web module configuration.
element - The sub-element of the web module configuration to process.
language - The language used when generating institution names.
Returns:
A TreeMap of institution names with full name as key and ID as value.
Throws:
java.lang.IllegalArgumentException - If config is null, or if element or language is null or an empty string.
java.lang.IllegalStateException - If no elements of type element are found in the configuration config. Also thrown if the values found in config contains less than or more than one occurrence of the ':' separator character.

insertLink

public static java.lang.String insertLink(java.lang.String token,
                                          java.lang.String data,
                                          java.lang.String name,
                                          java.lang.String url)
Replaces a given token with hyperlinks. The URL and name of the hyperlink is given as parameters. Every occurance of the token in the data string is replaced by a hyperlink.

Parameters:
token - The token to replace with link.
data - The data containing text and token(s).
name - The link text.
url - The URL to link to.
Returns:
A string with hyperlinks in stead of tokens.
Throws:
java.lang.IllegalArgumentException - If token, data, name or url is null or an empty string.

getConfig

static java.util.Properties getConfig(javax.servlet.ServletContext context)
Get the config from the context. The configuration is expected to be set by the controller before requests are sent to this servlet.

Parameters:
context - ServletContext containing the configuration.
Returns:
The configuration.
Throws:
java.lang.IllegalStateException - If config is not properly set in the context.


Copyright © 2001-2006 UNINETT FAS. All Rights Reserved.