public abstract class TextReplayRenderer extends Object implements ReplayRenderer
ReplayRenderer for rewriting textual resource with TextDocument.
Resource is first decoded (if Transfer-Encoding is applied),
and fully loaded into TextDocument object. Then updatePage(org.archive.wayback.replay.TextDocument, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.archive.wayback.core.WaybackRequest, org.archive.wayback.core.CaptureSearchResult, org.archive.wayback.core.Resource, org.archive.wayback.ResultURIConverter, org.archive.wayback.core.CaptureSearchResults)
method is called for actual rewrite. Then updated content is sent to the response.
Customization Properties:
jspInserts: a list of Servlets for annotation inserts. It is
updatePage's responsibility to perform actual insertion.charsetDetector: CharsetDetector for detecting resource's
charset. Default is StandardCharsetDetector.httpHeaderProcessor (constructor arg): HttpHeaderProcessor
for rewriting resource's HTTP headers.guessedCharsetHeader: name of response HTTP header for sending
out resource's charset detected by charsetDetector. Default is
GUESSED_CHARSET_HEADER.pageURIConverterFactory: You can use different URI conversion
just for TextDocument and {#updatePage} by setting this property
to non-null ContextResultURIConverterFactory. It does not
affect URI conversion for HTTP headers.| Modifier and Type | Field and Description |
|---|---|
static String |
GUESSED_CHARSET_HEADER |
static String |
ORIG_ENCODING |
| Constructor and Description |
|---|
TextReplayRenderer(HttpHeaderProcessor httpHeaderProcessor) |
| Modifier and Type | Method and Description |
|---|---|
protected CharSequence |
buildInsertText(TextDocument page,
javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse,
WaybackRequest wbRequest,
CaptureSearchResults results,
CaptureSearchResult result,
Resource resource)
return text to insert.
|
static Resource |
decodeResource(Resource resource) |
static Resource |
decodeResource(Resource headersResource,
Resource payloadResource)
return gzip-decoding wrapper Resource if Resource has
Content-Encoding: gzip. |
CharsetDetector |
getCharsetDetector() |
String |
getGuessedCharsetHeader() |
List<String> |
getJspInserts() |
void |
renderResource(javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse,
WaybackRequest wbRequest,
CaptureSearchResult result,
Resource httpHeadersResource,
Resource payloadResource,
ResultURIConverter uriConverter,
CaptureSearchResults results)
Generate response that replays capture archive
httpHeadersResource, reading archived content (HTTP entity) from
payloadResource. |
void |
renderResource(javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse,
WaybackRequest wbRequest,
CaptureSearchResult result,
Resource resource,
ResultURIConverter uriConverter,
CaptureSearchResults results)
Generate response that replays capture archive
resource. |
void |
setCharsetDetector(CharsetDetector charsetDetector) |
void |
setGuessedCharsetHeader(String guessedCharsetHeader) |
void |
setJspInserts(List<String> jspInserts) |
void |
setPageURIConverterFactory(ContextResultURIConverterFactory pageConverterFactory)
set
ContextResultURIConverterFactory that creates replacement
ResultURIConverter for this TextReplayRenderer. |
protected abstract void |
updatePage(TextDocument page,
javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse,
WaybackRequest wbRequest,
CaptureSearchResult result,
Resource resource,
ResultURIConverter uriConverter,
CaptureSearchResults results) |
public static String GUESSED_CHARSET_HEADER
public static String ORIG_ENCODING
public TextReplayRenderer(HttpHeaderProcessor httpHeaderProcessor)
protected abstract void updatePage(TextDocument page, javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse, WaybackRequest wbRequest, CaptureSearchResult result, Resource resource, ResultURIConverter uriConverter, CaptureSearchResults results) throws javax.servlet.ServletException, IOException
javax.servlet.ServletExceptionIOExceptionpublic void renderResource(javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse,
WaybackRequest wbRequest,
CaptureSearchResult result,
Resource resource,
ResultURIConverter uriConverter,
CaptureSearchResults results)
throws javax.servlet.ServletException,
IOException,
BadContentException
ReplayRendererresource.renderResource in interface ReplayRendererhttpRequest - the HttpServletRequesthttpResponse - the HttpServletResponsewbRequest - the WaybackRequest that returned the resultsresult - actual CaptureSearchResult that maps to resource to replayresource - resource to replayuriConverter - the URI converter to use to translate matching
results into replayable URLsresults - all CaptureSearchResults that were returned from the
ResourceIndex, probably including other capture dates of the same
URL.javax.servlet.ServletException - per usualIOException - per usualBadContentExceptionpublic void renderResource(javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse,
WaybackRequest wbRequest,
CaptureSearchResult result,
Resource httpHeadersResource,
Resource payloadResource,
ResultURIConverter uriConverter,
CaptureSearchResults results)
throws javax.servlet.ServletException,
IOException,
BadContentException
ReplayRendererhttpHeadersResource, reading archived content (HTTP entity) from
payloadResource.renderResource in interface ReplayRendererhttpRequest - the HttpServletRequesthttpResponse - the HttpServletResponsewbRequest - the WaybackRequest that returned the resultsresult - CaptureSearchResult that maps to resource to replayhttpHeadersResource - resource with HTTP headers to replay
(typically a revisit record.)payloadResource - resource with payload to replayuriConverter - the URI converter to use to translate matching
results into replayable URLsresults - all CaptureSearchResults that were returned from the
ResourceIndex, probably including other capture dates of
the same URL.javax.servlet.ServletException - per usualIOException - per usualBadContentExceptionpublic void setJspInserts(List<String> jspInserts)
jspInserts - the jspInserts to setpublic CharsetDetector getCharsetDetector()
public void setCharsetDetector(CharsetDetector charsetDetector)
charsetDetector - the charsetDetector to setpublic String getGuessedCharsetHeader()
public void setGuessedCharsetHeader(String guessedCharsetHeader)
guessedCharsetHeader - the String HTTP Header value used to indicate
to clients what Wayback determined was the pages original charset. If set
to null, the header will be omitted.public static Resource decodeResource(Resource resource) throws IOException
IOExceptionpublic static Resource decodeResource(Resource headersResource, Resource payloadResource) throws IOException
Content-Encoding: gzip.
return payloadResource otherwise.
if headerResource's content is gzip-compressed (i.e. Content-Encoding is "gzip"),
return a wrapping Resource that returns decoded content.
As a side-effect, Content-Encoding and
Transfer-Encoding headers are removed from headersResource (this happens only when
headerResoruce is gzip-compressed.). It is assumed that headerResource and
payloadResource are captures of identical response content.
TODO: XArchiveHttpHeaderProcessor also does HTTP header removal. Check for refactoring case.
headersResource - Resource to read HTTP headers from.payloadResource - Resource to read content from (same as headerResource for regular captures,
different Resource if headersResource is a revisit record.)IOExceptionpublic void setPageURIConverterFactory(ContextResultURIConverterFactory pageConverterFactory)
ContextResultURIConverterFactory that creates replacement
ResultURIConverter for this TextReplayRenderer.
If set to non-null, its getContextConverter method will be called
with replayURIPrefix. If the method returns non-null, it will be
passed to updatePage(org.archive.wayback.replay.TextDocument, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.archive.wayback.core.WaybackRequest, org.archive.wayback.core.CaptureSearchResult, org.archive.wayback.core.Resource, org.archive.wayback.ResultURIConverter, org.archive.wayback.core.CaptureSearchResults) instead of the original.pageConverterFactory - ContextResultURIConverterFactoryprotected CharSequence buildInsertText(TextDocument page, javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse, WaybackRequest wbRequest, CaptureSearchResults results, CaptureSearchResult result, Resource resource) throws IOException, javax.servlet.ServletException
jspInserts are executed in sequence, concatenating
their output.
page - for calling includeJspString methodhttpRequest - incoming requesthttpResponse - outgoing responsewbRequest - wayback request inforesults - capturesresult - capture being replayedresource - resource being replayedjspInserts
(empty if no jspInserts is configured.)IOException - error from TextDocument.includeJspString(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.archive.wayback.core.WaybackRequest, org.archive.wayback.core.CaptureSearchResults, org.archive.wayback.core.CaptureSearchResult, org.archive.wayback.core.Resource)javax.servlet.ServletException - error from TextDocument.includeJspString(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.archive.wayback.core.WaybackRequest, org.archive.wayback.core.CaptureSearchResults, org.archive.wayback.core.CaptureSearchResult, org.archive.wayback.core.Resource)Copyright © 2005–2015 IIPC. All rights reserved.