incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1068374 - in /sling/whiteboard/fmeschbe/adapterfactory: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/sling/ src/main/java/org/apache/sling/jcr/ src/main/java/org/apache/sling/jcr/ja...
Date Tue, 08 Feb 2011 13:20:23 GMT
Author: fmeschbe
Date: Tue Feb  8 13:20:22 2011
New Revision: 1068374

URL: http://svn.apache.org/viewvc?rev=1068374&view=rev
Log:
JCR/Jackrabbit AdapterFactory prototype

Added:
    sling/whiteboard/fmeschbe/adapterfactory/   (with props)
    sling/whiteboard/fmeschbe/adapterfactory/pom.xml   (with props)
    sling/whiteboard/fmeschbe/adapterfactory/src/
    sling/whiteboard/fmeschbe/adapterfactory/src/main/
    sling/whiteboard/fmeschbe/adapterfactory/src/main/java/
    sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/
    sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/
    sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/
    sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/
    sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/
    sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/
    sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/AccessControlAdapterFactory.java
  (with props)
    sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/PrincipalManagementAdapterFactory.java
  (with props)
    sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/UserManagementAdapterFactory.java
  (with props)

Propchange: sling/whiteboard/fmeschbe/adapterfactory/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Feb  8 13:20:22 2011
@@ -0,0 +1,4 @@
+.classpath
+.project
+target
+.settings

Added: sling/whiteboard/fmeschbe/adapterfactory/pom.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/adapterfactory/pom.xml?rev=1068374&view=auto
==============================================================================
--- sling/whiteboard/fmeschbe/adapterfactory/pom.xml (added)
+++ sling/whiteboard/fmeschbe/adapterfactory/pom.xml Tue Feb  8 13:20:22 2011
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+    
+    http://www.apache.org/licenses/LICENSE-2.0
+    
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>10</version>
+    </parent>
+
+    <artifactId>org.apache.sling.jcr.jackrabbit.adapterfactory</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+    <name>Apache Sling Jackrabbit AdapterFactory</name>
+    <description>
+        Provides AdapterFactory services to adapt Sling Resource and
+        ResourceResolver objects to various JCR and Jackrabbit security
+        and access control objects.
+    </description>
+
+    <scm>
+        <connection>
+            scm:svn:http://svn.day.com/repos/people/fmeschbe/cq5/jrusermanagement
+        </connection>
+        <developerConnection>
+            scm:svn:http://svn.day.com/repos/people/fmeschbe/cq5/jrusermanagement
+        </developerConnection>
+        <url>
+            http://svn.day.com/repos/people/pkoch/fmeschbe/cq5/jrusermanagement
+        </url>
+    </scm>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.sling</groupId>
+                <artifactId>maven-sling-plugin</artifactId>
+                <configuration>
+                    <slingUrlSuffix>/libs/sling/install</slingUrlSuffix>
+                    <slingUrl>http://localhost:4502/crx/repository/crx.default</slingUrl>
+                    <usePut>true</usePut>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Private-Package>
+                            org.apache.sling.jcr.jackrabbit.adapterfactory.*,
+                        </Private-Package>
+                        <Import-Package>
+                            org.apache.jackrabbit.api.*;resolution:=optional,
+                            *
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+    
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.api</artifactId>
+            <version>2.0.8</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.adapter</artifactId>
+            <version>2.0.8</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-api</artifactId>
+            <version>2.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.jcr</groupId>
+            <artifactId>jcr</artifactId>
+            <version>2.0</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>4.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <version>1.4.0</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>

