Class AbstractDownloadArchiveAction

java.lang.Object
org.alfresco.repo.action.CommonResourceAbstractBase
org.alfresco.repo.action.ParameterizedItemAbstractBase
org.alfresco.repo.action.executer.ActionExecuterAbstractBase
fr.becpg.repo.download.AbstractDownloadArchiveAction
All Implemented Interfaces:
org.alfresco.repo.action.executer.ActionExecuter, org.alfresco.repo.action.executer.LoggingAwareExecuter, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware
Direct Known Subclasses:
AbstractExportSearchAction, BeCPGCreateDownloadArchiveAction, ZipSearchAction

public abstract class AbstractDownloadArchiveAction extends org.alfresco.repo.action.executer.ActionExecuterAbstractBase
Base class for the actions building a download archive from a set of nodes. It owns everything the download protocol requires - crawler setup, status publication, content update and failure handling - so that each action only describes what it exports.
Version:
$Id: $Id
Author:
matthieu
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.alfresco.service.cmr.repository.ContentService
     
    protected org.alfresco.repo.download.ContentServiceHelper
     
    protected static final String
    Constant CREATION_ERROR="Unexpected error creating file for download"
    protected org.alfresco.repo.download.DownloadStorage
     
    protected org.alfresco.service.cmr.view.ExporterService
     
    private static final org.apache.commons.logging.Log
     
    protected org.alfresco.service.cmr.repository.MimetypeService
     
    protected org.alfresco.service.cmr.repository.NodeService
     
    protected org.alfresco.repo.transaction.RetryingTransactionHelper
     
    protected org.alfresco.repo.download.DownloadStatusUpdateService
     

    Fields inherited from class org.alfresco.repo.action.executer.ActionExecuterAbstractBase

    actionAccessRestrictions, actionDefinition, applicableTypes, publicAction

    Fields inherited from class org.alfresco.repo.action.ParameterizedItemAbstractBase

    adhocPropertiesAllowed, DISPLAY_LABEL, runtimeActionService

    Fields inherited from class org.alfresco.repo.action.CommonResourceAbstractBase

    name

    Fields inherited from interface org.alfresco.repo.action.executer.ActionExecuter

    PARAM_RESULT
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    applyMimetype(org.alfresco.service.cmr.repository.NodeRef downloadNodeRef, String extension)
     
    protected void
    completeDownload(org.alfresco.service.cmr.repository.NodeRef downloadNodeRef, File tempFile, DownloadProgressReporter reporter)
    Attach the produced file to the download node and mark it as done.
    protected boolean
    completeIfEmpty(org.alfresco.service.cmr.repository.NodeRef downloadNodeRef, org.alfresco.service.cmr.repository.NodeRef[] nodeRefs)
    Publish a terminal status when there is nothing to export.
    protected org.alfresco.service.cmr.view.ExporterCrawlerParameters
    createCrawlerParameters(org.alfresco.service.cmr.repository.NodeRef[] nodeRefs)
    Build the crawler parameters used to walk the requested nodes without their children, their associations nor their content.
    private void
    deleteTempFile(File tempFile)
     
    protected org.alfresco.service.cmr.repository.NodeRef[]
    getNodeRefsToExport(org.alfresco.service.cmr.repository.NodeRef downloadNodeRef, org.alfresco.service.cmr.download.DownloadRequest downloadRequest)
    The nodes to export: those stored on the download node itself, falling back on the associations of the download request when it carries none.
    protected void
    maximumContentSizeExceeded(org.alfresco.service.cmr.repository.NodeRef downloadNodeRef, long maximumContentSize, long size, long fileCount)
    Publish the status telling the client that the requested content is too large to be downloaded.
    protected void
    publishStatus(org.alfresco.service.cmr.repository.NodeRef downloadNodeRef, org.alfresco.service.cmr.download.DownloadStatus status, int sequenceNumber)
    Publish a status on the download node, in its own transaction.
    protected void
    runExport(org.alfresco.service.cmr.repository.NodeRef downloadNodeRef, Runnable exportTask, DownloadProgressReporter reporter, File tempFile)
    Run the given export task and publish the resulting status, whatever the outcome.
    protected <T extends org.alfresco.service.cmr.view.Exporter & DownloadProgressReporter>
    void
    runExport(org.alfresco.service.cmr.repository.NodeRef downloadNodeRef, org.alfresco.service.cmr.view.ExporterCrawlerParameters crawlerParameters, T handler, File tempFile)
    Run the export and publish the resulting status, whatever the outcome.
    void
    setContentService(org.alfresco.service.cmr.repository.ContentService contentService)
    Setter for the field contentService.
    void
    setContentServiceHelper(org.alfresco.repo.download.ContentServiceHelper contentServiceHelper)
    Setter for the field contentServiceHelper.
    void
    setDownloadStorage(org.alfresco.repo.download.DownloadStorage downloadStorage)
    Setter for the field downloadStorage.
    void
    setExporterService(org.alfresco.service.cmr.view.ExporterService exporterService)
    Setter for the field exporterService.
    void
    setMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)
    Setter for the field mimetypeService.
    void
    setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
    Setter for the field nodeService.
    void
    setTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper transactionHelper)
    Setter for the field transactionHelper.
    void
    setUpdateService(org.alfresco.repo.download.DownloadStatusUpdateService updateService)
    Setter for the field updateService.

    Methods inherited from class org.alfresco.repo.action.executer.ActionExecuterAbstractBase

    createActionDefinition, execute, executeImpl, getActionAccessRestrictions, getActionDefinition, getIgnoreLock, getQueueName, getTrackStatus, init, isApplicableType, onLogException, setActionAccessRestrictions, setApplicableTypes, setBaseNodeService, setDictionaryService, setIgnoreLock, setLockService, setMlAwareNodeService, setPublicAction, setQueueName, setTrackStatus, verifyActionAccessRestrictions

    Methods inherited from class org.alfresco.repo.action.ParameterizedItemAbstractBase

    addParameterDefinitions, checkMandatoryProperties, getAdhocPropertiesAllowed, getDescriptionKey, getLocalizedParameterDefinitions, getParamDisplayLabel, getParamDisplayLabel, getParameterDefintions, getTitleKey, setAdhocPropertiesAllowed, setLocales, setRuntimeActionService, toString

    Methods inherited from class org.alfresco.repo.action.CommonResourceAbstractBase

    setBeanName

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.alfresco.repo.action.executer.ActionExecuter

    isExecuteAsynchronously
  • Field Details

    • CREATION_ERROR

      protected static final String CREATION_ERROR
      Constant CREATION_ERROR="Unexpected error creating file for download"
      See Also:
    • logger

      private static final org.apache.commons.logging.Log logger
    • nodeService

      protected org.alfresco.service.cmr.repository.NodeService nodeService
    • contentServiceHelper

      protected org.alfresco.repo.download.ContentServiceHelper contentServiceHelper
    • downloadStorage

      protected org.alfresco.repo.download.DownloadStorage downloadStorage
    • exporterService

      protected org.alfresco.service.cmr.view.ExporterService exporterService
    • transactionHelper

      protected org.alfresco.repo.transaction.RetryingTransactionHelper transactionHelper
    • updateService

      protected org.alfresco.repo.download.DownloadStatusUpdateService updateService
    • mimetypeService

      protected org.alfresco.service.cmr.repository.MimetypeService mimetypeService
    • contentService

      protected org.alfresco.service.cmr.repository.ContentService contentService
  • Constructor Details

    • AbstractDownloadArchiveAction

      public AbstractDownloadArchiveAction()
  • Method Details

    • setContentService

      public void setContentService(org.alfresco.service.cmr.repository.ContentService contentService)

      Setter for the field contentService.

      Parameters:
      contentService - a ContentService object
    • setMimetypeService

      public void setMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)

      Setter for the field mimetypeService.

      Parameters:
      mimetypeService - a MimetypeService object
    • setNodeService

      public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)

      Setter for the field nodeService.

      Parameters:
      nodeService - a NodeService object
    • setContentServiceHelper

      public void setContentServiceHelper(org.alfresco.repo.download.ContentServiceHelper contentServiceHelper)

      Setter for the field contentServiceHelper.

      Parameters:
      contentServiceHelper - a ContentServiceHelper object
    • setDownloadStorage

      public void setDownloadStorage(org.alfresco.repo.download.DownloadStorage downloadStorage)

      Setter for the field downloadStorage.

      Parameters:
      downloadStorage - a DownloadStorage object
    • setExporterService

      public void setExporterService(org.alfresco.service.cmr.view.ExporterService exporterService)

      Setter for the field exporterService.

      Parameters:
      exporterService - a ExporterService object
    • setTransactionHelper

      public void setTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper transactionHelper)

      Setter for the field transactionHelper.

      Parameters:
      transactionHelper - a RetryingTransactionHelper object
    • setUpdateService

      public void setUpdateService(org.alfresco.repo.download.DownloadStatusUpdateService updateService)

      Setter for the field updateService.

      Parameters:
      updateService - a DownloadStatusUpdateService object
    • createCrawlerParameters

      protected org.alfresco.service.cmr.view.ExporterCrawlerParameters createCrawlerParameters(org.alfresco.service.cmr.repository.NodeRef[] nodeRefs)
      Build the crawler parameters used to walk the requested nodes without their children, their associations nor their content.
      Parameters:
      nodeRefs - an array of NodeRef objects
      Returns:
      a ExporterCrawlerParameters object
    • completeIfEmpty

      protected boolean completeIfEmpty(org.alfresco.service.cmr.repository.NodeRef downloadNodeRef, org.alfresco.service.cmr.repository.NodeRef[] nodeRefs)
      Publish a terminal status when there is nothing to export.
      Parameters:
      downloadNodeRef - a NodeRef object
      nodeRefs - an array of NodeRef objects
      Returns:
      true when the request was empty and has been completed
    • runExport

      protected <T extends org.alfresco.service.cmr.view.Exporter & DownloadProgressReporter> void runExport(org.alfresco.service.cmr.repository.NodeRef downloadNodeRef, org.alfresco.service.cmr.view.ExporterCrawlerParameters crawlerParameters, T handler, File tempFile)
      Run the export and publish the resulting status, whatever the outcome. A failure leaves the download node in a terminal state: without it the client polls a status that never changes and the user waits for a file that will never come.
      Type Parameters:
      T - the exporter type, reporting its own progress
      Parameters:
      downloadNodeRef - a NodeRef object
      crawlerParameters - a ExporterCrawlerParameters object
      handler - the exporter building the archive
      tempFile - a File object
    • runExport

      protected void runExport(org.alfresco.service.cmr.repository.NodeRef downloadNodeRef, Runnable exportTask, DownloadProgressReporter reporter, File tempFile)
      Run the given export task and publish the resulting status, whatever the outcome. A retryable failure is rethrown so that the transaction can be replayed: reporting a transient collision as a cancelled download would lose the archive for good.
      Parameters:
      downloadNodeRef - a NodeRef object
      exportTask - the task producing the archive
      reporter - a DownloadProgressReporter object
      tempFile - a File object
    • completeDownload

      protected void completeDownload(org.alfresco.service.cmr.repository.NodeRef downloadNodeRef, File tempFile, DownloadProgressReporter reporter)
      Attach the produced file to the download node and mark it as done.
      Parameters:
      downloadNodeRef - a NodeRef object
      tempFile - a File object
      reporter - a DownloadProgressReporter object
    • applyMimetype

      private void applyMimetype(org.alfresco.service.cmr.repository.NodeRef downloadNodeRef, String extension)
    • publishStatus

      protected void publishStatus(org.alfresco.service.cmr.repository.NodeRef downloadNodeRef, org.alfresco.service.cmr.download.DownloadStatus status, int sequenceNumber)
      Publish a status on the download node, in its own transaction.
      Parameters:
      downloadNodeRef - a NodeRef object
      status - a DownloadStatus object
      sequenceNumber - the sequence number of the status update
    • maximumContentSizeExceeded

      protected void maximumContentSizeExceeded(org.alfresco.service.cmr.repository.NodeRef downloadNodeRef, long maximumContentSize, long size, long fileCount)
      Publish the status telling the client that the requested content is too large to be downloaded.
      Parameters:
      downloadNodeRef - a NodeRef object
      maximumContentSize - the configured maximum size
      size - the size of the requested content
      fileCount - the number of requested files
    • getNodeRefsToExport

      protected org.alfresco.service.cmr.repository.NodeRef[] getNodeRefsToExport(org.alfresco.service.cmr.repository.NodeRef downloadNodeRef, org.alfresco.service.cmr.download.DownloadRequest downloadRequest)
      The nodes to export: those stored on the download node itself, falling back on the associations of the download request when it carries none.
      Parameters:
      downloadNodeRef - a NodeRef object
      downloadRequest - a DownloadRequest object
      Returns:
      an array of NodeRef objects
    • deleteTempFile

      private void deleteTempFile(File tempFile)