It's all about the answers!

Ask a question

SCM - Best way to get workspace connection for a file?


Srimanth Gunturi (206125) | asked Oct 22 '07, 11:47 p.m.
JAZZ DEVELOPER
Hello,
Just wanted to find out if there was an easier way to get the
IWorkspaceConnection associated with a IResource?

Currently I go through IResource > IShareable > IShare >
ISharingDescriptor > IWorkspaceHandle. From the IWorkspaceHandle I cycle
all repository connections trying to find that handle is the
repository's connection manager. Needless to say it seems a lot of code
for something which will be frequently called.
Regards,
Sri.

7 answers



permanent link
Dmitry Karasik (1.8k11) | answered Oct 23 '07, 5:09 a.m.
JAZZ DEVELOPER
On Mon, 22 Oct 2007 23:47:58 -0400, Srimanth Gunturi wrote:

Currently I go through IResource > IShareable > IShare
ISharingDescriptor > IWorkspaceHandle. From the IWorkspaceHandle I cycle
all repository connections trying to find that handle is the
repository's connection manager.

That is the right path to get the IWorkspaceHandle, once you have the
handle you can call IWorkspaceManager.getWorkspaceConnection(handle,
monitor), so there is no need to search for it within the workspace
manager.

- Dmitry

permanent link
Dmitry Karasik (1.8k11) | answered Oct 24 '07, 9:03 a.m.
JAZZ DEVELOPER
On Wed, 24 Oct 2007 12:25:34 -0400, Srimanth Gunturi wrote:

But to get IWorkspaceManager, one would need to cycle through the
repository connections in the workspace?

To get the IWorkspaceManager you can call

SCMPlatform.getWorkspaceManager(Repositories.getRepository
(sharingDescriptor));

- Dmitry

permanent link
Srimanth Gunturi (206125) | answered Oct 24 '07, 12:25 p.m.
JAZZ DEVELOPER
But to get IWorkspaceManager, one would need to cycle through the
repository connections in the workspace?
Regards,
Sri.


Dmitry Karasik wrote:
On Mon, 22 Oct 2007 23:47:58 -0400, Srimanth Gunturi wrote:

Currently I go through IResource > IShareable > IShare
ISharingDescriptor > IWorkspaceHandle. From the IWorkspaceHandle I cycle
all repository connections trying to find that handle is the
repository's connection manager.

That is the right path to get the IWorkspaceHandle, once you have the
handle you can call IWorkspaceManager.getWorkspaceConnection(handle,
monitor), so there is no need to search for it within the workspace
manager.

- Dmitry

permanent link
Jingwen Ou (5610) | answered Sep 26 '08, 1:43 a.m.
Is it possible to get all the IWorkspaceHandles of the workspace? I mean is there a API to do that, not collecting them through searching the whole workspace (SharingDescriptor > IWorkspaceHandle)?




But to get IWorkspaceManager, one would need to cycle through the
repository connections in the workspace?
Regards,
Sri.


Dmitry Karasik wrote:
On Mon, 22 Oct 2007 23:47:58 -0400, Srimanth Gunturi wrote:

Currently I go through IResource > IShareable > IShare
ISharingDescriptor > IWorkspaceHandle. From the IWorkspaceHandle I cycle
all repository connections trying to find that handle is the
repository's connection manager.

That is the right path to get the IWorkspaceHandle, once you have the
handle you can call IWorkspaceManager.getWorkspaceConnection(handle,
monitor), so there is no need to search for it within the workspace
manager.

- Dmitry

permanent link
Dmitry Karasik (1.8k11) | answered Sep 26 '08, 4:21 a.m.
JAZZ DEVELOPER
Is it possible to get all the IWorkspaceHandles of the workspace? I mean
is there a API to do that, not collecting them through searching the
whole workspace (SharingDescriptor > IWorkspaceHandle)?

The best you can do is:


for (IShare share : ISharingManager.allShares()) {
workspaces.add(share.getSharingDescriptor().getConnectionHandle());
}

- Dmitry

permanent link
Jingwen Ou (5610) | answered Sep 29 '08, 1:28 a.m.
I found another solution that might be simpler: IWorkspaceConnection.getContextHandle()

Is it possible to get all the IWorkspaceHandles of the workspace? I mean
is there a API to do that, not collecting them through searching the
whole workspace (SharingDescriptor > IWorkspaceHandle)?

The best you can do is:


for (IShare share : ISharingManager.allShares()) {
workspaces.add(share.getSharingDescriptor().getConnectionHandle());
}

- Dmitry

permanent link
Dmitry Karasik (1.8k11) | answered Sep 29 '08, 4:39 a.m.
JAZZ DEVELOPER
I found another solution that might be simpler:
IWorkspaceConnection.getContextHandle()

I thought you were talking about getting the workspace handles for all
the shares in the eclipse workspace since this thread was about getting
connections for filesystem objects and you said: "Is it possible to get
all the IWorkspaceHandles of the workspace?"

An IWorkspaceConnection has exactly 1 handle and you obtain it in exactly
the way you said, with getContextHandle().

- Dmitry

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.