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

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?

0 votes



One answer

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

0 votes

Comments

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.

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.

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.

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

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

Question asked: Feb 16 '16, 8:00 p.m.

Question was seen: 2,971 times

Last updated: Feb 17 '16, 6:45 a.m.

Confirmation Cancel Confirm