Class DownloadDistributionServiceImpl

java.lang.Object
org.opencastproject.job.api.AbstractJobProducer
org.opencastproject.distribution.api.AbstractDistributionService
org.opencastproject.distribution.download.DownloadDistributionServiceImpl
All Implemented Interfaces:
org.opencastproject.distribution.api.DistributionService, org.opencastproject.distribution.api.DownloadDistributionService, org.opencastproject.job.api.JobProducer, org.osgi.service.cm.ManagedService

public class DownloadDistributionServiceImpl extends org.opencastproject.distribution.api.AbstractDistributionService implements org.opencastproject.distribution.api.DistributionService, org.opencastproject.distribution.api.DownloadDistributionService, org.osgi.service.cm.ManagedService
Distributes media to the local media delivery directory.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final float
    The load on the system introduced by creating a distribute job
    static final float
    The load on the system introduced by creating a retract job
    static final String
    The key to look for in the service configuration file to override the DEFAULT_DISTRIBUTE_JOB_LOAD
    static final String
    Receipt type
    static final String
    The key to look for in the service configuration file to override the DEFAULT_RETRACT_JOB_LOAD

    Fields inherited from class org.opencastproject.distribution.api.AbstractDistributionService

    distributionChannel, distributionDirectory, organizationDirectoryService, securityService, serviceRegistry, serviceUrl, trustedHttpClient, userDirectoryService, workspace

    Fields inherited from class org.opencastproject.job.api.AbstractJobProducer

    ACCEPT_JOB_LOADS_EXCEEDING_PROPERTY, acceptJobLoadsExeedingMaxLoad, DEFAULT_ACCEPT_JOB_LOADS_EXCEEDING, executor, jobType

    Fields inherited from interface org.opencastproject.distribution.api.DistributionService

    CONFIG_KEY_STORE_TYPE, JOB_TYPE_PREFIX
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of the download distribution service.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    activate(org.osgi.service.component.ComponentContext cc)
    Activate method for this OSGi service implementation.
    org.opencastproject.mediapackage.Track
    checkDistributeHLSElement(org.opencastproject.mediapackage.Track element, boolean checkAvailability)
     
    org.opencastproject.job.api.Job
    distribute(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId)
     
    org.opencastproject.job.api.Job
    distribute(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId, boolean checkAvailability)
     
    org.opencastproject.job.api.Job
    distribute(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability)
     
    org.opencastproject.job.api.Job
    distribute(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability, boolean preserveReference)
     
    org.opencastproject.mediapackage.MediaPackageElement
    distributeElement(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, org.opencastproject.mediapackage.MediaPackageElement element, boolean checkAvailability, boolean preserveReference)
    Distribute a Mediapackage element to the download distribution service.
    org.opencastproject.mediapackage.MediaPackageElement[]
    distributeElements(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability)
    Distribute Mediapackage elements to the download distribution service.
    org.opencastproject.mediapackage.MediaPackageElement[]
    distributeElements(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability, boolean preserveReference)
    Distribute Mediapackage elements to the download distribution service.
    List<org.opencastproject.mediapackage.MediaPackageElement>
    distributeSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId)
     
    List<org.opencastproject.mediapackage.MediaPackageElement>
    distributeSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability)
     
    List<org.opencastproject.mediapackage.MediaPackageElement>
    distributeSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability, boolean preserveReference)
     
    protected File
    getDistributionFile(String channelId, org.opencastproject.mediapackage.MediaPackage mp, org.opencastproject.mediapackage.MediaPackageElement element)
    Gets the destination file to copy the contents of a mediapackage element.
     
    protected URI
    getDistributionUri(String channelId, String mediaPackageId, org.opencastproject.mediapackage.MediaPackageElement element)
    Gets the URI for the element to be distributed.
    protected File
    getMediaPackageDirectory(String channelId, org.opencastproject.mediapackage.MediaPackage mp)
    Gets the directory containing the distributed files for this mediapackage.
    protected String
    process(org.opencastproject.job.api.Job job)
    org.opencastproject.job.api.Job
    retract(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId)
     
    org.opencastproject.job.api.Job
    retract(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds)
     
    protected org.opencastproject.mediapackage.MediaPackageElement
    retractElement(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, org.opencastproject.mediapackage.MediaPackageElement element)
    Retract a media package element from the distribution channel.
    protected org.opencastproject.mediapackage.MediaPackageElement[]
    retractElements(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds)
    Retract a media package element from the distribution channel.
    List<org.opencastproject.mediapackage.MediaPackageElement>
    retractSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId)
     
    List<org.opencastproject.mediapackage.MediaPackageElement>
    retractSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds)
     
    void
    setOrganizationDirectoryService(org.opencastproject.security.api.OrganizationDirectoryService organizationDirectoryService)
     
    void
    setSecurityService(org.opencastproject.security.api.SecurityService securityService)
     
    void
    setServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry serviceRegistry)
     
    void
    setTrustedHttpClient(org.opencastproject.security.api.TrustedHttpClient trustedHttpClient)
     
    org.opencastproject.mediapackage.Track
    setUpHLSElementforDistribution(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, org.opencastproject.mediapackage.Track element, boolean preserveReference)
     
    void
    setUserDirectoryService(org.opencastproject.security.api.UserDirectoryService userDirectoryService)
     
    void
    setWorkspace(org.opencastproject.workspace.api.Workspace workspace)
     
    void
    updated(Dictionary properties)
     

    Methods inherited from class org.opencastproject.distribution.api.AbstractDistributionService

    getOrganizationDirectoryService, getSecurityService, getServiceRegistry, getTrustedHttpClient, getUserDirectoryService

    Methods inherited from class org.opencastproject.job.api.AbstractJobProducer

    acceptJob, countJobs, finallyUpdateJob, getJobType, incident, isReadyToAccept, isReadyToAcceptJobs

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • DownloadDistributionServiceImpl

      public DownloadDistributionServiceImpl()
      Creates a new instance of the download distribution service.
  • Method Details

    • activate

      public void activate(org.osgi.service.component.ComponentContext cc)
      Activate method for this OSGi service implementation.
      Overrides:
      activate in class org.opencastproject.job.api.AbstractJobProducer
      Parameters:
      cc - the OSGi component context
    • getDistributionType

      public String getDistributionType()
      Specified by:
      getDistributionType in interface org.opencastproject.distribution.api.DistributionService
    • distribute

      public org.opencastproject.job.api.Job distribute(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId) throws org.opencastproject.distribution.api.DistributionException, org.opencastproject.mediapackage.MediaPackageException
      Specified by:
      distribute in interface org.opencastproject.distribution.api.DistributionService
      Throws:
      org.opencastproject.distribution.api.DistributionException
      org.opencastproject.mediapackage.MediaPackageException
    • distribute

      public org.opencastproject.job.api.Job distribute(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId, boolean checkAvailability) throws org.opencastproject.distribution.api.DistributionException, org.opencastproject.mediapackage.MediaPackageException
      Specified by:
      distribute in interface org.opencastproject.distribution.api.DownloadDistributionService
      Throws:
      org.opencastproject.distribution.api.DistributionException
      org.opencastproject.mediapackage.MediaPackageException
    • distribute

      public org.opencastproject.job.api.Job distribute(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability) throws org.opencastproject.distribution.api.DistributionException, org.opencastproject.mediapackage.MediaPackageException
      Specified by:
      distribute in interface org.opencastproject.distribution.api.DownloadDistributionService
      Throws:
      org.opencastproject.distribution.api.DistributionException
      org.opencastproject.mediapackage.MediaPackageException
    • distribute

      public org.opencastproject.job.api.Job distribute(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability, boolean preserveReference) throws org.opencastproject.distribution.api.DistributionException, org.opencastproject.mediapackage.MediaPackageException
      Specified by:
      distribute in interface org.opencastproject.distribution.api.DownloadDistributionService
      Throws:
      org.opencastproject.distribution.api.DistributionException
      org.opencastproject.mediapackage.MediaPackageException
    • distributeElements

      public org.opencastproject.mediapackage.MediaPackageElement[] distributeElements(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability) throws org.opencastproject.distribution.api.DistributionException
      Distribute Mediapackage elements to the download distribution service.
      Parameters:
      channelId - # The id of the publication channel to be distributed to.
      mediapackage - The media package that contains the elements to be distributed.
      elementIds - The ids of the elements that should be distributed contained within the media package.
      checkAvailability - Check the availability of the distributed element via http.
      Returns:
      A reference to the MediaPackageElements that have been distributed.
      Throws:
      org.opencastproject.distribution.api.DistributionException - Thrown if the parent directory of the MediaPackageElement cannot be created, if the MediaPackageElement cannot be copied or another unexpected exception occurs.
    • distributeElements

      public org.opencastproject.mediapackage.MediaPackageElement[] distributeElements(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability, boolean preserveReference) throws org.opencastproject.distribution.api.DistributionException
      Distribute Mediapackage elements to the download distribution service.
      Parameters:
      channelId - # The id of the publication channel to be distributed to.
      mediapackage - The media package that contains the elements to be distributed.
      elementIds - The ids of the elements that should be distributed contained within the media package.
      checkAvailability - Check the availability of the distributed element via http.
      preserveReference - copy actual Reference to the new distributed element
      Returns:
      A reference to the MediaPackageElements that have been distributed.
      Throws:
      org.opencastproject.distribution.api.DistributionException - Thrown if the parent directory of the MediaPackageElement cannot be created, if the MediaPackageElement cannot be copied or another unexpected exception occurs.
    • distributeElement

      public org.opencastproject.mediapackage.MediaPackageElement distributeElement(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, org.opencastproject.mediapackage.MediaPackageElement element, boolean checkAvailability, boolean preserveReference) throws org.opencastproject.distribution.api.DistributionException
      Distribute a Mediapackage element to the download distribution service.
      Parameters:
      channelId - # The id of the publication channel to be distributed to.
      mediapackage - The media package that contains the element to be distributed.
      element - The the element that should be distributed contained within the media package.
      checkAvailability - Check the availability of the distributed element via http.
      preserveReference - Copy existing Track-Reference to the new distributed Track
      Returns:
      A reference to the MediaPackageElement that has been distributed.
      Throws:
      org.opencastproject.distribution.api.DistributionException - Thrown if the parent directory of the MediaPackageElement cannot be created, if the MediaPackageElement cannot be copied or another unexpected exception occurs.
    • setUpHLSElementforDistribution

      public org.opencastproject.mediapackage.Track setUpHLSElementforDistribution(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, org.opencastproject.mediapackage.Track element, boolean preserveReference) throws org.opencastproject.distribution.api.DistributionException
      Throws:
      org.opencastproject.distribution.api.DistributionException
    • checkDistributeHLSElement

      public org.opencastproject.mediapackage.Track checkDistributeHLSElement(org.opencastproject.mediapackage.Track element, boolean checkAvailability) throws org.opencastproject.distribution.api.DistributionException
      Throws:
      org.opencastproject.distribution.api.DistributionException
    • retract

      public org.opencastproject.job.api.Job retract(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId) throws org.opencastproject.distribution.api.DistributionException
      Specified by:
      retract in interface org.opencastproject.distribution.api.DistributionService
      Throws:
      org.opencastproject.distribution.api.DistributionException
    • retract

      public org.opencastproject.job.api.Job retract(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds) throws org.opencastproject.distribution.api.DistributionException
      Specified by:
      retract in interface org.opencastproject.distribution.api.DownloadDistributionService
      Throws:
      org.opencastproject.distribution.api.DistributionException
    • distributeSync

      public List<org.opencastproject.mediapackage.MediaPackageElement> distributeSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId) throws org.opencastproject.distribution.api.DistributionException, org.opencastproject.mediapackage.MediaPackageException
      Specified by:
      distributeSync in interface org.opencastproject.distribution.api.DistributionService
      Throws:
      org.opencastproject.distribution.api.DistributionException
      org.opencastproject.mediapackage.MediaPackageException
    • distributeSync

      public List<org.opencastproject.mediapackage.MediaPackageElement> distributeSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability, boolean preserveReference) throws org.opencastproject.distribution.api.DistributionException, org.opencastproject.mediapackage.MediaPackageException
      Throws:
      org.opencastproject.distribution.api.DistributionException
      org.opencastproject.mediapackage.MediaPackageException
    • distributeSync

      public List<org.opencastproject.mediapackage.MediaPackageElement> distributeSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability) throws org.opencastproject.distribution.api.DistributionException
      Specified by:
      distributeSync in interface org.opencastproject.distribution.api.DownloadDistributionService
      Throws:
      org.opencastproject.distribution.api.DistributionException
    • retractSync

      public List<org.opencastproject.mediapackage.MediaPackageElement> retractSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId) throws org.opencastproject.distribution.api.DistributionException, org.opencastproject.mediapackage.MediaPackageException
      Specified by:
      retractSync in interface org.opencastproject.distribution.api.DistributionService
      Throws:
      org.opencastproject.distribution.api.DistributionException
      org.opencastproject.mediapackage.MediaPackageException
    • retractSync

      public List<org.opencastproject.mediapackage.MediaPackageElement> retractSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds) throws org.opencastproject.distribution.api.DistributionException
      Specified by:
      retractSync in interface org.opencastproject.distribution.api.DownloadDistributionService
      Throws:
      org.opencastproject.distribution.api.DistributionException
    • retractElements

      protected org.opencastproject.mediapackage.MediaPackageElement[] retractElements(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds) throws org.opencastproject.distribution.api.DistributionException
      Retract a media package element from the distribution channel. The retracted element must not necessarily be the one given as parameter elementId. Instead, the element's distribution URI will be calculated. This way you are able to retract elements by providing the "original" element here.
      Parameters:
      channelId - the channel id
      mediapackage - the mediapackage
      elementIds - the element identifiers
      Returns:
      the retracted element or null if the element was not retracted
      Throws:
      org.opencastproject.distribution.api.DistributionException - in case of an error
    • retractElement

      protected org.opencastproject.mediapackage.MediaPackageElement retractElement(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, org.opencastproject.mediapackage.MediaPackageElement element) throws org.opencastproject.distribution.api.DistributionException
      Retract a media package element from the distribution channel. The retracted element must not necessarily be the one given as parameter elementId. Instead, the element's distribution URI will be calculated. This way you are able to retract elements by providing the "original" element here.
      Parameters:
      channelId - the channel id
      mediapackage - the mediapackage
      element - the element
      Returns:
      the retracted element or null if the element was not retracted
      Throws:
      org.opencastproject.distribution.api.DistributionException - in case of an error
    • process

      protected String process(org.opencastproject.job.api.Job job) throws Exception
      Specified by:
      process in class org.opencastproject.job.api.AbstractJobProducer
      Throws:
      Exception
      See Also:
      • AbstractJobProducer.process(org.opencastproject.job.api.Job)
    • getDistributionFile

      protected File getDistributionFile(String channelId, org.opencastproject.mediapackage.MediaPackage mp, org.opencastproject.mediapackage.MediaPackageElement element)
      Gets the destination file to copy the contents of a mediapackage element.
      Returns:
      The file to copy the content to
    • getMediaPackageDirectory

      protected File getMediaPackageDirectory(String channelId, org.opencastproject.mediapackage.MediaPackage mp)
      Gets the directory containing the distributed files for this mediapackage.
      Returns:
      the filesystem directory
    • getDistributionUri

      protected URI getDistributionUri(String channelId, String mediaPackageId, org.opencastproject.mediapackage.MediaPackageElement element) throws URISyntaxException
      Gets the URI for the element to be distributed.
      Parameters:
      mediaPackageId - the mediapackage identifier
      element - The mediapackage element being distributed
      Returns:
      The resulting URI after distribution
      Throws:
      URISyntaxException - if the concrete implementation tries to create a malformed uri
    • updated

      public void updated(Dictionary properties) throws org.osgi.service.cm.ConfigurationException
      Specified by:
      updated in interface org.osgi.service.cm.ManagedService
      Throws:
      org.osgi.service.cm.ConfigurationException
    • setWorkspace

      public void setWorkspace(org.opencastproject.workspace.api.Workspace workspace)
      Overrides:
      setWorkspace in class org.opencastproject.distribution.api.AbstractDistributionService
    • setServiceRegistry

      public void setServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry serviceRegistry)
      Overrides:
      setServiceRegistry in class org.opencastproject.distribution.api.AbstractDistributionService
    • setSecurityService

      public void setSecurityService(org.opencastproject.security.api.SecurityService securityService)
      Overrides:
      setSecurityService in class org.opencastproject.distribution.api.AbstractDistributionService
    • setUserDirectoryService

      public void setUserDirectoryService(org.opencastproject.security.api.UserDirectoryService userDirectoryService)
      Overrides:
      setUserDirectoryService in class org.opencastproject.distribution.api.AbstractDistributionService
    • setOrganizationDirectoryService

      public void setOrganizationDirectoryService(org.opencastproject.security.api.OrganizationDirectoryService organizationDirectoryService)
      Overrides:
      setOrganizationDirectoryService in class org.opencastproject.distribution.api.AbstractDistributionService
    • setTrustedHttpClient

      public void setTrustedHttpClient(org.opencastproject.security.api.TrustedHttpClient trustedHttpClient)
      Overrides:
      setTrustedHttpClient in class org.opencastproject.distribution.api.AbstractDistributionService