Andrew Connell [MVP SharePoint]
1579 Posts |  42 Articles |  4864 Comments
.NET  |  MCMS  |  SharePoint  |  Office System
SharePoint Quick Links
Article Categories
Archives
Post Categories


Add to Technorati Favorites

We heard at PDC that WSS v3 is going to include a trash bin/recycle bin OOTB.  However, we’re a good bit away from an RTM release and many want something now.  The problem with implementing your own recycle bin in the current versions of SharePoint revolves around the document library event sink and the async nature of the events.  You can trap and handle the Deleted event, but the problem is the event is fired async.  This means that by the time your code is run, the file is already deleted… thus you can’t do anything with it.  So some creative types have come up with what I’ve seen to be a limited few options.

Over the last few days there’s been a flurry of SharePoint Document Recycle Bin library activity that work with the existing WSS v2 & SPS 2003 versions with roughly 4 different options out there (one unsupported, which I’ll still mention with a big disclaimer):

  • First we have the method of creating a mirrored library using event sinks as method described in this article from the February 2005 issue of MSDN Magazine.  I’m not much of a fan of this option as your storage option just doubled in size… not really viable for those in corporate environments or have to pay for their hosting (including those corporate groups who pay “funny money” to other groups within their company for storage space, like, for example a SAN).
  • Another option is something Todd Bleeker w/ Mindsharp released this week: Mindsharp’s FREE Deleted Items Document Library Custom List Template.  What’s awesome about Todd’s solution is that it’s zero-touch server deployment… ok, and that it’s FREE!  I had the op to beta his Deleted Items Document Library a few times the last few months.  It’s a fantastic solution that meets many user’s requirements.  Because it’s all in an STP, there are a few things that it can’t account for, mainly WebDAV.  For example, if you delete a document from a mapped drive, or from the Windows Explorer, well it just can’t account for that.  I had the pleasure last week to see someone’s (Angus’) reaction to seeing it for the very first time as the three of us blew off the last session of the Publisher Summit.  This is probably the best, least impact, solution for organizations who need this capability, meeting 90% of the needs.  What I haven’t done is pick through Todd’s code… what a case study!
  • Dustin Miller has (err… will have) something he’s talking about called PowerRecycle (only vaporware at this point by his own admission).  Hard to comment on it since it’s not out there, but one thing he’s said is that “in order to work, will be doing quite a bit of ‘unsupported’ things

    For that reason, I don’t believe PowerRecycle will ever see the light of day within corporate installations of SharePoint [who are familiar with Fitz].  Many companies pay for support contracts, and if you’re doing something unsupported, Microsoft won’t… well… support it.  If you’ve spent time in the newsgroups, you’ll see people who’ve had irreversible issues because they’ve tinkered with the database.  I won’t ever recommend something that touches the SharePoint database… even adding a trigger or selecting a single record out of the database.  Why?  Because there are ~usually~ work arounds.  And if there aren’t, then… well… there aren’t and you can make a request for a change in the next version of the product (as v3 has).  In this case, there are work arounds (see Todd’s and Joel’s solutions). I’ll be interested to see how Dustin implements PowerRecycle, but it won’t make it past my dev box.

    In a recent post, Dustin says of his unsupported method: “That's just the only way to REALLY fix the problem of the lack of a recycle bin in WSS v2”.  I disagree… and you’ll see why, just keep reading…
  • Joel Oleson’s Recycle Bin has a very different implementation.  What’s unique here is Joel has built a ISAPI filter that intercepts the delete requests before they even make it to the SharePoint ISAPI filters.  When it finds a delete command, it dumps the file to the file system, then it hands the request off to other ISAPI filters (such as SharePoint’s filter) for processing.  Poof, all deleted documents are archived!  But… they are all on the file system… you have to have access to the server (physical, mapped drive, FTP, whatever).  For a production system, that’s not very viable… so a sysadmin would need to restore them for you.  Also, you need some sort of a cleanup job… I can see a very active system filling up the filesystem rather quickly.  This provides me the perfect transition to the real subject of my post…

