How to delete repository workspace directly?
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
Ralph Schoon (63.7k●3●36●48)
| 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
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.
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.
showing 5 of 6
show 1 more comments
|
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.