How to delete the workspace programmatically in RTC SCM API
Hello All,
We have a usecase wherein we, need to get the Changesets from a particular snapshot given(Baselines).
We are creating the workspace connection for getting the connection object as mentioned in below uri :
https://jazz.net/forum/questions/239965/how-to-get-the-changesets-linked-to-a-particular-snapshot
IWorkspaceConnection tempwrkspaceCon=workspaceMgr.createWorkspace(scopeHandle, "testStreamDemoPurpose2", "forTestingpurpsose", snapShot, null);
IChangeHistory changeHistory = wrkspaceCon.changeHistory(compHandle);
List<IChangeHistoryDescriptor> csDescriptorList = changeHistory.getHistoryDescriptors(Integer.MAX_VALUE, false, null);
for (IChangeHistoryDescriptor csDescriptor : csDescriptorList) {
//some more code.
}
After getting all the ChangeSets, we need to delete the tempwrkspaceCon workspace, because that is not required anymore.
Could you please suggest as how to delete the workspace pointer programmatically ?
Thanks.
One answer
I believe you use the same API you used to create the workspace to delete it: com.ibm.team.scm.client.IWorkspaceManager.deleteWorkspace(IWorkspaceHandle, IProgressMonitor)
Comments
Thanks for the reply Ralph.
I was not able to use this API, since i have the IWorkspaceConnection object and not the IWorkspaceHandle.
IWorkspaceConnection tempwrkspaceCon=workspaceMgr.createWorkspace(scopeHandle, "testStreamDemoPurpose2", "forTestingpurpsose", snapShot, null);
Is there any other way to delete the workspace from its connection object ?
If you want to do this kind of work, you basically have to learn how to search in the SDK. Finding the IWorkspaceManager.deleteWorkspace() after the createWorkspace was already at IWorkspaceManager is a no brainer. Searching for IWorkspaceManager.deleteWorkspace() in the SDK is a 30 seconds operation and finding one of the first is SCMPlatform.getWorkspaceManager(workspace.teamRepository()).deleteWorkspace(workspace.getResolvedWorkspace(), null); which shows that com.ibm.team.scm.client.IFlowNodeConnection.getResolvedWorkspace() always returns the IWorkspace which is its own handle. Before you ask com.ibm.team.scm.client.IWorkspaceConnection extends com.ibm.team.scm.client.IFlowNodeConnection.
The easiest way to search is to open a class or method, right click at it and open the declaration. On the declaration right click and select References to search for them.