It's all about the answers!

Ask a question

How do I get IFolder from IFolderHandle?


Akshay Daga (134) | asked Apr 16 '19, 12:39 a.m.

I want to fetch the parent folder of a file in SCM. I am able to fetch the file from changesets and from the file I can get parent folder's IFolderHandle. How do I translate it to IFolder?

2 answers



permanent link
Geoffrey Clemm (30.1k33035) | answered Apr 16 '19, 12:48 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

From a file version in a change set, you know which folder item is its parent, but you don't know which version of that folder item to select ... you need a configuration context (baseline, stream) to identify the version.


Comments
Akshay Daga commented Apr 16 '19, 12:53 a.m.

Thanks for quick response, but how do I fetch the baseline and stream info from changeset?


permanent link
Luca Martinucci (1.0k396112) | answered Apr 16 '19, 4:20 a.m.

Anyway, using the standard method to get an object from its handle (with the server-side Java SDK):


IFolderHandle folderHandle = ....;
// "this" is the current Java class, in this case the plugin (extension) that is running
AbstractService pluginAbstractService = (AbstractService) this;
IRepositoryItemService repositoryItemService = pluginAbstractService.getService(IRepositoryItemService.class);
IFolder folder = (IFolder) repositoryItemService.fetchItem(folderHandle, IRepositoryItemService.COMPLETE);


Comments
Akshay Daga commented Apr 16 '19, 4:31 a.m.

Exception in thread "main" java.lang.ClassCastException: com.ibm.team.filesystem.common.internal.impl.FileItemHandleImpl cannot be cast to com.ibm.team.repository.common.IManagedItemHandle



Getting this error if I use standard method.


Luca Martinucci commented Apr 16 '19, 6:56 a.m.

It looks like a casting error.

Check the class of the first argument of the fetchItem method.
It seems that you are trying to get a IManagedItem object, but the first argument of the fetchItem method is a FileItemHandle object.

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.