org.hd.d.pg2k.webSvr.exhibit
Class ThumbnailServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.hd.d.pg2k.webSvr.exhibit.ThumbnailServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public final class ThumbnailServlet
extends javax.servlet.http.HttpServlet

This is the servlet that serves thumbnail data. This is optimised to serve medium quantities of binary data efficiently, and to get headers right to optimise performance of caches, spiders, etc, while not losing site of usage logging.

See Also:
Serialized Form

Field Summary
private static boolean SEND_TN_MD5
          If true then we may generate/send the MD5 content hash for some/all thumbnails.
private static long serialVersionUID
          Unique Serialisation class ID generated by http://random.hd.org/.
 
Constructor Summary
ThumbnailServlet()
           
 
Method Summary
 void doAction(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Respond to a GET/HEAD request for the content served by this servlet.
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Respond to a GET request for the content served by this servlet.
 void doHead(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Respond to a HEAD request for the content served by this servlet.
private static DataSourceBean getDataSource(javax.servlet.ServletConfig config, javax.servlet.http.HttpServletRequest request)
          Get singleton (per-servlet-context) data pipeline/cache instance.
 long getLastModified(javax.servlet.http.HttpServletRequest request)
          Get `last-modified' time for a thumbnail, or -1 if not available.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doOptions, doPost, doPut, doTrace, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEND_TN_MD5

private static final boolean SEND_TN_MD5
If true then we may generate/send the MD5 content hash for some/all thumbnails.

See Also:
Constant Field Values

serialVersionUID

private static final long serialVersionUID
Unique Serialisation class ID generated by http://random.hd.org/.

See Also:
Constant Field Values
Constructor Detail

ThumbnailServlet

public ThumbnailServlet()
Method Detail

getDataSource

private static DataSourceBean getDataSource(javax.servlet.ServletConfig config,
                                            javax.servlet.http.HttpServletRequest request)
Get singleton (per-servlet-context) data pipeline/cache instance. The config param must not be null, but for some operations (such as calling destroy()) request can be null.


doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
Respond to a GET request for the content served by this servlet.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
request - The servlet request we are processing
response - The servlet response we are producing

doHead

public void doHead(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
Respond to a HEAD request for the content served by this servlet.

Overrides:
doHead in class javax.servlet.http.HttpServlet
Parameters:
request - The servlet request we are processing
response - The servlet response we are producing

doAction

public void doAction(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response)
Respond to a GET/HEAD request for the content served by this servlet. Returns the exhibit data, with a correct MIME type.

The request path is of the form /XXX/exhibitname where XXX identifies the required thumbnail/sample size (small or standard).

If an exhibit is requested by a syntactically-invalid name, we produce an HTTP `forbidden' (403) response.

If we request an exhibit with a valid name, but that does not exist, return return a `not-found' (404) response (unless there are no exhibits available, perhaps because of a database problem, in which case we may return `service unavailable' in the hope that that will prevent search engines from purging our exhibits if they happen to visit when we are reloading the database).

We refuse to deal with some dubious requests (eg apparently hotlinks directly to our exhibits from external sites) if we are too busy, so as to conserve resources for bona fide users. Dubious requests are rejected with a temporary failure (5xx) code.

TODO:

Parameters:
request - The servlet request we are processing
response - The servlet response we are producing

getLastModified

public final long getLastModified(javax.servlet.http.HttpServletRequest request)
Get `last-modified' time for a thumbnail, or -1 if not available. If we can find any thumbnails for the exhibit implied, and those thumbnails have a creation timestamp (older ones may not) then we return that as our last-modified date.

In case of any difficulty we return the -1 "not-known" value.

Overrides:
getLastModified in class javax.servlet.http.HttpServlet
Parameters:
request - The servlet request being processed

DHD Multimedia Gallery V1.57.21

Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.