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

Delete a file using Java Plain API

How do I delete a file using Plain Java API?
I am able to get the files IVersionableHandle, but I don't know how to delete it.
(I want to remove a former checked in file from a stream.)

0 votes



One answer

Permanent link
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);

0 votes

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.

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,949
× 27

Question asked: Jan 29 '18, 7:01 a.m.

Question was seen: 2,373 times

Last updated: Apr 01 '19, 6:30 a.m.

Confirmation Cancel Confirm