Class AwsS3DistributionServiceImpl

java.lang.Object
org.opencastproject.job.api.AbstractJobProducer
org.opencastproject.distribution.api.AbstractDistributionService
org.opencastproject.distribution.aws.s3.AwsS3DistributionServiceImpl
All Implemented Interfaces:
org.opencastproject.distribution.api.DistributionService, org.opencastproject.distribution.api.DownloadDistributionService, org.opencastproject.distribution.aws.s3.api.AwsS3DistributionService, org.opencastproject.job.api.JobProducer

public class AwsS3DistributionServiceImpl extends org.opencastproject.distribution.api.AbstractDistributionService implements org.opencastproject.distribution.aws.s3.api.AwsS3DistributionService, org.opencastproject.distribution.api.DistributionService
  • Field Details

  • Constructor Details

    • AwsS3DistributionServiceImpl

      public AwsS3DistributionServiceImpl()
      Creates a new instance of the AWS S3 distribution service.
  • Method Details

    • activate

      public void activate(org.osgi.service.component.ComponentContext cc)
      Overrides:
      activate in class org.opencastproject.job.api.AbstractJobProducer
    • getDistributionType

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

      public void deactivate()
    • distribute

      public org.opencastproject.job.api.Job distribute(String pubChannelId, org.opencastproject.mediapackage.MediaPackage mediaPackage, Set<String> downloadIds, 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
    • 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
      See Also:
      • DownloadDistributionService.distribute(String, org.opencastproject.mediapackage.MediaPackage, String, boolean)
    • 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
      See Also:
      • DistributionService.distribute(String, org.opencastproject.mediapackage.MediaPackage, String)
    • 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
      See Also:
      • DownloadDistributionService.distribute(String, org.opencastproject.mediapackage.MediaPackage, String, boolean)
    • 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.
    • distributeElement

      public org.opencastproject.mediapackage.MediaPackageElement distributeElement(String channelId, org.opencastproject.mediapackage.MediaPackage mediaPackage, org.opencastproject.mediapackage.MediaPackageElement element, boolean checkAvailability) throws org.opencastproject.distribution.api.DistributionException
      Distribute a media package element to AWS S3.
      Parameters:
      mediaPackage - The media package that contains the element to distribute.
      element - The element that should be distributed contained within the media package.
      checkAvailability - Checks if the distributed element is available
      Returns:
      A reference to the MediaPackageElement that has been distributed.
      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) 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
      Specified by:
      retractSync in interface org.opencastproject.distribution.api.DistributionService
      Throws:
      org.opencastproject.distribution.api.DistributionException
    • 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
    • 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
      Retracts the media package element with the given identifier from the distribution channel.
      Parameters:
      channelId - the channel id
      mediaPackage - the media package
      element - the element
      Returns:
      the retracted element or null if the element was not retracted
      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
    • buildObjectName

      protected String buildObjectName(String channelId, String mpId, org.opencastproject.mediapackage.MediaPackageElement element)
      Builds the aws s3 object name.
      Parameters:
      channelId -
      mpId -
      element -
      Returns:
    • buildObjectName

      protected String buildObjectName(String orgId, String channelId, String mpId, String elementId, String fileName)
      Builds the aws s3 object name using the raw elementID and filename
      Parameters:
      orgId -
      channelId -
      mpId -
      elementId -
      fileName -
      Returns:
    • getDistributionUri

      protected URI getDistributionUri(String objectName) throws URISyntaxException
      Gets the URI for the element to be distributed.
      Returns:
      The resulting URI after distribution
      Throws:
      URISyntaxException - if the concrete implementation tries to create a malformed uri
    • getDistributedObjectName

      protected String getDistributedObjectName(org.opencastproject.mediapackage.MediaPackageElement element)
      Gets the distributed object's name.
      Returns:
      The distributed object name
    • 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)
    • createAWSBucket

      protected void createAWSBucket()
      Creates the AWS S3 bucket if it doesn't exist yet.
    • presignedURI

      public URI presignedURI(URI uri) throws URISyntaxException
      Throws:
      URISyntaxException
    • setS3

      protected void setS3(com.amazonaws.services.s3.AmazonS3 s3)
      The methods below are used by the test class
    • setS3TransferManager

      protected void setS3TransferManager(com.amazonaws.services.s3.transfer.TransferManager s3TransferManager)
    • setBucketName

      protected void setBucketName(String bucketName)
    • setOpencastDistributionUrl

      protected void setOpencastDistributionUrl(String distributionUrl)
    • setStorageTmp

      protected void setStorageTmp(String path)
    • 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