Thanks Carsten and Eric for your advices. I think the Processor would be a good choice, but it's more intrusive than servlets from what I noticed because it can't be registered on a specific resourceType, nor to a specific operation. So, registering a Processor to do something after a Delete Operation in my case, would have an impact on all POST operations.
I've seen a discussion on this topic here ( http://www.mail-archive.com/[email protected]/msg03150.html ), but didn't see any updates afterwards in JIRA. I was thinking at what would it take to cache Processors based on their properties once installed, similar to Servlets properties; at least on 2 properties: Operation name and Resource Type. I was looking to see if I can inject my own implementation to do this, but at the moment it's not possible with SlingPostServlet. Would have been nice to have the Processors logic extracted out of SlingPostServlet, into a PostProcessorsCachingService, so that the line: operation.run(request, htmlResponse, processors); would be replaced by operation.run(request, htmlResponse, PostProcessorsCachingService.getProcessors(request) ); or something similar, to filter processors. Thanks for your help, Dragos Dascalita Haut On Fri, Mar 16, 2012 at 9:25 PM, Eric Norman <[email protected]>wrote: > If you want to use a servlet to override the behavior, you can perform your > extra logic in your servlet and then forward to the default sling post > servlet at the end to do the rest. > > For example, something like this: > > Resource resource = request.getResource(); > RequestDispatcher rd = request.getRequestDispatcher(resource.getPath(), > new RequestDispatcherOptions("sling/servlet/default")); > rd.forward(request, response); > > > On Thu, Mar 15, 2012 at 1:30 AM, Dascalita Dragos <[email protected] > >wrote: > > > Hi, > > > > I'd like to ask what is the best way to intercept a delete operation so > > that I can do some pre-preparation/validation/post-processing before > > actually letting Post Servlet deleting that node. > > > > So far, I've tried listening to TOPIC_RESOURCE_REMOVED , but when this > even > > is handled, the Node is already removed, so I can't perform anything as > > it's too late; I can't put my hands on the content that has been deleted. > > All I found out was the "path" info, but no resource data. > > > > Another thing I've tried was to extend SlingPostServlet, but it was a no > > go, b/c the org.apache.sling.servlets.post.impl.* is a private package, > > can't be used on other bundles, which makes sense. > > > > Another idea I had was to extend SlingAllMethodsServlet, but the problem > > I'm having is that I'm overriding the default workflow in Sling, which is > > something I don't want to do. I would not override the default workflow, > > just because I have a tiny logic to inject before deleting the content. > > > > I was thinking to decorate the DeleteOperation, but didn't figure it out > if > > I can/I should. > > > > I'm also thinking that I may register a PostProcessor to be called for > the > > DeleteOperation, but I think that it's too late since the content has > been > > already deleted. > > > > What would be your approach in this case ? > > > > Thanks, > > Dragos Dascalita Haut > > >
