You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2013/02/22 10:09:59 UTC

svn commit: r1448950 - in /sling/trunk: bundles/api/src/main/java/org/apache/sling/api/resource/ bundles/api/src/test/java/org/apache/sling/api/resource/ bundles/extensions/bundleresource/ bundles/extensions/fsresource/ bundles/jcr/jackrabbit-usermanag...

Author: cziegeler
Date: Fri Feb 22 09:09:59 2013
New Revision: 1448950

URL: http://svn.apache.org/r1448950
Log:
SLING-2739 :  Add methods for handling the resource type hierarchy to the resource resolver 

Modified:
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AbstractResource.java
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/package-info.java
    sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/ResourceUtilTest.java
    sling/trunk/bundles/extensions/bundleresource/pom.xml
    sling/trunk/bundles/extensions/fsresource/pom.xml
    sling/trunk/bundles/jcr/jackrabbit-usermanager/pom.xml
    sling/trunk/bundles/jcr/resource/pom.xml
    sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerTest.java
    sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceTest.java
    sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java
    sling/trunk/bundles/resourceresolver/pom.xml
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
    sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverImplTest.java
    sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderEntryTest.java
    sling/trunk/bundles/servlets/resolver/pom.xml
    sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java
    sling/trunk/contrib/extensions/mongodb/pom.xml
    sling/trunk/launchpad/builder/src/main/bundles/list.xml

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AbstractResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AbstractResource.java?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AbstractResource.java (original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AbstractResource.java Fri Feb 22 09:09:59 2013
@@ -109,32 +109,9 @@ public abstract class AbstractResource
      * Returns <code>true</code> if this resource is of the given resource type
      * or if any of the super resource types equals the given resource type.
      * <p>
-     * This method is implemented by first checking the resource type then
-     * walking up the resource super type chain using the
-     * {@link ResourceUtil#findResourceSuperType(Resource)} and
-     * {@link ResourceUtil#getResourceSuperType(ResourceResolver, String)}
-     * methods.
+     * This method delegates to {@link ResourceResolver#isResourceType(Resource, String)}
      */
-    public boolean isResourceType(String resourceType) {
-        /*
-        * Check if the resource is of the given type. This method first checks the
-        * resource type of the resource, then its super resource type and continues
-        * to go up the resource super type hierarchy.
-        */
-        if ( resourceType == null ) {
-            return false;
-        }
-        if (resourceType.equals(getResourceType())) {
-            return true;
-        }
-        String superType = ResourceUtil.findResourceSuperType(this);
-        while (superType != null) {
-            if (resourceType.equals(superType)) {
-                return true;
-            }
-            superType = ResourceUtil.getResourceSuperType(getResourceResolver(),
-                    superType);
-        }
-        return false;
+    public boolean isResourceType(final String resourceType) {
+        return this.getResourceResolver().isResourceType(this, resourceType);
     }
 }

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java (original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java Fri Feb 22 09:09:59 2013
@@ -538,6 +538,7 @@ public interface ResourceResolver extend
      * @throws UnsupportedOperationException If the resource provider does not allow to
      *                                       delete this resource.
      * @throws PersistenceException If the operation fails.
+     * @since 2.2
      */
     void delete(Resource resource)
     throws PersistenceException;
@@ -554,12 +555,14 @@ public interface ResourceResolver extend
      * @throws UnsupportedOperationException If the resource provider does not allow to
      *                                       create a resource at that location.
      * @throws PersistenceException If the operation fails.
+     * @since 2.2
      */
     Resource create(Resource parent, String name, Map<String, Object> properties)
     throws PersistenceException;
 
     /**
      * Revert all pending changes.
+     * @since 2.2
      */
     void revert();
 
@@ -567,11 +570,57 @@ public interface ResourceResolver extend
      * Persist all pending changes.
      *
      * @throws PersistenceException
+     * @since 2.2
      */
     void commit() throws PersistenceException;
 
     /**
      * Are there any pending changes?
+     * @since 2.2
      */
     boolean hasChanges();
+
+    /**
+     * Returns the super type of the given resource. This method checks first if
+     * the resource itself knows its super type by calling
+     * {@link Resource#getResourceSuperType()}. If that returns
+     * <code>null</code> {@link #getResourceSuperType(String)}
+     * is invoked with the resource type of the resource.
+     *
+     * @param resource The resource to return the resource super type for.
+     * @return The resource super type or <code>null</code>. This
+     *         method also returns <code>null</code> if the
+     *         provided resource is <code>null</code>
+     * @since 2.3
+     */
+    String getResourceSuperType(final Resource resource);
+
+    /**
+     * Returns the super type of the given resource type. This method converts
+     * the resource type to a resource path and checks the corresponding resource.
+     * If the resource exists, the {@link Resource#getResourceSuperType()} method
+     * is called.
+     *
+     * @param resourceType The resource type whose super type is to be returned.
+     * @return the super type of the <code>resourceType</code> or
+     *         <code>null</code> if the resource type does not exist or returns
+     *         <code>null</code> for its super type. It also returns
+     *         <code>null</code> if <code>resourceType> is null.
+     * @since 2.3
+     */
+    public String getResourceSuperType(final String resourceType);
+
+    /**
+     * Returns <code>true</code> if the resource type or any of the resource's
+     * super type(s) equals the given resource type.
+     *
+     * @param resource The resource to check
+     * @param resourceType The resource type to check this resource against.
+     * @return <code>true</code> if the resource type or any of the resource's
+     *         super type(s) equals the given resource type. <code>false</code>
+     *         is also returned if <code>resource</code> or<code>resourceType</code>
+     *         are <code>null</code>.
+     * @since 2.3
+     */
+    boolean isResourceType(final Resource resource, final String resourceType);
 }

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java (original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java Fri Feb 22 09:09:59 2013
@@ -165,13 +165,13 @@ public class ResourceUtil {
      * Utility method returns the ancestor's path at the given <code>level</code>
      * relative to <code>path</code>, which is normalized by {@link #normalize(String)}
      * before resolving the ancestor.
-     * 
+     *
      * <ul>
      * <li><code>level</code> = 0 returns the <code>path</code>.</li>
      * <li><code>level</code> = 1 returns the parent of <code>path</code>, if it exists, <code>null</code> otherwise.</li>
      * <li><code>level</code> = 2 returns the grandparent of <code>path</code>, if it exists, <code>null</code> otherwise.</li>
      * </ul>
-     * 
+     *
      * @param path The path whose ancestor is to be returned.
      * @param level The relative level of the ancestor, relative to <code>path</code>.
      * @return <code>null</code> if <code>path</code> doesn't have an ancestor at the
@@ -414,33 +414,12 @@ public class ResourceUtil {
      *         <code>null</code> if the resource type does not exists or returns
      *         <code>null</code> for its super type.
      * @since 2.0.6
+     * @deprecated Use {@link ResourceResolver#getResourceSuperType(String)}
      */
+    @Deprecated
     public static String getResourceSuperType(
             final ResourceResolver resourceResolver, final String resourceType) {
-        // normalize resource type to a path string
-        final String rtPath = resourceTypeToPath(resourceType);
-        // get the resource type resource and check its super type
-        String resourceSuperType = null;
-        // if the path is absolute, use it directly
-        if (rtPath != null && rtPath.startsWith("/")) {
-            final Resource rtResource = resourceResolver.getResource(rtPath);
-            if (rtResource != null) {
-                resourceSuperType = rtResource.getResourceSuperType();
-            }
-
-        } else {
-            // if the path is relative we use the search paths
-            for (final String searchPath : resourceResolver.getSearchPath()) {
-                final Resource rtResource = resourceResolver.getResource(searchPath
-                        + rtPath);
-                if (rtResource != null
-                        && rtResource.getResourceSuperType() != null) {
-                    resourceSuperType = rtResource.getResourceSuperType();
-                    break;
-                }
-            }
-        }
-        return resourceSuperType;
+        return resourceResolver.getResourceSuperType(resourceType);
     }
 
     /**
@@ -454,14 +433,11 @@ public class ResourceUtil {
      * @return the super type of the <code>resource</code> or <code>null</code>
      *         if no super type could be computed.
      * @since 2.0.6
+     * @deprecated Use {@link ResourceResolver#getResourceSuperType(Resource)}
      */
+    @Deprecated
     public static String findResourceSuperType(final Resource resource) {
-        String resourceSuperType = resource.getResourceSuperType();
-        if (resourceSuperType == null) {
-            resourceSuperType = getResourceSuperType(
-                    resource.getResourceResolver(), resource.getResourceType());
-        }
-        return resourceSuperType;
+        return resource.getResourceResolver().getResourceSuperType(resource);
     }
 
     /**
@@ -476,12 +452,11 @@ public class ResourceUtil {
      *         {@link Resource#isResourceType(String)} with the given
      *         <code>resourceType</code>.
      * @since 2.0.6
+     * @deprecated Use {@link ResourceResolver#isResourceType(Resource, String)}
      */
+    @Deprecated
     public static boolean isA(final Resource resource, final String resourceType) {
-        if (resource == null || resourceType == null) {
-            return false;
-        }
-        return resource.isResourceType(resourceType);
+        return resource.getResourceResolver().isResourceType(resource, resourceType);
     }
 
     /**

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/package-info.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/package-info.java?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/package-info.java (original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/package-info.java Fri Feb 22 09:09:59 2013
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-@Version("2.2")
+@Version("2.3")
 package org.apache.sling.api.resource;
 
 import aQute.bnd.annotation.Version;

Modified: sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/ResourceUtilTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/ResourceUtilTest.java?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/ResourceUtilTest.java (original)
+++ sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/ResourceUtilTest.java Fri Feb 22 09:09:59 2013
@@ -256,73 +256,6 @@ public class ResourceUtilTest {
         assertEquals("a/b", ResourceUtil.resourceTypeToPath("a:b"));
     }
 
-    @Test public void test_getResourceSuperType() {
-        // the resource resolver
-        final ResourceResolver resolver = this.context.mock(ResourceResolver.class);
-        // the resource to test
-        final Resource r = this.context.mock(Resource.class, "resource1");
-        final Resource r2 = this.context.mock(Resource.class, "resource2");
-        final Resource typeResource = this.context.mock(Resource.class, "typeResource");
-        this.context.checking(new Expectations() {{
-            allowing(r).getResourceType(); will(returnValue("a:b"));
-            allowing(r).getResourceResolver(); will(returnValue(resolver));
-
-            allowing(r2).getResourceType(); will(returnValue("a:c"));
-            allowing(r2).getResourceResolver(); will(returnValue(resolver));
-
-            allowing(typeResource).getResourceType();
-            will(returnValue("x:y"));
-            allowing(typeResource).getResourceSuperType();
-            will(returnValue("t:c"));
-
-            allowing(resolver).getResource("/a");
-            will(returnValue(r));
-            allowing(resolver).getResource("a/b");
-            will(returnValue(typeResource));
-            allowing(resolver).getResource("a/c");
-            will(returnValue(null));
-            allowing(resolver).getSearchPath();
-            will(returnValue(new String[] {""}));
-        }});
-        assertEquals("t:c", ResourceUtil.getResourceSuperType(r.getResourceResolver(), r.getResourceType()));
-        assertNull(ResourceUtil.getResourceSuperType(r2.getResourceResolver(), r2.getResourceType()));
-    }
-
-    @Test public void test_isA() {
-        // the resource resolver
-        final ResourceResolver resolver = this.context.mock(ResourceResolver.class);
-        // the resource to test
-        final Resource r = new SyntheticResource(resolver, "/a", "a:b") {
-            @Override
-            public String getResourceSuperType() {
-                return "d:e";
-            }
-        };
-        final Resource typeResource = this.context.mock(Resource.class, "typeResource");
-        this.context.checking(new Expectations() {{
-            allowing(typeResource).getResourceType();
-            will(returnValue("x:y"));
-            allowing(typeResource).getResourceSuperType();
-            will(returnValue("t:c"));
-
-            allowing(resolver).getResource("/a");
-            will(returnValue(r));
-            allowing(resolver).getResource("a/b");
-            will(returnValue(null));
-            allowing(resolver).getResource("t/c");
-            will(returnValue(null));
-            allowing(resolver).getResource("d/e");
-            will(returnValue(typeResource));
-            allowing(resolver).getSearchPath();
-            will(returnValue(new String[] {""}));
-        }});
-        assertTrue(ResourceUtil.isA(r, "a:b"));
-        assertTrue(ResourceUtil.isA(r, "d:e"));
-        assertFalse(ResourceUtil.isA(r, "x:y"));
-        assertTrue(ResourceUtil.isA(r, "t:c"));
-        assertFalse(ResourceUtil.isA(r, "h:p"));
-    }
-
     @SuppressWarnings("unchecked")
     @Test public void test_adaptTo() {
         // we define three resources

Modified: sling/trunk/bundles/extensions/bundleresource/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/bundleresource/pom.xml?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/bundleresource/pom.xml (original)
+++ sling/trunk/bundles/extensions/bundleresource/pom.xml Fri Feb 22 09:09:59 2013
@@ -93,7 +93,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.3.0</version>
+            <version>2.3.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

Modified: sling/trunk/bundles/extensions/fsresource/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/fsresource/pom.xml?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/fsresource/pom.xml (original)
+++ sling/trunk/bundles/extensions/fsresource/pom.xml Fri Feb 22 09:09:59 2013
@@ -91,7 +91,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.3.0</version>
+            <version>2.3.1-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>

Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/pom.xml?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/pom.xml (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/pom.xml Fri Feb 22 09:09:59 2013
@@ -74,6 +74,10 @@
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
+                        <Import-Package>
+                            org.apache.sling.api.resource;provide:=true,
+                            *
+                        </Import-Package>
                         <Export-Package>
                             org.apache.sling.jackrabbit.usermanager;version=2.2.1,
                         </Export-Package>
@@ -99,7 +103,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.1.0</version>
+            <version>2.3.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

Modified: sling/trunk/bundles/jcr/resource/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/pom.xml?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/pom.xml (original)
+++ sling/trunk/bundles/jcr/resource/pom.xml Fri Feb 22 09:09:59 2013
@@ -146,7 +146,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.3.0</version>
+            <version>2.3.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerTest.java?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerTest.java (original)
+++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerTest.java Fri Feb 22 09:09:59 2013
@@ -253,6 +253,22 @@ public class JcrResourceListenerTest ext
                     // TODO Auto-generated method stub
                     return false;
                 }
+
+                public String getResourceSuperType(Resource resource) {
+                    // TODO Auto-generated method stub
+                    return null;
+                }
+
+                public String getResourceSuperType(String resourceType) {
+                    // TODO Auto-generated method stub
+                    return null;
+                }
+
+                public boolean isResourceType(Resource resource,
+                        String resourceType) {
+                    // TODO Auto-generated method stub
+                    return false;
+                }
             };
             final ResourceResolverFactory factory = new ResourceResolverFactory() {
 

Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceTest.java?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceTest.java (original)
+++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceTest.java Fri Feb 22 09:09:59 2013
@@ -28,9 +28,7 @@ import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 
 import org.apache.jackrabbit.JcrConstants;
-import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceMetadata;
-import org.apache.sling.api.resource.ResourceUtil;
 import org.apache.sling.jcr.resource.JcrResourceConstants;
 
 public class JcrNodeResourceTest extends JcrItemResourceTestBase {
@@ -118,7 +116,7 @@ public class JcrNodeResourceTest extends
         jnr = new JcrNodeResource(null, node, null);
         assertEquals(typeName, jnr.getResourceType());
     }
-
+/*
     public void testResourceSuperType() throws Exception {
         String name = "resourceSuperType";
         String typeNodeName = "some_resource_type";
@@ -159,7 +157,7 @@ public class JcrNodeResourceTest extends
         assertEquals(typeName, jnr.getResourceType());
         assertNull(jnr.getResourceSuperType());
     }
-
+*/
     public void testAdaptToMap() throws Exception {
 
         String name = "adaptable";

Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java (original)
+++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java Fri Feb 22 09:09:59 2013
@@ -153,4 +153,19 @@ public class MockResourceResolver implem
         // TODO Auto-generated method stub
         return false;
     }
+
+    public String getResourceSuperType(Resource resource) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getResourceSuperType(String resourceType) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean isResourceType(Resource resource, String resourceType) {
+        // TODO Auto-generated method stub
+        return false;
+    }
 }

Modified: sling/trunk/bundles/resourceresolver/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/pom.xml?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/pom.xml (original)
+++ sling/trunk/bundles/resourceresolver/pom.xml Fri Feb 22 09:09:59 2013
@@ -114,7 +114,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.3.0</version>
+            <version>2.3.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

Modified: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java (original)
+++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java Fri Feb 22 09:09:59 2013
@@ -1083,4 +1083,72 @@ public class ResourceResolverImpl extend
     public boolean hasChanges() {
         return this.context.hasChanges(this);
     }
+
+    /**
+     * @see org.apache.sling.api.resource.ResourceResolver#getResourceSuperType(org.apache.sling.api.resource.Resource)
+     */
+    public String getResourceSuperType(final Resource resource) {
+        String resourceSuperType = null;
+        if ( resource != null ) {
+            resourceSuperType = resource.getResourceSuperType();
+            if (resourceSuperType == null) {
+                resourceSuperType = this.getResourceSuperType(resource.getResourceType());
+            }
+        }
+        return resourceSuperType;
+    }
+
+    /**
+     * @see org.apache.sling.api.resource.ResourceResolver#getResourceSuperType(java.lang.String)
+     */
+    public String getResourceSuperType(final String resourceType) {
+        // normalize resource type to a path string
+        final String rtPath = (resourceType == null ? null : ResourceUtil.resourceTypeToPath(resourceType));
+        // get the resource type resource and check its super type
+        String resourceSuperType = null;
+
+        if ( rtPath != null ) {
+            ResourceResolver adminResolver = null;
+            try {
+                adminResolver = this.factory.getAdministrativeResourceResolver(null);
+                final Resource rtResource = adminResolver.getResource(rtPath);
+                if (rtResource != null) {
+                    resourceSuperType = rtResource.getResourceSuperType();
+                }
+            } catch (final LoginException e) {
+                // we simply ignore this and return null
+            } finally {
+                if ( adminResolver != null ) {
+                    adminResolver.close();
+                }
+            }
+        }
+        return resourceSuperType;
+    }
+
+    /**
+     * @see org.apache.sling.api.resource.ResourceResolver#isResourceType(org.apache.sling.api.resource.Resource, java.lang.String)
+     */
+    public boolean isResourceType(final Resource resource, final String resourceType) {
+        boolean result = false;
+        if ( resource != null && resourceType != null ) {
+             // Check if the resource is of the given type. This method first checks the
+             // resource type of the resource, then its super resource type and continues
+             //  to go up the resource super type hierarchy.
+             if (resourceType.equals(resource.getResourceType())) {
+                 result = true;
+             } else {
+                 String superType = this.getResourceSuperType(resource);
+                 while (!result && superType != null) {
+                     if (resourceType.equals(superType)) {
+                         result = true;
+                     } else {
+                         superType = this.getResourceSuperType(superType);
+                     }
+                 }
+             }
+
+        }
+        return result;
+    }
 }

Modified: sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverImplTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverImplTest.java?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverImplTest.java (original)
+++ sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverImplTest.java Fri Feb 22 09:09:59 2013
@@ -27,10 +27,12 @@ import static org.junit.Assert.fail;
 
 import java.io.BufferedReader;
 import java.security.Principal;
+import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
@@ -42,11 +44,13 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpSession;
 
 import org.apache.sling.api.resource.AbstractResource;
+import org.apache.sling.api.resource.LoginException;
 import org.apache.sling.api.resource.NonExistingResource;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceMetadata;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.api.resource.SyntheticResource;
 import org.apache.sling.resourceresolver.impl.helper.ResourceResolverContext;
 import org.junit.Before;
 import org.junit.Test;
@@ -338,7 +342,98 @@ public class ResourceResolverImplTest {
         }
     }
 
-    private static final class ResourceImpl extends AbstractResource {
+    @Test public void test_getResourceSuperType() {
+        // the resource resolver
+        final List<ResourceResolver> resolvers = new ArrayList<ResourceResolver>();
+        final PathBasedResourceResolverImpl resolver = new PathBasedResourceResolverImpl(
+                new ResourceResolverFactoryImpl(new ResourceResolverFactoryActivator()) {
+
+                    @Override
+                    public ResourceResolver getAdministrativeResourceResolver(
+                            Map<String, Object> authenticationInfo)
+                            throws LoginException {
+                        return resolvers.get(0);
+                    }
+
+                },
+                new ResourceResolverContext(false, null));
+        resolvers.add(resolver);
+
+        // the resource to test
+        final Resource r = new ResourceImpl() {
+            @Override
+            public String getResourceType() {
+                return "a:b";
+            }
+        };
+        final Resource r2 = new ResourceImpl() {
+            @Override
+            public String getResourceType() {
+                return "a:c";
+            }
+        };
+        final Resource typeResource = new ResourceImpl() {
+            @Override
+            public String getResourceType() {
+                return "x:y";
+            }
+
+            @Override
+            public String getResourceSuperType() {
+                return "t:c";
+            }
+        };
+        resolver.setResource("/a", r);
+        resolver.setResource("/a/b", typeResource);
+
+        assertEquals("t:c", resolver.getResourceSuperType(r.getResourceType()));
+        assertNull(resolver.getResourceSuperType(r2.getResourceType()));
+    }
+
+    @Test public void test_isA() {
+        final Resource typeResource = new ResourceImpl() {
+
+            @Override
+            public String getResourceType() {
+                return "x:y";
+            }
+
+            @Override
+            public String getResourceSuperType() {
+                return "t:c";
+            }
+        };
+        final List<ResourceResolver> resolvers = new ArrayList<ResourceResolver>();
+        final PathBasedResourceResolverImpl resolver = new PathBasedResourceResolverImpl(
+                new ResourceResolverFactoryImpl(new ResourceResolverFactoryActivator()) {
+
+                    @Override
+                    public ResourceResolver getAdministrativeResourceResolver(
+                            Map<String, Object> authenticationInfo)
+                            throws LoginException {
+                        return resolvers.get(0);
+                    }
+
+                },
+                new ResourceResolverContext(false, null));
+        resolvers.add(resolver);
+        final Resource r = new SyntheticResource(resolver, "/a", "a:b") {
+            @Override
+            public String getResourceSuperType() {
+                return "d:e";
+            }
+        };
+        resolver.setResource("/a", r);
+        resolver.setResource("/d/e", typeResource);
+
+        assertTrue(resolver.isResourceType(r, "a:b"));
+        assertTrue(resolver.isResourceType(r, "d:e"));
+        assertFalse(resolver.isResourceType(r, "x:y"));
+        assertTrue(resolver.isResourceType(r, "t:c"));
+        assertFalse(resolver.isResourceType(r, "h:p"));
+    }
+
+    private static class ResourceImpl extends AbstractResource {
 
         public String getPath() {
             return "/some";
@@ -605,4 +700,28 @@ public class ResourceResolverImplTest {
             return false;
         }
     }
+    private static class PathBasedResourceResolverImpl extends ResourceResolverImpl {
+
+        private final Map<String, Resource> resources = new HashMap<String, Resource>();
+
+        public PathBasedResourceResolverImpl(
+                ResourceResolverFactoryImpl factory, ResourceResolverContext ctx) {
+            super(factory, ctx);
+        }
+
+        public void setResource(final String path, final Resource r) {
+            this.resources.put(path, r);
+        }
+
+        @Override
+        public String[] getSearchPath() {
+            return new String[] {""};
+        }
+
+        @Override
+        public Resource getResource(final String path) {
+            final String p = (path.startsWith("/") ? path : "/" + path);
+            return this.resources.get(p);
+        }
+    }
 }

Modified: sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderEntryTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderEntryTest.java?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderEntryTest.java (original)
+++ sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderEntryTest.java Fri Feb 22 09:09:59 2013
@@ -359,6 +359,21 @@ public class ResourceProviderEntryTest {
             // TODO Auto-generated method stub
             return false;
         }
+
+        public String getResourceSuperType(Resource resource) {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public String getResourceSuperType(String resourceType) {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public boolean isResourceType(Resource resource, String resourceType) {
+            // TODO Auto-generated method stub
+            return false;
+        }
     }
 
     private static class TestResource extends AbstractResource {

Modified: sling/trunk/bundles/servlets/resolver/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/resolver/pom.xml?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/resolver/pom.xml (original)
+++ sling/trunk/bundles/servlets/resolver/pom.xml Fri Feb 22 09:09:59 2013
@@ -78,7 +78,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.3.0</version>
+            <version>2.3.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

Modified: sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java (original)
+++ sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java Fri Feb 22 09:09:59 2013
@@ -64,16 +64,12 @@ import org.apache.sling.api.SlingHttpSer
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.request.RequestProgressTracker;
 import org.apache.sling.api.request.RequestUtil;
-import org.apache.sling.api.resource.AbstractResource;
 import org.apache.sling.api.resource.LoginException;
 import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ResourceDecorator;
-import org.apache.sling.api.resource.ResourceMetadata;
 import org.apache.sling.api.resource.ResourceProvider;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.api.resource.ResourceUtil;
-import org.apache.sling.api.resource.ResourceWrapper;
 import org.apache.sling.api.resource.SyntheticResource;
 import org.apache.sling.api.scripting.SlingScript;
 import org.apache.sling.api.scripting.SlingScriptResolver;
@@ -109,7 +105,7 @@ import org.slf4j.LoggerFactory;
  */
 @Component(name="org.apache.sling.servlets.resolver.SlingServletResolver", metatype=true,
            label="%servletresolver.name", description="%servletresolver.description")
-@Service(value={ServletResolver.class, SlingScriptResolver.class, ErrorHandler.class, ResourceDecorator.class})
+@Service(value={ServletResolver.class, SlingScriptResolver.class, ErrorHandler.class})
 @Properties({
     @Property(name="service.description", value="Sling Servlet Resolver and Error Handler"),
     @Property(name="service.vendor", value="The Apache Software Foundation"),
@@ -126,8 +122,7 @@ public class SlingServletResolver
     implements ServletResolver,
                SlingScriptResolver,
                ErrorHandler,
-               EventHandler,
-               ResourceDecorator {
+               EventHandler {
 
     /**
      * The default servlet root is the first search path (which is usally /apps)
@@ -1135,48 +1130,6 @@ public class SlingServletResolver
         }
     }
 
-    /**
-     * @see org.apache.sling.api.resource.ResourceDecorator#decorate(org.apache.sling.api.resource.Resource)
-     */
-    public Resource decorate(final Resource resource) {
-        return new ResourceWrapper(resource) {
-            @Override
-            public boolean isResourceType(final String type) {
-                return ResourceUtil.isA(new AbstractResource() {
-
-                    public String getResourceType() {
-                        return resource.getResourceType();
-                    }
-
-                    public String getResourceSuperType() {
-                        return resource.getResourceSuperType();
-                    }
-
-                    public ResourceResolver getResourceResolver() {
-                        return scriptResolver;
-                    }
-
-                    public ResourceMetadata getResourceMetadata() {
-                        return resource.getResourceMetadata();
-                    }
-
-                    public String getPath() {
-                        return resource.getPath();
-                    }
-                }, type);
-            }
-        };
-     }
-
-    /**
-     * @see org.apache.sling.api.resource.ResourceDecorator#decorate(org.apache.sling.api.resource.Resource, javax.servlet.http.HttpServletRequest)
-     */
-    @SuppressWarnings("javadoc")
-    public Resource decorate(final Resource resource, final HttpServletRequest request) {
-        // this is deprecated, but we just delegate anyway
-        return this.decorate(resource);
-    }
-
     @SuppressWarnings("serial")
     class ServletResolverWebConsolePlugin extends HttpServlet {
         private static final String PARAMETER_URL = "url";

Modified: sling/trunk/contrib/extensions/mongodb/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/mongodb/pom.xml?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/mongodb/pom.xml (original)
+++ sling/trunk/contrib/extensions/mongodb/pom.xml Fri Feb 22 09:09:59 2013
@@ -64,7 +64,7 @@
         <dependency>
     	    <groupId>org.apache.sling</groupId>
     	    <artifactId>org.apache.sling.api</artifactId>
-    	    <version>2.3.0</version>
+    	    <version>2.3.1-SNAPSHOT</version>
     	    <scope>provided</scope>
         </dependency>
         <dependency>

Modified: sling/trunk/launchpad/builder/src/main/bundles/list.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/builder/src/main/bundles/list.xml?rev=1448950&r1=1448949&r2=1448950&view=diff
==============================================================================
--- sling/trunk/launchpad/builder/src/main/bundles/list.xml (original)
+++ sling/trunk/launchpad/builder/src/main/bundles/list.xml Fri Feb 22 09:09:59 2013
@@ -71,7 +71,7 @@
         <bundle>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.3.0</version>
+            <version>2.3.1-SNAPSHOT</version>
         </bundle>
         <bundle>
             <groupId>org.apache.sling</groupId>
@@ -81,7 +81,7 @@
         <bundle>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.resourceresolver</artifactId>
-            <version>1.0.4</version>
+            <version>1.0.5-SNAPSHOT</version>
         </bundle>
         <bundle>
             <groupId>org.apache.sling</groupId>
@@ -116,7 +116,7 @@
         <bundle>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.servlets.resolver</artifactId>
-            <version>2.2.2</version>
+            <version>2.2.3-SNAPSHOT</version>
         </bundle>
         <bundle>
             <groupId>org.apache.sling</groupId>
@@ -136,7 +136,7 @@
         <bundle>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.jcr.resource</artifactId>
-            <version>2.2.4</version>
+            <version>2.2.5-SNAPSHOT</version>
         </bundle>
         <bundle>
             <groupId>org.apache.sling</groupId>
@@ -151,12 +151,12 @@
         <bundle>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.bundleresource.impl</artifactId>
-            <version>2.1.0</version>
+            <version>2.1.1-SNAPSHOT</version>
         </bundle>
         <bundle>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.fsresource</artifactId>
-            <version>1.1.0</version>
+            <version>1.1.1-SNAPSHOT</version>
         </bundle>
 
         <!-- Launchpad initial content -->