incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1363304 - in /sling/trunk/bundles: api/src/main/java/org/apache/sling/api/resource/ resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/
Date Thu, 19 Jul 2012 11:41:49 GMT
Author: cziegeler
Date: Thu Jul 19 11:41:48 2012
New Revision: 1363304

URL: http://svn.apache.org/viewvc?rev=1363304&view=rev
Log:
SLING-2530 : Implement CRUD based on resources

Modified:
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProvider.java
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ProviderHandler.java
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderEntry.java

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProvider.java?rev=1363304&r1=1363303&r2=1363304&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProvider.java
(original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProvider.java
Thu Jul 19 11:41:48 2012
@@ -54,6 +54,17 @@ public interface ResourceProvider {
     String ROOTS = "provider.roots";
 
     /**
+     * The name of the service registration property containing the a boolean
+     * flag whether this provider owns the tree registered by the roots. The
+     * default for this value is <code>false</code>. If a provider owns a root
+     * no other providers are asked for resources under this root if this
+     * provider does not have a resource. (value is "provider.ownsRoots").
+     *
+     * @since 2.2
+     */
+    String OWNS_ROOTS = "provider.ownsRoots";
+
+    /**
      * The resource type be set on resources returned by the
      * {@link #listChildren(Resource)} method to enable traversing the
      * resource

Modified: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ProviderHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ProviderHandler.java?rev=1363304&r1=1363303&r2=1363304&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ProviderHandler.java
(original)
+++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ProviderHandler.java
Thu Jul 19 11:41:48 2012
@@ -46,6 +46,9 @@ public abstract class ProviderHandler im
     /** Configured roots. */
     private final String[] roots;
 
+    /** Owns roots? */
+    private final boolean ownsRoots;
+
     /**
      * Create a new handler
      */
@@ -75,6 +78,7 @@ public abstract class ProviderHandler im
             Collections.sort(configuredRoots);
             this.roots = configuredRoots.toArray(new String[configuredRoots.size()]);
         }
+        this.ownsRoots = PropertiesUtil.toBoolean(properties.get(ResourceProvider.OWNS_ROOTS),
false);
     }
 
     /**
@@ -92,6 +96,13 @@ public abstract class ProviderHandler im
     }
 
     /**
+     * Does this provider own the roots?
+     */
+    public boolean ownsRoots() {
+        return this.ownsRoots;
+    }
+
+    /**
      * Return a sorted array of roots for this provider. If no roots are configured,
      * this will return <code>null</code>
      * @return The array of roots or <code>null</code>
@@ -142,6 +153,9 @@ public abstract class ProviderHandler im
      */
     public abstract Iterator<Resource> listChildren(final ResourceResolverContext ctx,
final Resource parent);
 
+    /**
+     * Return the resource provider.
+     */
     public abstract ResourceProvider getResourceProvider(final ResourceResolverContext ctx);
 
     /**

Modified: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderEntry.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderEntry.java?rev=1363304&r1=1363303&r2=1363304&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderEntry.java
(original)
+++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderEntry.java
Thu Jul 19 11:41:48 2012
@@ -287,8 +287,11 @@ public class ResourceProviderEntry imple
                         LOGGER.debug("Resolved Full {} using {} from {} ", new Object[] {
fullPath, rp, Arrays.toString(rps) });
                         return resource;
                     }
+                    if ( rp.ownsRoots() ) {
+                        LOGGER.debug("Resource null {} ", fullPath);
+                        return null;
+                    }
                 }
-                // TODO stop handling if provider claims subtree!
             }
 
             // resolve against this one
@@ -343,8 +346,10 @@ public class ResourceProviderEntry imple
                 if ( provider instanceof ModifyingResourceProvider ) {
                     return (ModifyingResourceProvider) provider;
                 }
+                if ( rp.ownsRoots() ) {
+                    throw new UnsupportedOperationException();
+                }
             }
-            // TODO stop handling if provider claims subtree!
         }
         throw new UnsupportedOperationException();
     }



Mime
View raw message