org.dspace.app.webui.util
Class UIUtil

java.lang.Object
  extended by org.dspace.app.util.Util
      extended by org.dspace.app.webui.util.UIUtil

public class UIUtil
extends Util

Miscellaneous UI utility methods

Version:
$Revision: 5845 $
Author:
Robert Tansley

Field Summary
static Logger log
          log4j category
 
Constructor Summary
UIUtil()
           
 
Method Summary
static java.lang.String displayDate(DCDate d, boolean time, boolean localTime, javax.servlet.http.HttpServletRequest request)
          Write a human-readable version of a DCDate.
static Collection getCollectionLocation(javax.servlet.http.HttpServletRequest request)
          Get the current collection location, that is, where the user "is".
static Community getCommunityLocation(javax.servlet.http.HttpServletRequest request)
          Get the current community location, that is, where the user "is".
static java.lang.String getOriginalURL(javax.servlet.http.HttpServletRequest request)
          Get the original request URL.
static java.lang.String getRequestLogInfo(javax.servlet.http.HttpServletRequest request)
          Return a string for logging, containing useful information about the current request - the URL, the method and parameters.
static java.util.Locale getSessionLocale(javax.servlet.http.HttpServletRequest request)
          Get the Locale for a session according to the user's language selection or language preferences.
static Context obtainContext(javax.servlet.http.HttpServletRequest request)
          Obtain a new context object.
static void sendAlert(javax.servlet.http.HttpServletRequest request, java.lang.Exception exception)
          Send an alert to the designated "alert recipient" - that is, when a database error or internal error occurs, this person is sent an e-mail with details.
static void setBitstreamDisposition(java.lang.String filename, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Evaluate filename and client and encode appropriate disposition
static void storeOriginalURL(javax.servlet.http.HttpServletRequest request)
          Put the original request URL into the request object as an attribute for later use.
 
Methods inherited from class org.dspace.app.util.Util
encodeBitstreamName, encodeBitstreamName, formatFileSize, getBoolParameter, getIntParameter, getIntParameters, getSourceVersion, getSubmitButton, nonBreakSpace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final Logger log
log4j category

Constructor Detail

UIUtil

public UIUtil()
Method Detail

obtainContext

public static Context obtainContext(javax.servlet.http.HttpServletRequest request)
                             throws java.sql.SQLException
Obtain a new context object. If a context object has already been created for this HTTP request, it is re-used, otherwise it is created. If a user has authenticated with the system, the current user of the context is set appropriately.

Parameters:
request - the HTTP request
Returns:
a context object
Throws:
java.sql.SQLException

getCommunityLocation

public static Community getCommunityLocation(javax.servlet.http.HttpServletRequest request)
Get the current community location, that is, where the user "is". This returns null if there is no location, i.e. "all of DSpace" is the location.

Parameters:
request - current HTTP request
Returns:
the current community location, or null

getCollectionLocation

public static Collection getCollectionLocation(javax.servlet.http.HttpServletRequest request)
Get the current collection location, that is, where the user "is". This returns null if there is no collection location, i.e. the location is "all of DSpace" or a community.

Parameters:
request - current HTTP request
Returns:
the current collection location, or null

storeOriginalURL

public static void storeOriginalURL(javax.servlet.http.HttpServletRequest request)
Put the original request URL into the request object as an attribute for later use. This is necessary because forwarding a request removes this information. The attribute is only written if it hasn't been before; thus it can be called after a forward safely.

Parameters:
request - the HTTP request

getOriginalURL

public static java.lang.String getOriginalURL(javax.servlet.http.HttpServletRequest request)
Get the original request URL.

Parameters:
request - the HTTP request
Returns:
the original request URL

displayDate

public static java.lang.String displayDate(DCDate d,
                                           boolean time,
                                           boolean localTime,
                                           javax.servlet.http.HttpServletRequest request)
Write a human-readable version of a DCDate.

Parameters:
d - the date
time - if true, display the time with the date
localTime - if true, adjust for local timezone, otherwise GMT
request - the servlet request
Returns:
the date in a human-readable form.

getRequestLogInfo

public static java.lang.String getRequestLogInfo(javax.servlet.http.HttpServletRequest request)
Return a string for logging, containing useful information about the current request - the URL, the method and parameters.

Parameters:
request - the request object.
Returns:
a multi-line string containing information about the request.

getSessionLocale

public static java.util.Locale getSessionLocale(javax.servlet.http.HttpServletRequest request)
Get the Locale for a session according to the user's language selection or language preferences. Order of selection - language selected via UI - language as set by application - language browser default

Parameters:
request - the request Object
Returns:
supportedLocale Locale supported by this DSpace Instance for this request

sendAlert

public static void sendAlert(javax.servlet.http.HttpServletRequest request,
                             java.lang.Exception exception)
Send an alert to the designated "alert recipient" - that is, when a database error or internal error occurs, this person is sent an e-mail with details.

The recipient is configured via the "alert.recipient" property in dspace.cfg. If this property is omitted, no alerts are sent.

This method "swallows" any exception that might occur - it will just be logged. This is because this method will usually be invoked as part of an error handling routine anyway.

Parameters:
request - the HTTP request leading to the error
exception - the exception causing the error, or null

setBitstreamDisposition

public static void setBitstreamDisposition(java.lang.String filename,
                                           javax.servlet.http.HttpServletRequest request,
                                           javax.servlet.http.HttpServletResponse response)
Evaluate filename and client and encode appropriate disposition

Parameters:
filename -
request -
response -
Throws:
java.io.UnsupportedEncodingException


Copyright © 2010 DuraSpace. All Rights Reserved.