get IShareable / IResource from IFileItem in stream
Dear Jazz participant,
I'm doing some research with the Jazz repository and i need to traverse through all files in a given stream (IFlowNodeConnection). I am able to get all the IFileItems from the stream and now i need to get an IResource from the IFileItem. I wanted to get the local full path of the file by getting an IShareable and use the method getLocalFullPath().
I tried to use some code i found somewhere on the forum:
ISharingManager sm = FileSystemCore.getSharingManager()
IShareable shareable = sm.findShareable(cfaRoot, versionableHandle,
componentHandle, contextHandle, progressMonitor);
IPath localPath = shareable.getLocalFullPath();
The problem is when I try to get the cfaRoot by calling ISharingManager.getDefaultCFARoot() this method returns null.
When I look at the implementation of this method in the source code it looks like all the method does is return null.
I suspect I need to use a different approach to get the IShareable because I'm not working with files that are in a local eclipse workspace, just with files that are somewhere in a stream in the repository on the Jazz server.
How could I get an IShareable or IResource from these IFileItems?
Thanks,
Theo van Oostrum
I'm doing some research with the Jazz repository and i need to traverse through all files in a given stream (IFlowNodeConnection). I am able to get all the IFileItems from the stream and now i need to get an IResource from the IFileItem. I wanted to get the local full path of the file by getting an IShareable and use the method getLocalFullPath().
I tried to use some code i found somewhere on the forum:
ISharingManager sm = FileSystemCore.getSharingManager()
IShareable shareable = sm.findShareable(cfaRoot, versionableHandle,
componentHandle, contextHandle, progressMonitor);
IPath localPath = shareable.getLocalFullPath();
The problem is when I try to get the cfaRoot by calling ISharingManager.getDefaultCFARoot() this method returns null.
When I look at the implementation of this method in the source code it looks like all the method does is return null.
I suspect I need to use a different approach to get the IShareable because I'm not working with files that are in a local eclipse workspace, just with files that are somewhere in a stream in the repository on the Jazz server.
How could I get an IShareable or IResource from these IFileItems?
Thanks,
Theo van Oostrum
2 answers
Theo,
You can't get an IShareable or an IResource for an IFileItem unless you
load the content from the stream. If you are looking to get the path of
an item, you can get it through the configuration of a component
(IFlowNodeConnection#configuration(IComponentHandle)). You can obtain
the paths for items from the configuration (see iConfiguration#resolvePath).
Michael
gt.oostrum wrote:
You can't get an IShareable or an IResource for an IFileItem unless you
load the content from the stream. If you are looking to get the path of
an item, you can get it through the configuration of a component
(IFlowNodeConnection#configuration(IComponentHandle)). You can obtain
the paths for items from the configuration (see iConfiguration#resolvePath).
Michael
gt.oostrum wrote:
Dear Jazz participant,
I'm doing some research with the Jazz repository and i need to
traverse through all files in a given stream (IFlowNodeConnection). I
am able to get all the IFileItems from the stream and now i need to
get an IResource from the IFileItem. I wanted to get the local full
path of the file by getting an IShareable and use the method
getLocalFullPath().
I tried to use some code i found somewhere on the forum:
ISharingManager sm = FileSystemCore.getSharingManager()
IShareable shareable = sm.findShareable(cfaRoot, versionableHandle,
componentHandle, contextHandle, progressMonitor);
IPath localPath = shareable.getLocalFullPath();
The problem is when I try to get the cfaRoot by calling
ISharingManager.getDefaultCFARoot() this method returns null.
When I look at the implementation of this method in the source code it
looks like all the method does is return null.
I suspect I need to use a different approach to get the IShareable
because I'm not working with files that are in a local eclipse
workspace, just with files that are somewhere in a stream in the
repository on the Jazz server.
How could I get an IShareable or IResource from these IFileItems?
Thanks,
Theo van Oostrum
...
I suspect I need to use a different approach to get the IShareable because I'm not working with files that are in a local eclipse workspace, just with files that are somewhere in a stream in the repository on the Jazz server.
You can get the current state of the stream/workspace by calling IWorkspaceConnection#configuration(), getting the root items (#childEntriesForRoots()), then walking down each component root calling #fetchCompleteItems(). If you want file content, you can call IFileItem#getContent() for the IVersionables that are instances of IFileItem.
e