Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

 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, 

1

0 votes

Comments

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

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.

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


Accepted answer

Permanent link
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

2 votes

Comments

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
 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, 

0 votes

Comments

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();
    

 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

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:


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 log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938
× 411
× 51

Question asked: May 08 '14, 12:36 a.m.

Question was seen: 6,763 times

Last updated: May 08 '14, 1:21 p.m.

Confirmation Cancel Confirm