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 (Created) (JIRA)" <ji...@apache.org> on 2012/04/14 07:18:26 UTC

[jira] [Created] (SLING-2457) ResourceUtil.isA() fails if resource has a type, whose super type is not readable

ResourceUtil.isA() fails if resource has a type, whose super type is not readable
---------------------------------------------------------------------------------

                 Key: SLING-2457
                 URL: https://issues.apache.org/jira/browse/SLING-2457
             Project: Sling
          Issue Type: Bug
          Components: API
    Affects Versions: API 2.2.0
            Reporter: Tyson Norris


* define a resource at /content/component/foo whose type is myapp/components/bar
* define bar at /apps/myapp/components/bar
* on /apps/myapp/components/bar, set sling:resourceSuperType as /libs/components/bar2

If resolver from resource.getResourceResolver() cannot access /libs/components/bar2, then ResouceUtil.isA(resource, "components/bar2") returns false, otherwise it returns true.

There could be an argument that it should not return true in any case, however, if you set resourceSuperType on resource as "components/bar2", then it returns true with current implementation. 

At least one of these is wrong, I think. 

--
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-2457) ResourceUtil.isA() fails if resource has a type, whose super type is not readable

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

Carsten Ziegeler updated SLING-2457:
------------------------------------

    Fix Version/s: API 2.2.6
                   Servlets Resolver 2.1.4
    
> ResourceUtil.isA() fails if resource has a type, whose super type is not readable
> ---------------------------------------------------------------------------------
>
>                 Key: SLING-2457
>                 URL: https://issues.apache.org/jira/browse/SLING-2457
>             Project: Sling
>          Issue Type: Bug
>          Components: API
>    Affects Versions: API 2.2.0
>            Reporter: Tyson Norris
>            Assignee: Carsten Ziegeler
>             Fix For: Servlets Resolver 2.1.4, API 2.2.6
>
>
> * define a resource at /content/component/foo whose type is myapp/components/bar
> * define bar at /apps/myapp/components/bar
> * on /apps/myapp/components/bar, set sling:resourceSuperType as /libs/components/bar2
> If resolver from resource.getResourceResolver() cannot access /libs/components/bar2, then ResouceUtil.isA(resource, "components/bar2") returns false, otherwise it returns true.
> There could be an argument that it should not return true in any case, however, if you set resourceSuperType on resource as "components/bar2", then it returns true with current implementation. 
> At least one of these is wrong, I think. 

--
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-2457) ResourceUtil.isA() fails if resource has a type, whose super type is not readable

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

Felix Meschberger commented on SLING-2457:
------------------------------------------

This is arguably not correct, yes.

Maybe the isA check should follow what the Servlet Resolver does (a special user is used to look the scripts up). Maybe even that same user should be used. So here is the proposal:

* The Servlet Resolver provides a ResourceDecorator which implements the isResourceType method using the servlet resolver user
* The ResourceUtil.isA method is modified as follows:
      - rename isA to a new package private isAInternal method 
      - create new isA method calling Resource.isResourceType first and on failure calls isAInternal
      - change AbstractResource.isResourceType to call new ResourceUtil.isAInternal directly
      - the o.a.s.resource package export micro version is incremented to signal this fix

