Package fr.becpg.repo.download
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
FieldsModifier and TypeFieldDescriptionprotected org.alfresco.service.cmr.repository.ContentServiceprotected org.alfresco.repo.download.ContentServiceHelperprotected static final StringConstantCREATION_ERROR="Unexpected error creating file for download"protected org.alfresco.repo.download.DownloadStorageprotected org.alfresco.service.cmr.view.ExporterServiceprivate static final org.apache.commons.logging.Logprotected org.alfresco.service.cmr.repository.MimetypeServiceprotected org.alfresco.service.cmr.repository.NodeServiceprotected org.alfresco.repo.transaction.RetryingTransactionHelperprotected org.alfresco.repo.download.DownloadStatusUpdateServiceFields inherited from class org.alfresco.repo.action.executer.ActionExecuterAbstractBase
actionAccessRestrictions, actionDefinition, applicableTypes, publicActionFields inherited from class org.alfresco.repo.action.ParameterizedItemAbstractBase
adhocPropertiesAllowed, DISPLAY_LABEL, runtimeActionServiceFields inherited from class org.alfresco.repo.action.CommonResourceAbstractBase
nameFields inherited from interface org.alfresco.repo.action.executer.ActionExecuter
PARAM_RESULT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidapplyMimetype(org.alfresco.service.cmr.repository.NodeRef downloadNodeRef, String extension) protected voidcompleteDownload(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 booleancompleteIfEmpty(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.ExporterCrawlerParameterscreateCrawlerParameters(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 voiddeleteTempFile(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 voidmaximumContentSizeExceeded(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 voidpublishStatus(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 voidrunExport(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>
voidrunExport(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.voidsetContentService(org.alfresco.service.cmr.repository.ContentService contentService) Setter for the fieldcontentService.voidsetContentServiceHelper(org.alfresco.repo.download.ContentServiceHelper contentServiceHelper) Setter for the fieldcontentServiceHelper.voidsetDownloadStorage(org.alfresco.repo.download.DownloadStorage downloadStorage) Setter for the fielddownloadStorage.voidsetExporterService(org.alfresco.service.cmr.view.ExporterService exporterService) Setter for the fieldexporterService.voidsetMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService) Setter for the fieldmimetypeService.voidsetNodeService(org.alfresco.service.cmr.repository.NodeService nodeService) Setter for the fieldnodeService.voidsetTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper transactionHelper) Setter for the fieldtransactionHelper.voidsetUpdateService(org.alfresco.repo.download.DownloadStatusUpdateService updateService) Setter for the fieldupdateService.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, verifyActionAccessRestrictionsMethods inherited from class org.alfresco.repo.action.ParameterizedItemAbstractBase
addParameterDefinitions, checkMandatoryProperties, getAdhocPropertiesAllowed, getDescriptionKey, getLocalizedParameterDefinitions, getParamDisplayLabel, getParamDisplayLabel, getParameterDefintions, getTitleKey, setAdhocPropertiesAllowed, setLocales, setRuntimeActionService, toStringMethods inherited from class org.alfresco.repo.action.CommonResourceAbstractBase
setBeanNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.alfresco.repo.action.executer.ActionExecuter
isExecuteAsynchronously
-
Field Details
-
CREATION_ERROR
ConstantCREATION_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- aContentServiceobject
-
setMimetypeService
public void setMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService) Setter for the field
mimetypeService.- Parameters:
mimetypeService- aMimetypeServiceobject
-
setNodeService
public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService) Setter for the field
nodeService.- Parameters:
nodeService- aNodeServiceobject
-
setContentServiceHelper
public void setContentServiceHelper(org.alfresco.repo.download.ContentServiceHelper contentServiceHelper) Setter for the field
contentServiceHelper.- Parameters:
contentServiceHelper- aContentServiceHelperobject
-
setDownloadStorage
public void setDownloadStorage(org.alfresco.repo.download.DownloadStorage downloadStorage) Setter for the field
downloadStorage.- Parameters:
downloadStorage- aDownloadStorageobject
-
setExporterService
public void setExporterService(org.alfresco.service.cmr.view.ExporterService exporterService) Setter for the field
exporterService.- Parameters:
exporterService- aExporterServiceobject
-
setTransactionHelper
public void setTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper transactionHelper) Setter for the field
transactionHelper.- Parameters:
transactionHelper- aRetryingTransactionHelperobject
-
setUpdateService
public void setUpdateService(org.alfresco.repo.download.DownloadStatusUpdateService updateService) Setter for the field
updateService.- Parameters:
updateService- aDownloadStatusUpdateServiceobject
-
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 ofNodeRefobjects- Returns:
- a
ExporterCrawlerParametersobject
-
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- aNodeRefobjectnodeRefs- an array ofNodeRefobjects- 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- aNodeRefobjectcrawlerParameters- aExporterCrawlerParametersobjecthandler- the exporter building the archivetempFile- aFileobject
-
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- aNodeRefobjectexportTask- the task producing the archivereporter- aDownloadProgressReporterobjecttempFile- aFileobject
-
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- aNodeRefobjecttempFile- aFileobjectreporter- aDownloadProgressReporterobject
-
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- aNodeRefobjectstatus- aDownloadStatusobjectsequenceNumber- 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- aNodeRefobjectmaximumContentSize- the configured maximum sizesize- the size of the requested contentfileCount- 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- aNodeRefobjectdownloadRequest- aDownloadRequestobject- Returns:
- an array of
NodeRefobjects
-
deleteTempFile
-