Dekoh platform API

dekoh.portal.image
Class AbstractResizeImageServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by dekoh.portal.util.FileServer
              extended by dekoh.portal.image.AbstractResizeImageServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig

public abstract class AbstractResizeImageServlet
extends FileServer

Many DigitalObjects may have a photo file to identify them. A Music Album has Covert Art image, A Book has a cover page image etc. Applications dealing with digital objects whose preview may include a resized image can extends this servlet.

This Servlet works off a directory where images once resized are cached. Subsequent HTTP requests to get the resized images are served from this cache unless the SourceFile is modified.

This servlet also overrides FileServer.getLastModified(javax.servlet.http.HttpServletRequest) to optimize network badwidth when the cached image file is not updated since previous get request from the same User-Agent.

Note : It is advisable that the servlets extending this class be loadeded on startup.

Since:
Jun 22, 2007
See Also:
ResizeImageCache, ImageResizer.DEFAULT_COMPRESSION_QUALITY, Serialized Form

Field Summary
protected static PLogger logger
           
 
Fields inherited from class dekoh.portal.util.FileServer
FILE_EXT_HEADER, FILE_TO_SERVE, UNKNOWN
 
Constructor Summary
AbstractResizeImageServlet()
           
 
Method Summary
protected abstract  DigitalObject getAccessingDigitalObject(HttpServletRequest request, int id)
           
protected  File getCacheDir(ServletContext servletContext)
          Will point to public_html/${applicationContextRoot}/WEB-INF/cache.
protected  EXIFOrientation getEXIFOrientation(DigitalObject digitalObject)
          Some photos may be better viewed when oriented in a perticulat direction, for such pictures resized image should also be oriented in same direction as the original image.
protected  File getRequestedFile(HttpServletRequest request)
          Serves the resource requested in FileServer.doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) or FileServer.doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) method of this servlet.
protected  ResizeImageCache getResizeImageCache(HttpServletRequest request)
           
protected abstract  File getSourceImageFile(DigitalObject digitalObject)
           
protected  File resize(HttpServletRequest request)
           
protected  ImageSize resizeToWhat(HttpServletRequest request)
           
protected  int resizeWhat(HttpServletRequest request)
           
 
Methods inherited from class dekoh.portal.util.FileServer
authorizedToAccessCachedCopy, copyStream, doGet, doPost, getLastModified, handleExceptionInLastModified, serveRequestedFile
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, 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

logger

protected static final PLogger logger
Constructor Detail

AbstractResizeImageServlet

public AbstractResizeImageServlet()
Method Detail

getCacheDir

protected File getCacheDir(ServletContext servletContext)
Will point to public_html/${applicationContextRoot}/WEB-INF/cache. Once initialized this variable never changes.


getAccessingDigitalObject

protected abstract DigitalObject getAccessingDigitalObject(HttpServletRequest request,
                                                           int id)

getSourceImageFile

protected abstract File getSourceImageFile(DigitalObject digitalObject)
                                    throws IOException
Throws:
IOException

getRequestedFile

protected final File getRequestedFile(HttpServletRequest request)
                               throws IOException
Description copied from class: FileServer
Serves the resource requested in FileServer.doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) or FileServer.doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) method of this servlet. Bytes of this file will be written to output stream of the HttpServletResponse.

Specified by:
getRequestedFile in class FileServer
Parameters:
request - - HttpServletRequest
Returns:
File if the return value is null or a File that does not exist on disc, a 404/Page not found response will be sent.
Throws:
IOException - throws when could not create the requried file

resize

protected File resize(HttpServletRequest request)
               throws IOException
Throws:
IOException

getResizeImageCache

protected ResizeImageCache getResizeImageCache(HttpServletRequest request)

getEXIFOrientation

protected EXIFOrientation getEXIFOrientation(DigitalObject digitalObject)
Some photos may be better viewed when oriented in a perticulat direction, for such pictures resized image should also be oriented in same direction as the original image.

Override this method if this information can be learnt from the digitalObject.

Parameters:
digitalObject -
Returns:
default value, indicating Top left

resizeWhat

protected int resizeWhat(HttpServletRequest request)

resizeToWhat

protected ImageSize resizeToWhat(HttpServletRequest request)

Dekoh platform API

© 2009 Pramati Technologies - Dekoh - Portal for Developers