dekoh.portal.image
Class AbstractResizeImageServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
dekoh.portal.util.FileServer
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
|
| 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 |
logger
protected static final PLogger logger
AbstractResizeImageServlet
public AbstractResizeImageServlet()
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)
© 2009 Pramati Technologies - Dekoh - Portal for Developers