[ 
https://issues.apache.org/jira/browse/SLING-6187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15826738#comment-15826738
 ] 

Justin Edelson commented on SLING-6187:
---------------------------------------

[~alexander.klimetschek] the way the patch works is that:

1. Look for all the modifications which have an @ in them. Consider the part 
before the @ to be the "base path".
2. For each of those, identify if there is a item in the modification list with 
that "base path"
3. If there is one, fail.

So if the modification list contains
* {{foo}} + {{foo@Suffix}} - fail
* {{foo}} - ok
* {{foo@Suffix}} - ok

I realized I forgot to include the test for the last case in the diff. Here it 
is:

{code}
    public void testRemainingPostfixWithoutUnPostfixedIsSuccessful() {
        TestingResourceResolver resourceResolver = new 
TestingResourceResolver();

        MockSlingHttpServlet3Request request = new 
MockSlingHttpServlet3Request("/test", null, null, null, null);
        request.setResourceResolver(resourceResolver);

        final PostOperation operation = new AbstractPostOperation() {
            @Override
            protected void doRun(SlingHttpServletRequest request, PostResponse 
response, List<Modification> changes) throws RepositoryException {
                changes.add(Modification.onChange(ModificationType.CREATE, 
"/content/test@Postfix"));
            }
        };

        HtmlResponse response = new HtmlResponse();
        operation.run(request, response, new SlingPostProcessor[0]);
        assertTrue(response.isSuccessful());
        assertTrue(resourceResolver.commitCalled);
        assertFalse(resourceResolver.revertCalled);
    }
{code}

> Provide a way for a POST request to assert a set of required 
> SlingPostProcessors
> --------------------------------------------------------------------------------
>
>                 Key: SLING-6187
>                 URL: https://issues.apache.org/jira/browse/SLING-6187
>             Project: Sling
>          Issue Type: Improvement
>          Components: Servlets
>            Reporter: Justin Edelson
>            Assignee: Justin Edelson
>             Fix For: Servlets Post 2.3.16
>
>         Attachments: SLING-6187c.diff, SLING-6187.patch, 
> SLING-6187-profile.diff, SLING-6187-profile.diff, SLING-6187-validating.diff
>
>
> I would like to add support for a new "special" request parameter understood 
> by the Sling Post Servlet named {{:requiredPostProcessors}}. This parameter 
> may contain a comma-delimited list of names (see below) which *must* be 
> available *at the time the request is processed* in order for the request to 
> be handled. Whether or not those processors _do_ anything or whether the 
> request succeeds or not is a separate question; this is just a preflight 
> check if you will.
> If any of the required SlingPostProcessors are not available, the request 
> will fail with a 501 error.
> The name of a SlingPostProcessor will be defined by a newly defined service 
> registration property {{postProcessor.name}} and default to the simple name 
> of the SlingPostProcessor's implementation class if that property is not 
> defined.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to