@Test public void testReplaceAndDistributeAcl() throws Exception { URI mpURI = LiveScheduleServiceImplTest.class.getResource("/live-mp.xml").toURI(); MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder() .loadFromXml(mpURI.toURL().openStream()); Job job = createJob(1L, "anything", "<?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(String.class), EasyMock.anyBoolean())).andReturn(job).once(); EasyMock.expect(serviceRegistry.getJob(1L)).andReturn(job).anyTimes(); replayServices(); service.setDownloadDistributionService(downloadDistributionService); AccessControlList acl = new AccessControlList(new AccessControlEntry("user", "read", true)); MediaPackage mp1 = service.replaceAndDistributeAcl(mp, acl); Attachment[] atts = mp1.getAttachments(MediaPackageElements.XACML_POLICY_EPISODE); Assert.assertNotNull(atts); Assert.assertEquals(1, atts.length); Attachment att = atts[0]; Assert.assertEquals("http: Assert.assertEquals("security/xacml+episode", att.getFlavor().toString()); EasyMock.verify(downloadDistributionService); }
MediaPackage replaceAndDistributeAcl(MediaPackage previousMp, AccessControlList acl) throws LiveScheduleException { try { MediaPackage mp = (MediaPackage) previousMp.clone(); Attachment[] atts = mp.getAttachments(MediaPackageElements.XACML_POLICY_EPISODE); if (atts.length > 0) mp.remove(atts[0]); authService.setAcl(mp, AclScope.Episode, acl); atts = mp.getAttachments(MediaPackageElements.XACML_POLICY_EPISODE); if (atts.length > 0) { String aclId = atts[0].getIdentifier(); Job distributionJob = downloadDistributionService.distribute(CHANNEL_ID, mp, aclId, false); if (!waitForStatus(distributionJob).isSuccess()) throw new LiveScheduleException( "Acl for live media package " + mp.getIdentifier() + " could not be distributed"); MediaPackageElement e = mp.getElementById(aclId); mp.remove(e); workspace.delete(e.getURI()); mp.add(MediaPackageElementParser.getFromXml(distributionJob.getPayload())); } return mp; } catch (LiveScheduleException e) { throw e; } catch (Exception e) { throw new LiveScheduleException(e); } }
LiveScheduleServiceImpl implements LiveScheduleService { MediaPackage replaceAndDistributeAcl(MediaPackage previousMp, AccessControlList acl) throws LiveScheduleException { try { MediaPackage mp = (MediaPackage) previousMp.clone(); Attachment[] atts = mp.getAttachments(MediaPackageElements.XACML_POLICY_EPISODE); if (atts.length > 0) mp.remove(atts[0]); authService.setAcl(mp, AclScope.Episode, acl); atts = mp.getAttachments(MediaPackageElements.XACML_POLICY_EPISODE); if (atts.length > 0) { String aclId = atts[0].getIdentifier(); Job distributionJob = downloadDistributionService.distribute(CHANNEL_ID, mp, aclId, false); if (!waitForStatus(distributionJob).isSuccess()) throw new LiveScheduleException( "Acl for live media package " + mp.getIdentifier() + " could not be distributed"); MediaPackageElement e = mp.getElementById(aclId); mp.remove(e); workspace.delete(e.getURI()); mp.add(MediaPackageElementParser.getFromXml(distributionJob.getPayload())); } return mp; } catch (LiveScheduleException e) { throw e; } catch (Exception e) { throw new LiveScheduleException(e); } } }
LiveScheduleServiceImpl implements LiveScheduleService { MediaPackage replaceAndDistributeAcl(MediaPackage previousMp, AccessControlList acl) throws LiveScheduleException { try { MediaPackage mp = (MediaPackage) previousMp.clone(); Attachment[] atts = mp.getAttachments(MediaPackageElements.XACML_POLICY_EPISODE); if (atts.length > 0) mp.remove(atts[0]); authService.setAcl(mp, AclScope.Episode, acl); atts = mp.getAttachments(MediaPackageElements.XACML_POLICY_EPISODE); if (atts.length > 0) { String aclId = atts[0].getIdentifier(); Job distributionJob = downloadDistributionService.distribute(CHANNEL_ID, mp, aclId, false); if (!waitForStatus(distributionJob).isSuccess()) throw new LiveScheduleException( "Acl for live media package " + mp.getIdentifier() + " could not be distributed"); MediaPackageElement e = mp.getElementById(aclId); mp.remove(e); workspace.delete(e.getURI()); mp.add(MediaPackageElementParser.getFromXml(distributionJob.getPayload())); } return mp; } catch (LiveScheduleException e) { throw e; } catch (Exception e) { throw new LiveScheduleException(e); } }  }
LiveScheduleServiceImpl implements LiveScheduleService { MediaPackage replaceAndDistributeAcl(MediaPackage previousMp, AccessControlList acl) throws LiveScheduleException { try { MediaPackage mp = (MediaPackage) previousMp.clone(); Attachment[] atts = mp.getAttachments(MediaPackageElements.XACML_POLICY_EPISODE); if (atts.length > 0) mp.remove(atts[0]); authService.setAcl(mp, AclScope.Episode, acl); atts = mp.getAttachments(MediaPackageElements.XACML_POLICY_EPISODE); if (atts.length > 0) { String aclId = atts[0].getIdentifier(); Job distributionJob = downloadDistributionService.distribute(CHANNEL_ID, mp, aclId, false); if (!waitForStatus(distributionJob).isSuccess()) throw new LiveScheduleException( "Acl for live media package " + mp.getIdentifier() + " could not be distributed"); MediaPackageElement e = mp.getElementById(aclId); mp.remove(e); workspace.delete(e.getURI()); mp.add(MediaPackageElementParser.getFromXml(distributionJob.getPayload())); } return mp; } catch (LiveScheduleException e) { throw e; } 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 { MediaPackage replaceAndDistributeAcl(MediaPackage previousMp, AccessControlList acl) throws LiveScheduleException { try { MediaPackage mp = (MediaPackage) previousMp.clone(); Attachment[] atts = mp.getAttachments(MediaPackageElements.XACML_POLICY_EPISODE); if (atts.length > 0) mp.remove(atts[0]); authService.setAcl(mp, AclScope.Episode, acl); atts = mp.getAttachments(MediaPackageElements.XACML_POLICY_EPISODE); if (atts.length > 0) { String aclId = atts[0].getIdentifier(); Job distributionJob = downloadDistributionService.distribute(CHANNEL_ID, mp, aclId, false); if (!waitForStatus(distributionJob).isSuccess()) throw new LiveScheduleException( "Acl for live media package " + mp.getIdentifier() + " could not be distributed"); MediaPackageElement e = mp.getElementById(aclId); mp.remove(e); workspace.delete(e.getURI()); mp.add(MediaPackageElementParser.getFromXml(distributionJob.getPayload())); } return mp; } catch (LiveScheduleException e) { throw e; } 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; }