The Servlet Resolver ResourceDecorator would be something like this:

  public Resource decorate(Resource r) {
     return new ResourceWrapper(r) {
        public boolean isResourceType(final String type) {
          return ResourceUtil.isA(new ResourceWrapper(getResource()) {
            public ResourceResolver getResourceResolver() {
              return servletResolverResourceResolver;
            }
          }, type);
     };
  };

(NB: The AbstractResource.getParent() and ResourceUtil.getParent(Resource) methods should probably also be modified analogous to the isResourceType and isA methods to allow for proper Resource decoration.)
                
> ResourceUtil.isA() fails if resource has a type, whose super type is not readable
> ---------------------------------------------------------------------------------
>
>                 Key: SLING-2457
>                 URL: https://issues.apache.org/jira/browse/SLING-2457
>             Project: Sling
>          Issue Type: Bug
>          Components: API
>    Affects Versions: API 2.2.0
>            Reporter: Tyson Norris
>
> * define a resource at /content/component/foo whose type is myapp/components/bar
> * define bar at /apps/myapp/components/bar
> * on /apps/myapp/components/bar, set sling:resourceSuperType as /libs/components/bar2
> If resolver from resource.getResourceResolver() cannot access /libs/components/bar2, then ResouceUtil.isA(resource, "components/bar2") returns false, otherwise it returns true.
> There could be an argument that it should not return true in any case, however, if you set resourceSuperType on resource as "components/bar2", then it returns true with current implementation. 
> At least one of these is wrong, I think. 

--
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-2457) ResourceUtil.isA() fails if resource has a type, whose super type is not readable

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

Jeff Young commented on SLING-2457:
-----------------------------------

Is the fail-over from Resource.isResourceType to isAInternal really buying us anything?  Why not just modify the existing isA to use isResourceType?

(I presume it has something to do with AbstractResource, since your proposal short-circuits the isResourceType call there, but I'm not able to connect the dots.)

                
> ResourceUtil.isA() fails if resource has a type, whose super type is not readable
> ---------------------------------------------------------------------------------
>
>                 Key: SLING-2457
>                 URL: https://issues.apache.org/jira/browse/SLING-2457
>             Project: Sling
>          Issue Type: Bug
>          Components: API
>    Affects Versions: API 2.2.0
>            Reporter: Tyson Norris
>
> * define a resource at /content/component/foo whose type is myapp/components/bar
> * define bar at /apps/myapp/components/bar
> * on /apps/myapp/components/bar, set sling:resourceSuperType as /libs/components/bar2
> If resolver from resource.getResourceResolver() cannot access /libs/components/bar2, then ResouceUtil.isA(resource, "components/bar2") returns false, otherwise it returns true.
> There could be an argument that it should not return true in any case, however, if you set resourceSuperType on resource as "components/bar2", then it returns true with current implementation. 
> At least one of these is wrong, I think. 

--
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] [Resolved] (SLING-2457) ResourceUtil.isA() fails if resource has a type, whose super type is not readable

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

Carsten Ziegeler resolved SLING-2457.
-------------------------------------

    Resolution: Fixed

Implemented as Felix suggested
                
> ResourceUtil.isA() fails if resource has a type, whose super type is not readable
> ---------------------------------------------------------------------------------
>
>                 Key: SLING-2457
>                 URL: https://issues.apache.org/jira/browse/SLING-2457
>             Project: Sling
>          Issue Type: Bug
>          Components: API
>    Affects Versions: API 2.2.0
>            Reporter: Tyson Norris
>            Assignee: Carsten Ziegeler
>             Fix For: Servlets Resolver 2.1.4, API 2.2.6
>
>
> * define a resource at /content/component/foo whose type is myapp/components/bar
> * define bar at /apps/myapp/components/bar
> * on /apps/myapp/components/bar, set sling:resourceSuperType as /libs/components/bar2
> If resolver from resource.getResourceResolver() cannot access /libs/components/bar2, then ResouceUtil.isA(resource, "components/bar2") returns false, otherwise it returns true.
> There could be an argument that it should not return true in any case, however, if you set resourceSuperType on resource as "components/bar2", then it returns true with current implementation. 
> At least one of these is wrong, I think. 

--
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] [Assigned] (SLING-2457) ResourceUtil.isA() fails if resource has a type, whose super type is not readable

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

Carsten Ziegeler reassigned SLING-2457:
---------------------------------------

    Assignee: Carsten Ziegeler
    
