Page 1 of 1
Retrieving deleted file history
Posted: Mon Jun 16, 2008 7:58 am
by Aestros
I'm working with the API and I've encountered a problem. I need to get every version of a project from vault. Everything works fine for the moment except for deleted files.
The only way to retrieve history of a deleted file is to force an undelete on it and this makes a new log in the file history. So my question is, can we get the history of a deleted file without undeleting it ?
Posted: Mon Jun 16, 2008 11:45 am
by shannon
There isn't a way to get the history for a deleted file.
However, getting each version of a folder should cover all the versions of the files within that folder.
Posted: Mon Jun 16, 2008 11:57 am
by Aestros
Thanks for the tips. It seems to work if I get the folder instead of the file directly.
Posted: Mon Jul 07, 2008 2:28 pm
by Aestros
One more question about undelete operation.
I've tried to find a way to "undelete" files with the API but I wasn't able to find a function to do it.
Can you help me out ?
Thanks !
Posted: Mon Jul 07, 2008 2:49 pm
by shannon
You'll just need to create changeset items and commit them:
Code: Select all
VaultClientOperationsLib.ChangeSetItemColl items = new ChangeSetItemColl();
foreach (VaultDeletedObject d in deletedObjects)
{
VaultClientOperationsLib.ChangeSetItem item = null;
if (d != null)
{
item = new ChangeSetItem_Undelete(VaultDateTime.Now, String.Empty, String.Empty, d.ID, d.FullPath, d.DeletionID);
}
items.Add(item);
}
ret = _clientInstance.Commit(items);
And you get a list of deleted items from a folder this way:
Code: Select all
ClientInstance.ListDeletedObjects(_vFolder.FullPath, false);
Posted: Mon Jul 07, 2008 2:54 pm
by Aestros
Was already able to get all the deleted objects
.
The "ChangeSetItemColl" routine was what I was looking.
Thanks a lot again for the fast answer
Posted: Mon Jul 07, 2008 2:58 pm
by shannon
Great, just wanted to cover all the bases
Posted: Tue Jul 08, 2008 11:34 am
by Aestros
One more thing.
Your routine work very well, it's easy to undelete every files with this, but, the comment are not showing up in Vault Client even if I change the 1st string.Empty and add a comment parameter in the .commit call. Is this an expected behavior ? Because I know you can't add comment directly from your Client application when undeleting objects but your API function support it.
Original code
Code: Select all
VaultClientOperationsLib.ChangeSetItemColl items = new ChangeSetItemColl();
foreach (VaultDeletedObject d in deletedObjects)
{
VaultClientOperationsLib.ChangeSetItem item = null;
if (d != null)
{
item = new ChangeSetItem_Undelete(VaultDateTime.Now, String.Empty, String.Empty, d.ID, d.FullPath, d.DeletionID);
}
items.Add(item);
}
ret = _clientInstance.Commit(items);
Changed line #1 :
Code: Select all
item = new ChangeSetItem_Undelete(VaultDateTime.Now,"Automated Undelete", String.Empty, d.ID, d.FullPath, d.DeletionID);
Changed line #2 :
Code: Select all
ret = _clientInstance.Commit(items,"Automated Undelete");
Posted: Tue Jul 08, 2008 11:58 am
by shannon
Try setting the comment this way:
ClientInstance.InternalChangeSet_SetComment("comment");
I think you're wanting to set the change set comment, not an item comment.
Posted: Tue Jul 08, 2008 12:29 pm
by Aestros
Nice !
It's working for the "Change Set Comment" as you said.
Thanks !