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

How can I get the URL from a Changeset on a Participant?

When a change set is accesed via web browser you have an url address with this format:    

https://<jts-server>:9443/ccm/web/projects/<Project_Area_Name>#action=com.ibm.team.scm.viewChangeSet&contextItemId=&contextItemType=null&changeSetItemId=<UUID>

I have a Participant for sending notifications when a delivery is performed. I resolve the change sets with:
 
List<IChangeSet> changeSets = auditableServer.resolveAuditables(changeSetHandles, ItemProfile.<IChangeSet>createFullProfile(IChangeSet.ITEM_TYPE, true), monitor);

And I would like fetch the URL but I didn't find any method on IChangeSet or a Service to use for get this information. All I found is about WorkItem related artifacts associated.
How can I get the URL?

0 votes


Accepted answer

Permanent link

The data usually does not provide a URL, you have to compute that. For any element, you can use .origin() to get the team repository and from that you can get the public URI e.g.

((ITeamRepository) workItem.getOrigin()).publicUriRoot()

You can use com.ibm.team.repository.common.Location to create URI's

Location location = Location.namedLocation(workItem, ((ITeamRepository) workItem.getOrigin()).publicUriRoot());

You can use the Location to get the URI/URL.

Note there are different Location types namedLocation, itemLocation and you would have to look at the URL of an existing item to see the pattern and find out which location to use.

I usually use existing data and print that to understand what is supposed to be there.

See https://rsjazz.wordpress.com/2012/09/19/the-rtc-workitem-link-api-linking-workitems-to-other-elements/
for some related code (you can get URI's from references and create them from URI's.

There is also code that creates URI's in  the WCL: https://rsjazz.wordpress.com/2017/03/29/the-work-item-command-line-is-now-open-source/

Fran Burgos selected this answer as the correct answer

1 vote

Comments

Finally I did with: 
URI uri = ChangeSetLocationFactory.createChangeSetWebURL(changeSetsHandle, targetWorkspace, getPublicRepositoryURL(), null);

As you noticed nameLocation and itemLocation are different. nameLocation works fine with WorkItems and itemLocation with Changesets and Workspaces (nameLocation on changeSets throws an IllegalStateException because referenced item has not defined a naming identifier). But when you use itemLocation on a Changeset the URI's result doesn't use the context (target workspace) hence with ChangeSetLocationFactory you get the complete URL with the worspace context too.

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,954

Question asked: Jul 21 '17, 7:08 a.m.

Question was seen: 1,125 times

Last updated: Jul 25 '17, 6:31 a.m.

Confirmation Cancel Confirm