Of all the above options, IMHO Todd’s is the best option.  Todd’s nails about 90% of the situations out there with zero touch to the server… and it’s incredibly easy to deploy.  However there are only a few limitations (that I’m willing to live with):

  • It only works for new libraries: have existing libraries?  You’ll have to convert them to this new library to give them recycle bin functionality.
  • It doesn’t work with WebDAV: It’s all wrapped up in an STP… it can’t account for WebDAV.

Joel’s solution provides the preservation of all deleted file… all the files (including WebDAV).  It also works for all existing libraries and can be mass applied at the scope of a virtual server.  What’s missing from Joel’s implementation?  A UI where an end user can restore a document.  Right now, only those with access to the filesystem of the SharePoint WFE server can retrieve the document.  How many end users or first level help desk folk do you know that have access to a WFE box?  I sure as hell hope that number is infinitely close to zero!

What’s really needed out there?  I think something of a cross between Todd’s and Joel’s solution.  Todd perfected the UI for, adding in multiple document templates for a library.  Joel’s solution works for existing libraries.  What else?  Something that does the following:

  • Allows end users to restore their own documents they’ve deleted
  • Allows anyone who has access to the document library where a document was deleted to see all documents in the “trash” from that library & restore them
  • Allow sysadmins to easily restore specific documents
  • Set a retention schedule for purging deleted documents

Sounds good huh?  How would I do it?  Let’s say you take Joel’s solution that saves a file that’s to be deleted from a library and stick it on the filesystem somewhere.  Then, you create an event sink handler that catches the Deleted event from the document libraries, grabs all the necessary information, grabs the file from the file system that Joel’s ISAPI filter persisted, and store all that information into a SQL database (no, not a SharePoint database, a separate database).

Now, you could write a SQL job to run every X days/weeks/months that could automatically purge anything that was X days/weeks/months old (providing a retention schedule).  You could also write a web app (wrapped up with appropriate security) to allow sysadmins, help desk jockies, or end users to restore their documents.  Or, even better yet, take Todd’s idea and extend the document library list template to include this web interface right in it!  What’s left is to just write a separate batch file that purges any files left on the file system as they were (1) saved by the ISAPI filter but (2) not moved into the database by your event sink so that library must not be publishing events and therefore want it’s documents stuffed in a recycle bin upon deletion.

I admit, this is just an idea and exists in vaporland (along with many of my other pet project ideas).  Maybe someone else will take this idea and the fame that goes along with it.  Go for it… for now, Todd’s and Joel’s solutions meet my needs (until a paying customer thinks otherwise… in that case, use my contact form in the menu above!).  If you aren’t happy with any of these work arounds, just stick it out and wait for SharePoint v3.

posted on Tuesday, October 11, 2005 10:28 PM

Feedback

# One More Recycle Bin Alternative by Todd 10/12/2005 6:08 AM The Boiler Room - Mark Kruger, S
Gravatar

# chjohn: New improved SharePoint Recycle Bin released!!! (must have) 10/12/2005 6:08 AM The Boiler Room - Mark Kruger, S
Gravatar

# re: Thinking a bit more about all these recycle bins... 10/12/2005 10:02 AM AC [MVP MCMS]
Gravatar Mark-

Good point... BizTalk would be a great solution... for those that already have it. I'd like to keep it simple for now.

Now all I need is the time to implement! :)

# re: Thinking a bit more about all these recycle bins... 10/12/2005 7:38 PM Dustin Miller
Gravatar First, I don't want to sound like a Todd-hater here. It's a clever bit of code that he did there. Here's the big problem with Todd's solution, though: The Web UI isn't the only interface with SharePoint, and in most customer implementations that I've seen, it's seldom used for doclibs; most end up using WebDAV (network share, mapped drive, or opening/saving/browsing in Office from Network Places). Those items, when deleted, are gone forever.

And none of these solutions even touches list items, a big deal for a lot of customers.

So: Still think there's a supported way for a recycle bin that gives everyone the functionality they need? I don't. :) The only way, the only sure-fire, no data lost, catch every possible call into SharePoint to delete an item/document tool is going to live in the database. An ISAPI filter /might/ be workable, but I'm not sure of the implications there when documents are deleted through WebDAV.

