org.mmbase.servlet
Class ImageServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.mmbase.servlet.MMBaseServlet
              extended by org.mmbase.servlet.BridgeServlet
                  extended by org.mmbase.servlet.HandleServlet
                      extended by org.mmbase.servlet.ImageServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig, MMBaseStarter

public class ImageServlet
extends HandleServlet

ImageServlet handles nodes as images. If you want to convert an image (resize it, turn it, change its colors etc) then you want to serve an 'icaches' node ('icaches' are cached conversions of images), which you have to create yourself before calling this servlet. The cache() function of Images can be used for this. An URL can be gotten with cachepath().

Since:
MMBase-1.6
Version:
$Id: ImageServlet.java 40474 2010-01-11 17:35:36Z michiel $
Author:
Michiel Meeuwissen
See Also:
AbstractImages, Images.executeFunction(org.mmbase.module.core.MMObjectNode, java.lang.String, java.util.List), AttachmentServlet, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.mmbase.servlet.BridgeServlet
BridgeServlet.QueryParts
 
Field Summary
 
Fields inherited from class org.mmbase.servlet.HandleServlet
legalizeFileName
 
Fields inherited from class org.mmbase.servlet.BridgeServlet
FILE_PATTERN, MESSAGE_ATTRIBUTE
 
Fields inherited from class org.mmbase.servlet.MMBaseServlet
mmbase, retryAfter
 
Constructor Summary
ImageServlet()
           
 
Method Summary
protected  Node desperatelyGetNode(Cloud cloud, String nodeIdentifier)
          Overridden to support 'title aliases'.
protected  Map<String,Integer> getAssociations()
          On default, servlets are not associated with any function.
protected  Cloud getClassCloud()
          Obtains a cloud using 'class' security.
protected  String getMimeType(Node node)
          Forces download in browsers.
protected  Node getServedNode(BridgeServlet.QueryParts query, Node node)
          ImageServlet can serve a icache node in stead (using the 'extra parameters)'
 String getServletInfo()
          Returns information about this servlet.
 void init()
          Takes care of the 'expire' init-parameter.
protected  boolean setContent(BridgeServlet.QueryParts query, Node node, String mimeType)
          Content-Disposition header Sets the content disposition header.
 
Methods inherited from class org.mmbase.servlet.HandleServlet
doGet, getContentDisposition, getFileName, getSize, main, sendBytes, sendBytes, setCacheControl, setExpires
 
Methods inherited from class org.mmbase.servlet.BridgeServlet
findCloud, getAnonymousCloud, getCloud, getCloudName, getLastModified, getNode, readQuery, readQuery, readQueryFromRequestURI, readServletPath
 
Methods inherited from class org.mmbase.servlet.MMBaseServlet
associateMapping, checkInited, decRefCount, destroy, getBasePath, getMMBase, getRequestURL, getServletByAssociation, getServletByMapping, getServletMappings, getServletMappingsByAssociation, incRefCount, service, setInitException, setMMBase
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageServlet

public ImageServlet()
Method Detail

init

public void init()
          throws ServletException
Description copied from class: HandleServlet
Takes care of the 'expire' init-parameter. Inits lastmodifiedField. The init of an MMBaseServlet checks if MMBase is running. It not then it is started.

Overrides:
init in class HandleServlet
Throws:
ServletException

getClassCloud

protected final Cloud getClassCloud()
Description copied from class: BridgeServlet
Obtains a cloud using 'class' security. If e.g. you authorize org.mmbase.servlet.ImageServlet by class-security for read all rights, it will be used.

Overrides:
getClassCloud in class HandleServlet

getServletInfo

public String getServletInfo()
Description copied from class: MMBaseServlet
Returns information about this servlet. Don't forget to override it.

Specified by:
getServletInfo in interface Servlet
Overrides:
getServletInfo in class MMBaseServlet

getAssociations

protected Map<String,Integer> getAssociations()
Description copied from class: MMBaseServlet
On default, servlets are not associated with any function. This function is called in the init method.

Overrides:
getAssociations in class HandleServlet
Returns:
A map of Strings (function) -> Integer (priority). Never null.

getMimeType

protected String getMimeType(Node node)
Description copied from class: HandleServlet
Forces download in browsers. This is overriden in several extensions.

Overrides:
getMimeType in class HandleServlet

setContent

protected boolean setContent(BridgeServlet.QueryParts query,
                             Node node,
                             String mimeType)
                      throws IOException
Content-Disposition header Sets the content disposition header.

Overrides:
setContent in class HandleServlet
Returns:
true on success
Throws:
IOException

getServedNode

protected Node getServedNode(BridgeServlet.QueryParts query,
                             Node node)
                      throws IOException
ImageServlet can serve a icache node in stead (using the 'extra parameters)'

Overrides:
getServedNode in class BridgeServlet
Parameters:
query - A QueryParts object, which you must have obtained by BridgeServlet.readQuery(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
node - The node which is specified on the URL (obtained by BridgeServlet.getNode(org.mmbase.servlet.BridgeServlet.QueryParts)
Throws:
IOException
Since:
MMBase-1.7.4

desperatelyGetNode

protected Node desperatelyGetNode(Cloud cloud,
                                  String nodeIdentifier)
Overridden to support 'title aliases'.

Overrides:
desperatelyGetNode in class BridgeServlet
Since:
MMBase-1.7.5


MMBase 2.0-SNAPSHOT - null