com.wewebu.ow.server.servlets
Class OwMultifileDownload

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.wewebu.ow.server.servlets.OwAbstractUpload
              extended by com.wewebu.ow.server.servlets.OwMultifileDownload
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class OwMultifileDownload
extends OwAbstractUpload

OwMultifileDownload Servlet provides one or several object contents for download as a zipped archive or as a single content file depending on the request and init parameters.
The OwMultifileDownload Servlet processes the request by creating an archive of folders containing content files and/or other folders. Content files rely on OwContentElements. The created archive can be zipped or served as single file (if and only if it contains a single content file).
The content archive is folder-structured , can contain multiple entries with the same name and it is modeled using OwMultifileDownload.OwContentArchiveEntry objects. The archive structure is created by the createContentArchive(List, OwMainAppContext) overridable method.

Alfresco Workdesk
Copyright (c) Alfresco Software, Inc.
All rights reserved.

For licensing information read the license.txt file or
go to: http://wiki.alfresco.com

See Also:
Serialized Form

Nested Class Summary
protected  class OwMultifileDownload.OwBufferedSingleContentEntry
          An archive entry containing a single content file.
protected static interface OwMultifileDownload.OwContentArchiveEntry
           A content archive entry.
Each entry contains 0 or more files, can be zipped on a ZipOutputStream under a specified path and can be "served" on a HttpServletResponse.
protected  class OwMultifileDownload.OwContentElementEntry
          An OwContentElement based implementation of OwMultifileDownload.OwBufferedSingleContentEntry
protected  class OwMultifileDownload.OwFolderArchiveEntry
          A folder archive entry.
 
Field Summary
static String ATTRIBUTE_NAME_FILES_TO_DOWNLOAD
           
 
Constructor Summary
OwMultifileDownload()
           
 
Method Summary
protected  void addMultiContentArchiveEntry(OwMultifileDownload.OwFolderArchiveEntry parentFolder_p, OwObject object_p)
          (overridable) Adds an OwMultifileDownload.OwContentArchiveEntry to the specified parent folder for the specified OwObject.
protected  void addSingleContentEntry(OwMultifileDownload.OwFolderArchiveEntry parentFolder_p, OwObject object_p)
          (overridable) Adds an OwMultifileDownload.OwContentArchiveEntry to the specified parent folder for the specified OwObject.
protected  String createArchivedContentFileName(String defaultName_p, OwContentElement element_p)
          (overridable) Creates file names for OwContentElement based folder archive entries
protected  String createArchivedObjectFolderName(String objectName_p)
          (overridable) Creates folder names for OwObject based folder archive entries
protected  OwMultifileDownload.OwFolderArchiveEntry createContentArchive(List<OwObject> objectsToZip_p, OwMainAppContext context_p)
          (overridable) Creates the archive that will be served by processRequest(HttpServletRequest, HttpServletResponse)
 String getServletInfo()
          Returns a short description of the servlet.
 void init(javax.servlet.ServletConfig config_p)
          Initializes the servlet.
protected  void processRequest(javax.servlet.http.HttpServletRequest request_p, javax.servlet.http.HttpServletResponse response_p)
          Processes requests for both HTTP GET and POST methods.
 
Methods inherited from class com.wewebu.ow.server.servlets.OwAbstractUpload
createFileName, doGet, doPost
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, 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

ATTRIBUTE_NAME_FILES_TO_DOWNLOAD

public static final String ATTRIBUTE_NAME_FILES_TO_DOWNLOAD
See Also:
Constant Field Values
Constructor Detail

OwMultifileDownload

public OwMultifileDownload()
Method Detail

getServletInfo

public String getServletInfo()
Returns a short description of the servlet.

Specified by:
getServletInfo in interface javax.servlet.Servlet
Overrides:
getServletInfo in class javax.servlet.GenericServlet

init

public void init(javax.servlet.ServletConfig config_p)
          throws javax.servlet.ServletException
Initializes the servlet.

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException

createArchivedObjectFolderName

protected String createArchivedObjectFolderName(String objectName_p)
(overridable) Creates folder names for OwObject based folder archive entries

Parameters:
objectName_p - the name of the object who's content folder is archived
Returns:
the folder name

createArchivedContentFileName

protected String createArchivedContentFileName(String defaultName_p,
                                               OwContentElement element_p)
(overridable) Creates file names for OwContentElement based folder archive entries

Parameters:
defaultName_p - file name prefix to be used if no name can be acquired through OwContentElement's MIME parameter
element_p - the content element for which the name is generated
Returns:
the name of the file content element archive file

createContentArchive

protected OwMultifileDownload.OwFolderArchiveEntry createContentArchive(List<OwObject> objectsToZip_p,
                                                                        OwMainAppContext context_p)
                                                                 throws IOException
(overridable) Creates the archive that will be served by processRequest(HttpServletRequest, HttpServletResponse)

Parameters:
objectsToZip_p - the objects that provide content for the returned archive
context_p -
Returns:
a content archive folder
Throws:
IOException

addSingleContentEntry

protected void addSingleContentEntry(OwMultifileDownload.OwFolderArchiveEntry parentFolder_p,
                                     OwObject object_p)
                              throws Exception
(overridable) Adds an OwMultifileDownload.OwContentArchiveEntry to the specified parent folder for the specified OwObject. It is assumed that the passed OwObject contains a single OwContentElement in its OwContentCollection.

Parameters:
parentFolder_p - the folder to add single content entry to
object_p - single content object
Throws:
Exception

addMultiContentArchiveEntry

protected void addMultiContentArchiveEntry(OwMultifileDownload.OwFolderArchiveEntry parentFolder_p,
                                           OwObject object_p)
                                    throws Exception
(overridable) Adds an OwMultifileDownload.OwContentArchiveEntry to the specified parent folder for the specified OwObject. It is assumed that the passed OwObject contains more than one OwContentElements in its OwContentCollection.

Parameters:
parentFolder_p - the folder to add the multiple content entry to
object_p - a multiple content object
Throws:
Exception

processRequest

protected void processRequest(javax.servlet.http.HttpServletRequest request_p,
                              javax.servlet.http.HttpServletResponse response_p)
                       throws javax.servlet.ServletException,
                              IOException
Processes requests for both HTTP GET and POST methods. Creates an archive via createContentArchive(List, OwMainAppContext) and serializes it to the HttpServletResponse parameter.

Specified by:
processRequest in class OwAbstractUpload
Parameters:
request_p - servlet request
response_p - servlet response
Throws:
javax.servlet.ServletException
IOException


Copyright © 2013 Alfresco Business Solutions. All Rights Reserved.