You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Tyson Norris (JIRA)" <ji...@apache.org> on 2012/07/14 01:54:34 UTC

[jira] [Created] (SLING-2533) ResourceCollector fails to resolve selector scripts when no extension is used

Tyson Norris created SLING-2533:
-----------------------------------

             Summary: ResourceCollector fails to resolve selector scripts when no extension is used
                 Key: SLING-2533
                 URL: https://issues.apache.org/jira/browse/SLING-2533
             Project: Sling
          Issue Type: Bug
          Components: Servlets
    Affects Versions: Servlets Resolver 2.1.2
         Environment: this applies to version 2.1.3-SNAPSHOT
            Reporter: Tyson Norris


A specific use case where this comes up is:
request: http://localhost:4502/content/test/include

In JCR repo:
- node at content/test/include has sling:resourceType=test/main
- script to render this resource is /apps/test/main/GET.jsp
- script to render different type with selector referneced via:
<sling:include resourceType="test/sometype" replaceSelectors="special"/>
- script to render the different type is /apps/test/sometype/special.jsp 

in this case, special.jsp script is only resoved if renamed to special.GET.jsp

Note that:
- no extension on requested URL
- using a replaced selector in sling:include should behave similar to specifying an exentsion when the extension is null, I think. 

See attached patch to ResourceCollector and ScriptSelectionTest 


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SLING-2533) ResourceCollector fails to resolve selector scripts when no extension is used

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13414482#comment-13414482 ] 

Felix Meschberger commented on SLING-2533:
------------------------------------------

Conceptually, there can only be a selector if there also is an extension.

Now, this is really a case where Sling's RequestDispatcher is setup with a defined selector where the extension still does not exist.

Given the basic concept (no selector without an extension) this use is probably an error and is expected to fail.

Another angle to look at this: Extensions play a vital role in Sling for selecting the default response content type and thus to easily convey the client's response type preference. As such requests without extensions should be handled with extreme care up to the point that they should be discouraged.

So, rather than applying the patch, I am (at this point) more inclined to change the RequestDispatcher such as to fail with an exception if the extension is null but the selector is not.
                
> ResourceCollector fails to resolve selector scripts when no extension is used
> -----------------------------------------------------------------------------
>
>                 Key: SLING-2533
>                 URL: https://issues.apache.org/jira/browse/SLING-2533
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Resolver 2.1.2
>         Environment: this applies to version 2.1.3-SNAPSHOT
>            Reporter: Tyson Norris
>         Attachments: sling-2533.patch
>
>
> A specific use case where this comes up is:
> request: http://localhost:4502/content/test/include
> In JCR repo:
> - node at content/test/include has sling:resourceType=test/main
> - script to render this resource is /apps/test/main/GET.jsp
> - script to render different type with selector referneced via:
> <sling:include resourceType="test/sometype" replaceSelectors="special"/>
> - script to render the different type is /apps/test/sometype/special.jsp 
> in this case, special.jsp script is only resoved if renamed to special.GET.jsp
> Note that:
> - no extension on requested URL
> - using a replaced selector in sling:include should behave similar to specifying an exentsion when the extension is null, I think. 
> See attached patch to ResourceCollector and ScriptSelectionTest 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SLING-2533) ResourceCollector fails to resolve selector scripts when no extension is used

Posted by "Tyson Norris (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13415227#comment-13415227 ] 

Tyson Norris commented on SLING-2533:
-------------------------------------

I would summarize the problem here is exposed by the need to select alternate rendering scripts, in this case via sling:include. 

For example, alternate scripts can be selected by specifying an extension or selector in the url, but using sling:include, the selector specified is ignored when no extension is specified...

Maybe if this is conceptually illegal, could sling:include should be able to override/add an extension, in the same way that it can add/override selectors. 

Would specifying the extension in sling:include be tolerable? 
                
> ResourceCollector fails to resolve selector scripts when no extension is used
> -----------------------------------------------------------------------------
>
>                 Key: SLING-2533
>                 URL: https://issues.apache.org/jira/browse/SLING-2533
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Resolver 2.1.2
>         Environment: this applies to version 2.1.3-SNAPSHOT
>            Reporter: Tyson Norris
>         Attachments: sling-2533.patch
>
>
> A specific use case where this comes up is:
> request: http://localhost:4502/content/test/include
> In JCR repo:
> - node at content/test/include has sling:resourceType=test/main
> - script to render this resource is /apps/test/main/GET.jsp
> - script to render different type with selector referneced via:
> <sling:include resourceType="test/sometype" replaceSelectors="special"/>
> - script to render the different type is /apps/test/sometype/special.jsp 
> in this case, special.jsp script is only resoved if renamed to special.GET.jsp
> Note that:
> - no extension on requested URL
> - using a replaced selector in sling:include should behave similar to specifying an exentsion when the extension is null, I think. 
> See attached patch to ResourceCollector and ScriptSelectionTest 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SLING-2533) ResourceCollector fails to resolve selector scripts when no extension is used

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13416263#comment-13416263 ] 

