There's actually a direct solution to this problem. Register a service
using the interface org.apache.sling.servlets.post.NodeNameGenerator
instead of a PostProcessor.

Your NodeNameGenerator would look like this:

@Component
@Service
public class MyNodeNameGenerator implements NodeNameGenerator {
   public String getNodeName(SlingHttpServletRequest request, String
parentPath, boolean requirePrefix, NodeNameGenerator defaultNNG) {
     if (parentPath.equals("/parent")) {
        return "folderA/" + defaultNNG.getNodeName(request, parentPath,
requirePrefix, defaultNNG);
      } else {

         return null;
      }
   }
}

On 1/21/11 6:58 AM, Markus Joschko wrote:
> Hi,
> I face some difficulties in realizing the following case:
> 
> I have a node to which I want to add children. The problem is, that
> (depending on the content of the to be created node) it is not added
> to the node directly but a folder is created to which the node is
> added. Like that
> 
> + parent
>      + folderA (dynamically created)
>          - childABC
>      + folderB (dynamically created)
>          -childBAC
> 
> Because the folders might not be available, I post to parent/* and
> registered a postprocessor to create the folder and move the just
> created child to the corresponding folder.
> That works fine. However the redirect url is still pointing to the
> previous location (parent/childABC) instead of
> parent/folderA/childABC.
> And I can't find a way to modify the location of the response within
> the postprocessor.
> 
> So I wonder whether I am on the right track or should choose a
> different approach. Alternatively I could create my own postoperation
> but that seems to be cumbersome as extending from ModifyOperation
> isn't easy because of the dependencies in the constructor and
> AbstractCreateOperation is package private. So I would basically need
> to copy code directly.
> 
> Any thoughts on this?
> 
> Thanks,
>  Markus

Reply via email to