incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r608912 - in /incubator/sling/whiteboard/fmeschbe/resource/jcr/resource: ./ src/main/java/org/apache/sling/jcr/resource/ src/main/java/org/apache/sling/jcr/resource/internal/ src/main/java/org/apache/sling/jcr/resource/internal/helper/ src/...
Date Fri, 04 Jan 2008 16:38:38 GMT
Author: fmeschbe
Date: Fri Jan  4 08:38:36 2008
New Revision: 608912

URL: http://svn.apache.org/viewvc?rev=608912&view=rev
Log:
First steps towards a Prototype of "Everything is a Resource"

Added:
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvderEntry.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
Removed:
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/AbstractMappedObject.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/DefaultMappedObject.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/ResourceProvider.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/resources/graffito-jcr-mapping.dtd
Modified:
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/pom.xml
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/PathResolver.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/SyntheticResource.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntry.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResource.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResourceIterator.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResourceProvider.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResourceURLConnection.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceIterator.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/JsonReader.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/test/java/org/apache/sling/jcr/resource/JcrResourceUtilTest.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntryTest.java
    incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/loader/JsonReaderTest.java

Modified: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/pom.xml?rev=608912&r1=608911&r2=608912&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/pom.xml (original)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/pom.xml Fri Jan  4 08:38:36 2008
@@ -68,44 +68,18 @@
                     <instructions>
                         <Export-Package>
                             org.apache.sling.jcr.resource;version=${pom.version},
-                            org.apache.jackrabbit.ocm.exception;
-                            org.apache.jackrabbit.ocm.mapper;
-                            org.apache.jackrabbit.ocm.manager;
-                            org.apache.jackrabbit.ocm.manager.atomictypeconverter;
-                            org.apache.jackrabbit.ocm.manager.collectionconverter;
-                            org.apache.jackrabbit.ocm.manager.collectionconverter.impl;
-                            org.apache.jackrabbit.ocm.query;
-                            org.apache.jackrabbit.ocm.version;version=1.4
                         </Export-Package>
                         <Private-Package>
-                            org.apache.sling.jcr.resource.internal.*,
-                            org.apache.jackrabbit.net,
-                            org.apache.jackrabbit.ocm.lock,
-                            org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl,
-                            org.apache.jackrabbit.ocm.manager.beanconverter,
-                            org.apache.jackrabbit.ocm.manager.beanconverter.impl,
-                            org.apache.jackrabbit.ocm.manager.cache,
-                            org.apache.jackrabbit.ocm.manager.cache.impl,
-                            org.apache.jackrabbit.ocm.manager.impl,
-                            org.apache.jackrabbit.ocm.manager.objectconverter,
-                            org.apache.jackrabbit.ocm.manager.objectconverter.impl,
-                            org.apache.jackrabbit.ocm.mapper.impl,
-                            org.apache.jackrabbit.ocm.mapper.impl.annotation,
-                            org.apache.jackrabbit.ocm.mapper.model,
-                            org.apache.jackrabbit.ocm.query.impl,
-                            org.apache.jackrabbit.ocm.reflection,
-                            org.apache.jackrabbit.ocm.repository,
-                            org.kxml2.io, org.xmlpull.v1
+                            org.apache.sling.jcr.resource.internal.*
                         </Private-Package>
-                        <Import-Package>
-                            !org.apache.jackrabbit.ocm.mapper.impl.digester,
-                            *
-                        </Import-Package>
 
                         <Sling-Namespaces>
-                            sling=http://sling.apache.org/jcr/sling/1.0,
-                            ocm=http://jackrabbit.apache.org/ocm
+                            sling=http://sling.apache.org/jcr/sling/1.0
                         </Sling-Namespaces>
+
+                        <Embed-Dependency>
+                            jackrabbit-classloader, kxml2
+                        </Embed-Dependency>
                     </instructions>
                 </configuration>
             </plugin>
@@ -141,6 +115,11 @@
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.osgi.commons</artifactId>
+            <version>2.0.0-incubator-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.jcr.api</artifactId>
             <version>2.0.0-incubator-SNAPSHOT</version>
         </dependency>
@@ -149,25 +128,22 @@
             <artifactId>slf4j-simple</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.apache.jackrabbit</groupId>
-            <artifactId>jackrabbit-ocm</artifactId>
-        </dependency>
+        <!-- for adapting JCR resources to URLs -->
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
             <artifactId>jackrabbit-classloader</artifactId>
             <version>1.3.1</version>
-            <scope>compile</scope>
         </dependency>
 
         <dependency>
             <groupId>net.sf.kxml</groupId>
             <artifactId>kxml2</artifactId>
+            <scope>provided</scope>
         </dependency>
 
         <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-io</artifactId>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
         </dependency>
 
         <dependency>

Modified: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/PathResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/PathResolver.java?rev=608912&r1=608911&r2=608912&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/PathResolver.java (original)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/PathResolver.java Fri Jan  4 08:38:36 2008
@@ -20,7 +20,6 @@
 
 import org.apache.sling.api.SlingException;
 import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ResourceResolver;
 
 /**
  * The <code>PathResolver</code> interface defines additional methods to the
@@ -31,7 +30,7 @@
  * This reverse mapping may be used for example to create links for existing
  * paths.
  */
-public interface PathResolver extends ResourceResolver {
+public interface PathResolver {
 
     /**
      * Resolves the given url string to a <code>Resource</code> applying the
@@ -59,22 +58,6 @@
      * @param path The resource path to map to an url string
      * @return The external (URI) representation of the resource path.
      */
-    String pathToURL(String path);
-
-    /**
-     * Maps a Content path to an url string, which when fed to the
-     * {@link #resolve(String)} method returns a resource of the given path.
-     * This method may be used to get the external (URI) representation of a
-     * resource, which is guaranteed to map back to the same handle, when used
-     * in a request.
-     *
-     * @param prefix A prefix to prepend to the url string, ignored if empty or
-     *            <code>null</code>
-     * @param path The resource path to map to an url string
-     * @param suffix A suffix to append to the url string, ignored if empty or
-     *            <code>null</code>
-     * @return The external (URI) representation of the resource path.
-     */
-    String pathToURL(String prefix, String path, String suffix);
+    String pathToURL(Resource resource);
 
 }

Modified: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/SyntheticResource.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/SyntheticResource.java?rev=608912&r1=608911&r2=608912&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/SyntheticResource.java (original)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/SyntheticResource.java Fri Jan  4 08:38:36 2008
@@ -20,6 +20,7 @@
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceMetadata;
+import org.apache.sling.api.resource.ResourceProvider;
 
 /**
  * The <code>SyntheticResource</code> class is a simple implementation of the
@@ -68,6 +69,11 @@
         return resourceMetadata;
     }
 
+    /** synthetic resources have no provider */
+    public ResourceProvider getResourceProvider() {
+        return null;
+    }
+    
     public <Type> Type adaptTo(Class<Type> type) {
         return null;
     }

Modified: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java?rev=608912&r1=608911&r2=608912&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java (original)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java Fri Jan  4 08:38:36 2008
@@ -27,7 +27,6 @@
 import java.util.List;
 import java.util.Map;
 
-import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Value;
@@ -35,23 +34,19 @@
 import javax.jcr.query.RowIterator;
 import javax.servlet.http.HttpServletRequest;
 
-import org.apache.jackrabbit.ocm.exception.JcrMappingException;
-import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
-import org.apache.jackrabbit.ocm.reflection.ReflectionUtils;
 import org.apache.sling.api.SlingException;
 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.jcr.resource.DefaultMappedObject;
 import org.apache.sling.jcr.resource.JcrResourceUtil;
 import org.apache.sling.jcr.resource.PathResolver;
 import org.apache.sling.jcr.resource.internal.helper.Descendable;
 import org.apache.sling.jcr.resource.internal.helper.Mapping;
 import org.apache.sling.jcr.resource.internal.helper.ResourcePathIterator;
-import org.apache.sling.jcr.resource.internal.helper.ResourceProvider;
-import org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResource;
+import org.apache.sling.jcr.resource.internal.helper.ResourceProviderEntry;
 import org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResourceIterator;
+import org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvderEntry;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -68,32 +63,12 @@
     /** default log */
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    /**
-     * The class used to load repository content into if a mapping cannot be
-     * found for a given existing node. See {@link #getObject(String, Class)}.
-     */
-    public static final Class<?> DEFAULT_CONTENT_CLASS = DefaultMappedObject.class;
-
-    protected static final String ACTION_READ = "read";
-
-    protected static final String ACTION_CREATE = "add_node,set_property";
-
-    protected static final String ACTION_ADD_NODE = "add_node";
-
-    protected static final String ACTION_SET_PROPERTY = "set_property";
-
-    protected static final String ACTION_REMOVE = "remove";
-
+    private final JcrResourceProvderEntry rootProvider;
     private final JcrResourceResolverFactoryImpl factory;
-
-    private final Session session;
-
-    private ObjectContentManager objectContentManager;
-
-    public JcrResourceResolver(JcrResourceResolverFactoryImpl factory,
-            Session session) {
+    
+    public JcrResourceResolver(JcrResourceProvderEntry rootProvider, JcrResourceResolverFactoryImpl factory) {
+        this.rootProvider = rootProvider;
         this.factory = factory;
-        this.session = session;
     }
 
     // ---------- ResourceResolver interface ----------------------------------
@@ -110,8 +85,20 @@
     }
 
     public Resource getResource(String path) throws SlingException {
-        return getResource(path, null);
-    }
+        path = JcrResourceUtil.normalize(path);
+        if (path != null) {
+            try {
+                Resource resource = getResourceInternal(path);
+                return resource;
+            } catch (Exception ex) {
+                throw new SlingException("Problem accessing resource" + path,
+                    ex);
+            }
+        }
+
+        // relative path segments cannot be resolved
+        return null;
+     }
 
     public Resource getResource(Resource base, String path)
             throws SlingException {
@@ -161,7 +148,7 @@
         try {
             QueryResult res = JcrResourceUtil.query(getSession(), query,
                 language);
-            return new JcrNodeResourceIterator(this, res.getNodes());
+            return new JcrNodeResourceIterator(rootProvider.getResourceProvider(), res.getNodes());
         } catch (javax.jcr.query.InvalidQueryException iqe) {
             throw new SlingException(iqe);
         } catch (RepositoryException re) {
@@ -210,8 +197,6 @@
     public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
         if (type == Session.class) {
             return (AdapterType) getSession();
-        } else if (type == ObjectContentManager.class) {
-            return (AdapterType) objectContentManager;
         } else if (type == PathResolver.class) {
             return (AdapterType) this;
         }
@@ -265,14 +250,11 @@
         }
     }
 