Felix Meschberger commented on SLING-2533:
------------------------------------------

> Would specifying the extension in sling:include be tolerable? 

If this would not be possible (yet), I would consider this a valid extension, yes. And IIRC there has been some discussion around this, but I fail to remember any outcome.

> So far, users solved it by having a request filter upfront which checked if there is no extension but a usable accept header and then simply rewrote the request url path by appending the correct extension.

IMHO this sounds like sensible. OTOH we could as well implement this support when deciding the extension and there is none really.
                
> ResourceCollector fails to resolve selector scripts when no extension is used
> -----------------------------------------------------------------------------
>
>                 Key: SLING-2533
>                 URL: https://issues.apache.org/jira/browse/SLING-2533
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Resolver 2.1.2
>         Environment: this applies to version 2.1.3-SNAPSHOT
>            Reporter: Tyson Norris
>         Attachments: sling-2533.patch
>
>
> A specific use case where this comes up is:
> request: http://localhost:4502/content/test/include
> In JCR repo:
> - node at content/test/include has sling:resourceType=test/main
> - script to render this resource is /apps/test/main/GET.jsp
> - script to render different type with selector referneced via:
> <sling:include resourceType="test/sometype" replaceSelectors="special"/>
> - script to render the different type is /apps/test/sometype/special.jsp 
> in this case, special.jsp script is only resoved if renamed to special.GET.jsp
> Note that:
> - no extension on requested URL
> - using a replaced selector in sling:include should behave similar to specifying an exentsion when the extension is null, I think. 
> See attached patch to ResourceCollector and ScriptSelectionTest 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SLING-2533) ResourceCollector fails to resolve selector scripts when no extension is used

Posted by "dan mcweeney (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13415190#comment-13415190 ] 

dan mcweeney commented on SLING-2533:
-------------------------------------

This grew out of a need to make Sling more aware of the Accept header instead of just relying on the extension.  If a client does a  GET to a URL without an extension but that also has a well defined Accept header, e.g. "application/json" that is easy to route.  I agree that there is ambiguity if a client does a GET with no extension and an Accept header of "*/*" but the server can the just "do it's best" and send back some sensible default.  I think all this patch is trying to do is establish some sensible defaults for script resolution when a request like that occurs or if Sling doesn't become more aware of Accept header.
                
> ResourceCollector fails to resolve selector scripts when no extension is used
> -----------------------------------------------------------------------------
>
>                 Key: SLING-2533
>                 URL: https://issues.apache.org/jira/browse/SLING-2533
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Resolver 2.1.2
>         Environment: this applies to version 2.1.3-SNAPSHOT
>            Reporter: Tyson Norris
>         Attachments: sling-2533.patch
>
>
> A specific use case where this comes up is:
> request: http://localhost:4502/content/test/include
> In JCR repo:
> - node at content/test/include has sling:resourceType=test/main
> - script to render this resource is /apps/test/main/GET.jsp
> - script to render different type with selector referneced via:
> <sling:include resourceType="test/sometype" replaceSelectors="special"/>
> - script to render the different type is /apps/test/sometype/special.jsp 
> in this case, special.jsp script is only resoved if renamed to special.GET.jsp
> Note that:
> - no extension on requested URL
> - using a replaced selector in sling:include should behave similar to specifying an exentsion when the extension is null, I think. 
> See attached patch to ResourceCollector and ScriptSelectionTest 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SLING-2533) ResourceCollector fails to resolve selector scripts when no extension is used

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13414624#comment-13414624 ] 

Carsten Ziegeler commented on SLING-2533:
-----------------------------------------

I tend to agree with Felix here
                
> ResourceCollector fails to resolve selector scripts when no extension is used
> -----------------------------------------------------------------------------
>
>                 Key: SLING-2533
>                 URL: https://issues.apache.org/jira/browse/SLING-2533
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Resolver 2.1.2
>         Environment: this applies to version 2.1.3-SNAPSHOT
>            Reporter: Tyson Norris
>         Attachments: sling-2533.patch
>
>
> A specific use case where this comes up is:
> request: http://localhost:4502/content/test/include
> In JCR repo:
> - node at content/test/include has sling:resourceType=test/main
> - script to render this resource is /apps/test/main/GET.jsp
> - script to render different type with selector referneced via:
> <sling:include resourceType="test/sometype" replaceSelectors="special"/>
> - script to render the different type is /apps/test/sometype/special.jsp 
> in this case, special.jsp script is only resoved if renamed to special.GET.jsp
> Note that:
> - no extension on requested URL
> - using a replaced selector in sling:include should behave similar to specifying an exentsion when the extension is null, I think. 
> See attached patch to ResourceCollector and ScriptSelectionTest 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SLING-2533) ResourceCollector fails to resolve selector scripts when no extension is used

Posted by "Julian Sedding (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13415399#comment-13415399 ] 

Julian Sedding commented on SLING-2533:
---------------------------------------

