Author: ieb
Date: Sun Oct 28 21:28:41 2012
New Revision: 1403096

URL: http://svn.apache.org/viewvc?rev=1403096&view=rev
Log:
SLING-2538 Removed fallback code for old resource implementations and moved 
functionallity from
           ResourceUtil into AbstractResource call sequence simpler between the 
two.
           Implementations of the pre 2.1.0 API will need to ensure that they 
update to post 2.1.0
           past this point.

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/ResourceUtil.java

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=1403096&r1=1403095&r2=1403096&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
 Sun Oct 28 21:28:41 2012
@@ -56,15 +56,12 @@ public abstract class AbstractResource
      * calling the {@link ResourceUtil#getParent(String)} method and then to
      * retrieve that resource from the resource resolver.
      */
-    @SuppressWarnings("deprecation")
     public Resource getParent() {
-        //
-        // Implemented calling the deprecated ResourceUtil.getParent method
-        // (which actually has the implementation) to prevent problems if there
-        // are implementations of the pre-2.1.0 Resource interface in the
-        // framework.
-        //
-        return ResourceUtil.getParent(this);
+        final String parentPath = ResourceUtil.getParent(getPath());
+        if (parentPath == null) {
+            return null;
+        }
+        return getResourceResolver().getResource(parentPath);
     }
 
     /**
@@ -107,11 +104,25 @@ public abstract class AbstractResource
      * methods.
      */
     public boolean isResourceType(String resourceType) {
-        //
-        // 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.
-        //
-        return ResourceUtil.internalIsA(this, 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; 
     }
 }

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=1403096&r1=1403095&r2=1403096&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
 Sun Oct 28 21:28:41 2012
@@ -204,11 +204,7 @@ public class ResourceUtil {
      */
     @Deprecated
     public static Resource getParent(Resource rsrc) {
-        final String parentPath = ResourceUtil.getParent(rsrc.getPath());
-        if (parentPath == null) {
-            return null;
-        }
-        return rsrc.getResourceResolver().getResource(parentPath);
+        return rsrc.getParent();
     }
 
     /**
@@ -485,46 +481,11 @@ public class ResourceUtil {
         if (resource == null || resourceType == null) {
             return false;
         }
-
-        try {
-            return resource.isResourceType(resourceType);
-        } catch (final AbstractMethodError ame) {
-            // this might occur with old pre 2.1.0 resource implementations 
(see SLING-2457)
-            return internalIsA(resource, 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.
-     *
-     * @param resource the resource to check
-     * @param resourceType the resource type to check the resource against
-     * @return <code>false</code> if <code>resource</code> is 
<code>null</code>.
-     *         Otherwise returns the result of calling
-     *         {@link Resource#isResourceType(String)} with the given
-     *         <code>resourceType</code>.
-     */
-    static boolean internalIsA(final Resource resource, final String 
resourceType) {
-        if (resourceType.equals(resource.getResourceType())) {
-            return true;
-        }
-
-        String superType = findResourceSuperType(resource);
-        while (superType != null) {
-            if (resourceType.equals(superType)) {
-                return true;
-            }
-            superType = getResourceSuperType(resource.getResourceResolver(),
-                    superType);
-        }
-
-        return false;
+        return resource.isResourceType(resourceType);
     }
 
     /**
-     * Return an iterator for objecs of the specified type. A new iterator is
+     * Return an iterator for objects of the specified type. A new iterator is
      * returned which tries to adapt the provided resources to the given type
      * (using {@link Resource#adaptTo(Class)}. If a resource in the original
      * iterator is not adaptable to the given class, this object is skipped.


Reply via email to