AwsS3DistributionServiceImpl extends AbstractDistributionService implements AwsS3DistributionService, DistributionService { public MediaPackageElement[] distributeElements(String channelId, MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability) throws DistributionException { notNull(mediapackage, "mediapackage"); notNull(elementIds, "elementIds"); notNull(channelId, "channelId"); final Set<MediaPackageElement> elements = getElements(mediapackage, elementIds); List<MediaPackageElement> distributedElements = new ArrayList<>(); if (AdaptivePlaylist.hasHLSPlaylist(elements)) { return distributeHLSElements(channelId, mediapackage, elements, checkAvailability); } for (MediaPackageElement element : elements) { MediaPackageElement distributedElement = distributeElement(channelId, mediapackage, element, checkAvailability); distributedElements.add(distributedElement); } return distributedElements.toArray(new MediaPackageElement[distributedElements.size()]); } AwsS3DistributionServiceImpl(); @Override void activate(ComponentContext cc); @Override String getDistributionType(); void deactivate(); @Override Job distribute(String pubChannelId, MediaPackage mediaPackage, Set<String> downloadIds,
    boolean checkAvailability, boolean preserveReference); @Override Job distribute(String channelId, MediaPackage mediaPackage, Set<String> elementIds, boolean checkAvailability); @Override Job distribute(String channelId, MediaPackage mediapackage, String elementId); @Override Job distribute(String channelId, MediaPackage mediaPackage, String elementId, boolean checkAvailability); MediaPackageElement[] distributeElements(String channelId, MediaPackage mediapackage, Set<String> elementIds,
          boolean checkAvailability); MediaPackageElement distributeElement(String channelId, final MediaPackage mediaPackage,
          MediaPackageElement element, boolean checkAvailability); @Override Job retract(String channelId, MediaPackage mediapackage, String elementId); @Override Job retract(String channelId, MediaPackage mediapackage, Set<String> elementIds); @Override List<MediaPackageElement> distributeSync(String channelId, MediaPackage mediapackage, Set<String> elementIds,
         boolean checkAvailability); @Override List<MediaPackageElement> retractSync(String channelId, MediaPackage mediaPackage, Set<String> elementIds); @Override Job restore(String channelId, MediaPackage mediaPackage, String elementId); @Override Job restore(String channelId, MediaPackage mediaPackage, String elementId, String fileName); static final String JOB_TYPE; static final String AWS_S3_DISTRIBUTION_ENABLE; static final String AWS_S3_DISTRIBUTION_BASE_CONFIG; static final String AWS_S3_ACCESS_KEY_ID_CONFIG; static final String AWS_S3_SECRET_ACCESS_KEY_CONFIG; static final String AWS_S3_REGION_CONFIG; static final String AWS_S3_BUCKET_CONFIG; static final String AWS_S3_ENDPOINT_CONFIG; static final String AWS_S3_PATH_STYLE_CONFIG; static final String OPENCAST_DOWNLOAD_URL; static final String OPENCAST_STORAGE_DIR; static final String DEFAULT_TEMP_DIR; static final float DEFAULT_DISTRIBUTE_JOB_LOAD; static final float DEFAULT_RETRACT_JOB_LOAD; static final float DEFAULT_RESTORE_JOB_LOAD; static final String DISTRIBUTE_JOB_LOAD_KEY; static final String RETRACT_JOB_LOAD_KEY; static final String RESTORE_JOB_LOAD_KEY; }
@Test public void testDistributeHLSElement() throws Exception { MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder(); URI mpURI = AwsS3DistributionServiceImpl.class.getResource("/hls_mediapackage.xml").toURI(); mp = builder.loadFromXml(mpURI.toURL().openStream()); mpURI = AwsS3DistributionServiceImpl.class.getResource("/distributed_hls_mediapackage.xml").toURI(); distributedMp = builder.loadFromXml(mpURI.toURL().openStream()); Upload upload = EasyMock.createNiceMock(Upload.class); EasyMock.expect(tm.upload(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class), EasyMock.anyObject(File.class))).andReturn(upload).anyTimes(); EasyMock.replay(upload, tm); Set<String> mpeIds = new LinkedHashSet<String>(); mpeIds.add("presenter-mp4"); mpeIds.add("presenter-m3u8"); MediaPackageElement[] mpes = service.distributeElements("channelId", mp, mpeIds, false); MediaPackageElement mpe = mpes[0]; Assert.assertEquals(new URI( "http: mpe.getURI()); Path tempfile = storageDir.toPath().resolve(mp.getIdentifier().toString()); Assert.assertFalse(Files.exists(tempfile)); }