Class ZipWorkflowOperationHandler

  • All Implemented Interfaces:
    org.opencastproject.workflow.api.WorkflowOperationHandler

    public class ZipWorkflowOperationHandler
    extends org.opencastproject.workflow.api.AbstractWorkflowOperationHandler
    Produces a zipped archive of a mediapackage, places it in the archive collection, and removes the rest of the mediapackage elements from both the mediapackage xml and if possible, from storage altogether.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.opencastproject.workflow.api.AbstractWorkflowOperationHandler

        org.opencastproject.workflow.api.AbstractWorkflowOperationHandler.Configuration
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void activate​(org.osgi.service.component.ComponentContext cc)
      Activate the component, generating the temporary storage directory for building zip archives if necessary.
      void setWorkspace​(org.opencastproject.workspace.api.Workspace workspace)
      Sets the workspace to use.
      org.opencastproject.workflow.api.WorkflowOperationResult start​(org.opencastproject.workflow.api.WorkflowInstance workflowInstance, org.opencastproject.job.api.JobContext context)
      protected File zip​(org.opencastproject.mediapackage.MediaPackage mediaPackage, List<org.opencastproject.mediapackage.MediaPackageElementFlavor> flavorsToZip, boolean compress)
      Creates a zip archive of all elements in a mediapackage.
      • Methods inherited from class org.opencastproject.workflow.api.AbstractWorkflowOperationHandler

        asList, cfgKeyMissing, createResult, createResult, createResult, createResult, destroy, equals, getCfg, getConfig, getConfig, getConfig, getDescription, getFileNameFromElements, getId, getOptConfig, getOptConfig, getTagsAndFlavors, hashCode, setJobBarrierPollingInterval, setServiceRegistry, skip, toString, waitForStatus, waitForStatus
    • Field Detail

      • ZIP_COLLECTION_PROPERTY

        public static final String ZIP_COLLECTION_PROPERTY
        The workflow operation's property to consult to determine the collection to use to store an archive
        See Also:
        Constant Field Values
      • INCLUDE_FLAVORS_PROPERTY

        public static final String INCLUDE_FLAVORS_PROPERTY
        The element flavors to include in the zip file
        See Also:
        Constant Field Values
      • TARGET_FLAVOR_PROPERTY

        public static final String TARGET_FLAVOR_PROPERTY
        The zip archive's target element flavor
        See Also:
        Constant Field Values
      • COMPRESS_PROPERTY

        public static final String COMPRESS_PROPERTY
        The property indicating whether to apply compression to the archive
        See Also:
        Constant Field Values
      • DEFAULT_ZIP_COLLECTION

        public static final String DEFAULT_ZIP_COLLECTION
        The default collection in the working file repository to store archives
        See Also:
        Constant Field Values
      • DEFAULT_ZIP_ARCHIVE_TEMP_DIR

        public static final String DEFAULT_ZIP_ARCHIVE_TEMP_DIR
        The default location to use when building an zip archive relative to the storage directory
        See Also:
        Constant Field Values
      • ZIP_ARCHIVE_TEMP_DIR_CFG_KEY

        public static final String ZIP_ARCHIVE_TEMP_DIR_CFG_KEY
        Key for configuring the location of the archive-temp folder
        See Also:
        Constant Field Values
      • DEFAULT_ARCHIVE_FLAVOR

        public static final org.opencastproject.mediapackage.MediaPackageElementFlavor DEFAULT_ARCHIVE_FLAVOR
        The default flavor to use for a mediapackage archive
      • tempStorageDir

        protected File tempStorageDir
        The temporary storage location
      • workspace

        protected org.opencastproject.workspace.api.Workspace workspace
        The workspace to use in retrieving and storing files.
    • Constructor Detail

      • ZipWorkflowOperationHandler

        public ZipWorkflowOperationHandler()
    • Method Detail

      • setWorkspace

        public void setWorkspace​(org.opencastproject.workspace.api.Workspace workspace)
        Sets the workspace to use.
        Parameters:
        workspace - the workspace
      • activate

        protected void activate​(org.osgi.service.component.ComponentContext cc)
        Activate the component, generating the temporary storage directory for building zip archives if necessary.
        Overrides:
        activate in class org.opencastproject.workflow.api.AbstractWorkflowOperationHandler
        See Also:
        AbstractWorkflowOperationHandler.activate(org.osgi.service.component.ComponentContext)
      • start

        public org.opencastproject.workflow.api.WorkflowOperationResult start​(org.opencastproject.workflow.api.WorkflowInstance workflowInstance,
                                                                              org.opencastproject.job.api.JobContext context)
                                                                       throws org.opencastproject.workflow.api.WorkflowOperationException
        Specified by:
        start in interface org.opencastproject.workflow.api.WorkflowOperationHandler
        Specified by:
        start in class org.opencastproject.workflow.api.AbstractWorkflowOperationHandler
        Throws:
        org.opencastproject.workflow.api.WorkflowOperationException
        See Also:
        AbstractWorkflowOperationHandler.start(org.opencastproject.workflow.api.WorkflowInstance, JobContext)
      • zip

        protected File zip​(org.opencastproject.mediapackage.MediaPackage mediaPackage,
                           List<org.opencastproject.mediapackage.MediaPackageElementFlavor> flavorsToZip,
                           boolean compress)
                    throws IOException,
                           org.opencastproject.util.NotFoundException,
                           org.opencastproject.mediapackage.MediaPackageException,
                           org.opencastproject.workflow.api.WorkflowOperationException
        Creates a zip archive of all elements in a mediapackage.
        Parameters:
        mediaPackage - the mediapackage to zip
        Returns:
        the zip file
        Throws:
        IOException - If an IO exception occurs
        org.opencastproject.util.NotFoundException - If a file referenced in the mediapackage can not be found
        org.opencastproject.mediapackage.MediaPackageException - If the mediapackage can not be serialized to xml
        org.opencastproject.workflow.api.WorkflowOperationException - If the mediapackage is invalid