Delete a file using Java Plain API
One answer
ITeamRepository repo = getRepo();
IWorkspaceHandle workspaceHandle = getWorkspace();
IVersionableHandle fileToDelete = getVersionable();
IChangeSetHandle changeSet = getChangeSet(); // Change set to check into
IWorkspaceManager wm = ScmPlatform.getWorkspaceManager(repo);
IWorkspaceConnection wc = wm.getWorkspaceConnection(workspaceHandle, monitor);
Collection ops = new ArrayList();
ops.add(wc.configurationOpFactory().delete(fileToDelete ));
IUpdateReport report = wc.commit(Collections.singletonList(changeSet ), Collections.singletonList(ops), monitor);
Comments
Is there a public API for deleting file\folder from sandbox without committing the local change to change-set ?
Did you mean undo the unresolved file changes? If so,
ILocalChangeManager lcm = FileSystemCore.getSharingManager().getLocalChangeManager();
You have to iterate over the changes to find your change:
ILocalChange[] localChanges = lscm.getPendingChanges(...);
Then call undo changes only for those changes you have to undo:
lscm.undoChanges(localChanges, ...);
Thanks for your reply, Shashikant.
No, the file in sandbox may be in sync with the stream. Up until now I used java.io.File.delete to delete the file and then I fetched the local changes with ILocalChangeManager in order to check-in them or check-in and deliver. java.io.File.delete returns sometimes false on failure with no documentation on the relevant error. I'm looking for a public RTC SDK client API to replace it.