-    public String pathToURL(String path) {
-        return pathToURL(null, path, null);
-    }
-
-    public String pathToURL(String prefix, String path, String suffix) {
-        String href = null;
+    public String pathToURL(Resource resource) {
+        String path = resource.getURI();
 
         // get first map
+        String href = null;
         Mapping[] mappings = factory.getMappings();
         for (int i = 0; i < mappings.length && href == null; i++) {
             href = mappings[i].mapHandle(path);
@@ -291,245 +273,14 @@
             href = virtual;
         }
 
-        // handle prefix and suffix
-        if (prefix != null && !prefix.equals("") && !prefix.equals("/")) {
-            href = prefix + href;
-        }
-        if (suffix != null) {
-            href += suffix;
-        }
-
-        log.debug("MapHandle: {} + {} + {} -> {}", new Object[] { prefix, path,
-            suffix, href });
+        log.debug("MapHandle: {} -> {}", path, href);
         return href;
     }
 
-    // ---------- former ResourceManager interface -----------------------------------
-
-    /**
-     * @throws AccessControlException If this manager has does not have enough
-     *             permisssions to store the resource's object.
-     */
-    public void store(Resource resource) throws SlingException {
-        String path = resource.getURI();
-        Object data = resource.adaptTo(Object.class);
-        if (data != null) {
-            try {
-                if (itemExists(path)) {
-                    checkPermission(path, ACTION_SET_PROPERTY);
-                    getObjectContentManager().update(data);
-                } else {
-                    checkPermission(path, ACTION_CREATE);
-                    getObjectContentManager().insert(data);
-                }
-            } catch (RepositoryException re) {
-                throw new SlingException("Problem storing object for resource "
-                    + path, re);
-            }
-        } else {
-            log.info("store: The resource {} has no object to store", path);
-        }
-    }
-
-    /**
-     * @throws AccessControlException if this manager has no read access
-     */
-    public Resource getResource(String path, Class<?> type)
-            throws SlingException {
-        path = JcrResourceUtil.normalize(path);
-        if (path != null) {
-            try {
-                Resource resource = getResourceInternal(path);
-                if (type != null && resource instanceof JcrNodeResource) {
-                    ((JcrNodeResource) resource).setObjectType(type);
-                }
-                return resource;
-            } catch (Exception ex) {
-                throw new SlingException("Problem accessing resource" + path,
-                    ex);
-            }
-        }
-
-        // relative path segments cannot be resolved
-        return null;
-    }
-
-    public void delete(Resource resource) throws SlingException {
-        String path = resource.getURI();
-        try {
-            checkPermission(path, ACTION_REMOVE);
-            getObjectContentManager().remove(path);
-        } catch (AccessControlException ace) {
-            // rethrow access control issues
-            throw ace;
-        } catch (Exception ex) {
-            throw new SlingException("Problem deleting resource " + path, ex);
-        }
-    }
-
-    public void copy(Resource resource, String destination, boolean deep)
-            throws SlingException {
-
-        String source = resource.getURI();
-        try {
-
-            checkPermission(destination, ACTION_CREATE);
-
-            if (deep) {
-                // recursively copy directly in the repository
-                getSession().getWorkspace().copy(source, destination);
-            } else {
-                // TODO: Create node at destination:
-                // - same primary node type
-                // - same mixins
-                // - same non-protected properties
-            }
-
-        } catch (AccessControlException ace) {
-            // rethrow access control issues
-            throw ace;
-        } catch (Exception ex) {
-            throw new SlingException("Problem copying resource " + source
-                + " to " + destination, ex);
-        }
-    }
-
-    public void move(Resource resource, String destination)
-            throws SlingException {
-        String source = resource.getURI();
-
-        try {
-            checkPermission(source, ACTION_REMOVE);
-            checkPermission(destination, ACTION_CREATE);
-
-            getSession().move(source, destination);
-
-        } catch (AccessControlException ace) {
-            // rethrow access control issues
-            throw ace;
-        } catch (Exception ex) {
-            throw new SlingException("Problem moving resource " + source
-                + " to " + destination, ex);
-        }
-    }
-
-    public void orderBefore(Resource resource, String afterName)
-            throws SlingException {
-
-        String path = resource.getURI();
-        Node node = resource.adaptTo(Node.class);
-        if (node == null) {
-            log.info("orderBefore: Resource {} is not based on a JCR", path);
-            return;
-        }
-
-        try {
-            Node parent = node.getParent();
-
-            // check whether the parent node supports child node ordering
-            if (!parent.getPrimaryNodeType().hasOrderableChildNodes()) {
-                return;
-            }
-
-            String name = path.substring(path.lastIndexOf('/') + 1);
-            parent.orderBefore(name, afterName);
-        } catch (AccessControlException ace) {
-            // rethrow access control issues
-            throw ace;
-        } catch (Exception ex) {
-            throw new SlingException("Problem ordering resource " + path
-                + " before " + afterName, ex);
-        }
-    }
-
-    /**
-     * Returns <code>true</code> if this manager has unsaved changes or if an
-     * error occurrs checking for such changes.
-     */
-    public boolean hasChanges() {
-        try {
-            return getSession().hasPendingChanges();
-        } catch (RepositoryException re) {
-            log.error(
-                "hasChanges: Problem checking for session changes, assuming true",
-                re);
-            return true;
-        }
-    }
-
-    public void save() throws SlingException {
-        try {
-            getSession().save();
-        } catch (RepositoryException re) {
-            throw new SlingException("Problems while saving changes", re);
-        }
-    }
-
-    public void rollback() {
-        try {
-            getSession().refresh(false);
-        } catch (RepositoryException re) {
-            log.error("rollback: Problem rolling back changes", re);
-        }
-    }
-
     // ---------- implementation helper ----------------------------------------
 
-    /**
-     * Loads the object to which the repository node at the given
-     * <code>path</code> is mapping. If no mapping exists for an existing
-     * node, the node's content is loaded into a new instance of the
-     * {@link #DEFAULT_CONTENT_CLASS default content class}.
-     *
-     * @param type Load the node's content into an object of the given type if
-     *            not <code>null</code>.
-     * @return the <code>Content</code> object loaded from the node or
-     *         <code>null</code> if no node exists at the given path.
-     */
-    public Object getObject(String path, Class<?> type) {
-        try {
-            if (itemExists(path)) {
-
-                ObjectContentManager ocm = getObjectContentManager();
-
-                // load object with explicit type, fail if not possible
-                if (type != null) {
-                    return ocm.getObject(type, path);
-                }
-
-                // have the mapper find a type or fall back to default type
-                try {
-
-                    return ocm.getObject(path);
-
-                } catch (JcrMappingException jme) {
-
-                    // fall back to default content
-                    try {
-                        return ocm.getObject(DEFAULT_CONTENT_CLASS, path);
-                    } catch (Throwable t) {
-                        // don't care for this exception, use initial one
-                        throw jme;
-                    }
-                }
-            }
-        } catch (Exception ex) {
-            log.error("getObject: Problem while mapping resource {}", ex);
-        }
-
-        // item does not exist or is no content or errors mapping item
-        return null;
-    }
-
     public Session getSession() {
-        return session;
-    }
-
-    protected ObjectContentManager getObjectContentManager() {
-        if (objectContentManager == null) {
-            objectContentManager = factory.getObjectContentManager(getSession());
-        }
-        return objectContentManager;
+        return rootProvider.getSession();
     }
 
     private Resource transformURL(String uri) throws SlingException {
@@ -590,12 +341,14 @@
      */
     protected Resource getResourceInternal(String path) throws Exception {
 
-        ResourceProvider rp = factory.getResourceProvider(path);
-        Resource resource = rp.getResource(this, path);
-        if (resource == null && rp != factory) {
-            resource = factory.getResource(this, path);
-        }
+        Resource resource= null;
 
+        ResourceProviderEntry rp = rootProvider.getResourceProvider(path);
+        while (rp != null && resource == null) {
+            resource = rp.getResourceProvider().getResource(path);
+            rp = rp.getParentEntry();
+        }
+        
         if (resource != null) {
             resource.getResourceMetadata().put(
                 ResourceMetadata.RESOLUTION_PATH, path);
@@ -604,45 +357,6 @@
 
         log.debug("Cannot resolve path '{}' to a resource", path);
         return null;
-    }
-
-    /**
-     * Checks whether the item exists and this content manager's session has
-     * read access to the item. If the item does not exist, access control is
-     * ignored by this method and <code>false</code> is returned.
-     *
-     * @param path The path to the item to check
-     * @return <code>true</code> if the item exists and this content manager's
-     *         session has read access. If the item does not exist,
-     *         <code>false</code> is returned ignoring access control.
-     * @throws RepositoryException
-     * @throws AccessControlException If the item really exists but this content
-     *             manager's session has no read access to it.
-     */
-    public boolean itemExists(String path) throws RepositoryException {
-        if (factory.itemReallyExists(getSession(), path)) {
-            checkPermission(path, ACTION_READ);
-            return true;
-        }
-
-        return false;
-    }
-
-    /**
-     * @param path
-     * @param actions
-     * @throws RepositoryException
-     * @throws AccessControlException if this manager does not have the
-     *             permission for the listed action(s).
-     */
-    protected void checkPermission(String path, String actions)
-            throws RepositoryException {
-        getSession().checkPermission(path, actions);
-    }
-
-    protected void setPath(Object content, String path) {
-        // TODO: Investigate more here !!
-        ReflectionUtils.setNestedProperty(content, "path", path);
     }
 
 }

Modified: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java?rev=608912&r1=608911&r2=608912&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java (original)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java Fri Jan  4 08:38:36 2008
@@ -32,23 +32,19 @@
 
 import org.apache.commons.collections.BidiMap;
 import org.apache.commons.collections.bidimap.TreeBidiMap;
-import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
-import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.commons.mime.MimeTypeService;
 import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.jcr.resource.JcrResourceResolverFactory;
 import org.apache.sling.jcr.resource.internal.helper.Mapping;
-import org.apache.sling.jcr.resource.internal.helper.ResourceProvider;
 import org.apache.sling.jcr.resource.internal.helper.ResourceProviderEntry;
 import org.apache.sling.jcr.resource.internal.helper.bundle.BundleResourceProvider;
-import org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResource;
+import org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvderEntry;
 import org.apache.sling.jcr.resource.internal.loader.Loader;
-import org.apache.sling.jcr.resource.internal.mapping.ObjectContentManagerFactory;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
 import org.osgi.framework.ServiceReference;
-import org.osgi.framework.SynchronousBundleListener;
 import org.osgi.service.component.ComponentContext;
 import org.osgi.service.event.Event;
 import org.osgi.service.event.EventAdmin;
@@ -66,7 +62,7 @@
  * descriptors provided by bundles.
  * <li>Fires OSGi EventAdmin events on behalf of internal helper objects
  * </ul>
- * 
+ *
  * @scr.component immediate="true" label="%resource.resolver.name"
  *                description="%resource.resolver.description"
  * @scr.property name="service.description" value="Sling
@@ -75,7 +71,7 @@
  * @scr.service interface="org.apache.sling.jcr.resource.JcrResourceResolverFactory"
  */
 public class JcrResourceResolverFactoryImpl implements
-        JcrResourceResolverFactory, SynchronousBundleListener, ResourceProvider {
+        JcrResourceResolverFactory, BundleListener {
 
     /**
      * @scr.property value="true" type="Boolean"
@@ -87,7 +83,7 @@
      * maven plugin and the sling management console cannot handle empty
      * multivalue properties at the moment. So we just add a dummy direct
      * mapping.
-     * 
+     *
      * @scr.property values.1="/-/"
      */
     private static final String PROP_VIRTUAL = "resource.resolver.virtual";
@@ -105,14 +101,14 @@
 
     /**
      * The JCR Repository we access to resolve resources
-     * 
+     *
      * @scr.reference
      */
     private SlingRepository repository;
 
     /**
      * The OSGi EventAdmin service used to dispatch events
-     * 
+     *
      * @scr.reference cardinality="0..1" policy="dynamic"
      */
     private EventAdmin eventAdmin;
@@ -120,7 +116,7 @@
     /**
      * The MimeTypeService used by the initial content initialContentLoader to
      * resolve MIME types for files to be installed.
-     * 
+     *
      * @scr.reference cardinality="0..1" policy="dynamic"
      */
     private MimeTypeService mimeTypeService;
@@ -144,18 +140,12 @@
      * Map of administrative sessions used to check item existence. Indexed by
      * workspace name. The map is filled on-demand. The sessions are closed when
      * the factory is deactivated.
-     * 
+     *
      * @see #itemReallyExists(Session, String)
      */
     private Map<String, Session> adminSessions = new HashMap<String, Session>();
 
     /**
-     * The {@link ObjectContentManagerFactory} used retrieve object content
-     * managers on-demand on behalf of {@link JcrResourceResolver} instances.
-     */
-    private ObjectContentManagerFactory objectContentManagerFactory;
-
-    /**
      * The initial content loader which is called to load initial content up
      * into the repository when the providing bundle is installed.
      */
@@ -166,7 +156,7 @@
     private Map<Long, BundleResourceProvider> bundleResourceProviderMap = new HashMap<Long, BundleResourceProvider>();
 
     public JcrResourceResolverFactoryImpl() {
-        this.rootProviderEntry = new ResourceProviderEntry("/", this);
+        this.rootProviderEntry = new ResourceProviderEntry("/", null, null);
     }
 
     // ---------- JcrResourceResolverFactory -----------------------------------
@@ -179,7 +169,9 @@
      * may be cast.
      */
     public ResourceResolver getResourceResolver(Session session) {
-        return new JcrResourceResolver(this, session);
+        JcrResourceProvderEntry sessionRoot = new JcrResourceProvderEntry(this,
+            session, rootProviderEntry.getEntries());
+        return new JcrResourceResolver(sessionRoot, this);
     }
 
     // ---------- BundleListener -----------------------------------------------
@@ -188,7 +180,7 @@
      * Loads and unloads any components provided by the bundle whose state
      * changed. If the bundle has been started, the components are loaded. If
      * the bundle is about to stop, the components are unloaded.
-     * 
+     *
      * @param event The <code>BundleEvent</code> representing the bundle state
      *            change.
      */
@@ -214,15 +206,13 @@
                 }
                 break;
 
-            case BundleEvent.STARTING: // STARTED:
-                // register mappings before the bundle gets activated
-                objectContentManagerFactory.registerMapperClient(event.getBundle());
+            case BundleEvent.STARTED:
+                // register resource provider for the started bundle
                 addBundleResourceProvider(event.getBundle());
                 break;
 
             case BundleEvent.STOPPED:
-                // remove mappings after the bundle has stopped
-                objectContentManagerFactory.unregisterMapperClient(event.getBundle());
+                // remove resource provider after the bundle has stopped
                 removeBundleResourceProvider(event.getBundle());
                 break;
 
@@ -232,28 +222,11 @@
         }
     }
 
-    // ---------- ResourceProvider ---------------------------------------------
-
-    public String[] getRoots() {
-        return new String[] { "/" };
-    }
-
-    public Resource getResource(JcrResourceResolver jcrResourceResolver,
-            String path) throws RepositoryException {
-
-        if (jcrResourceResolver.itemExists(path)) {
-            log.info("getResource: Found JCR Node Resource at path '{}'", path);
-            return new JcrNodeResource(jcrResourceResolver, path);
-        }
-
-        return null;
-    }
-
     // ---------- EventAdmin Event Dispatching ---------------------------------
 
     /**
      * Fires an OSGi event through the EventAdmin service.
-     * 
+     *
      * @param sourceBundle The Bundle from which the event originates. This may
      *            be <code>null</code> if there is no originating bundle.
      * @param eventName The name of the event
@@ -301,13 +274,11 @@
 
     // ---------- Implementation helpers --------------------------------------
 
-    /** return the ObjectContentManager, used by JcrResourceResolver */
-    ObjectContentManager getObjectContentManager(Session session) {
-        return objectContentManagerFactory.getObjectContentManager(session);
-    }
-
-    /** check existence of an item with admin session, used by JcrResourceResolver */
-    boolean itemReallyExists(Session clientSession, String path)
+    /**
+     * check existence of an item with admin session, used by
+     * JcrResourceResolver
+     */
+    public boolean itemReallyExists(Session clientSession, String path)
             throws RepositoryException {
 
         // assume this session has more access rights than the client Session
@@ -353,7 +324,10 @@
         if (prefixes != null) {
             BundleResourceProvider brp = new BundleResourceProvider(bundle,
                 prefixes);
-            rootProviderEntry.addResourceProvider(brp);
+            String[] rootPaths = brp.getRoots();
+            for (int i=0; i < rootPaths.length; i++) {
+                rootProviderEntry.addResourceProvider(rootPaths[i], brp);
+            }
             bundleResourceProviderMap.put(bundle.getBundleId(), brp);
         }
     }
@@ -361,14 +335,13 @@
     private void removeBundleResourceProvider(Bundle bundle) {
         BundleResourceProvider brp = bundleResourceProviderMap.get(bundle.getBundleId());
         if (brp != null) {
-            rootProviderEntry.removeResourceProvider(brp);
+            String[] rootPaths = brp.getRoots();
+            for (int i=0; i < rootPaths.length; i++) {
+                rootProviderEntry.removeResourceProvider(rootPaths[i]);
+            }
         }
     }
 
-    ResourceProvider getResourceProvider(String path) {
-        return rootProviderEntry.getResourceProvider(path);
-    }
-
     // ---------- SCR Integration ---------------------------------------------
 
     /** Activates this component, called by SCR before registering as a service */
@@ -376,7 +349,6 @@
         this.serviceReference = componentContext.getServiceReference();
 
         this.initialContentLoader = new Loader(this);
-        this.objectContentManagerFactory = new ObjectContentManagerFactory(this);
 
         componentContext.getBundleContext().addBundleListener(this);
 
@@ -392,8 +364,7 @@
                 }
 
                 if (bundle.getState() == Bundle.ACTIVE) {
-                    // register active bundles with the mapper client
-                    objectContentManagerFactory.registerMapperClient(bundle);
+                    // add bundle resource provider for active bundles 
                     addBundleResourceProvider(bundle);
                 }
             }