IMHO the described issue is actually consistent behaviour. The SlingServletResolver has the concept of default extensions (html by default), which allow the extension name to be omitted in the script name. That's why your example works with the "html" extension, but not with a "txt" extension. I.e. selector.html.jsp is equivalent to selector.jsp, but selector.txt.jsp is not.

Consider the above example to be the "empty extension". The "empty extension" is not in the set of default extensions and therefore is treated like the "txt" extension. I.e. selector.<empty extension>.jsp is not equivalent to selector.jsp. Since writing the empty extension is a bit difficult the method name becomes necessary, which leads to say that selector.GET.jsp is only equivalent to selector.jsp if a default extension is used, but not in the case of the "empty extension".

FWIW, you can work around this issue quite easily by specifying a default extension in your sling:include. E.g. <sling:include path=".special.html" resourceType="test/sometype"/> should do the trick. Beware of unforeseen consequences further down the inlcude stack.

Sling was designed for use *with* extensions, therefore your mileage *without* may vary. (I'm actually surprised that it works so well.)

                
> ResourceCollector fails to resolve selector scripts when no extension is used
> -----------------------------------------------------------------------------
>
>                 Key: SLING-2533
>                 URL: https://issues.apache.org/jira/browse/SLING-2533
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Resolver 2.1.2
>         Environment: this applies to version 2.1.3-SNAPSHOT
>            Reporter: Tyson Norris
>         Attachments: sling-2533.patch
>
>
> A specific use case where this comes up is:
> request: http://localhost:4502/content/test/include
> In JCR repo:
> - node at content/test/include has sling:resourceType=test/main
> - script to render this resource is /apps/test/main/GET.jsp
> - script to render different type with selector referneced via:
> <sling:include resourceType="test/sometype" replaceSelectors="special"/>
> - script to render the different type is /apps/test/sometype/special.jsp 
> in this case, special.jsp script is only resoved if renamed to special.GET.jsp
> Note that:
> - no extension on requested URL
> - using a replaced selector in sling:include should behave similar to specifying an exentsion when the extension is null, I think. 
> See attached patch to ResourceCollector and ScriptSelectionTest 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SLING-2533) ResourceCollector fails to resolve selector scripts when no extension is used

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13416257#comment-13416257 ] 

Carsten Ziegeler commented on SLING-2533:
-----------------------------------------

Maybe supporting the accept header directly in Sling would be a good idea - not really sure. This is not the first time I hear the request for it :) So far, users solved it by having a request filter upfront which checked if there is no extension but a usable accept header and then simply rewrote the request url path by appending the correct extension. All requests getting into Sling use a proper extension. Not the nicest solution but does the trick.
                
> ResourceCollector fails to resolve selector scripts when no extension is used
> -----------------------------------------------------------------------------
>
>                 Key: SLING-2533
>                 URL: https://issues.apache.org/jira/browse/SLING-2533
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Resolver 2.1.2
>         Environment: this applies to version 2.1.3-SNAPSHOT
>            Reporter: Tyson Norris
>         Attachments: sling-2533.patch
>
>
> A specific use case where this comes up is:
> request: http://localhost:4502/content/test/include
> In JCR repo:
> - node at content/test/include has sling:resourceType=test/main
> - script to render this resource is /apps/test/main/GET.jsp
> - script to render different type with selector referneced via:
> <sling:include resourceType="test/sometype" replaceSelectors="special"/>
> - script to render the different type is /apps/test/sometype/special.jsp 
> in this case, special.jsp script is only resoved if renamed to special.GET.jsp
> Note that:
> - no extension on requested URL
> - using a replaced selector in sling:include should behave similar to specifying an exentsion when the extension is null, I think. 
> See attached patch to ResourceCollector and ScriptSelectionTest 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (SLING-2533) ResourceCollector fails to resolve selector scripts when no extension is used

Posted by "Tyson Norris (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2533?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tyson Norris updated SLING-2533:
--------------------------------

    Attachment: sling-2533.patch
    
> ResourceCollector fails to resolve selector scripts when no extension is used
> -----------------------------------------------------------------------------
>
>                 Key: SLING-2533
>                 URL: https://issues.apache.org/jira/browse/SLING-2533
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Resolver 2.1.2
>         Environment: this applies to version 2.1.3-SNAPSHOT
>            Reporter: Tyson Norris
>         Attachments: sling-2533.patch
>
>
> A specific use case where this comes up is:
> request: http://localhost:4502/content/test/include
> In JCR repo:
> - node at content/test/include has sling:resourceType=test/main
> - script to render this resource is /apps/test/main/GET.jsp
> - script to render different type with selector referneced via:
> <sling:include resourceType="test/sometype" replaceSelectors="special"/>
> - script to render the different type is /apps/test/sometype/special.jsp 
> in this case, special.jsp script is only resoved if renamed to special.GET.jsp
> Note that:
> - no extension on requested URL
> - using a replaced selector in sling:include should behave similar to specifying an exentsion when the extension is null, I think. 
> See attached patch to ResourceCollector and ScriptSelectionTest 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira