org.archive.wayback.core
Class UIResults

java.lang.Object
  extended by org.archive.wayback.core.UIResults

public class UIResults
extends Object

Simple class which acts as the go-between between Java request handling code and .jsp files which actually draw various forms of results for end user consumption. Designed to be flexible enough to handle forward various types of data to the eventual .jsp files, and provides a handful of convenience method to simplify .jsp code. 5 main "forms" of this object: 1) Generic: has WaybackRequest, uriConverter 2) Exception: has WaybackRequest, uriConverter, WaybackException 3) CaptureQuery: has WaybackRequest, uriConverter, CaptureSearchResults 4) UrlQuery: has WaybackRequest, uriConverter, UrlSearchResults 5) Replay: has WaybackRequest, uriConverter, CaptureSearchResult, CaptureSearchResults, Resource There are constructors to create each of these forms from the appropriate component objects. There is also a common method "forward()" which will store the UIResults object into an HttpServletRequest, for later retrieval by .jsp files. There are static methods to extract each of these from an HttpServletRequest, which will also verify that the appropriate internal objects are present. These methods are intended to be used by the target .jsp files.

Version:
$Date: 2010-09-29 05:28:38 +0700 (Wed, 29 Sep 2010) $, $Revision: 3262 $
Author:
brad

Constructor Summary
UIResults(WaybackRequest wbRequest, ResultURIConverter uriConverter)
          Constructor for a "generic" UIResults, where little/no context is available.
UIResults(WaybackRequest wbRequest, ResultURIConverter uriConverter, CaptureSearchResults captureResults)
          Constructor for "Url Query" UIResults, where the request successfully matched something from the index.
UIResults(WaybackRequest wbRequest, ResultURIConverter uriConverter, CaptureSearchResults captureResults, CaptureSearchResult result, Resource resource)
          Constructor for "Replay" UIResults, where the request successfully matched something from the index, the document was retrieved from the ResourceStore, and is going to be shown to the user.
UIResults(WaybackRequest wbRequest, ResultURIConverter uriConverter, UrlSearchResults urlResults)
          Constructor for "Url Prefix Query" UIResults, where the request successfully matched something from the index.
UIResults(WaybackRequest wbRequest, ResultURIConverter uriConverter, WaybackException exception)
          Constructor for a "exception" UIResults, where little/no context is available.
 
Method Summary
static String encodeXMLContent(String content)
          Deprecated. use getFormatter().escapeHtml(String)
static String encodeXMLEntity(String tagName)
          Deprecated. use getFormatter().escapeHtml(String)
static String encodeXMLEntityQuote(String content)
          Deprecated. use getFormatter().escapeHtml(String)
static UIResults extractCaptureQuery(javax.servlet.http.HttpServletRequest httpRequest)
          Extract a CaptureQuery UIResults from the HttpServletRequest.
static UIResults extractException(javax.servlet.http.HttpServletRequest httpRequest)
          Extract an Exception UIResults from the HttpServletRequest.
static UIResults extractReplay(javax.servlet.http.HttpServletRequest httpRequest)
          Extract a Replay UIResults from the HttpServletRequest.
static UIResults extractUrlQuery(javax.servlet.http.HttpServletRequest httpRequest)
          Extract a UrlQuery UIResults from the HttpServletRequest.
 void forward(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String target)
          Store this UIResults object in the given HttpServletRequest, then forward the request to target, in this case, an image, html file, .jsp, any file which can return a complete document.
 CaptureSearchResults getCaptureResults()
           
 String getContentJsp()
           
 String getContextConfig(String configName)
          Get a String generic AccessPoint config (ala AccessPoint.configs Spring config)
 String getContextPrefix()
          Deprecated. use getWbRequest().getContextPrefix()
 WaybackException getException()
           
 StringFormatter getFormatter()
          Deprecated. use getWbRequest().getFormatter()
static UIResults getGeneric(javax.servlet.http.HttpServletRequest httpRequest)
          Extract a generic UIResults from the HttpServletRequest.
 String getOriginalRequestURL()
           
 String getQueryPrefix()
           
 String getReplayPrefix()
           
 Resource getResource()
           
 CaptureSearchResult getResult()
           
 String getServerPrefix()
          Deprecated. use getWbRequest().getServerPrefix()
 String getStaticPrefix()
           
 ResultURIConverter getUriConverter()
          Deprecated. use getURIConverter()
 ResultURIConverter getURIConverter()
           
 UrlSearchResults getUrlResults()
           
 WaybackRequest getWbRequest()
           
 String makeCaptureQueryUrl(String url)
          Create a self-referencing URL that will perform a query for all copies of the given URL.
 String makeReplayUrl(String url, String timestamp)
          Deprecated. use resultToReplayUrl(CaptureSearchResult) or getURIConverter.makeReplayURI()
 String resultToReplayUrl(CaptureSearchResult result)
          Create a replay URL for the given CaptureSearchResult
 void setContentJsp(String contentJsp)
          Deprecated. use forward()
 String urlForPage(int pageNum)
          Create a self-referencing URL that will drive to the given page, simplifying rendering pagination
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UIResults

public UIResults(WaybackRequest wbRequest,
                 ResultURIConverter uriConverter)
Constructor for a "generic" UIResults, where little/no context is available. Likely used for static UI requests, and more specifically, for template .jsp files, including header/footer .jsps. These may be called in multiple contexts, but don't expect much data to be avaialble beyond the AccessPoint that handled the request.

Parameters:
wbRequest - WaybackRequest with some or no information
uriConverter - the ResultURIConveter to use with the AccessPoint handling the request.

UIResults

public UIResults(WaybackRequest wbRequest,
                 ResultURIConverter uriConverter,
                 WaybackException exception)
Constructor for a "exception" UIResults, where little/no context is available. Likely used for exception rendering .jsp files.

Parameters:
wbRequest - WaybackRequest with some or no information, but at least the AccessPoint that handled the request.
uriConverter - the ResultURIConveter to use with the AccessPoint handling the request.
exception - WaybackException to be rendered.

UIResults

public UIResults(WaybackRequest wbRequest,
                 ResultURIConverter uriConverter,
                 CaptureSearchResults captureResults)
Constructor for "Url Query" UIResults, where the request successfully matched something from the index. Used to hand off search results and context to the query rendering .jsp files.

Parameters:
wbRequest - WaybackRequest with a valid request
uriConverter - the ResultURIConveter to use with the AccessPoint handling the request.
captureResults - CaptureSearchResults object with matching data.

UIResults

public UIResults(WaybackRequest wbRequest,
                 ResultURIConverter uriConverter,
                 UrlSearchResults urlResults)
Constructor for "Url Prefix Query" UIResults, where the request successfully matched something from the index. Used to hand off search results and context to the query rendering .jsp files.

Parameters:
wbRequest - WaybackRequest with a valid request
uriConverter - the ResultURIConveter to use with the AccessPoint
urlResults - UrlSearchResults object with matching data.

UIResults

public UIResults(WaybackRequest wbRequest,
                 ResultURIConverter uriConverter,
                 CaptureSearchResults captureResults,
                 CaptureSearchResult result,
                 Resource resource)
Constructor for "Replay" UIResults, where the request successfully matched something from the index, the document was retrieved from the ResourceStore, and is going to be shown to the user.

Parameters:
wbRequest - WaybackRequest with some or no information
uriConverter - the ResultURIConveter to use with the AccessPoint
captureResults - CaptureSearchResults object with matching data.
result - the specific CaptureSearchResult being replayed
resource - the actual Resource being replayed
Method Detail

getWbRequest

public WaybackRequest getWbRequest()
Returns:
Returns the wbRequest.

getURIConverter

public ResultURIConverter getURIConverter()
Returns:
the ResultURIConverter

getCaptureResults

public CaptureSearchResults getCaptureResults()
Returns:
the captureResults

getUrlResults

public UrlSearchResults getUrlResults()
Returns:
the urlResults

getResult

public CaptureSearchResult getResult()
Returns:
the result

getResource

public Resource getResource()
Returns:
the resource

getException

public WaybackException getException()
Returns:
the exception

getContentJsp

public String getContentJsp()
Returns:
the contentJsp

getOriginalRequestURL

public String getOriginalRequestURL()
Returns:
the original URL as received by Wayback, before forwarding to a .jsp

makeCaptureQueryUrl

public String makeCaptureQueryUrl(String url)
Create a self-referencing URL that will perform a query for all copies of the given URL.

Parameters:
url - to search for copies of
Returns:
String url that will make a query for all captures of an URL.

getContextConfig

public String getContextConfig(String configName)
Get a String generic AccessPoint config (ala AccessPoint.configs Spring config)

Parameters:
configName - key for configuration property
Returns:
String configuration for the context, if present, otherwise null

resultToReplayUrl

public String resultToReplayUrl(CaptureSearchResult result)
Create a replay URL for the given CaptureSearchResult

Parameters:
result - CaptureSearchResult to replay
Returns:
URL string that will replay the specified Resource Result.

urlForPage

public String urlForPage(int pageNum)
Create a self-referencing URL that will drive to the given page, simplifying rendering pagination

Parameters:
pageNum - page number of results to link to.
Returns:
String URL which will drive browser to search results for a different page of results for the same query

getStaticPrefix

public String getStaticPrefix()
Returns:
the defined staticPrefix for the AccessPoint

getQueryPrefix

public String getQueryPrefix()
Returns:
the defined queryPrefix for the AccessPoint

getReplayPrefix

public String getReplayPrefix()
Returns:
the defined replayPrefix for the AccessPoint

forward

public void forward(javax.servlet.http.HttpServletRequest request,
                    javax.servlet.http.HttpServletResponse response,
                    String target)
             throws javax.servlet.ServletException,
                    IOException
Store this UIResults object in the given HttpServletRequest, then forward the request to target, in this case, an image, html file, .jsp, any file which can return a complete document. Specifically, this means that if target is a .jsp, it must render it's own header and footer.

Parameters:
request - the HttpServletRequest
response - the HttpServletResponse
target - the String path to the .jsp to handle drawing the data, relative to the contextRoot (ex. "/WEB-INF/query/foo.jsp")
Throws:
javax.servlet.ServletException - for usual reasons...
IOException - for usual reasons...

getGeneric

public static UIResults getGeneric(javax.servlet.http.HttpServletRequest httpRequest)
Extract a generic UIResults from the HttpServletRequest. Probably used by a header/footer template .jsp file.

Parameters:
httpRequest - the HttpServletRequest where the UIResults was ferreted away
Returns:
generic UIResult with info from httpRequest applied.

extractException

public static UIResults extractException(javax.servlet.http.HttpServletRequest httpRequest)
                                  throws javax.servlet.ServletException
Extract an Exception UIResults from the HttpServletRequest. Probably used by a .jsp responsible for actual drawing errors for the user.

Parameters:
httpRequest - the HttpServletRequest where the UIResults was ferreted away
Returns:
Exception UIResult with info from httpRequest applied.
Throws:
javax.servlet.ServletException - if expected information is not available. Likely means a programming bug, or a configuration problem.

extractCaptureQuery

public static UIResults extractCaptureQuery(javax.servlet.http.HttpServletRequest httpRequest)
                                     throws javax.servlet.ServletException
Extract a CaptureQuery UIResults from the HttpServletRequest. Probably used by a .jsp responsible for actually drawing search results for the user.

Parameters:
httpRequest - the HttpServletRequest where the UIResults was ferreted away
Returns:
CaptureQuery UIResult with info from httpRequest applied.
Throws:
javax.servlet.ServletException - if expected information is not available. Likely means a programming bug, or a configuration problem.

extractUrlQuery

public static UIResults extractUrlQuery(javax.servlet.http.HttpServletRequest httpRequest)
                                 throws javax.servlet.ServletException
Extract a UrlQuery UIResults from the HttpServletRequest. Probably used by a .jsp responsible for actually drawing search results for the user.

Parameters:
httpRequest - the HttpServletRequest where the UIResults was ferreted away
Returns:
UrlQuery UIResult with info from httpRequest applied.
Throws:
javax.servlet.ServletException - if expected information is not available. Likely means a programming bug, or a configuration problem.

extractReplay

public static UIResults extractReplay(javax.servlet.http.HttpServletRequest httpRequest)
                               throws javax.servlet.ServletException
Extract a Replay UIResults from the HttpServletRequest. Probably used by a .jsp insert, responsible for rendering content into replayed Resources to enhance the Replay experience.

Parameters:
httpRequest - the HttpServletRequest where the UIResults was ferreted away
Returns:
Replay UIResult with info from httpRequest applied.
Throws:
javax.servlet.ServletException - if expected information is not available. Likely means a programming bug, or a configuration problem.

getUriConverter

public ResultURIConverter getUriConverter()
Deprecated. use getURIConverter()

Returns:
the uriConverter

encodeXMLEntity

public static String encodeXMLEntity(String tagName)
Deprecated. use getFormatter().escapeHtml(String)

return a string appropriate for inclusion as an XML tag

Parameters:
tagName - raw string to be encoded
Returns:
encoded tagName

encodeXMLContent

public static String encodeXMLContent(String content)
Deprecated. use getFormatter().escapeHtml(String)

return a string appropriate for inclusion as an XML tag

Parameters:
content - to escape
Returns:
encoded content

encodeXMLEntityQuote

public static String encodeXMLEntityQuote(String content)
Deprecated. use getFormatter().escapeHtml(String)

return a string appropriate for inclusion as an XML tag

Parameters:
content - to encode
Returns:
encoded content

getContextPrefix

public String getContextPrefix()
Deprecated. use getWbRequest().getContextPrefix()

Returns:
URL that points to the root of the current WaybackContext

getFormatter

public StringFormatter getFormatter()
Deprecated. use getWbRequest().getFormatter()

Returns:
StringFormatter localized to user request

getServerPrefix

public String getServerPrefix()
Deprecated. use getWbRequest().getServerPrefix()

Returns:
URL that points to the root of the Server

setContentJsp

public void setContentJsp(String contentJsp)
Deprecated. use forward()

Parameters:
contentJsp - the contentJsp to set

makeReplayUrl

public String makeReplayUrl(String url,
                            String timestamp)
Deprecated. use resultToReplayUrl(CaptureSearchResult) or getURIConverter.makeReplayURI()

Parameters:
url - to replay
timestamp - to replay
Returns:
String url that will replay the url at timestamp


Copyright © 2005-2011 Internet Archive. All Rights Reserved.