org.mmbase.servlet
Class HandleServlet

Package class diagram package HandleServlet
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
All Implemented Interfaces:
Serializable, Servlet, ServletConfig, MMBaseStarter
Direct Known Subclasses:
AttachmentServlet, ImageServlet

public class HandleServlet
extends BridgeServlet

Base servlet for nodes with a 'handle' field. It serves as a basic implementation for more specialized servlets. The mime-type is always application/x-binary, forcing the browser to download.

Since:
MMBase-1.6
Version:
$Id: HandleServlet.java 44572 2011-01-06 08:56:39Z michiel $
Author:
Michiel Meeuwissen
See Also:
ImageServlet, AttachmentServlet, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.mmbase.servlet.BridgeServlet
BridgeServlet.QueryParts
 
Field Summary
protected static Pattern 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
HandleServlet()
           
 
Method Summary
 void doGet(HttpServletRequest req, HttpServletResponse res)
          Serves a node with a byte[] handle field as an attachment.
protected  Map<String,Integer> getAssociations()
           
protected  Cloud getClassCloud()
           
protected  String getContentDisposition(BridgeServlet.QueryParts query, Node node, String def)
           
protected  String getFileName(Node node, Node titleNode, String def)
           
protected  String getMimeType(Node node)
          Forces download in browsers.
protected  long getSize(NodeManager manager, Node node)
           
 void init()
          Takes care of the 'expire' init-parameter.
static void main(String[] argv)
           
protected  void sendBytes(HttpServletResponse res, byte[] bytes)
          Deprecated.  
protected  void sendBytes(HttpServletResponse res, InputStream bytes)
           
protected  boolean setCacheControl(HttpServletResponse res, Node node)
          Sets cache-controlling headers.
protected  boolean setContent(BridgeServlet.QueryParts query, Node node, String mimeType)
          Sets the content disposition header.
protected  boolean setExpires(HttpServletResponse res, Node node)
          Sets the exires header.
 
Methods inherited from class org.mmbase.servlet.BridgeServlet
, desperatelyGetNode, findCloud, getAnonymousCloud, getCloud, getCloudName, getLastModified, getNode, getServedNode, readQuery, readQuery, readQueryFromRequestURI, readServletPath
 
Methods inherited from class org.mmbase.servlet.MMBaseServlet
associateMapping, checkInited, decRefCount, destroy, getBasePath, getMMBase, getRequestURL, getServletByAssociation, getServletByMapping, getServletInfo, 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
 

Field Detail

legalizeFileName

protected static final Pattern legalizeFileName
Constructor Detail

HandleServlet

public HandleServlet()
Method Detail

getAssociations

protected Map<String,Integer> getAssociations()
Overrides:
getAssociations in class MMBaseServlet

init

public void init()
          throws ServletException
Takes care of the 'expire' init-parameter.

Overrides:
init in class BridgeServlet
Throws:
ServletException

getClassCloud

protected Cloud getClassCloud()
Overrides:
getClassCloud in class BridgeServlet

getMimeType

protected String getMimeType(Node node)
Forces download in browsers. This is overriden in several extensions.


getFileName

protected String getFileName(Node node,
                             Node titleNode,
                             String def)
Since:
MMBase-1.8

getContentDisposition

protected String getContentDisposition(BridgeServlet.QueryParts query,
                                       Node node,
                                       String def)
Since:
MMBase-1.9

setContent

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

Returns:
true on success
Throws:
IOException

setExpires

protected boolean setExpires(HttpServletResponse res,
                             Node node)
Sets the exires header.

Returns:
true on sucess

setCacheControl

protected boolean setCacheControl(HttpServletResponse res,
                                  Node node)
Sets cache-controlling headers. Only nodes which are to be served to 'anonymous' might be (front proxy) cached. To other nodes there might be read restrictions, so they should not be stored in front-proxy caches.

Returns:
true if cacheing is disabled.
Since:
MMBase-1.7

getSize

protected long getSize(NodeManager manager,
                       Node node)

doGet

public void doGet(HttpServletRequest req,
                  HttpServletResponse res)
           throws ServletException,
                  IOException
Serves a node with a byte[] handle field as an attachment.

Overrides:
doGet in class MMBaseServlet
Throws:
ServletException
IOException

sendBytes

protected final void sendBytes(HttpServletResponse res,
                               byte[] bytes)
                        throws IOException
Deprecated. 

Utility function to send bytes at the end of doGet implementation.

Throws:
IOException

sendBytes

protected final void sendBytes(HttpServletResponse res,
                               InputStream bytes)
                        throws IOException
Throws:
IOException

main

public static void main(String[] argv)


MMBase2 Resources 2.0-SNAPSHOT - 2013-03-30T06:37