@Test public void testReplaceVariables() throws Exception { replayServices(); MediaPackageElementFlavor flavor = new MediaPackageElementFlavor("presenter", "delivery"); String expectedStreamName = MP_ID + "-" + CAPTURE_AGENT_NAME + "-presenter-delivery-stream-3840x1080_suffix"; String actualStreamName = service.replaceVariables(MP_ID, CAPTURE_AGENT_NAME, STREAM_NAME, flavor, "3840x1080"); Assert.assertEquals(expectedStreamName, actualStreamName); }
String replaceVariables(String mpId, String caName, String toBeReplaced, MediaPackageElementFlavor flavor, String resolution) { final Pattern pat = Pattern.compile("#\\{(\\w+)\\}"); Matcher matcher = pat.matcher(toBeReplaced); StringBuffer sb = new StringBuffer(); while (matcher.find()) { if (matcher.group(1).equals(REPLACE_ID)) { matcher.appendReplacement(sb, mpId); } else if (matcher.group(1).equals(REPLACE_FLAVOR)) { matcher.appendReplacement(sb, flavor.getType() + "-" + flavor.getSubtype()); } else if (matcher.group(1).equals(REPLACE_CA_NAME)) { matcher.appendReplacement(sb, caName); } else if (matcher.group(1).equals(REPLACE_RESOLUTION)) { matcher.appendReplacement(sb, resolution); } } matcher.appendTail(sb); return sb.toString(); }
LiveScheduleServiceImpl implements LiveScheduleService { String replaceVariables(String mpId, String caName, String toBeReplaced, MediaPackageElementFlavor flavor, String resolution) { final Pattern pat = Pattern.compile("#\\{(\\w+)\\}"); Matcher matcher = pat.matcher(toBeReplaced); StringBuffer sb = new StringBuffer(); while (matcher.find()) { if (matcher.group(1).equals(REPLACE_ID)) { matcher.appendReplacement(sb, mpId); } else if (matcher.group(1).equals(REPLACE_FLAVOR)) { matcher.appendReplacement(sb, flavor.getType() + "-" + flavor.getSubtype()); } else if (matcher.group(1).equals(REPLACE_CA_NAME)) { matcher.appendReplacement(sb, caName); } else if (matcher.group(1).equals(REPLACE_RESOLUTION)) { matcher.appendReplacement(sb, resolution); } } matcher.appendTail(sb); return sb.toString(); } }
LiveScheduleServiceImpl implements LiveScheduleService { String replaceVariables(String mpId, String caName, String toBeReplaced, MediaPackageElementFlavor flavor, String resolution) { final Pattern pat = Pattern.compile("#\\{(\\w+)\\}"); Matcher matcher = pat.matcher(toBeReplaced); StringBuffer sb = new StringBuffer(); while (matcher.find()) { if (matcher.group(1).equals(REPLACE_ID)) { matcher.appendReplacement(sb, mpId); } else if (matcher.group(1).equals(REPLACE_FLAVOR)) { matcher.appendReplacement(sb, flavor.getType() + "-" + flavor.getSubtype()); } else if (matcher.group(1).equals(REPLACE_CA_NAME)) { matcher.appendReplacement(sb, caName); } else if (matcher.group(1).equals(REPLACE_RESOLUTION)) { matcher.appendReplacement(sb, resolution); } } matcher.appendTail(sb); return sb.toString(); }  }
LiveScheduleServiceImpl implements LiveScheduleService { String replaceVariables(String mpId, String caName, String toBeReplaced, MediaPackageElementFlavor flavor, String resolution) { final Pattern pat = Pattern.compile("#\\{(\\w+)\\}"); Matcher matcher = pat.matcher(toBeReplaced); StringBuffer sb = new StringBuffer(); while (matcher.find()) { if (matcher.group(1).equals(REPLACE_ID)) { matcher.appendReplacement(sb, mpId); } else if (matcher.group(1).equals(REPLACE_FLAVOR)) { matcher.appendReplacement(sb, flavor.getType() + "-" + flavor.getSubtype()); } else if (matcher.group(1).equals(REPLACE_CA_NAME)) { matcher.appendReplacement(sb, caName); } else if (matcher.group(1).equals(REPLACE_RESOLUTION)) { matcher.appendReplacement(sb, resolution); } } matcher.appendTail(sb); return sb.toString(); }  @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 { String replaceVariables(String mpId, String caName, String toBeReplaced, MediaPackageElementFlavor flavor, String resolution) { final Pattern pat = Pattern.compile("#\\{(\\w+)\\}"); Matcher matcher = pat.matcher(toBeReplaced); StringBuffer sb = new StringBuffer(); while (matcher.find()) { if (matcher.group(1).equals(REPLACE_ID)) { matcher.appendReplacement(sb, mpId); } else if (matcher.group(1).equals(REPLACE_FLAVOR)) { matcher.appendReplacement(sb, flavor.getType() + "-" + flavor.getSubtype()); } else if (matcher.group(1).equals(REPLACE_CA_NAME)) { matcher.appendReplacement(sb, caName); } else if (matcher.group(1).equals(REPLACE_RESOLUTION)) { matcher.appendReplacement(sb, resolution); } } matcher.appendTail(sb); return sb.toString(); }  @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; }