You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Philipp Koch (JIRA)" <ji...@apache.org> on 2008/01/16 10:49:34 UTC

[jira] Created: (SLING-164) JcrResourceResolver.adaptTo(ObjectContentManager.class) returns (in most cases) null

JcrResourceResolver.adaptTo(ObjectContentManager.class) returns (in most cases) null
------------------------------------------------------------------------------------

                 Key: SLING-164
                 URL: https://issues.apache.org/jira/browse/SLING-164
             Project: Sling
          Issue Type: Bug
          Components: Resource
            Reporter: Philipp Koch
            Priority: Critical


the adaptTo method returns currently the value set in the objectContentManager field. this field might not be initialized (in most cases) resp. set to null.
the below pasted fix should solve the problem.

@SuppressWarnings("unchecked")
    public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
        if (type == Session.class) {
            return (AdapterType) getSession();
        } else if (type == ObjectContentManager.class) {
            return (AdapterType) getObjectContentManager();
        } else if (type == PathResolver.class) {
            return (AdapterType) this;
        }

        // no adapter available
        return null;
    }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (SLING-164) JcrResourceResolver.adaptTo(ObjectContentManager.class) returns (in most cases) null

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

Carsten Ziegeler closed SLING-164.
----------------------------------

    Resolution: Fixed

This issue has been fixed some minutes ago.

> JcrResourceResolver.adaptTo(ObjectContentManager.class) returns (in most cases) null
> ------------------------------------------------------------------------------------
>
>                 Key: SLING-164
>                 URL: https://issues.apache.org/jira/browse/SLING-164
>             Project: Sling
>          Issue Type: Bug
>          Components: Resource
>            Reporter: Philipp Koch
>            Priority: Critical
>
> the adaptTo method returns currently the value set in the objectContentManager field. this field might not be initialized (in most cases) resp. set to null.
> the below pasted fix should solve the problem.
> @SuppressWarnings("unchecked")
>     public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
>         if (type == Session.class) {
>             return (AdapterType) getSession();
>         } else if (type == ObjectContentManager.class) {
>             return (AdapterType) getObjectContentManager();
>         } else if (type == PathResolver.class) {
>             return (AdapterType) this;
>         }
>         // no adapter available
>         return null;
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.