It's all about the answers!

Ask a question

URI for file


Hendrik Haddorp (1312) | asked May 28 '13, 12:34 p.m.
Hi,
I was hoping to be able to create an URI pointing to the Jazz web UI for a given file. My impression was that this is possible using com.ibm.team.repository.common.Location.contentLocation(IContent content, java.lang.String repoUrl, java.lang.String serviceName). However I'm not able to get an IContent object from an IFileItem object.

According to the com.ibm.team.repository.client.IContentManager JavaDoc IFileItem.getContet() should return an IContent object but in reality I get an IFileContent object and that does not seem to be compatible.

Would be great if somebody could tell me how this can be done.

regards,
Hendrik

Accepted answer


permanent link
Tim Mok (6.6k38) | answered May 28 '13, 4:55 p.m.
JAZZ DEVELOPER
You can use SCMLocationUtil#getVersionableLocation() to construct a URI to a file. However, it requires a workspace and component as context.
Location versionableLocation = SCMLocationUtil.getVersionableLocation(repo.getRepositoryURI(), workspaceHandle, componentHandle, new Path(filePath));
versionableLocation.toAbsoluteUri().toASCIIString();
You won't really need the IFileItem as long as you know the path to the file.
Hendrik Haddorp selected this answer as the correct answer

Comments
Hendrik Haddorp commented May 29 '13, 5:29 a.m.

Thanks, that works. Only problem is that the API is not documented in the SDK. Strangely it only does a relatively simple call to Location.pathLocation(), which is part of the SDK. Is there no way to do this in a way that is documented?

Your answer


Register or 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.