How to fetch Iversionable/IfileItem of a file by passing itemid and stateid of the file
Accepted answer
UUID itemId = getFileItemId();
UUID stateId = getFileState();
IComponentHandle componentHandle = getComponentHandle();
IWorkspaceConnection workspaceConnection = getWorkspaceConnection();
IFileItemHandle fileItemHandle = (IFileItemHandle) IFileItem.ITEM_TYPE.createItemHandle(itemId, stateId);
IFileItem file = (IFileItem) workspaceConnection.configuration(componentHandle).fetchCompleteItem(fileItemHandle, monitor);
Comments
Currently i am taking State id and item id of a file from different location and these two parameters are of String type. How i can convert them into UUID type.
and one more thing is that, i have various baselines of same component and snapshots of streams. SO i don't want to pass/specify any specific component or stream as a input parameter.
I want to retrieve the file irrespective of streams, snapshots, baselines and JUST WANT TO USE UUID of ITEM ID AND STATE ID
UUID.valueOf(string) see https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/
The server API is: IScmService.fetchState(...)
Or from the client API you can call:
IVersionableManager vmgr = SCMPlatform.getWorkspaceManager(repo).versionableManager();
IVersionable versionable = vmgr.fetchCompleteState(versionableHandle, monitor);
how i can get relative path of the file?
You can use:
IScmService.configurationLocateAncestors(...)
or
IScmService.configurationDetermineAncestorsInHistory(...) (this will give you the path of a file even if it was recently deleted in the stream - it goes through the change set history to try to find the path 'where the file used to be).