It's all about the answers!

Ask a question

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


0
1
Leonardo Marzo (24964852) | asked May 08 '14, 12:36 a.m.
 Hi, 

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, 

Comments
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.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


1
Ralph Schoon commented May 08 '14, 4:26 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.

Accepted answer


permanent link
Tim Mok (6.6k38) | answered May 08 '14, 9:55 a.m.
JAZZ DEVELOPER
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

Comments
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 (24964852) | 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? 

Thanks, 


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

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\com.ibm.team.scm.common_3.2.0.v20131019_0328.jar

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 http://stackoverflow.com/questions/860187/access-restriction-on-class-due-to-restriction-on-required-library-rt-jar, 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.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


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.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.