Propchange: sling/whiteboard/fmeschbe/adapterfactory/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/fmeschbe/adapterfactory/pom.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/AccessControlAdapterFactory.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/AccessControlAdapterFactory.java?rev=1068374&view=auto
==============================================================================
--- sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/AccessControlAdapterFactory.java
(added)
+++ sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/AccessControlAdapterFactory.java
Tue Feb  8 13:20:22 2011
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.jcr.jackrabbit.adapterfactory;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.security.AccessControlManager;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager;
+import org.apache.sling.api.adapter.AdapterFactory;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.osgi.framework.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Component(metatype = false)
+@Service
+@Properties({
+    @org.apache.felix.scr.annotations.Property(name = Constants.SERVICE_DESCRIPTION, value
= "AdapterFactory adapting Resource[Resolver] to JCR or Jackrabbit AccessControlManager"),
+    @org.apache.felix.scr.annotations.Property(name = Constants.SERVICE_VENDOR, value = "The
Apache Software Foundation"),
+    @org.apache.felix.scr.annotations.Property(name = AdapterFactory.ADAPTABLE_CLASSES, value
= {
+        "org.apache.sling.api.resource.ResourceResolver",
+        "org.apache.sling.api.resource.Resource" }),
+    @org.apache.felix.scr.annotations.Property(name = AdapterFactory.ADAPTER_CLASSES, value
= {
+        "javax.jcr.security.AccessControlManager",
+        "org.apache.jackrabbit.api.security.JackrabbitAccessControlManager" }) })
+public class AccessControlAdapterFactory implements AdapterFactory {
+
+    /** default log */
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @SuppressWarnings("unchecked")
+    public <AdapterType> AdapterType getAdapter(final Object adaptable,
+            final Class<AdapterType> type) {
+        final ResourceResolver resolver;
+        if (adaptable instanceof ResourceResolver) {
+            resolver = (ResourceResolver) adaptable;
+        } else if (adaptable instanceof Resource) {
+            resolver = ((Resource) adaptable).getResourceResolver();
+        } else {
+            log.warn(
+                "getAdapter: Unexpected call with unsupported adaptable {}; ResourceResolver
or Resource is required to adapt to {}",
+                adaptable, type);
+            return null;
+        }
+
+        final Session s = resolver.adaptTo(Session.class);
+        if (s == null) {
+            log.info(
+                "getAdapter: ResourceResolver must adapt to JCR session; not adapting {}
to {}",
+                adaptable, type);
+            return null;
+        }
+
+        if (type == AccessControlManager.class) {
+            try {
+                return (AdapterType) s.getAccessControlManager();
+            } catch (RepositoryException re) {
+
+            }
+        } else if (type == JackrabbitAccessControlManager.class) {
+            try {
+                AccessControlManager acm = s.getAccessControlManager();
+                if (acm instanceof JackrabbitAccessControlManager) {
+                    return (AdapterType) acm;
+                }
+            } catch (RepositoryException re) {
+
+            }
+        }
+
+        log.warn(
+            "getAdapter: Unexpected call with unsupported type {}; cannot adapt {}",
+            type, adaptable);
+        return null;
+    }
+}

Propchange: sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/AccessControlAdapterFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/AccessControlAdapterFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/PrincipalManagementAdapterFactory.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/PrincipalManagementAdapterFactory.java?rev=1068374&view=auto
==============================================================================
--- sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/PrincipalManagementAdapterFactory.java
(added)
+++ sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/PrincipalManagementAdapterFactory.java
Tue Feb  8 13:20:22 2011
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.jcr.jackrabbit.adapterfactory;
+
+import java.security.Principal;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.principal.PrincipalManager;
+import org.apache.sling.api.adapter.AdapterFactory;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.osgi.framework.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Component(metatype = false)
+@Service
+@Properties({
+    @org.apache.felix.scr.annotations.Property(name = Constants.SERVICE_DESCRIPTION, value
= "AdapterFactory adapting Resource[Resolver] to Jackrabbit PrincipalManager, Principal, or
JackrabbitPrincipal"),
+    @org.apache.felix.scr.annotations.Property(name = Constants.SERVICE_VENDOR, value = "The
Apache Software Foundation"),
+    @org.apache.felix.scr.annotations.Property(name = AdapterFactory.ADAPTABLE_CLASSES, value
= {
+        "org.apache.sling.api.resource.ResourceResolver",
+        "org.apache.sling.api.resource.Resource" }),
+    @org.apache.felix.scr.annotations.Property(name = AdapterFactory.ADAPTER_CLASSES, value
= {
+        "org.apache.jackrabbit.api.security.principal.PrincipalManager",
+        "java.security.Principal",
+        "org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal" }) })
+public class PrincipalManagementAdapterFactory implements AdapterFactory {
+
+    /** default log */
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @SuppressWarnings("unchecked")
+    public <AdapterType> AdapterType getAdapter(final Object adaptable,
+            final Class<AdapterType> type) {
+
+        final ResourceResolver resolver;
+        if (adaptable instanceof ResourceResolver) {
+            resolver = (ResourceResolver) adaptable;
+        } else if (adaptable instanceof Resource) {
+            resolver = ((Resource) adaptable).getResourceResolver();
+        } else {
+            log.warn(
+                "getAdapter: Unexpected call with unsupported adaptable {}; ResourceResolver
or Resource is required to adapt to {}",
+                adaptable, type);
+            return null;
+        }
+
+        final Session s = resolver.adaptTo(Session.class);
+        final JackrabbitSession js;
+        if (s == null) {
+            log.info(
+                "getAdapter: ResourceResolver must adapt to JCR session; not adapting {}
to {}",
+                adaptable, type);
+            return null;
+        } else if (s instanceof JackrabbitSession) {
+            js = (JackrabbitSession) s;
+        } else {
+            log.warn(
+                "getAdapter: Cannot use non-Jackrabbit Session {} ({}) to adapt {} to {}",
+                new Object[] { s, s.getClass().getName(), adaptable, type });
+            return null;
+        }
+
+        final PrincipalManager principalManager;
+        try {
+            principalManager = js.getPrincipalManager();
+        } catch (AccessDeniedException e) {
+            log.warn("getAdapter: No Permission to access PrinicipalManager");
+            return null;
+        } catch (UnsupportedRepositoryOperationException e) {
+            log.debug(
+                "getAdapter: PrinicipalManagement not supported here; not adapting {} to
{}",
+                adaptable, type);
+            return null;
+        } catch (RepositoryException e) {
+            log.debug("getAdapter: General problem adapting " + adaptable
+                + " to " + type, e);
+            return null;
+        }
+
+        if (type == PrincipalManager.class) {
+            return (AdapterType) principalManager;
+        }
+
+        Principal p = principalManager.getPrincipal(s.getUserID());
+        if (type.isInstance(p)) {
+            return (AdapterType) p;
+        }
+        log.info(
+            "getAdapter: No Principal found or not requested type for user {}",
+            s.getUserID());
+        return null;
+    }
+}

Propchange: sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/PrincipalManagementAdapterFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/PrincipalManagementAdapterFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/UserManagementAdapterFactory.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/UserManagementAdapterFactory.java?rev=1068374&view=auto
==============================================================================
--- sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/UserManagementAdapterFactory.java
(added)
+++ sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/UserManagementAdapterFactory.java
Tue Feb  8 13:20:22 2011
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.jcr.jackrabbit.adapterfactory;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.api.security.user.UserManager;
+import org.apache.sling.api.adapter.AdapterFactory;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.osgi.framework.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Component(metatype = false)
+@Service
+@Properties({
+    @org.apache.felix.scr.annotations.Property(name = Constants.SERVICE_DESCRIPTION, value
= "AdapterFactory adapting Resource[Resolver] to Jackrabbit UserManager, User, or Authorizable"),
+    @org.apache.felix.scr.annotations.Property(name = Constants.SERVICE_VENDOR, value = "The
Apache Software Foundation"),
+    @org.apache.felix.scr.annotations.Property(name = AdapterFactory.ADAPTABLE_CLASSES, value
= {
+        "org.apache.sling.api.resource.ResourceResolver",
+        "org.apache.sling.api.resource.Resource" }),
+    @org.apache.felix.scr.annotations.Property(name = AdapterFactory.ADAPTER_CLASSES, value
= {
+        "org.apache.jackrabbit.api.security.user.UserManager",
+        "org.apache.jackrabbit.api.security.user.User",
+        "org.apache.jackrabbit.api.security.user.Authorizable" }) })
+public class UserManagementAdapterFactory implements AdapterFactory {
+
+    /** default log */
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @SuppressWarnings("unchecked")
+    public <AdapterType> AdapterType getAdapter(final Object adaptable,
+            final Class<AdapterType> type) {
+
+        final ResourceResolver resolver;
+        if (adaptable instanceof ResourceResolver) {
+            resolver = (ResourceResolver) adaptable;
+        } else if (adaptable instanceof Resource) {
+            resolver = ((Resource) adaptable).getResourceResolver();
+        } else {
+            log.warn(
+                "getAdapter: Unexpected call with unsupported adaptable {}; ResourceResolver
or Resource is required to adapt to {}",
+                adaptable, type);
+            return null;
+        }
+
+        final Session s = resolver.adaptTo(Session.class);
+        final JackrabbitSession js;
+        if (s == null) {
+            log.info(
+                "getAdapter: ResourceResolver must adapt to JCR session; not adapting {}
to {}",
+                adaptable, type);
+            return null;
+        } else if (s instanceof JackrabbitSession) {
+            js = (JackrabbitSession) s;
+        } else {
+            log.warn(
+                "getAdapter: Cannot use non-Jackrabbit Session {} ({}) to adapt {} to {}",
+                new Object[] { s, s.getClass().getName(), adaptable, type });
+            return null;
+        }
+
+        if (type == UserManager.class) {
+            try {
+                return (AdapterType) js.getUserManager();
+            } catch (RepositoryException re) {
+
+            }
+
+        } else if (type == User.class) {
+            try {
+                Authorizable a = js.getUserManager().getAuthorizable(
+                    s.getUserID());
+                if (a instanceof User) {
+                    return (AdapterType) a;
+                }
+                log.error("getAdapter: No User found for user {}",
+                    s.getUserID());
+            } catch (RepositoryException re) {
+
+            }
+
+        } else if (type == Authorizable.class) {
+            try {
+                Authorizable a = js.getUserManager().getAuthorizable(
+                    s.getUserID());
+                if (a != null) {
+                    return (AdapterType) a;
+                }
+                log.error("getAdapter: No Authorizable found for user {}",
+                    s.getUserID());
+            } catch (RepositoryException re) {
+
+            }
+        }
+
+        log.warn(
+            "getAdapter: Unexpected call with unsupported type {}; cannot adapt {}",
+            type, adaptable);
+        return null;
+    }
+}

Propchange: sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/UserManagementAdapterFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/fmeschbe/adapterfactory/src/main/java/org/apache/sling/jcr/jackrabbit/adapterfactory/UserManagementAdapterFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url



Mime
View raw message