It's all about the answers!

Ask a question

How to delete repository workspace directly?


Alexandra Li (1124) | asked Feb 16 '16, 8:00 p.m.
My original intention is creating a repository workspace first, then delete it directly.
My code:
IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(repo);
IWorkspaceConnection repoWorkspace = null;
repoWorkspace = wm.createWorkspace(repo.loggedInContributor(), workspaceName,workspaceDesc, monitor);

.//operation with the repoWorkspace .....

IWorkspaceSearchCriteria criteria = IWorkspaceSearchCriteria.FACTORY.newInstance().setExactName(workspaceName);
List<IWorkspaceHandle> workspaceHandles= wm.findWorkspaces(criteria,   Integer.MAX_VALUE, null);
wm.deleteWorkspace(workspaceHandles.get(0), null);

Now my question:
In my code, I have use criteria to find it first, then delete it. And I think it's not very good.So how can i delete it directly?

One answer



permanent link
Ralph Schoon (63.1k33646) | answered Feb 17 '16, 2:04 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
What do you mean with directly? If you store the original workspace object (wm in your example), you should be able to use that to delete the workspace. You only have to find it again, obviously, if you lost the object/interface class you got when creating it.

Comments
Alexandra Li commented Feb 17 '16, 4:56 a.m.

I mean, I don't lost the object, all the code i post in one function, so I think the "find" operation is useless. BUT, I don't know how to delelte it without to find it again.


Ralph Schoon commented Feb 17 '16, 5:07 a.m. | edited Feb 17 '16, 5:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Sorry, but all you need in your code above is the IWorkspaceConnectionHandle, or the IWorkspaeConnection. If you have the IWorkspaceConnection - which you have, that should also implement or provide the IWorkspaceConnectionHandle (most objects implement or make the handle aavailable) you need for delete. So you can just pass

wm.deleteWorkspace(repoWorkspace , null);

in your code above to the IWorkspaceManager wm.


Alexandra Li commented Feb 17 '16, 5:13 a.m.

if use wm.delelteWorkspace(repoWorkspace, null); it shows an error that "repoWorkspace" is not "IWorkspaceHandle", and also can not do cast.


Ralph Schoon commented Feb 17 '16, 5:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Have a look at IWorkspaceConnection and look for a getter such ad getItemHandle or the like.


Alexandra Li commented Feb 17 '16, 6:06 a.m.

so far, I don't get the method to get the IWorkspaceHandle.


Ralph Schoon commented Feb 17 '16, 6:45 a.m. | edited Feb 17 '16, 6:45 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

In your Development environment set up as described in the Extensions Workshop and in https://rsjazz.wordpress.com/2015/09/30/learning-to-fly-getting-started-with-the-rtc-java-apis/ Open the declaration for IWorkspaceManager, locate the delete function you want to use. Do a Java search fir the references of said method and browse the references in the SDK.

You will then find that you need to use the getResolvedWorkspace to get the latest version



wm.deleteWorkspace(repoWorkspace.getResolvedWorkspace(), monitor);


showing 5 of 6 show 1 more comments

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.