DavidVCorbin Absent Member.
Absent Member.
1830 views

Accessing content from before file deletion...

This is a followup to the previous question about the ReCycle Bin...

When an item is retrieved from the Bin, it has a history of what happened before the deletion. This is great, and what is desired. Where I am now running into trouble is getting the content from the pre-deleted Item instance...

 

      public Stream GetStream()
        {
            CheckoutManager checkoutManager = r_Item.View.CreateCheckoutManager();
            StarTeam.File myFile = r_Item as StarTeam.File;
            Stream myStream = new MemoryStream();
            checkoutManager.CheckoutTo(myFile, myStream);
            checkoutManager.Commit();
            myStream.Seek(0, SeekOrigin.Begin);
            return myStream;
        }

 

Not this code works perfectly for all items that have NOT been deleted....

0 Likes
11 Replies
Micro Focus Expert
Micro Focus Expert

RE: Accessing content from before file deletion...

>>getting the content from the pre-deleted Item instance...
you cannot use the deleted item from the recycle bin to fetch the content. The starteam server does not support this query.

you need to
a) find out when the item was deleted
b) create a rolled back (historical) view configuration set to a time just before the item was deleted
c) find the item in that rolled back view - hint, it'll have the same viewmemberid
d) checkout the content from any/all revision(s) of that file in that view.
e) close the rolled back view
0 Likes
DavidVCorbin Absent Member.
Absent Member.

RE: Accessing content from before file deletion...

I was afraid of that (was hoping the View property of the item would do all that...)

Worried about manageability and performance. Tens of thousands of items (many with hundreds of revisions), often deleted and re-created over a many year period. Makes it very hard to get a "walking history" so that one can see the overall picture at each point in time (where there has been any change since previous point)....
0 Likes
DavidVCorbin Absent Member.
Absent Member.

RE: Accessing content from before file deletion...

Looks like there are still issues....

The problems *seem* to arise when files are MOVED (or entire folders are moved). I have been unable to track the source vs. destinations....
0 Likes
Micro Focus Expert
Micro Focus Expert

RE: Accessing content from before file deletion...

to determine if a starteam artifact has been moved, you need to call the api

public ViewMemberRevision[] ViewMember::ViewMemberRevisions() {...}

walk the returned array looking for the entry where the ParentFolderItemID is not the current parent folder.
that's when the move occurred, and from where, and at what time.
0 Likes
DavidVCorbin Absent Member.
Absent Member.

RE: Accessing content from before file deletion...

Anil,

Thanks... This is becoming incredibly complex.... I have worked with a large number of systems, and nearly all of them have a very simple API of "GetHistory" which returns a linear list of *all* events (add, change, move, delete,, et.al.)..

Getting a FULL dump of *everything* (and having faith that it is 100% accurate) is such a struggle.....
0 Likes
DavidVCorbin Absent Member.
Absent Member.

RE: Accessing content from before file deletion...

Just looked at that, and it is a member of the View...So how do I know *all* of the possible views I need to get when there is over a decade of history????
0 Likes
Micro Focus Expert
Micro Focus Expert

RE: Accessing content from before file deletion...

ummm,

public ViewMemberRevision[] ViewMember::ViewMemberRevisions() {...}

 

A File is a ViewMember. I'm not sure what you're looking at.

0 Likes
DavidVCorbin Absent Member.
Absent Member.

RE: Accessing content from before file deletion...

Not sure what I am looking at either, that is why I am posting here <grin>

Seriously, is there any possibility of getting a sample that retrieves the *full* history into a simple CSV file?

The conceptual goal is that with this file (and an api call pasted on column contents to get actual file content) it would be possible to "replay" the entire history.....
0 Likes
DavidVCorbin Absent Member.
Absent Member.

RE: Accessing content from before file deletion...

What is the content difference (I see they are different objects between ViewMemberRevisions and History?? They always seem to return the same elements (though represented as different types)

Also, for Folders in the ReCycle bin, the DeletedTime does not seem to be populated??

REALLY hoping I can get a working sample that covers all this...(I would think a history dump would be a common sample).
0 Likes
Micro Focus Expert
Micro Focus Expert

RE: Accessing content from before file deletion...

I'm not sure what you mean by 'content' difference. We use content to represent the ascii/binary data associated with a file artifact instance.

>>a sample that retrieves the *full* history into a simple CSV file?
try running the command line (CommandProcessor class) command
new CommandProcessor(view).Execute("select lifecycle from file where viewmemberid = 1234");
this returns a string[][] of results which describes the life cycle of an artifact.
you could also run it from the command line stcmd and write its output into a .csv file.

here's a fraction of the code involved... it's not a sample... and please be warned. it's computationally expensive.

vw = m_processor.m_view.getRecycleBin();
((RecycleBin) vw).setIncludeActiveItems(true);
((RecycleBin) vw).setIncludeDeletedItems(true);
((RecycleBin) vw).setIncludeDeletedFolders(true);

File[] hh = file.getHistory().toArray(new File[0]);
ViewMemberRevision[] rr = new ViewMemberRevision[0];
ViewConfiguration cfg = file.getView().getConfiguration();
if (cfg.isTip() || cfg.isTimeBased())
rr = file.getViewMemberRevisions();
Vector c = new Vector();
for (int j = 0; j < hh.length; j++)
c.add(hh);
for (int j = 0; j < rr.length; j++) {
DateTime dt = rr.getTime();
for (int k = c.size() - 1; k >= 0; k--) {
Object o = c.get(k);
if (o instanceof Item) {
Item m = (Item) o;
if (dt.isAfter(m.getModifiedTime()))
continue;
c.insertElementAt(rr, k + 1);
break;
}
}
}

the basic gist of the algorithm is that you derive the lifecycle by combining history and view member revisions...

that's about all i can give you in terms of code hints, i'm afraid.
More than that, I'd be giving away the store...

If you need to discuss the StarTeam architecture, you are more than welcome to contact MicroFocus Customer Support. They will schedule a conference call involving you, me, and a couple other folks who'd be happy to give you a good overview.

Take care
anil
0 Likes
DavidVCorbin Absent Member.
Absent Member.

RE: Accessing content from before file deletion...

Anil,

Thanks for your help. I will discuss with the client and see if they can setup a call (alas, that could take days, and my contract ends tomorrow - was really hoping to have a working solution).

I can (sort of) see how that gets the history for an Item...but I am looking for the entire history of a project. Every interaction by every user impacting every artifact (Item) since the creation of the project until the current time/date....

When a project has more than a decade of history, and items are repeatedly moved, as well as deleted and then re-added, and then deleted (repeat "n" times) this gets much more complex than I have ever seen with *any* other source management system.

David
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.