@Test public void testUpdateLiveEvent() throws Exception { URI mpURI = LiveScheduleServiceImplTest.class.getResource("/assetmanager-mp-with-live.xml").toURI(); MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder() .loadFromXml(mpURI.toURL().openStream()); setUpAssetManager(mp); mpURI = LiveScheduleServiceImplTest.class.getResource("/live-mp.xml").toURI(); MediaPackage previousMp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder() .loadFromXml(mpURI.toURL().openStream()); 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(); Job jobRetract = createJob(3L, "anything", "anything"); EasyMock.expect(downloadDistributionService.retract(EasyMock.anyString(), EasyMock.anyObject(MediaPackage.class), EasyMock.anyObject(Set.class))).andReturn(jobRetract); EasyMock.expect(serviceRegistry.getJob(3L)).andReturn(jobRetract).anyTimes(); replayServices(); service.setDownloadDistributionService(downloadDistributionService); episodeDC.set(DublinCore.PROPERTY_SPATIAL, DublinCoreValue.mk("another_ca")); episodeDC.set(DublinCore.PROPERTY_TEMPORAL, DublinCoreValue.mk("start=2017-10-12T19:00:00Z;end=2017-10-12T19:02:00Z; scheme=W3C-DTF;")); Assert.assertTrue(service.updateLiveEvent(previousMp, episodeDC)); MediaPackage searchMp = capturedMp.getValue(); Assert.assertEquals(MP_ID, searchMp.getIdentifier().toString()); Assert.assertEquals(120000L, searchMp.getDuration().longValue()); Assert.assertEquals(2, searchMp.getCatalogs().length); assertExpectedLiveTracks(searchMp.getTracks(), 120000L, "another_ca", "_suffix", false); Assert.assertEquals(0, searchMp.getPublications().length); }
boolean updateLiveEvent(MediaPackage previousMp, DublinCoreCatalog episodeDC) throws LiveScheduleException { Snapshot snapshot = getSnapshot(previousMp.getIdentifier().toString()); if (snapshot.getVersion().equals(snapshotVersionCache.getIfPresent(previousMp.getIdentifier().toString()))) { logger.debug("Snapshot version {} was created by us so this change is ignored.", snapshot.getVersion()); return false; } MediaPackage tempMp = (MediaPackage) snapshot.getMediaPackage().clone(); setDuration(tempMp, episodeDC); Map<String, Track> generatedTracks = addLiveTracks(tempMp, episodeDC.getFirst(DublinCore.PROPERTY_SPATIAL)); createOrUpdatePublicationTracks(tempMp, generatedTracks); if (isSameMediaPackage(previousMp, tempMp)) { logger.debug("Live media package {} seems to be the same. Not updating.", previousMp); return false; } logger.info("Updating live media package {}", previousMp); MediaPackage mp = addAndDistributeElements(snapshot); for (Track t : tempMp.getTracks()) mp.add(t); removeLivePublicationChannel(mp); publish(mp); retractPreviousElements(previousMp, mp); return true; }
LiveScheduleServiceImpl implements LiveScheduleService { boolean updateLiveEvent(MediaPackage previousMp, DublinCoreCatalog episodeDC) throws LiveScheduleException { Snapshot snapshot = getSnapshot(previousMp.getIdentifier().toString()); if (snapshot.getVersion().equals(snapshotVersionCache.getIfPresent(previousMp.getIdentifier().toString()))) { logger.debug("Snapshot version {} was created by us so this change is ignored.", snapshot.getVersion()); return false; } MediaPackage tempMp = (MediaPackage) snapshot.getMediaPackage().clone(); setDuration(tempMp, episodeDC); Map<String, Track> generatedTracks = addLiveTracks(tempMp, episodeDC.getFirst(DublinCore.PROPERTY_SPATIAL)); createOrUpdatePublicationTracks(tempMp, generatedTracks); if (isSameMediaPackage(previousMp, tempMp)) { logger.debug("Live media package {} seems to be the same. Not updating.", previousMp); return false; } logger.info("Updating live media package {}", previousMp); MediaPackage mp = addAndDistributeElements(snapshot); for (Track t : tempMp.getTracks()) mp.add(t); removeLivePublicationChannel(mp); publish(mp); retractPreviousElements(previousMp, mp); return true; } }
LiveScheduleServiceImpl implements LiveScheduleService { boolean updateLiveEvent(MediaPackage previousMp, DublinCoreCatalog episodeDC) throws LiveScheduleException { Snapshot snapshot = getSnapshot(previousMp.getIdentifier().toString()); if (snapshot.getVersion().equals(snapshotVersionCache.getIfPresent(previousMp.getIdentifier().toString()))) { logger.debug("Snapshot version {} was created by us so this change is ignored.", snapshot.getVersion()); return false; } MediaPackage tempMp = (MediaPackage) snapshot.getMediaPackage().clone(); setDuration(tempMp, episodeDC); Map<String, Track> generatedTracks = addLiveTracks(tempMp, episodeDC.getFirst(DublinCore.PROPERTY_SPATIAL)); createOrUpdatePublicationTracks(tempMp, generatedTracks); if (isSameMediaPackage(previousMp, tempMp)) { logger.debug("Live media package {} seems to be the same. Not updating.", previousMp); return false; } logger.info("Updating live media package {}", previousMp); MediaPackage mp = addAndDistributeElements(snapshot); for (Track t : tempMp.getTracks()) mp.add(t); removeLivePublicationChannel(mp); publish(mp); retractPreviousElements(previousMp, mp); return true; }  }
LiveScheduleServiceImpl implements LiveScheduleService { boolean updateLiveEvent(MediaPackage previousMp, DublinCoreCatalog episodeDC) throws LiveScheduleException { Snapshot snapshot = getSnapshot(previousMp.getIdentifier().toString()); if (snapshot.getVersion().equals(snapshotVersionCache.getIfPresent(previousMp.getIdentifier().toString()))) { logger.debug("Snapshot version {} was created by us so this change is ignored.", snapshot.getVersion()); return false; } MediaPackage tempMp = (MediaPackage) snapshot.getMediaPackage().clone(); setDuration(tempMp, episodeDC); Map<String, Track> generatedTracks = addLiveTracks(tempMp, episodeDC.getFirst(DublinCore.PROPERTY_SPATIAL)); createOrUpdatePublicationTracks(tempMp, generatedTracks); if (isSameMediaPackage(previousMp, tempMp)) { logger.debug("Live media package {} seems to be the same. Not updating.", previousMp); return false; } logger.info("Updating live media package {}", previousMp); MediaPackage mp = addAndDistributeElements(snapshot); for (Track t : tempMp.getTracks()) mp.add(t); removeLivePublicationChannel(mp); publish(mp); retractPreviousElements(previousMp, mp); return true; }  @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 updateLiveEvent(MediaPackage previousMp, DublinCoreCatalog episodeDC) throws LiveScheduleException { Snapshot snapshot = getSnapshot(previousMp.getIdentifier().toString()); if (snapshot.getVersion().equals(snapshotVersionCache.getIfPresent(previousMp.getIdentifier().toString()))) { logger.debug("Snapshot version {} was created by us so this change is ignored.", snapshot.getVersion()); return false; } MediaPackage tempMp = (MediaPackage) snapshot.getMediaPackage().clone(); setDuration(tempMp, episodeDC); Map<String, Track> generatedTracks = addLiveTracks(tempMp, episodeDC.getFirst(DublinCore.PROPERTY_SPATIAL)); createOrUpdatePublicationTracks(tempMp, generatedTracks); if (isSameMediaPackage(previousMp, tempMp)) { logger.debug("Live media package {} seems to be the same. Not updating.", previousMp); return false; } logger.info("Updating live media package {}", previousMp); MediaPackage mp = addAndDistributeElements(snapshot); for (Track t : tempMp.getTracks()) mp.add(t); removeLivePublicationChannel(mp); publish(mp); retractPreviousElements(previousMp, mp); return true; }  @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; }