@@ -437,7 +408,6 @@
     protected void deactivate(ComponentContext componentContext) {
         componentContext.getBundleContext().removeBundleListener(this);
 
-        objectContentManagerFactory.dispose();
         initialContentLoader.dispose();
 
         Session[] sessions = adminSessions.values().toArray(

Modified: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntry.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntry.java?rev=608912&r1=608911&r2=608912&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntry.java (original)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntry.java Fri Jan  4 08:38:36 2008
@@ -22,6 +22,8 @@
 import java.util.SortedSet;
 import java.util.TreeSet;
 
+import org.apache.sling.api.resource.ResourceProvider;
+
 public class ResourceProviderEntry implements Comparable<ResourceProviderEntry> {
 
     private final String path;
@@ -29,10 +31,12 @@
     private final String prefix;
 
     private final ResourceProvider provider;
+    
+    private final ResourceProviderEntry parentEntry;
 
     private ResourceProviderEntry[] entries;
 
-    public ResourceProviderEntry(String path, ResourceProvider provider) {
+    public ResourceProviderEntry(String path, ResourceProvider provider, ResourceProviderEntry parentEntry) {
         if (path.endsWith("/")) {
             this.path = path.substring(0, path.length() - 1);
             this.prefix = path;
@@ -41,25 +45,24 @@
             this.prefix = path + "/";
         }
         this.provider = provider;
+        this.parentEntry = parentEntry;
     }
 
-    public void addResourceProvider(ResourceProvider provider) {
-        String[] roots = provider.getRoots();
-        for (int i = 0; i < roots.length; i++) {
-            addResourceProvider(roots[i], provider);
-        }
+    public ResourceProviderEntry getParentEntry() {
+        return parentEntry;
     }
-
-    public void removeResourceProvider(ResourceProvider provider) {
-        String[] roots = provider.getRoots();
-        for (int i = 0; i < roots.length; i++) {
-            removeResourceProvider(roots[i]);
-        }
+    
+    public ResourceProvider getResourceProvider() {
+        return provider;
+    }
+    
+    public ResourceProviderEntry[] getEntries() {
+        return entries;
     }
 
-    public ResourceProvider getResourceProvider(String path) {
+    public ResourceProviderEntry getResourceProvider(String path) {
         if (path.equals(this.path)) {
-            return provider;
+            return this;
         } else if (match(path)) {
             if (entries != null) {
 
@@ -67,15 +70,15 @@
                 path = path.substring(this.prefix.length());
 
                 for (ResourceProviderEntry entry : entries) {
-                    ResourceProvider provider = entry.getResourceProvider(path);
-                    if (provider != null) {
-                        return provider;
+                    ResourceProviderEntry test = entry.getResourceProvider(path);
+                    if (test != null) {
+                        return test;
                     }
                 }
             }
 
             // no more specific provider, return mine
-            return provider;
+            return this;
         }
 
         // no match for my prefix, return null
@@ -86,15 +89,7 @@
         return path.startsWith(prefix);
     }
 
-    // ---------- Comparable<ResourceProviderEntry> interface ------------------
-
-    public int compareTo(ResourceProviderEntry o) {
-        return prefix.compareTo(o.prefix);
-    }
-
-    // ---------- internal -----------------------------------------------------
-
-    private boolean addResourceProvider(String prefix, ResourceProvider provider) {
+    public boolean addResourceProvider(String prefix, ResourceProvider provider) {
         if (prefix.equals(this.path)) {
             throw new IllegalStateException(
                 "ResourceProviderEntry for prefix already exists");
@@ -112,7 +107,7 @@
                     } else if (entry.prefix.startsWith(prefix)
                         && entry.prefix.charAt(prefix.length()) == '/') {
                         ResourceProviderEntry newEntry = new ResourceProviderEntry(
-                            prefix, provider);
+                            prefix, provider, this);
                         newEntry.addResourceProvider(entry.path, entry.provider);
                         entries[i] = newEntry;
                         return true;
@@ -123,7 +118,7 @@
 
             // none found, so add it here
             ResourceProviderEntry entry = new ResourceProviderEntry(prefix,
-                provider);
+                provider, this);
             if (entries == null) {
                 entries = new ResourceProviderEntry[] { entry };
             } else {
@@ -140,7 +135,7 @@
         return false;
     }
 
-    private boolean removeResourceProvider(String prefix) {
+    public boolean removeResourceProvider(String prefix) {
         if (prefix.equals(path)) {
             return true;
         } else if (match(prefix)) {
@@ -186,4 +181,11 @@
 
         return false;
     }
+
+    // ---------- Comparable<ResourceProviderEntry> interface ------------------
+
+    public int compareTo(ResourceProviderEntry o) {
+        return prefix.compareTo(o.prefix);
+    }
+
 }

Modified: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResource.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResource.java?rev=608912&r1=608911&r2=608912&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResource.java (original)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResource.java Fri Jan  4 08:38:36 2008
@@ -30,6 +30,7 @@
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceMetadata;
+import org.apache.sling.api.resource.ResourceProvider;
 import org.apache.sling.jcr.resource.internal.helper.Descendable;
 import org.osgi.framework.Bundle;
 import org.slf4j.Logger;
@@ -41,6 +42,8 @@
     /** default log */
     private final Logger log = LoggerFactory.getLogger(getClass());
 
+    private final ResourceProvider resourceProvider;
+    
     private final Bundle bundle;
 
     private final String path;
@@ -51,12 +54,12 @@
 
     private final ResourceMetadata metadata;
 
-    public static BundleResource getResource(Bundle bundle, String path) {
+    public static BundleResource getResource(ResourceProvider resourceProvider, Bundle bundle, String path) {
 
         // if the entry has no trailing slash, try to with a trailing
         // slash in case the entry would be a folder
         if (!path.endsWith("/")) {
-            BundleResource br = getResource(bundle, path + "/");
+            BundleResource br = getResource(resourceProvider, bundle, path + "/");
             if (br != null) {
                 return br;
             }
@@ -65,14 +68,15 @@
         // has trailing slash or not a folder, try path itself
         URL entry = bundle.getEntry(path);
         if (entry != null) {
-            return new BundleResource(bundle, path);
+            return new BundleResource(resourceProvider, bundle, path);
         }
 
         // the bundle does not contain the path
         return null;
     }
 
-    public BundleResource(Bundle bundle, String path) {
+    public BundleResource(ResourceProvider resourceProvider, Bundle bundle, String path) {
+        this.resourceProvider = resourceProvider;
         this.bundle = bundle;
         this.path = path.endsWith("/")
                 ? path.substring(0, path.length() - 1)
@@ -97,6 +101,10 @@
         return metadata;
     }
 
+    public ResourceProvider getResourceProvider() {
+        return resourceProvider;
+    }
+    
     @SuppressWarnings("unchecked")
     public <Type> Type adaptTo(Class<Type> type) {
         if (type == InputStream.class) {
@@ -162,7 +170,7 @@
         if (!isFile()) {
             URL descendent = bundle.getEntry(path + relPath);
             if (descendent != null) {
-                new BundleResource(bundle, descendent.getPath());
+                new BundleResource(resourceProvider, bundle, descendent.getPath());
             }
         }
 

Modified: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResourceIterator.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResourceIterator.java?rev=608912&r1=608911&r2=608912&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResourceIterator.java (original)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResourceIterator.java Fri Jan  4 08:38:36 2008
@@ -23,6 +23,7 @@
 import java.util.NoSuchElementException;
 
 import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceProvider;
 import org.osgi.framework.Bundle;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,6 +38,9 @@
     /** default log */
     private final Logger log = LoggerFactory.getLogger(getClass());
 
+    /** The bundle resource provider */
+    private ResourceProvider resourceProvider;
+    
     /** Bundle providing the entry resources */
     private Bundle bundle;
 
@@ -58,6 +62,7 @@
         if (parent.isFile()) {
 
             // if the parent is a file, the iterator is empty
+            this.resourceProvider = null;
             this.bundle = null;
             this.entries = null;
             this.prefixLength = 0;
@@ -67,6 +72,7 @@
             // trailing slash to enumerate children
             String parentPath = parent.getURI() + "/";
 
+            this.resourceProvider = parent.getResourceProvider();
             this.bundle = parent.getBundle();
             // unchecked cast
             this.entries = parent.getBundle().getEntryPaths(parentPath);
@@ -115,7 +121,7 @@
             int slash = entry.indexOf('/', prefixLength);
             if (slash < 0 || slash == entry.length() - 1) {
                 log.debug("seek: Using entry {}", entry);
-                return new BundleResource(bundle, entry);
+                return new BundleResource(resourceProvider, bundle, entry);
             }
 
             log.debug("seek: Ignoring entry {}", entry);

Modified: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResourceProvider.java?rev=608912&r1=608911&r2=608912&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResourceProvider.java (original)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResourceProvider.java Fri Jan  4 08:38:36 2008
@@ -19,12 +19,15 @@
 package org.apache.sling.jcr.resource.internal.helper.bundle;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 import java.util.StringTokenizer;
 
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.sling.api.SlingException;
 import org.apache.sling.api.resource.Resource;
-import org.apache.sling.jcr.resource.internal.JcrResourceResolver;
-import org.apache.sling.jcr.resource.internal.helper.ResourceProvider;
+import org.apache.sling.api.resource.ResourceProvider;
 import org.osgi.framework.Bundle;
 
 public class BundleResourceProvider implements ResourceProvider {
@@ -59,13 +62,22 @@
         return roots;
     }
 
+    public Resource getResource(HttpServletRequest request, String path) {
+        return getResource(path);
+    }
+
     /**
      * Returns a BundleResource for the path if such an entry exists in the
      * bundle of this provider. The JcrResourceResolver is ignored by this
      * implementation.
      */
-    public Resource getResource(JcrResourceResolver jrm, String path) {
-        return BundleResource.getResource(bundle, path);
+    public Resource getResource(String path) {
+        return BundleResource.getResource(this, bundle, path);
     }
 
+    public Iterator<Resource> listChildren(Resource parent)
+            throws SlingException {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

Modified: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResourceURLConnection.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResourceURLConnection.java?rev=608912&r1=608911&r2=608912&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResourceURLConnection.java (original)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/BundleResourceURLConnection.java Fri Jan  4 08:38:36 2008
@@ -22,6 +22,7 @@
 import java.io.InputStream;
 import java.net.URL;
 import java.net.URLConnection;
+
 import org.osgi.framework.Bundle;
 
 /**

Modified: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java?rev=608912&r1=608911&r2=608912&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java (original)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java Fri Jan  4 08:38:36 2008
@@ -41,23 +41,23 @@
 import org.apache.jackrabbit.net.URLFactory;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceMetadata;
-import org.apache.sling.jcr.resource.internal.JcrResourceResolver;
+import org.apache.sling.api.resource.ResourceProvider;
 import org.apache.sling.jcr.resource.internal.helper.Descendable;
+import org.apache.sling.osgi.commons.SlingAdaptable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /** A Resource that wraps a JCR Node */
-public class JcrNodeResource implements Resource, Descendable {
+public class JcrNodeResource extends SlingAdaptable implements Resource,
+        Descendable {
 
     /** default log */
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    private static final Object UNDEFINED = "undefined";
-
     /** The relative path name of the data property of an nt:file node */
     private static final String FILE_DATA_PROP = JCR_CONTENT + "/" + JCR_DATA;
 
-    private final JcrResourceResolver resourceResolver;
+    private final ResourceProvider resourceProvider;
 
     private final Node node;
 
@@ -65,16 +65,12 @@
 
     private final String resourceType;
 
-    private Object object = UNDEFINED;
-
-    private Class<?> objectType;
-
     private final ResourceMetadata metadata;
 
-    public JcrNodeResource(JcrResourceResolver cMgr, String path)
+    JcrNodeResource(JcrResourceProvider resourceProvider, String path)
             throws RepositoryException {
-        this.resourceResolver = cMgr;
-        node = (Node) cMgr.getSession().getItem(path);
+        this.resourceProvider = resourceProvider;
+        node = (Node) resourceProvider.getSession().getItem(path);
         this.path = node.getPath();
         metadata = new ResourceMetadata();
         resourceType = getResourceTypeForNode(node);
@@ -83,9 +79,9 @@
         setMetaData(node, metadata);
     }
 
-    public JcrNodeResource(JcrResourceResolver resourceResolver, Node node)
+    JcrNodeResource(ResourceProvider resourceProvider, Node node)
             throws RepositoryException {
-        this.resourceResolver = resourceResolver;
+        this.resourceProvider = resourceProvider;
         this.node = node;
         this.path = node.getPath();
         metadata = new ResourceMetadata();
@@ -116,20 +112,18 @@
             return (Type) getInputStream(); // unchecked cast
         } else if (type == URL.class) {
             return (Type) getURL(); // unchecked cast
-        } else if (type.isInstance(getObject())) {
-            return (Type) getObject(); // unchecked cast
         }
 
-        // fall back to nothing
-        return null;
+        // fall back to default implementation
+        return super.adaptTo(type);
     }
 
     public String toString() {
         return "JcrNodeResource, type=" + resourceType + ", path=" + path;
     }
 
-    JcrResourceResolver getResourceResolver() {
-        return resourceResolver;
+    public ResourceProvider getResourceProvider() {
+        return resourceProvider;
     }
 
     Node getNode() {
@@ -161,15 +155,6 @@
         return null;
     }
 
-    private Object getObject() {
-        if (object == UNDEFINED) {
-            // lazy loaded object
-            object = resourceResolver.getObject(getURI(), objectType);
-        }
-
-        return object;
-    }
-
     private URL getURL() {
         try {
             return URLFactory.createURL(node.getSession(), node.getPath());
@@ -189,7 +174,7 @@
     public Resource getDescendent(String relPath) {
         try {
             if (node.hasNode(relPath)) {
-                return new JcrNodeResource(resourceResolver,
+                return new JcrNodeResource(resourceProvider,
                     node.getNode(relPath));
             }
 
@@ -201,10 +186,6 @@
                 + path, re);
             return null;
         }
-    }
-
-    public void setObjectType(Class<?> objectType) {
-        this.objectType = objectType;
     }
 
     /**

Modified: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceIterator.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceIterator.java?rev=608912&r1=608911&r2=608912&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceIterator.java (original)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceIterator.java Fri Jan  4 08:38:36 2008
@@ -25,7 +25,7 @@
 import javax.jcr.RepositoryException;
 
 import org.apache.sling.api.resource.Resource;
-import org.apache.sling.jcr.resource.internal.JcrResourceResolver;
+import org.apache.sling.api.resource.ResourceProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,7 +41,7 @@
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     /** resource manager used to create resources from nodes */
-    private JcrResourceResolver resourceResolver;
+    private ResourceProvider resourceProvider;
 
     /** underlying node iterator to be used for resources */
     private NodeIterator nodes;
@@ -57,20 +57,20 @@
         try {
             NodeIterator nodes = parent.getNode().getNodes();
 
-            this.resourceResolver = parent.getResourceResolver();
+            this.resourceProvider = parent.getResourceProvider();
             this.nodes = nodes;
             this.nextResult = seek();
         } catch (RepositoryException re) {
             log.error("<init>: Cannot get children of resource " + parent, re);
-            this.resourceResolver = null;
+            this.resourceProvider = null;
             this.nodes = null;
             this.nextResult = null;
         }
     }
 
-    public JcrNodeResourceIterator(JcrResourceResolver resourceResolver,
+    public JcrNodeResourceIterator(ResourceProvider resourceProvider,
             NodeIterator nodes) {
-        this.resourceResolver = resourceResolver;
+        this.resourceProvider = resourceProvider;
         this.nodes = nodes;
         this.nextResult = seek();
     }
@@ -100,7 +100,7 @@
     private Resource seek() {
         while (nodes.hasNext()) {
             try {
-                return new JcrNodeResource(resourceResolver, nodes.nextNode());
+                return new JcrNodeResource(resourceProvider, nodes.nextNode());
             } catch (Throwable t) {
                 log.error(
                     "seek: Problem creating Resource for next node, skipping",

Added: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvderEntry.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvderEntry.java?rev=608912&view=auto
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvderEntry.java (added)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvderEntry.java Fri Jan  4 08:38:36 2008
@@ -0,0 +1,42 @@
+/*
+ * 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.resource.internal.helper.jcr;
+
+import javax.jcr.Session;
+
+import org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl;
+import org.apache.sling.jcr.resource.internal.helper.ResourceProviderEntry;
+
+public class JcrResourceProvderEntry extends ResourceProviderEntry {
+
+    private final Session session;
+    
+    public JcrResourceProvderEntry(
+            JcrResourceResolverFactoryImpl resourceResolverFactory,
+            Session session, ResourceProviderEntry[] entries) {
+        super("/", new JcrResourceProvider(resourceResolverFactory, session),
+            null);
+        
+        this.session = session;
+    }
+    
+    public Session getSession() {
+        return session;
+    }
+}

Added: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java?rev=608912&view=auto
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java (added)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java Fri Jan  4 08:38:36 2008
@@ -0,0 +1,149 @@
+/*
+ * 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.resource.internal.helper.jcr;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.sling.api.SlingException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceProvider;
+import org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl;
+import org.apache.sling.jcr.resource.internal.helper.Descendable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The <code>JcrResourceResolver</code> class implements the Sling
+ * <code>ResourceResolver</code> and <code>ResourceResolver</code> interfaces
+ * and in addition is a {@link PathResolver}. Instances of this class are
+ * retrieved through the
+ * {@link org.apache.sling.jcr.resource.JcrResourceResolverFactory#getResourceResolver(Session)}
+ * method.
+ */
+public class JcrResourceProvider implements ResourceProvider {
+
+    /** default log */
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    protected static final String ACTION_READ = "read";
+
+    private final JcrResourceResolverFactoryImpl factory;
+
+    private final Session session;
+
+    public JcrResourceProvider(JcrResourceResolverFactoryImpl factory,
+            Session session) {
+        this.factory = factory;
+        this.session = session;
+    }
+
+    // ---------- ResourceProvider interface ----------------------------------
+
+    public String[] getRoots() {
+        return new String[] { "/" };
+    }
+
+    public Resource getResource(HttpServletRequest request, String path) throws SlingException {
+        return getResource(path);
+    }
+
+    public Resource getResource(String path)
+            throws SlingException {
+
+        try {
+            if (itemExists(path)) {
+                log.info("getResource: Found JCR Node Resource at path '{}'",
+                    path);
+                return new JcrNodeResource(this, path);
+            }
+        } catch (RepositoryException re) {
+            throw new SlingException("Problem retrieving node based resource "
+                + path, re);
+        }
+
+        return null;
+    }
+
+    public Iterator<Resource> listChildren(Resource parent) {
+        if (parent instanceof Descendable) {
+            return ((Descendable) parent).listChildren();
+        }
+
+        try {
+            parent = getResource(parent.getURI());
+            if (parent instanceof Descendable) {
+                return ((Descendable) parent).listChildren();
+            }
+        } catch (SlingException se) {
+            log.warn("listChildren: Error trying to resolve parent resource "
+                + parent.getURI(), se);
+        }
+
+        // return an empty iterator if parent has no node
+        List<Resource> empty = Collections.emptyList();
+        return empty.iterator();
+    }
+
+    public Session getSession() {
+        return session;
+    }
+
+    // ---------- implementation helper ----------------------------------------
+
+    /**
+     * Checks whether the item exists and this content manager's session has
+     * read access to the item. If the item does not exist, access control is
+     * ignored by this method and <code>false</code> is returned.
+     *
+     * @param path The path to the item to check
+     * @return <code>true</code> if the item exists and this content manager's
+     *         session has read access. If the item does not exist,
+     *         <code>false</code> is returned ignoring access control.
+     * @throws RepositoryException
+     * @throws AccessControlException If the item really exists but this content
+     *             manager's session has no read access to it.
+     */
+    public boolean itemExists(String path) throws RepositoryException {
+        if (factory.itemReallyExists(getSession(), path)) {
+            checkPermission(path, ACTION_READ);
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * @param path
+     * @param actions
+     * @throws RepositoryException
+     * @throws AccessControlException if this manager does not have the
+     *             permission for the listed action(s).
+     */
+    protected void checkPermission(String path, String actions)
+            throws RepositoryException {
+        getSession().checkPermission(path, actions);
+    }
+
+}

Modified: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/JsonReader.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/JsonReader.java?rev=608912&r1=608911&r2=608912&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/JsonReader.java (original)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/JsonReader.java Fri Jan  4 08:38:36 2008
@@ -18,13 +18,14 @@
  */
 package org.apache.sling.jcr.resource.internal.loader;
 
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Iterator;
 
 import javax.jcr.PropertyType;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.sling.commons.json.JSONArray;
 import org.apache.sling.commons.json.JSONException;
 import org.apache.sling.commons.json.JSONObject;
@@ -37,7 +38,7 @@
 
     public Node parse(InputStream ins) throws IOException {
         try {
-            String jsonString = IOUtils.toString(ins).trim();
+            String jsonString = toString(ins).trim();
             if (!jsonString.startsWith("{")) {
                 jsonString = "{" + jsonString + "}";
             }
@@ -165,5 +166,36 @@
 
         // fall back to default
         return PropertyType.TYPENAME_STRING;
+    }
+    
+    private String toString(InputStream ins) throws IOException {
+        if (!ins.markSupported()) {
+            ins = new BufferedInputStream(ins);
+        }
+        
+        String encoding;
+        ins.mark(5);
+        int c = ins.read();
+        if (c == '#') {
+            // character encoding following
+            StringBuffer buf = new StringBuffer();
+            for (c = ins.read(); !Character.isWhitespace((char) c); c = ins.read()) {
+                buf.append((char) c);
+            }
+            encoding = buf.toString();
+        } else {
+            ins.reset();
+            encoding = "UTF-8";
+        }
+
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        byte[] buf = new byte[1024];
+        int rd;
+        while ( (rd = ins.read(buf)) >= 0) {
+            bos.write(buf, 0, rd);
+        }
+        bos.close(); // just to comply with the contract
+        
+        return new String(bos.toByteArray(), encoding);
     }
 }

Modified: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/test/java/org/apache/sling/jcr/resource/JcrResourceUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/test/java/org/apache/sling/jcr/resource/JcrResourceUtilTest.java?rev=608912&r1=608911&r2=608912&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/test/java/org/apache/sling/jcr/resource/JcrResourceUtilTest.java (original)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/test/java/org/apache/sling/jcr/resource/JcrResourceUtilTest.java Fri Jan  4 08:38:36 2008
@@ -18,8 +18,6 @@
  */
 package org.apache.sling.jcr.resource;
 
-import org.apache.sling.jcr.resource.JcrResourceUtil;
-
 import junit.framework.TestCase;
 
 public class JcrResourceUtilTest extends TestCase {

Modified: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntryTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntryTest.java?rev=608912&r1=608911&r2=608912&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntryTest.java (original)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntryTest.java Fri Jan  4 08:38:36 2008
@@ -18,12 +18,14 @@
  */
 package org.apache.sling.jcr.resource.internal.helper;
 
+import java.util.Iterator;
+
+import javax.servlet.http.HttpServletRequest;
+
 import junit.framework.TestCase;
 
 import org.apache.sling.api.resource.Resource;
-import org.apache.sling.jcr.resource.internal.JcrResourceResolver;
-import org.apache.sling.jcr.resource.internal.helper.ResourceProvider;
-import org.apache.sling.jcr.resource.internal.helper.ResourceProviderEntry;
+import org.apache.sling.api.resource.ResourceProvider;
 
 public class ResourceProviderEntryTest extends TestCase {
 
@@ -36,7 +38,7 @@
         super.setUp();
 
         rootProvider = new TestResourceProvider("/");
-        root = new ResourceProviderEntry("/", rootProvider);
+        root = new ResourceProviderEntry("/", rootProvider, null);
     }
 
     @Override
@@ -46,29 +48,29 @@
 
     public void testRootProvider() {
         assertNull(root.getResourceProvider("relpath"));
-        assertEquals(rootProvider, root.getResourceProvider("/"));
-        assertEquals(rootProvider, root.getResourceProvider("/rootel"));
-        assertEquals(rootProvider, root.getResourceProvider("/rootel/child"));
-        assertEquals(rootProvider,
+        assertEquals(root, root.getResourceProvider("/"));
+        assertEquals(root, root.getResourceProvider("/rootel"));
+        assertEquals(root, root.getResourceProvider("/rootel/child"));
+        assertEquals(root,
             root.getResourceProvider("/apps/sling/sample/html.js"));
-        assertEquals(rootProvider,
+        assertEquals(root,
             root.getResourceProvider("/apps/sling/microsling/html.js"));
     }
 
     public void testAdd1Provider() {
         String firstPath = "/rootel";
         ResourceProvider first = new TestResourceProvider(firstPath);
-        root.addResourceProvider(first);
+        root.addResourceProvider(firstPath, first);
 
-        assertEquals(rootProvider, root.getResourceProvider("/"));
-        assertEquals(first, root.getResourceProvider("/rootel"));
-        assertEquals(first, root.getResourceProvider("/rootel/html.js"));
-        assertEquals(first, root.getResourceProvider("/rootel/child"));
-        assertEquals(first, root.getResourceProvider("/rootel/child/html.js"));
+        assertEquals(root, root.getResourceProvider("/"));
+        assertEquals(first, root.getResourceProvider("/rootel").getResourceProvider());
+        assertEquals(first, root.getResourceProvider("/rootel/html.js").getResourceProvider());
+        assertEquals(first, root.getResourceProvider("/rootel/child").getResourceProvider());
+        assertEquals(first, root.getResourceProvider("/rootel/child/html.js").getResourceProvider());
         assertEquals(rootProvider,
-            root.getResourceProvider("/apps/sling/sample/html.js"));
+            root.getResourceProvider("/apps/sling/sample/html.js").getResourceProvider());
         assertEquals(rootProvider,
-            root.getResourceProvider("/apps/sling/microsling/html.js"));
+            root.getResourceProvider("/apps/sling/microsling/html.js").getResourceProvider());
     }
 
     public void testAdd3Providers() {
@@ -80,19 +82,19 @@
         ResourceProvider second = new TestResourceProvider(secondPath);
         ResourceProvider third = new TestResourceProvider(thirdPath);
 
-        root.addResourceProvider(first);
-        root.addResourceProvider(second);
-        root.addResourceProvider(third);
-
-        assertEquals(rootProvider, root.getResourceProvider("/"));
-        assertEquals(first, root.getResourceProvider("/rootel"));
-        assertEquals(first, root.getResourceProvider("/rootel/html.js"));
-        assertEquals(second, root.getResourceProvider("/rootel/child"));
-        assertEquals(second, root.getResourceProvider("/rootel/child/html.js"));
+        root.addResourceProvider(firstPath, first);
+        root.addResourceProvider(secondPath, second);
+        root.addResourceProvider(thirdPath, third);
+
+        assertEquals(rootProvider, root.getResourceProvider("/").getResourceProvider());
+        assertEquals(first, root.getResourceProvider("/rootel").getResourceProvider());
+        assertEquals(first, root.getResourceProvider("/rootel/html.js").getResourceProvider());
+        assertEquals(second, root.getResourceProvider("/rootel/child").getResourceProvider());
+        assertEquals(second, root.getResourceProvider("/rootel/child/html.js").getResourceProvider());
         assertEquals(third,
-            root.getResourceProvider("/apps/sling/sample/html.js"));
+            root.getResourceProvider("/apps/sling/sample/html.js").getResourceProvider());
         assertEquals(rootProvider,
-            root.getResourceProvider("/apps/sling/microsling/html.js"));
+            root.getResourceProvider("/apps/sling/microsling/html.js").getResourceProvider());
     }
 
     public void testAdd3ProvidersReverse() {
@@ -104,19 +106,19 @@
         ResourceProvider second = new TestResourceProvider(secondPath);
         ResourceProvider third = new TestResourceProvider(thirdPath);
 
-        root.addResourceProvider(third);
-        root.addResourceProvider(second);
-        root.addResourceProvider(first);
-
-        assertEquals(rootProvider, root.getResourceProvider("/"));
-        assertEquals(first, root.getResourceProvider("/rootel"));
-        assertEquals(first, root.getResourceProvider("/rootel/html.js"));
-        assertEquals(second, root.getResourceProvider("/rootel/child"));
-        assertEquals(second, root.getResourceProvider("/rootel/child/html.js"));
+        root.addResourceProvider(thirdPath, third);
+        root.addResourceProvider(secondPath, second);
+        root.addResourceProvider(firstPath, first);
+
+        assertEquals(rootProvider, root.getResourceProvider("/").getResourceProvider());
+        assertEquals(first, root.getResourceProvider("/rootel").getResourceProvider());
+        assertEquals(first, root.getResourceProvider("/rootel/html.js").getResourceProvider());
+        assertEquals(second, root.getResourceProvider("/rootel/child").getResourceProvider());
+        assertEquals(second, root.getResourceProvider("/rootel/child/html.js").getResourceProvider());
         assertEquals(third,
-            root.getResourceProvider("/apps/sling/sample/html.js"));
+            root.getResourceProvider("/apps/sling/sample/html.js").getResourceProvider());
         assertEquals(rootProvider,
-            root.getResourceProvider("/apps/sling/microsling/html.js"));
+            root.getResourceProvider("/apps/sling/microsling/html.js").getResourceProvider());
     }
 
     public void testRemoveProviders() {
@@ -128,25 +130,25 @@
         ResourceProvider second = new TestResourceProvider(secondPath);
         ResourceProvider third = new TestResourceProvider(thirdPath);
 
-        root.addResourceProvider(first);
-        root.addResourceProvider(second);
-        root.addResourceProvider(third);
+        root.addResourceProvider(firstPath, first);
+        root.addResourceProvider(secondPath, second);
+        root.addResourceProvider(thirdPath, third);
 
-        assertEquals(rootProvider, root.getResourceProvider("/"));
-        assertEquals(first, root.getResourceProvider("/rootel/html.js"));
-        assertEquals(second, root.getResourceProvider("/rootel/child/html.js"));
+        assertEquals(rootProvider, root.getResourceProvider("/").getResourceProvider());
+        assertEquals(first, root.getResourceProvider("/rootel/html.js").getResourceProvider());
+        assertEquals(second, root.getResourceProvider("/rootel/child/html.js").getResourceProvider());
 
-        root.removeResourceProvider(first);
+        root.removeResourceProvider(firstPath);
 
-        assertEquals(rootProvider, root.getResourceProvider("/"));
-        assertEquals(rootProvider, root.getResourceProvider("/rootel/html.js"));
-        assertEquals(second, root.getResourceProvider("/rootel/child/html.js"));
+        assertEquals(rootProvider, root.getResourceProvider("/").getResourceProvider());
+        assertEquals(rootProvider, root.getResourceProvider("/rootel/html.js").getResourceProvider());
+        assertEquals(second, root.getResourceProvider("/rootel/child/html.js").getResourceProvider());
 
-        root.addResourceProvider(first);
+        root.addResourceProvider(firstPath, first);
 
-        assertEquals(rootProvider, root.getResourceProvider("/"));
-        assertEquals(first, root.getResourceProvider("/rootel/html.js"));
-        assertEquals(second, root.getResourceProvider("/rootel/child/html.js"));
+        assertEquals(rootProvider, root.getResourceProvider("/").getResourceProvider());
+        assertEquals(first, root.getResourceProvider("/rootel/html.js").getResourceProvider());
+        assertEquals(second, root.getResourceProvider("/rootel/child/html.js").getResourceProvider());
     }
 
     private static class TestResourceProvider implements ResourceProvider {
@@ -157,7 +159,11 @@
             roots = new String[] { root };
         }
 
-        public Resource getResource(JcrResourceResolver jcrResourceResolver, String path) {
+        public Resource getResource(HttpServletRequest request, String path) {
+            return null;
+        }
+
+        public Resource getResource(String path) {
             return null;
         }
 
@@ -165,5 +171,8 @@
             return roots;
         }
 
+        public Iterator<Resource> listChildren(Resource parent) {
+            return null;
+        }
     }
 }

Modified: incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/loader/JsonReaderTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/loader/JsonReaderTest.java?rev=608912&r1=608911&r2=608912&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/loader/JsonReaderTest.java (original)
+++ incubator/sling/whiteboard/fmeschbe/resource/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/loader/JsonReaderTest.java Fri Jan  4 08:38:36 2008
@@ -278,7 +278,9 @@
     //---------- internal helper ----------------------------------------------
 
     private Node parse(String json) throws IOException {
-        InputStream ins = new ByteArrayInputStream(json.getBytes());
+        String charSet = "ISO-8859-1";
+        json = "#" + charSet + "\r\n" + json;
+        InputStream ins = new ByteArrayInputStream(json.getBytes(charSet));
         return this.jsonReader.parse(ins);
     }
 



Mime
View raw message