How to get IWorkspaceConnection from FileItemWrapper/FolderItemWrapper using RTC SDK?
Accepted answer
One other answer
IWorkspaceHandle wpHandle = (IWorkspaceHandle) IWorkspace.ITEM_TYPE.createItemHandle(UUID.valueOf(folderSelection.getWorkspace().getContextHandle().getItemId().getUuidValue()), null);Now I need to get the Component the FileItemWrapper/FolderItemWrapper is in. Do you know how to get it?
IWorkspaceConnection wsConn = mgr.getWorkspaceConnection(wpHandle,null);
Comments
The way I suggest to get the workspace connection would look like this:
(IWorkspaceConnection) FileItemWrapper.getWorkspace().getConnection();
(IWorkspaceConnection) FileItemWrapper.getWorkspace().fetchComponentId().toHandle();
Almost there. That line shows me the following warning in Eclipse:
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: https://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/ 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.
I figured it out! It was a ClassCastException. The final code to get the component is this:
Comments
Donald Nong
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
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER May 08 '14, 3:54 a.m.Please see: http://rsjazz.wordpress.com/2014/02/21/adding-context-menus-for-jazz-objects-to-the-rtc-eclipse-client/
They are part of the Client SDK and the elements you get for UI selections in some of the views/editors.
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER May 08 '14, 4:26 a.m.Leonardo,
I don't have time to look into your question right now. Some hints I could provide:
https://jazz.net/library/article/807 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.
http://rsjazz.wordpress.com/2013/09/24/managing-workspaces-streams-and-components-using-the-plain-java-client-libraries/
and
http://rsjazz.wordpress.com/2013/09/30/delivering-change-sets-and-baselines-to-a-stream-using-the-plain-java-client-libraries/
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.
1 vote