How to get RTC Stream URL from Java API
Accepted answer
I am not totally sure if this works for you, but I would suggest to look into
logger.info("Publish links to build result..."); IBuildResult buildResult = BuildUtil.getBuildResult(teamRepository, buildResultUUID, monitor);URI componentURI = URIUtil.getURIForItem(componentHandle); BuildUtil.publishLink(teamRepository, buildResult, "IP Links", componentURI.toString(), "Component - " + componentName, monitor); URI baselineURI = URIUtil.getURIForItem(baseline.getBaseline()); BuildUtil.publishLink(teamRepository, buildResult, "IP Links", baselineURI.toString(), "Baseline - " + baselineName, monitor); URI streamURI = URIUtil.getURIForItem(targetStream.getResolvedWorkspace().getItemHandle()); BuildUtil.publishLink(teamRepository, buildResult, "IP Links", streamURI.toString(), "Stream - " + scmConnection, monitor); </pre>
Comments
Thanks Ralph.
I will test this. How about getting the component url. Is it the similar way ?
My current output based on above code will lead like below
Look at the URIUtil it uses available code to get the URI from a handle. The API know how to make the rest.
public static URI getURIForItem(IItemHandle item) {
Location location = Location.itemLocation(item, getPublicURI(item));
return location.toAbsoluteUri();
}
Should not be too difficult to get the code and test it.
Thanks Ralph.
Both the way works. I opted for URIUtil to get both Stream and Component URI.
One other answer
I tried the constructing the Stream URL from Java API.
Thanks to Ralph blog scm
Code Snippet
private static String BASE_STREAM_URL = "resource/itemOid/com.ibm.team.scm.Workspace/";
TeamPlatform.startup(); String repositoryURI = "https://xxx/ccm"; String userId = "xxx"; String password = "xxx"; ITeamRepository teamRepository = TeamPlatform .getTeamRepositoryService().getTeamRepository(repositoryURI); teamRepository.registerLoginHandler(new LoginHandler(userId, password)); teamRepository.login(null);IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(teamRepository); IWorkspaceSearchCriteria wsSearchCriteria = WorkspaceSearchCriteria.FACTORY.newInstance(); wsSearchCriteria.setKind(IWorkspaceSearchCriteria.STREAMS); wsSearchCriteria.setPartialOwnerNameIgnoreCase("xxx"); // Provide the project Area Name List<IWorkspaceHandle> workspaceHandles = findConnections(workspaceManager,wsSearchCriteria); List<? extends IWorkspaceConnection> connections = workspaceManager.getWorkspaceConnections(workspaceHandles, null); System.out.println(workspaceHandles.size()); for (Iterator<? extends IWorkspaceConnection> iterator = connections.iterator(); iterator.hasNext();) { IWorkspaceConnection workspaceConnection = (IWorkspaceConnection) iterator.next(); String workspaceConnectionName = workspaceConnection.getName(); System.out.println(workspaceConnectionName); System.out.println(teamRepository.getRepositoryURI()+BASE_STREAM_URL+workspaceConnection.getContextHandle().getItemId().getUuidValue()); }
private static List<IWorkspaceHandle> findConnections(IWorkspaceManager workspaceManager,IWorkspaceSearchCriteria criteria) throws TeamRepositoryException { List<IWorkspaceHandle> connections = workspaceManager.findWorkspaces(criteria, Integer.MAX_VALUE, null); return connections; }