It's all about the answers!

Ask a question

How to get IWorkspaceConnection from FileItemWrapper/FolderItemWrapper using RTC SDK?

Leonardo Marzo (24954852) | asked May 08 '14, 12:36 a.m.

I´m developing an Eclipse plugin using the RTC SDK. I need to get the Workspace or Stream given a FileItemWrapper or a FolderItemWrapper. How can I do that? 

Most of the examples that I found require the name of the workspace/stream (IWorkspaceSearchCriteria) to get it. I don't have the name of the workspace (or I don't know how to get it from the plugin); but I have the workspace id: FolderItemWrapper.getWorkspace().

How can I get the IWorkspaceConnection using the workspace id instead of the workspace' name?

I´ll appreciate your help. 

Thank you, 

Donald Nong commented May 08 '14, 3:43 a.m.

How/where did you get the FileItemWrapper or FolderItemWrapper class? I can't find them in the RTC SDK.

Ralph Schoon commented May 08 '14, 3:54 a.m.

Please see:

They are part of the Client SDK and the elements you get for UI selections in some of the views/editors.

Ralph Schoon commented May 08 '14, 4:26 a.m.


I don't have time to look into your question right now. Some hints I could provide: shows how you can use the AuditableClient to find elements with the UUID. You will likely get an IWorkspaceHandle back and have to get what you need from that.


have some hints, as far as I remember.

I have not played with the other ItemWrapper classes, so I don't know what you get from them. I would try to see what I get and then look into the SDK to find my way around. That is the way I usually do it, if I am in your situation.

Accepted answer

permanent link
Tim Mok (6.6k38) | answered May 08 '14, 9:55 a.m.
The wrapper has a namespace, which would be a workspace namespace for a FolderItemWrapper/FileItemWrapper. With the namespace, you can call #getWorkspaceConnection (cast to WorkspaceNamespace first) or #getConnection (then cast to IWorkspaceConnection).
Leonardo Marzo selected this answer as the correct answer

Leonardo Marzo commented May 08 '14, 10:34 a.m.

Thanks Tim! That's the shortest way :)

IWorkspaceConnection con = (IWorkspaceConnection) folderWrapper.getWorkspace().getConnection(null);
How can I get the Component now ??

One other answer

permanent link
Leonardo Marzo (24954852) | answered May 08 '14, 10:00 a.m.
edited May 08 '14, 10:01 a.m.
 Thanks for your answers Ralph and Tim. I was able to get the Stream with this code:
IWorkspaceHandle wpHandle = (IWorkspaceHandle) IWorkspace.ITEM_TYPE.createItemHandle(UUID.valueOf(folderSelection.getWorkspace().getContextHandle().getItemId().getUuidValue()), null);
IWorkspaceConnection wsConn = mgr.getWorkspaceConnection(wpHandle,null);
Now I need to get the Component the FileItemWrapper/FolderItemWrapper is in. Do you know how to get it? 


Tim Mok commented May 08 '14, 10:30 a.m. | edited May 08 '14, 10:37 a.m.

The way I suggest to get the workspace connection would look like this:

(IWorkspaceConnection) FileItemWrapper.getWorkspace().getConnection();
For the component, you can try using the namespace again.
(IWorkspaceConnection) FileItemWrapper.getWorkspace().fetchComponentId().toHandle();

Leonardo Marzo commented May 08 '14, 12:04 p.m.

 Almost there. That line shows me the following warning in Eclipse: 

Discouraged access: The method toHandle() from the type ItemId<IComponent> is not accessible due to restriction on required library RTC405Dev\installs\rtc-sdk\plugins\

and when I try to debug that line, I get a "Source not found" error. It seems that something in the configuration of my plugin is wrong. I tried with the following solution, but the problem is still there. I checked the plugin dependencies, and everything seem to be ok. 

Any thoughts? Thank you

Ralph Schoon commented May 08 '14, 12:15 p.m.

This is only a warning and means that the method is not in a public package (which means internal API, I think). This does not necessarily mean, it does not work, it only means this API could change without notice. If the source can not be found that can mean the SDK/Plain Java is not set up correctly.

If you use PlainJava and the SDK see here: in "Make the SDK Source Code Available for the Plain Java Clients Libraries"

Or it can mean, that this code is not shipped with the SDK at all. There are parts of the code that are not shipped with the SDK, so you can't see the code. But the libraries contain the binaries and thus it runs.

Leonardo Marzo commented May 08 '14, 1:21 p.m.

I figured it out! It was a ClassCastException. The final code to get the component is this:

IComponentHandle componentHandle = folderSelection.getWorkspace().fetchComponentId(null).toHandle();

IComponent component = (IComponent) teamRepository.itemManager().fetchCompleteItem(componentHandle, IItemManager.DEFAULT, monitor);

Hope it helps. Thank you guys!

Your answer

Register or to post your answer.