How do I get IFolder from IFolderHandle?
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
Geoffrey Clemm (30.1k●3●30●35)
| 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?
|
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
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.