Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to get RTC Stream URL from Java API

 Hello All,


I need to get the Stream URL from Java API.
This URL will be stored for documentation purpose and when user paste this link in browser, it should get resolved and navigate to corresponding stream in browser

Regards,
Chandan

0 votes


Accepted answer

Permanent link

 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>


Chandan M B selected this answer as the correct answer

1 vote

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

Permanent link

 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&lt;IWorkspaceHandle&gt; workspaceHandles = findConnections(workspaceManager,wsSearchCriteria);
        List&lt;? extends IWorkspaceConnection&gt; connections = workspaceManager.getWorkspaceConnections(workspaceHandles, null);
        System.out.println(workspaceHandles.size());
        for (Iterator&lt;? extends IWorkspaceConnection&gt; 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;
              }

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,943

Question asked: Nov 17 '21, 9:57 a.m.

Question was seen: 1,096 times

Last updated: Nov 18 '21, 11:22 a.m.

Related questions
Confirmation Cancel Confirm