> ResourceUtil.isA() fails if resource has a type, whose super type is not readable
> ---------------------------------------------------------------------------------
>
>                 Key: SLING-2457
>                 URL: https://issues.apache.org/jira/browse/SLING-2457
>             Project: Sling
>          Issue Type: Bug
>          Components: API
>    Affects Versions: API 2.2.0
>            Reporter: Tyson Norris
>            Assignee: Carsten Ziegeler
>
> * define a resource at /content/component/foo whose type is myapp/components/bar
> * define bar at /apps/myapp/components/bar
> * on /apps/myapp/components/bar, set sling:resourceSuperType as /libs/components/bar2
> If resolver from resource.getResourceResolver() cannot access /libs/components/bar2, then ResouceUtil.isA(resource, "components/bar2") returns false, otherwise it returns true.
> There could be an argument that it should not return true in any case, however, if you set resourceSuperType on resource as "components/bar2", then it returns true with current implementation. 
> At least one of these is wrong, I think. 

--
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-2457) ResourceUtil.isA() fails if resource has a type, whose super type is not readable

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

Tobias Bocanegra commented on SLING-2457:
-----------------------------------------

Resource type resolution should work independent of the access permissions. The same is already true for script resolution. i.e. the request to /content/component/foo would already resolve to a script in components/bar2 (if not present in components/bar).

                
> ResourceUtil.isA() fails if resource has a type, whose super type is not readable
> ---------------------------------------------------------------------------------
>
>                 Key: SLING-2457
>                 URL: https://issues.apache.org/jira/browse/SLING-2457
>             Project: Sling
>          Issue Type: Bug
>          Components: API
>    Affects Versions: API 2.2.0
>            Reporter: Tyson Norris
>
> * define a resource at /content/component/foo whose type is myapp/components/bar
> * define bar at /apps/myapp/components/bar
> * on /apps/myapp/components/bar, set sling:resourceSuperType as /libs/components/bar2
> If resolver from resource.getResourceResolver() cannot access /libs/components/bar2, then ResouceUtil.isA(resource, "components/bar2") returns false, otherwise it returns true.
> There could be an argument that it should not return true in any case, however, if you set resourceSuperType on resource as "components/bar2", then it returns true with current implementation. 
> At least one of these is wrong, I think. 

--
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-2457) ResourceUtil.isA() fails if resource has a type, whose super type is not readable

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

Felix Meschberger commented on SLING-2457:
------------------------------------------

> Is the fail-over from Resource.isResourceType to isAInternal really buying us anything?
> Why not just modify the existing isA to use isResourceType?

>From AbstractResource.isResourceType:

        // Implemented calling the ResourceUtil.isA method (which actually has
        // the implementation) to prevent problems if there are implementations
        // of the pre-2.1.0 Resource interface in the framework.

If there happens to be an old Resource interface implementation, which does not implement the isResourceType method and does not extend from AbstractResource (which newer implementations should), and the providing bundle does not properly import the o.a.s.resource package with appropriate version ranges, calling Resource.isResourceType would result in an AbstractMethodError (we have seen that).
                
> ResourceUtil.isA() fails if resource has a type, whose super type is not readable
> ---------------------------------------------------------------------------------
>
>                 Key: SLING-2457
>                 URL: https://issues.apache.org/jira/browse/SLING-2457
>             Project: Sling
>          Issue Type: Bug
>          Components: API
>    Affects Versions: API 2.2.0
>            Reporter: Tyson Norris
>
> * define a resource at /content/component/foo whose type is myapp/components/bar
> * define bar at /apps/myapp/components/bar
> * on /apps/myapp/components/bar, set sling:resourceSuperType as /libs/components/bar2
> If resolver from resource.getResourceResolver() cannot access /libs/components/bar2, then ResouceUtil.isA(resource, "components/bar2") returns false, otherwise it returns true.
> There could be an argument that it should not return true in any case, however, if you set resourceSuperType on resource as "components/bar2", then it returns true with current implementation. 
> At least one of these is wrong, I think. 

--
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