How do I get IFolder from IFolderHandle?
2 answers
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.
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
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.
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.