nl.gx.webmanager.handler.util
Class Util

java.lang.Object
  extended by nl.gx.webmanager.handler.util.Util

public class Util
extends java.lang.Object


Constructor Summary
Util(javax.servlet.ServletConfig servletConfig)
           
 
Method Summary
 java.lang.String encodeURL(java.lang.String url, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Sign url.
 java.lang.String encrypt(java.lang.String value)
          Return the encrypted, normalized value.
 java.lang.String getContents(java.lang.String urlString, boolean allowCache)
          Return the contents of url.
 java.lang.String getContents(java.lang.String urlString, nl.gx.proxy.Header[] headers, boolean allowCache)
          Return the contents of url.
 javax.sql.DataSource getDataSource(java.lang.String datasource)
           
 java.lang.String getExternalContents(java.net.URL url)
          Return the contents of url.
static Util getInstance()
           
static nl.gx.webmanager.handler.config.ObjectTimeStampFetcher getObjectTimeStampFetcher()
          Creates an instance of an ObjectTimeStampFetcher.
 nl.gx.proxy.connection.HttpConnection getShowConnection(java.lang.String urlString, nl.gx.proxy.Header[] headers, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Creates a connection to the Controller servlet.
 java.lang.String getShowContents(java.lang.String urlString, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Return the contents of url.
static nl.gx.proxy.TimeStampFetcher getSoftTimeStampFetcher(nl.gx.webmanager.handler.config.ObjectTimeStampFetcher objectTimestampFetcher)
          Creates an instance a softTimeStampFetcher for the given objectTimestampFetcher.
 java.lang.String getUserName(javax.servlet.http.HttpServletRequest req)
          Returns whatever is stored under GX_username in the session.
 boolean isCacheAllowed(java.lang.String requestServerName, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Checks whether caching is allow for a request on the specified host.
static boolean isSecureServerName(java.lang.String servername)
          Indicates whether the servername argument is a secure domain.
static void setInstance(Util util)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util(javax.servlet.ServletConfig servletConfig)
Method Detail

getObjectTimeStampFetcher

public static nl.gx.webmanager.handler.config.ObjectTimeStampFetcher getObjectTimeStampFetcher()
Creates an instance of an ObjectTimeStampFetcher. The configured 'timestampfetcher_classname' will be constructed, when this fails the default TSFetcher will be instantiated.

Returns:
an instance of an ObjectTimeStampFetcher

getSoftTimeStampFetcher

public static nl.gx.proxy.TimeStampFetcher getSoftTimeStampFetcher(nl.gx.webmanager.handler.config.ObjectTimeStampFetcher objectTimestampFetcher)
Creates an instance a softTimeStampFetcher for the given objectTimestampFetcher.

Parameters:
objectTimestampFetcher - an objectTimestampFetcher
Returns:
softTimeStamp fetcher for the given objectTimestampFetcher

setInstance

public static void setInstance(Util util)

getInstance

public static Util getInstance()

getDataSource

public javax.sql.DataSource getDataSource(java.lang.String datasource)
                                   throws java.sql.SQLException
Throws:
java.sql.SQLException

getUserName

public java.lang.String getUserName(javax.servlet.http.HttpServletRequest req)
Returns whatever is stored under GX_username in the session.

Parameters:
req - The request from which the user header should be read.
Returns:
the username under stored at GX_username

encodeURL

public java.lang.String encodeURL(java.lang.String url,
                                  javax.servlet.http.HttpServletRequest req,
                                  javax.servlet.http.HttpServletResponse res)
                           throws java.io.UnsupportedEncodingException
Sign url.

Parameters:
url -
req -
res -
Returns:
encoded url
Throws:
java.io.UnsupportedEncodingException

encrypt

public java.lang.String encrypt(java.lang.String value)
Return the encrypted, normalized value.

Parameters:
value -
Returns:
Return the encrypted, normalized value

getShowContents

public java.lang.String getShowContents(java.lang.String urlString,
                                        javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response)
                                 throws java.io.IOException
Return the contents of url.

Parameters:
urlString - The url for which the content should be returned
headers - The extra request headers that should be added to the request to the origin server
allowCache - Indicates whether cached content is acceptable
Returns:
The contents of url
Throws:
java.io.IOException - If the content could not be read completely

getShowConnection

public nl.gx.proxy.connection.HttpConnection getShowConnection(java.lang.String urlString,
                                                               nl.gx.proxy.Header[] headers,
                                                               javax.servlet.http.HttpServletRequest request,
                                                               javax.servlet.http.HttpServletResponse response)
                                                        throws java.net.MalformedURLException,
                                                               java.io.IOException
Creates a connection to the Controller servlet.

Parameters:
urlString - The url representation of the contents that should be retrieved
headers - The headers that should be set when fetching the contents.
request - The original request that should be used in a request dispatcher.
response - The original reponse that should be used in a request dispatcher.
Returns:
A connection representing the contents of the url.
Throws:
java.net.MalformedURLException - If the urlString argument could not be parsed.
java.io.IOException - If the content could not be retrieved successfully

getContents

public java.lang.String getContents(java.lang.String urlString,
                                    boolean allowCache)
                             throws java.io.IOException
Return the contents of url.

Parameters:
urlString - The url for which the content should be returned
allowCache - Indicates whether cached content is acceptable
Returns:
The contents of url
Throws:
java.io.IOException - If the content could not be read completely

getContents

public java.lang.String getContents(java.lang.String urlString,
                                    nl.gx.proxy.Header[] headers,
                                    boolean allowCache)
                             throws java.io.IOException
Return the contents of url.

Parameters:
urlString - The url for which the content should be returned
headers - The extra request headers that should be added to the request to the origin server
allowCache - Indicates whether cached content is acceptable
Returns:
The contents of url
Throws:
java.io.IOException - If the content could not be read completely

getExternalContents

public java.lang.String getExternalContents(java.net.URL url)
                                     throws java.io.IOException
Return the contents of url.

Parameters:
url - The url for which the content should be returned
Returns:
The contents of url
Throws:
java.io.IOException - If the content could not be read completely

isCacheAllowed

public boolean isCacheAllowed(java.lang.String requestServerName,
                              javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
Checks whether caching is allow for a request on the specified host.

Parameters:
requestServerName - The host in the original request.
Returns:
true if a request for on the specified requestServerName should check the cache for a cached version. false if caching is not allowed for that servername. Possible reason for this are: the hostname is an editing domain or caching has been disabled in general.

isSecureServerName

public static boolean isSecureServerName(java.lang.String servername)
Indicates whether the servername argument is a secure domain.

Parameters:
servername - the servername from where the request came
Returns:
true if it is a configured secure servername, false otherwise.


Copyright © 2007-2011 GX Software BV. All Rights Reserved.