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

Programmatically restore deleted file

 Hi Everyone,

Is it possible to programatically restore a deleted file?  The configuration object doesn't seem to have anything that supports files that it no longer knows about it.  Is it possible to find the versionableHandle and save it to the configuration?  What options do I have?

Thanks,
Scott

0 votes

Comments

 I've been able to get a versionableHandle by using IConfiguration#determineAncestorsInHistory(), but that only gets me a versionableHandle.  If I want to save it to a configuration, I need a versionable.  Does anybody know how to grab a versionable of a previously deleted file?


Thanks,
Scott

 Switching gears a bit, attempting to grab the versionable using IVersionableManager#fetchCompleteState().  The problem is, my IVersionableHandle that I retrieve from determineAncestorsInHistory() does not have a stateID.  However, the javadoc for the IAncestorReport#getNameItemPairs() says that "all item handles within the ancestor report carry state ids."  I assume that my IVersionableHandle has no stateid because it's been deleted.


Still struggling here, any help on getting an IVersionable from a deleted item would be great.

Thanks,
Scott



One answer

Permanent link
What you want to do is determine which of the versions you want to restore. One way to do this is determine the history of the item within the configuration and choose the version. IFlowNodeConnection#changeHistory(IComponentHandle) will get you an IChangeHistory which you can use to get the history of the versionable. The history will identify the change sets it was changed in.  The change set has changes with before/after and merge states to help you choose the right state to restore.

To restore the state, you just need to commit it in a change set. Using IWorkspaceConfiguration#IConfigurationOpFactory#revert will create an op to commit, or you can retrieve the full versionable and save it again using IConfigurationOpFactory#save to get the commit op. Going the save route will result in a new state id being generated.

1 vote

Comments

Hi Heather,


Thanks so much for the response.  The problem I'm having is during the #revert() #save() stage, sorry for not articulating this well enough.  I'm grabbing the IVersionableHandle a little differently than you describe, via IChangeSetSearchCritera (I don't think this matters, however).

Once I have the IVersionableHandle that I want to revert to, when calling IWorkspaceConfiguration#IConfigurationOpFactory#revert(), I get an IllegalArguementException.  I tried going the save() route as well, but saving requires an IVersionable not an IVersionableHandle.  I've been unable to figure out how to get an IVersionable of an IVersionableHandle that has been deleted.  Doing a fetch from the configuration throws a "does not exist in configuration exception".

Thanks in advance,
Scott

Hi Scott

If you are using IChangeSetSearchCriteria, not a problem. Once you have picked the change set that has a reference to the version you want restored, retrieve the IChangeSet using IItemManager. IChangeSet#changes() will provide a list of all the versionables changed in the change set. Iterate to find the IChange for your versionable. Get the versionable state handle from IChange#beforeState() IChange#afterState() or IChange#mergeStates() (which you pick depends on which version you are picking).

You can use IConfigurationOpFactory#revert on that handle. The parent folder must still be in the configuration. If thats not the case, then you can retrieve the full versionable (using IVersionableManager), create a working copy, set a different parent and use IConfigurationOpFactory#save.

  • Heather

ps. You may want to use the comment link rather than adding new answers to your question.

Hi Heather,

Thanks so much. I was not grabbing the versionableStateHandle. Instead, I was using IChange#item(). Grabbing a state handle has resolved my issue!

Scott

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

Question asked: Sep 06 '12, 3:25 p.m.

Question was seen: 5,336 times

Last updated: Sep 10 '12, 5:29 p.m.

Confirmation Cancel Confirm