@Test public void testRetractPreviousElements() throws Exception { URI mpURI = LiveScheduleServiceImplTest.class.getResource("/live-mp.xml").toURI(); MediaPackage previousMp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder() .loadFromXml(mpURI.toURL().openStream()); MediaPackage newMp = (MediaPackage) previousMp.clone(); Catalog catalog = newMp.getCatalog("episode-dc-published"); catalog.setURI(new URI("CHANGED/episode_dublincore.xml")); Job job = createJob(1L, "anything", "anything"); Capture<Set<String>> capturedElementId = Capture.newInstance(); EasyMock.expect(downloadDistributionService.retract(EasyMock.anyString(), EasyMock.anyObject(MediaPackage.class), EasyMock.capture(capturedElementId))).andReturn(job); EasyMock.expect(serviceRegistry.getJob(1L)).andReturn(job).anyTimes(); replayServices(); service.setDownloadDistributionService(downloadDistributionService); service.retractPreviousElements(previousMp, newMp); Set<String> ids = capturedElementId.getValue(); Assert.assertEquals(1, ids.size()); Assert.assertEquals("episode-dc-published", ids.iterator().next()); EasyMock.verify(downloadDistributionService); }
void retractPreviousElements(MediaPackage previousMp, MediaPackage newMp) throws LiveScheduleException { try { Set<String> elementIds = new HashSet<String>(); for (MediaPackageElement element : previousMp.getElements()) { if (!Track.TYPE.equals(element.getElementType())) { boolean canBeDeleted = true; for (MediaPackageElement newElement : newMp.getElements()) { if (element.getURI().equals(newElement.getURI())) { logger.debug( "Not retracting element {} with URI {} from download distribution because it is still used by updated live media package", element.getIdentifier(), element.getURI()); canBeDeleted = false; break; } } if (canBeDeleted) elementIds.add(element.getIdentifier()); } } if (elementIds.size() > 0) { Job job = downloadDistributionService.retract(CHANNEL_ID, previousMp, elementIds); if (!waitForStatus(job).isSuccess()) logger.warn("One of the download retract jobs did not complete successfully"); else logger.debug("Retraction of previously published elements complete"); } } catch (DistributionException e) { throw new LiveScheduleException(e); } }
LiveScheduleServiceImpl implements LiveScheduleService { void retractPreviousElements(MediaPackage previousMp, MediaPackage newMp) throws LiveScheduleException { try { Set<String> elementIds = new HashSet<String>(); for (MediaPackageElement element : previousMp.getElements()) { if (!Track.TYPE.equals(element.getElementType())) { boolean canBeDeleted = true; for (MediaPackageElement newElement : newMp.getElements()) { if (element.getURI().equals(newElement.getURI())) { logger.debug( "Not retracting element {} with URI {} from download distribution because it is still used by updated live media package", element.getIdentifier(), element.getURI()); canBeDeleted = false; break; } } if (canBeDeleted) elementIds.add(element.getIdentifier()); } } if (elementIds.size() > 0) { Job job = downloadDistributionService.retract(CHANNEL_ID, previousMp, elementIds); if (!waitForStatus(job).isSuccess()) logger.warn("One of the download retract jobs did not complete successfully"); else logger.debug("Retraction of previously published elements complete"); } } catch (DistributionException e) { throw new LiveScheduleException(e); } } }
LiveScheduleServiceImpl implements LiveScheduleService { void retractPreviousElements(MediaPackage previousMp, MediaPackage newMp) throws LiveScheduleException { try { Set<String> elementIds = new HashSet<String>(); for (MediaPackageElement element : previousMp.getElements()) { if (!Track.TYPE.equals(element.getElementType())) { boolean canBeDeleted = true; for (MediaPackageElement newElement : newMp.getElements()) { if (element.getURI().equals(newElement.getURI())) { logger.debug( "Not retracting element {} with URI {} from download distribution because it is still used by updated live media package", element.getIdentifier(), element.getURI()); canBeDeleted = false; break; } } if (canBeDeleted) elementIds.add(element.getIdentifier()); } } if (elementIds.size() > 0) { Job job = downloadDistributionService.retract(CHANNEL_ID, previousMp, elementIds); if (!waitForStatus(job).isSuccess()) logger.warn("One of the download retract jobs did not complete successfully"); else logger.debug("Retraction of previously published elements complete"); } } catch (DistributionException e) { throw new LiveScheduleException(e); } }  }
LiveScheduleServiceImpl implements LiveScheduleService { void retractPreviousElements(MediaPackage previousMp, MediaPackage newMp) throws LiveScheduleException { try { Set<String> elementIds = new HashSet<String>(); for (MediaPackageElement element : previousMp.getElements()) { if (!Track.TYPE.equals(element.getElementType())) { boolean canBeDeleted = true; for (MediaPackageElement newElement : newMp.getElements()) { if (element.getURI().equals(newElement.getURI())) { logger.debug( "Not retracting element {} with URI {} from download distribution because it is still used by updated live media package", element.getIdentifier(), element.getURI()); canBeDeleted = false; break; } } if (canBeDeleted) elementIds.add(element.getIdentifier()); } } if (elementIds.size() > 0) { Job job = downloadDistributionService.retract(CHANNEL_ID, previousMp, elementIds); if (!waitForStatus(job).isSuccess()) logger.warn("One of the download retract jobs did not complete successfully"); else logger.debug("Retraction of previously published elements complete"); } } catch (DistributionException 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 { void retractPreviousElements(MediaPackage previousMp, MediaPackage newMp) throws LiveScheduleException { try { Set<String> elementIds = new HashSet<String>(); for (MediaPackageElement element : previousMp.getElements()) { if (!Track.TYPE.equals(element.getElementType())) { boolean canBeDeleted = true; for (MediaPackageElement newElement : newMp.getElements()) { if (element.getURI().equals(newElement.getURI())) { logger.debug( "Not retracting element {} with URI {} from download distribution because it is still used by updated live media package", element.getIdentifier(), element.getURI()); canBeDeleted = false; break; } } if (canBeDeleted) elementIds.add(element.getIdentifier()); } } if (elementIds.size() > 0) { Job job = downloadDistributionService.retract(CHANNEL_ID, previousMp, elementIds); if (!waitForStatus(job).isSuccess()) logger.warn("One of the download retract jobs did not complete successfully"); else logger.debug("Retraction of previously published elements complete"); } } catch (DistributionException 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; }