org.alfresco.web.app.servlet
Class GuestDownloadContentServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.alfresco.web.app.servlet.BaseServlet
              extended by org.alfresco.web.app.servlet.BaseDownloadContentServlet
                  extended by org.alfresco.web.app.servlet.GuestDownloadContentServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class GuestDownloadContentServlet
extends BaseDownloadContentServlet

Servlet responsible for streaming node content from the repo directly to the response stream. The appropriate mimetype is calculated based on filename extension.

The URL to the servlet should be generated thus:

/alfresco/guestDownload/attach/workspace/SpacesStore/0000-0000-0000-0000/myfile.pdf
or
/alfresco/guestDownload/direct/workspace/SpacesStore/0000-0000-0000-0000/myfile.pdf
or
/alfresco/guestDownload/[direct|attach]?path=/Company%20Home/MyFolder/myfile.pdf
The protocol, followed by either the store and Id (NodeRef) or instead specify a name based encoded Path to the content, note that the filename element is used for mimetype lookup and as the returning filename for the response stream.

The 'attach' or 'direct' element is used to indicate whether to display the stream directly in the browser or download it as a file attachment.

By default, the download assumes that the content is on the content property.
To retrieve the content of a specific model property, use a 'property' arg, providing the workspace, node ID AND the qualified name of the property.

This servlet only accesses content available to the guest user. If the guest user does not have access to the requested a 403 Forbidden response is returned to the caller.

This servlet does not effect the current session, therefore if guest access is required to a resource this servlet can be used without logging out the current user.

See Also:
Serialized Form

Nested Class Summary
 class GuestDownloadContentServlet.DownloadContentWork
          Class to wrap the call to processDownloadRequest.
 
Nested classes/interfaces inherited from class org.alfresco.web.app.servlet.BaseServlet
BaseServlet.PathRefInfo
 
Field Summary
 
Fields inherited from class org.alfresco.web.app.servlet.BaseDownloadContentServlet
ARG_PATH, ARG_PROPERTY, MIMETYPE_OCTET_STREAM, MSG_ERROR_CONTENT_MISSING, MSG_ERROR_NOT_FOUND, URL_ATTACH, URL_ATTACH_LONG, URL_DIRECT, URL_DIRECT_LONG
 
Fields inherited from class org.alfresco.web.app.servlet.BaseServlet
FACES_SERVLET, KEY_ROOT_PATH, KEY_STORE
 
Constructor Summary
GuestDownloadContentServlet()
           
 
Method Summary
protected  void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           
static java.lang.String generateBrowserURL(org.alfresco.service.cmr.repository.NodeRef ref, java.lang.String name)
          Helper to generate a URL to a content node for downloading content from the server.
static java.lang.String generateDownloadURL(org.alfresco.service.cmr.repository.NodeRef ref, java.lang.String name)
          Helper to generate a URL to a content node for downloading content from the server.
protected  org.apache.commons.logging.Log getLogger()
          Gets the logger to use for this request.
 
Methods inherited from class org.alfresco.web.app.servlet.BaseDownloadContentServlet
generateUrl, processDownloadRequest
 
Methods inherited from class org.alfresco.web.app.servlet.BaseServlet
checkAccess, getServiceRegistry, redirectToLoginPage, resolveNamePath, resolveWebDAVPath, resolveWebDAVPath, resolveWebDAVPath, resolveWebDAVPath, servletAuthenticate, servletAuthenticate, setNoCacheHeaders, validRedirectJSP
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, 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
 

Constructor Detail

GuestDownloadContentServlet

public GuestDownloadContentServlet()
Method Detail

getLogger

protected org.apache.commons.logging.Log getLogger()
Description copied from class: BaseDownloadContentServlet
Gets the logger to use for this request.

This will show all debug entries from this class as though they came from the subclass.

Specified by:
getLogger in class BaseDownloadContentServlet
Returns:
The logger

doGet

protected void doGet(javax.servlet.http.HttpServletRequest req,
                     javax.servlet.http.HttpServletResponse res)
              throws javax.servlet.ServletException,
                     java.io.IOException
Overrides:
doGet in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
java.io.IOException
See Also:
HttpServlet.doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

generateDownloadURL

public static final java.lang.String generateDownloadURL(org.alfresco.service.cmr.repository.NodeRef ref,
                                                         java.lang.String name)
Helper to generate a URL to a content node for downloading content from the server. The content is supplied as an HTTP1.1 attachment to the response. This generally means a browser should prompt the user to save the content to specified location.

Parameters:
ref - NodeRef of the content node to generate URL for (cannot be null)
name - File name to return in the URL (cannot be null)
Returns:
URL to download the content from the specified node

generateBrowserURL

public static final java.lang.String generateBrowserURL(org.alfresco.service.cmr.repository.NodeRef ref,
                                                        java.lang.String name)
Helper to generate a URL to a content node for downloading content from the server. The content is supplied directly in the reponse. This generally means a browser will attempt to open the content directly if possible, else it will prompt to save the file.

Parameters:
ref - NodeRef of the content node to generate URL for (cannot be null)
name - File name to return in the URL (cannot be null)
Returns:
URL to download the content from the specified node


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.