In an ideal world, we could just disable WebDAV and Todd's solution (or any of the other ones out there) would be a perfect fit. But the web UI isn't the only way into the data. That's the #1 thing we learned from our earlier (premature) release of PowerRecycle (back when it was PowerUndelete). Customers don't want partial protection, they want complete protection.

# On Recycle Bins and 10/12/2005 5:58 PM The Dean's Office
Gravatar

# re: Thinking a bit more about all these recycle bins... 10/12/2005 10:47 PM AC [MVP MCMS]
Gravatar Dustin - Your point is well taken. Each of these solutions has it's own issues associated with it, and each should be disclosed when offered to a customer. While the ISAPI filter will work for all situations (I saw you corrected yourself in your post on your site), a database modification method will work with lists as well.

However, in a corporate environment when you're the one responsible for hosting and maintaining the availability of the environment and have a support contract you pay tens, if not hundreds of thousands of $$$ annually, doing something that's unsupported just isn't an option.

# If two recycle bins theoretically collided... 10/11/2005 8:06 PM Heather Solomon's Blog - Design,
Gravatar

# re: Thinking a bit more about all these recycle bins... 10/12/2005 9:06 AM Mark Kruger
Gravatar AC, you make some very good points. I just wanted to comment on the last part of your post. Rather than using this proposed SQL job... why not just utilize BizTalk Server and have a workflow which would handle many of your proposed configurations such as a file drop location, schedule, security, logging, purging of documents, etc...? Just my $.02

# re: Thinking a bit more about all these recycle bins... 10/13/2005 7:20 PM Dustin Miller
Gravatar You're assuming that MS won't support you. That's a big assumption.

# re: Thinking a bit more about all these recycle bins... 10/13/2005 8:40 PM Dustin Miller
Gravatar Also, I'm curious: Who calls MS for support, and are the calling PSS or the developer support group? What kinds of support do customers commonly require of MS? From my informal survey of my customers, some of whom are 30,000+ desktops strong, none of them have called MS for anything, they handle it all internally.

# re: Thinking a bit more about all these recycle bins... 10/13/2005 9:19 PM Todd Bleeker
Gravatar Andrew,

I _do_ describe how to add self-restore functionality to existing document libraries in the documentation. It takes roughly five minutes for each library.

I think that a combination of approaches is certainly acceptable. In fact, because the documents are only renamed (rather than removed), the Deleted Items Document Library empowers Document Library Event Handlers to manipulate all documents in the library. So, if you want to do some kind of server processing on a given event to manipulate documents or on the library as a whole, all documents (deleted or otherwise) are still there and easy to identify when the event handler fires.

Use the ISAPI filter to catch the documents that users delete in ways that they themselves cannot be restored.

<Todd />

Post Feedback

Title:
Name:
Email:
(email will not be displayed)
Url:
Comments: 
Please add 5 and 6 and type the answer here:    
All Comments Are Filtered & Moderated
Unfortunately comment spammers are just too effecient and are constantly dirtying up blogs with irrelevant and unwanted comments trying to improve their standing on search engines. All comments on this blog are moderated. I do not censor comments, but I don't approve comments with vulger language or those soliciting products. Most of the time comments are approved within a few hours of being submitted with the only exception when I'm traveling.

Why are you asking for my email address?
The only reason I'm asking for your email address, which isn't required to submit a comment, is to provide a gravatar if you've created an account for yourself and associated your email address with a small image. If you have a gravatar created for the email address you submit, it will appear next to your comment. Otherwise nothing will appear.

What is a gravatar?
A gravatar is a "globally recognized avatar." You can get more information about gravatars, as well as create your own for free, at www.gravatar.com. You can also view my gravatar here.


Copyright © 2003 - 2010 Andrew Connell
Creative Commons License 
This work is licensed under a Creative Commons License
Site design by Heather Solomon.

 
 
MOSS WCM Training
Looking for MOSS 2007 WCM developer training? Look no further! I teach my 5-day hands-on and online WCM classes for developers I offer through my company: Critical Path Training.

Get more information on the WCM courses!