How to get a VersionableHandle given a file name & versi
I would like to retrieve the content of a specific file version from the server. Given the name and full path to a file and the file version number, how is it possible to retrieve the VersionableHandle?
The SCM code snippet example currently available shows how to get a handle to a file in the Jazz server for a locally loaded file in the Eclipse workspace. However I would like to get it for any file in a SCM stream or workspace.
The article on "Jazz Platform Architecture - Notes on service programming model" mentions that we need to use IFileSystemService for file system related service calls. But when I looked at the Jazz source code, I found that SCMPlatform.getWorkspaceManager.fetchCompleteStates was used in most places. Could someone also recommend the right approach to retrieve a file item from the server.
Regards,
Swathi.
The SCM code snippet example currently available shows how to get a handle to a file in the Jazz server for a locally loaded file in the Eclipse workspace. However I would like to get it for any file in a SCM stream or workspace.
The article on "Jazz Platform Architecture - Notes on service programming model" mentions that we need to use IFileSystemService for file system related service calls. But when I looked at the Jazz source code, I found that SCMPlatform.getWorkspaceManager.fetchCompleteStates was used in most places. Could someone also recommend the right approach to retrieve a file item from the server.
Regards,
Swathi.
Accepted answer
Just to add to the previous answer, to retrieve the content of a specific file version, after getting the IVersionable:
IVersionedContentManager versionedContentManager = SCMPlatform.getWorkspaceManager(repository).getSCMContentManager(); IFileItem file = (IFileItem) version; InputStream stream = versionedContentManager.retrieveContentStream(versionHandle, file.getContent(), monitor);
2 other answers
IVersionableHandle versionHandle = (IVersionableHandle) IFileItem.ITEM_TYPE.createItemHandle(UUID.valueOf(fileUuid), UUID.valueOf(stateUuid));
IVersionableManager verManager = SCMPlatform.getWorkspaceManager(repository).versionableManager();
IVersionable version = verManager.fetchCompleteState(versionHandle, monitor);
IVersionableManager verManager = SCMPlatform.getWorkspaceManager(repository).versionableManager();
IVersionable version = verManager.fetchCompleteState(versionHandle, monitor);