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
>