@Test public void testCreateLiveEvent() throws Exception { URI mpURI = LiveScheduleServiceImplTest.class.getResource("/assetmanager-mp.xml").toURI(); MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder() .loadFromXml(mpURI.toURL().openStream()); setUpAssetManager(mp); URI catalogURI = LiveScheduleServiceImplTest.class.getResource("/episode.xml").toURI(); DublinCoreCatalog episodeDC = DublinCores.read(catalogURI.toURL().openStream()); catalogURI = LiveScheduleServiceImplTest.class.getResource("/series.xml").toURI(); DublinCoreCatalog seriesDC = DublinCores.read(catalogURI.toURL().openStream()); EasyMock.expect(seriesService.getSeries(SERIES_ID)).andReturn(seriesDC).anyTimes(); Job job = createJob(1L, "anything", "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<catalog id=\"9ad6ebcb-b414-4b15-ab62-5e5ddede447e\" type=\"dublincore/episode\" xmlns=\"http: + "<mimetype>text/xml</mimetype>" + "<url>http: + "###<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<catalog id=\"23113662-1a84-457a-85d5-0b3e32d2413a\" type=\"dublincore/series\" xmlns=\"http: + "<mimetype>text/xml</mimetype>" + "<url>http: + "###<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<attachment id=\"security-policy-episode\" type=\"security/xacml+episode\" xmlns=\"http: + "<mimetype>text/xml</mimetype>" + "<url>http: EasyMock.expect(downloadDistributionService.distribute(EasyMock.anyString(), EasyMock.anyObject(MediaPackage.class), EasyMock.anyObject(Set.class), EasyMock.anyBoolean())).andReturn(job); EasyMock.expect(serviceRegistry.getJob(1L)).andReturn(job).anyTimes(); Job jobPub = createJob(2L, "anything", "anything"); Capture<MediaPackage> capturedMp = Capture.newInstance(); EasyMock.expect(searchService.add(EasyMock.capture(capturedMp))).andReturn(jobPub); EasyMock.expect(serviceRegistry.getJob(2L)).andReturn(job).anyTimes(); Capture<MediaPackage> capturedSnapshotMp = Capture.newInstance(); Version v = EasyMock.createNiceMock(Version.class); Snapshot s = EasyMock.createNiceMock(Snapshot.class); EasyMock.expect(s.getVersion()).andReturn(v); EasyMock.replay(s, v); EasyMock.expect( assetManager.takeSnapshot(EasyMock.capture(capturedSnapshotMp))).andReturn(s); replayServices(); service.setDownloadDistributionService(downloadDistributionService); service.createLiveEvent(MP_ID, episodeDC); MediaPackage searchMp = capturedMp.getValue(); Assert.assertEquals(MP_ID, searchMp.getIdentifier().toString()); Assert.assertEquals(DURATION, searchMp.getDuration().longValue()); Assert.assertEquals(2, searchMp.getCatalogs().length); assertExpectedLiveTracks(searchMp.getTracks(), DURATION, CAPTURE_AGENT_NAME, "_suffix", false); MediaPackage archivedMp = capturedSnapshotMp.getValue(); Assert.assertEquals(MP_ID, archivedMp.getIdentifier().toString()); Assert.assertEquals(1, archivedMp.getPublications().length); Assert.assertEquals(LiveScheduleService.CHANNEL_ID, archivedMp.getPublications()[0].getChannel()); Assert.assertEquals(v, service.getSnapshotVersionCache().getIfPresent(MP_ID)); }
boolean createLiveEvent(String mpId, DublinCoreCatalog episodeDC) throws LiveScheduleException { try { logger.info("Creating live media package {}", mpId); Snapshot snapshot = getSnapshot(mpId); MediaPackage tempMp = (MediaPackage) snapshot.getMediaPackage().clone(); setDuration(tempMp, episodeDC); Map<String, Track> generatedTracks = addLiveTracks(tempMp, episodeDC.getFirst(DublinCore.PROPERTY_SPATIAL)); MediaPackage mp = addAndDistributeElements(snapshot); for (Track t : tempMp.getTracks()) mp.add(t); publish(mp); Organization currentOrg = null; try { currentOrg = organizationService.getOrganization(snapshot.getOrganizationId()); } catch (NotFoundException e) { logger.warn("Organization in snapshot not found: {}", snapshot.getOrganizationId()); } MediaPackage archivedMp = snapshot.getMediaPackage(); addLivePublicationChannel(currentOrg, archivedMp, generatedTracks); snapshotVersionCache.put(mpId, assetManager.takeSnapshot(archivedMp).getVersion()); return true; } catch (Exception e) { throw new LiveScheduleException(e); } }
LiveScheduleServiceImpl implements LiveScheduleService { boolean createLiveEvent(String mpId, DublinCoreCatalog episodeDC) throws LiveScheduleException { try { logger.info("Creating live media package {}", mpId); Snapshot snapshot = getSnapshot(mpId); MediaPackage tempMp = (MediaPackage) snapshot.getMediaPackage().clone(); setDuration(tempMp, episodeDC); Map<String, Track> generatedTracks = addLiveTracks(tempMp, episodeDC.getFirst(DublinCore.PROPERTY_SPATIAL)); MediaPackage mp = addAndDistributeElements(snapshot); for (Track t : tempMp.getTracks()) mp.add(t); publish(mp); Organization currentOrg = null; try { currentOrg = organizationService.getOrganization(snapshot.getOrganizationId()); } catch (NotFoundException e) { logger.warn("Organization in snapshot not found: {}", snapshot.getOrganizationId()); } MediaPackage archivedMp = snapshot.getMediaPackage(); addLivePublicationChannel(currentOrg, archivedMp, generatedTracks); snapshotVersionCache.put(mpId, assetManager.takeSnapshot(archivedMp).getVersion()); return true; } catch (Exception e) { throw new LiveScheduleException(e); } } }
LiveScheduleServiceImpl implements LiveScheduleService { boolean createLiveEvent(String mpId, DublinCoreCatalog episodeDC) throws LiveScheduleException { try { logger.info("Creating live media package {}", mpId); Snapshot snapshot = getSnapshot(mpId); MediaPackage tempMp = (MediaPackage) snapshot.getMediaPackage().clone(); setDuration(tempMp, episodeDC); Map<String, Track> generatedTracks = addLiveTracks(tempMp, episodeDC.getFirst(DublinCore.PROPERTY_SPATIAL)); MediaPackage mp = addAndDistributeElements(snapshot); for (Track t : tempMp.getTracks()) mp.add(t); publish(mp); Organization currentOrg = null; try { currentOrg = organizationService.getOrganization(snapshot.getOrganizationId()); } catch (NotFoundException e) { logger.warn("Organization in snapshot not found: {}", snapshot.getOrganizationId()); } MediaPackage archivedMp = snapshot.getMediaPackage(); addLivePublicationChannel(currentOrg, archivedMp, generatedTracks); snapshotVersionCache.put(mpId, assetManager.takeSnapshot(archivedMp).getVersion()); return true; } catch (Exception e) { throw new LiveScheduleException(e); } }  }
LiveScheduleServiceImpl implements LiveScheduleService { boolean createLiveEvent(String mpId, DublinCoreCatalog episodeDC) throws LiveScheduleException { try { logger.info("Creating live media package {}", mpId); Snapshot snapshot = getSnapshot(mpId); MediaPackage tempMp = (MediaPackage) snapshot.getMediaPackage().clone(); setDuration(tempMp, episodeDC); Map<String, Track> generatedTracks = addLiveTracks(tempMp, episodeDC.getFirst(DublinCore.PROPERTY_SPATIAL)); MediaPackage mp = addAndDistributeElements(snapshot); for (Track t : tempMp.getTracks()) mp.add(t); publish(mp); Organization currentOrg = null; try { currentOrg = organizationService.getOrganization(snapshot.getOrganizationId()); } catch (NotFoundException e) { logger.warn("Organization in snapshot not found: {}", snapshot.getOrganizationId()); } MediaPackage archivedMp = snapshot.getMediaPackage(); addLivePublicationChannel(currentOrg, archivedMp, generatedTracks); snapshotVersionCache.put(mpId, assetManager.takeSnapshot(archivedMp).getVersion()); return true; } catch (Exception e) { throw new LiveScheduleException(e); } }  @Override boolean createOrUpdateLiveEvent(String mpId, DublinCoreCatalog episodeDC); @Override boolean deleteLiveEvent(String mpId); @Override boolean updateLiveEventAcl(String mpId, AccessControlList acl); void setDublinCoreService(DublinCoreCatalogService service); void setSearchService(SearchService service); void setSeriesService(SeriesService service); void setServiceRegistry(ServiceRegistry service); void setCaptureAgentService(CaptureAgentStateService service); void setDownloadDistributionService(DownloadDistributionService service); void setWorkspace(Workspace ws); void setAssetManager(AssetManager assetManager); void setAuthorizationService(AuthorizationService service); void setOrganizationService(OrganizationDirectoryService service); }
LiveScheduleServiceImpl implements LiveScheduleService { boolean createLiveEvent(String mpId, DublinCoreCatalog episodeDC) throws LiveScheduleException { try { logger.info("Creating live media package {}", mpId); Snapshot snapshot = getSnapshot(mpId); MediaPackage tempMp = (MediaPackage) snapshot.getMediaPackage().clone(); setDuration(tempMp, episodeDC); Map<String, Track> generatedTracks = addLiveTracks(tempMp, episodeDC.getFirst(DublinCore.PROPERTY_SPATIAL)); MediaPackage mp = addAndDistributeElements(snapshot); for (Track t : tempMp.getTracks()) mp.add(t); publish(mp); Organization currentOrg = null; try { currentOrg = organizationService.getOrganization(snapshot.getOrganizationId()); } catch (NotFoundException e) { logger.warn("Organization in snapshot not found: {}", snapshot.getOrganizationId()); } MediaPackage archivedMp = snapshot.getMediaPackage(); addLivePublicationChannel(currentOrg, archivedMp, generatedTracks); snapshotVersionCache.put(mpId, assetManager.takeSnapshot(archivedMp).getVersion()); return true; } catch (Exception e) { throw new LiveScheduleException(e); } }  @Override boolean createOrUpdateLiveEvent(String mpId, DublinCoreCatalog episodeDC); @Override boolean deleteLiveEvent(String mpId); @Override boolean updateLiveEventAcl(String mpId, AccessControlList acl); void setDublinCoreService(DublinCoreCatalogService service); void setSearchService(SearchService service); void setSeriesService(SeriesService service); void setServiceRegistry(ServiceRegistry service); void setCaptureAgentService(CaptureAgentStateService service); void setDownloadDistributionService(DownloadDistributionService service); void setWorkspace(Workspace ws); void setAssetManager(AssetManager assetManager); void setAuthorizationService(AuthorizationService service); void setOrganizationService(OrganizationDirectoryService service); static final String CA_PROPERTY_RESOLUTION_URL_PREFIX; static final String REPLACE_ID; static final String REPLACE_FLAVOR; static final String REPLACE_CA_NAME; static final String REPLACE_RESOLUTION; static final String LIVE_STREAMING_URL; static final String LIVE_STREAM_NAME; static final String LIVE_STREAM_MIME_TYPE; static final String LIVE_STREAM_RESOLUTION; static final String LIVE_TARGET_FLAVORS; static final String LIVE_DISTRIBUTION_SERVICE; static final String LIVE_PUBLISH_STREAMING; }