jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r657756 [1/2] - in /jackrabbit/sandbox/jackrabbit-ngp: ./ src/main/java/org/apache/jackrabbit/ngp/ src/main/java/org/apache/jackrabbit/ngp/node/ src/main/java/org/apache/jackrabbit/ngp/nodetype/ src/main/java/org/apache/jackrabbit/ngp/sessi...
Date Mon, 19 May 2008 08:43:28 GMT
Author: jukka
Date: Mon May 19 01:43:27 2008
New Revision: 657756

URL: http://svn.apache.org/viewvc?rev=657756&view=rev
Log:
NGP: Number of changes written over the weekend
    - Simplified core abstraction in o.a.j.ngp.state:
      - Node (bundle) states can be either transient or persistent
      - Only transient states can be modified
    - Don't use the file journal for now, all persistent states remain in memory
    - Support for simple single-valued string properties
    - Dummy namespace and node type support
    - JCR TCK (far from passing...)

Added:
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/NamespaceRegistryImpl.java
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/PropertyImpl.java
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/WorkspaceImpl.java
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/NodeDefinitionImpl.java
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/NodeTypeImpl.java
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/NodeTypeManagerImpl.java
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/PropertyDefinitionImpl.java
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/state/
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/state/NodeState.java
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/state/PersistentNodeState.java
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/state/TransientNodeState.java
    jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/JCRAPITest.java
    jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/RepositoryStubImpl.java
    jackrabbit/sandbox/jackrabbit-ngp/src/test/java/repositoryStubImpl.properties
Removed:
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/node/
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/session/
Modified:
    jackrabbit/sandbox/jackrabbit-ngp/   (props changed)
    jackrabbit/sandbox/jackrabbit-ngp/pom.xml
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/NodeImpl.java
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/RepositoryImpl.java
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/SessionImpl.java
    jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/AbstractRepositoryTest.java
    jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/NodeTest.java
    jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/RepositoryTest.java
    jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/SessionTest.java

Propchange: jackrabbit/sandbox/jackrabbit-ngp/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon May 19 01:43:27 2008
@@ -1,3 +1,4 @@
-target
-.classpath
-.project
+target
+.classpath
+.project
+.settings

Modified: jackrabbit/sandbox/jackrabbit-ngp/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/pom.xml?rev=657756&r1=657755&r2=657756&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/pom.xml (original)
+++ jackrabbit/sandbox/jackrabbit-ngp/pom.xml Mon May 19 01:43:27 2008
@@ -39,7 +39,7 @@
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-jcr-commons</artifactId>
-      <version>1.4</version>
+      <version>1.5-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>commons-collections</groupId>
@@ -57,6 +57,12 @@
       <version>1.4</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-jcr-tests</artifactId>
+      <version>1.5-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>4.4</version>

Added: jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/NamespaceRegistryImpl.java?rev=657756&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/NamespaceRegistryImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/NamespaceRegistryImpl.java Mon May 19 01:43:27 2008
@@ -0,0 +1,85 @@
+/*
+ * 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.jackrabbit.ngp;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.NamespaceException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+import org.apache.jackrabbit.commons.NamespaceHelper;
+
+public class NamespaceRegistryImpl implements NamespaceRegistry {
+
+    private final Map<String, String> namespaces =
+        new HashMap<String, String>();
+
+    public NamespaceRegistryImpl() {
+        namespaces.put("", "");
+        namespaces.put("jcr", NamespaceHelper.JCR);
+        namespaces.put("nt", NamespaceHelper.NT);
+        namespaces.put("mix", NamespaceHelper.MIX);
+        // TODO: Shouldn't be needed!
+        namespaces.put("sv", "http://www.jcp.org/jcr/sv/1.0");
+    }
+
+    public String getPrefix(String uri) throws RepositoryException {
+        for (Map.Entry<String, String> entry : namespaces.entrySet()) {
+            if (entry.getValue().equals(uri)) {
+                return entry.getKey();
+            }
+        }
+        throw new NamespaceException("Unknown namespace URI: " + uri);
+    }
+
+    public String[] getPrefixes() throws RepositoryException {
+        return (String[])
+            namespaces.keySet().toArray(new String[namespaces.size()]);
+    }
+
+    public String getURI(String prefix) throws RepositoryException {
+        String uri = namespaces.get(prefix);
+        if (uri != null) {
+            return uri;
+        } else {
+            throw new NamespaceException("Unknown namespace prefix: " + prefix);
+        }
+    }
+
+    public String[] getURIs() throws RepositoryException {
+        return (String[])
+            namespaces.values().toArray(new String[namespaces.size()]);
+    }
+
+    public void registerNamespace(String prefix, String uri)
+            throws RepositoryException {
+        if (namespaces.containsKey(prefix)) {
+            throw new NamespaceException("Prefix already registered: " + prefix);
+        } else if (namespaces.containsValue(uri)) {
+            throw new NamespaceException("URI already registered: " + uri);
+        }
+        namespaces.put(prefix, uri);
+    }
+
+    public void unregisterNamespace(String prefix) throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+}

Modified: jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/NodeImpl.java?rev=657756&r1=657755&r2=657756&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/NodeImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/NodeImpl.java Mon May 19 01:43:27 2008
@@ -1,4 +1,4 @@
-/**
+/*
  * 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.
@@ -17,54 +17,69 @@
 package org.apache.jackrabbit.ngp;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
-import java.util.Map;
+import java.util.HashSet;
+import java.util.Set;
 
-import javax.jcr.AccessDeniedException;
-import javax.jcr.InvalidItemStateException;
 import javax.jcr.Item;
-import javax.jcr.ItemExistsException;
 import javax.jcr.ItemNotFoundException;
-import javax.jcr.MergeException;
-import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.Property;
 import javax.jcr.PropertyIterator;
-import javax.jcr.ReferentialIntegrityException;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
 import javax.jcr.lock.Lock;
-import javax.jcr.lock.LockException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.version.Version;
-import javax.jcr.version.VersionException;
 
 import org.apache.jackrabbit.commons.AbstractNode;
 import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
-import org.apache.jackrabbit.ngp.node.NodeState;
+import org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter;
+import org.apache.jackrabbit.ngp.nodetype.NodeDefinitionImpl;
+import org.apache.jackrabbit.ngp.state.NodeState;
+import org.apache.jackrabbit.ngp.state.PersistentNodeState;
+import org.apache.jackrabbit.ngp.state.TransientNodeState;
 
 public class NodeImpl extends AbstractNode {
 
-    private final Session session;
+    private final SessionImpl session;
 
-    private final Node parent;
+    private final NodeImpl parent;
 
     private final String name;
 
-    private final NodeState state;
-
-    NodeImpl(Session session, Node parent, String name, NodeState state) {
+    NodeImpl(SessionImpl session, NodeImpl parent, String name) {
         this.session = session;
         this.parent = parent;
         this.name = name;
-        this.state = state;
+    }
+
+    NodeState getNodeState() {
+        if (parent == null) {
+            return session.getRoot();
+        } else {
+            // Guaranteed to exist, but may be PersistentNodeState.DEL
+            return parent.getNodeState().getNodes().get(name);
+        }
+    }
+
+    TransientNodeState getTransientNodeState() {
+        NodeState state = getNodeState();
+        if (!state.isTransient()) {
+            state = new TransientNodeState((PersistentNodeState) state);
+            if (parent == null) {
+                session.setRoot(state);
+            } else {
+                parent.getTransientNodeState().setNode(name, state);
+            }
+        }
+        return (TransientNodeState) state;
     }
 
     /**
@@ -82,259 +97,253 @@
 
     public Node getParent() throws ItemNotFoundException {
         if (parent != null) {
-            // TODO: Support moves
-            return parent;
+            return parent; // TODO: Support moves
         } else {
             throw new ItemNotFoundException("The root node has no parent");
         }
     }
 
     public String getName() {
-        // TODO: Support renames
-        return name;
+        return name; // TODO: Support renames
     }
 
     public int getIndex() throws RepositoryException {
-        // TODO: Support same-name-siblings
-        return 1;
+        return 1; // TODO: Support same-name-siblings
     }
 
     public boolean isModified() {
-        return false;
+        synchronized (session) {
+            return getNodeState().isModified();
+        }
     }
 
     public boolean isNew() {
-        return false;
+        synchronized (session) {
+            return getNodeState().isNew();
+        }
+    }
+
+    public PropertyIterator getProperties() throws RepositoryException {
+        synchronized (session) {
+            Set<String> names = getNodeState().getProperties().keySet();
+            Collection<Property> properties =
+                new ArrayList<Property>(names.size());
+            for (String name : names) {
+                properties.add(new PropertyImpl(session, this, name));
+            }
+            return new PropertyIteratorAdapter(properties);
+        }
+    }
+
+    public Property getProperty(String relPath) throws RepositoryException {
+        // TODO: Support relative paths
+        synchronized (session) {
+            if (getNodeState().getProperties().containsKey(relPath)) {
+                return new PropertyImpl(session, this, relPath);
+            } else {
+                throw new PathNotFoundException(relPath);
+            }
+        }
+    }
+
+    public Property setProperty(String name, Value value)
+            throws RepositoryException {
+        synchronized (session) {
+            getTransientNodeState().setProperty(name, value.getString());
+            return new PropertyImpl(session, this, name);
+        }
+    }
+
+    public Property setProperty(String name, Value[] values)
+            throws RepositoryException {
+        throw new ValueFormatException("Not a multi-valued property");
     }
 
     public NodeIterator getNodes() throws RepositoryException {
         synchronized (session) {
-            Map<String, NodeState> states = state.getNodes();
-            Collection<Node> nodes = new ArrayList<Node>(states.size());
-            for (Map.Entry<String, NodeState> entry : states.entrySet()) {
-                nodes.add(new NodeImpl(
-                        session, this, entry.getKey(), entry.getValue()));
+            Set<String> names = getNodeState().getNodes().keySet();
+            Collection<Node> nodes = new ArrayList<Node>(names.size());
+            for (String name : names) {
+                nodes.add(new NodeImpl(session, this, name));
             }
             return new NodeIteratorAdapter(nodes);
         }
     }
 
     public Node getNode(String relPath) throws RepositoryException {
-        int i = relPath.indexOf('/');
-        if (i > 0) {
-            Node node = getNode(relPath.substring(0, i));
-            return node.getNode(relPath.substring(i + 1));
-        } else if (i == 0) {
-            return getSession().getRootNode().getNode(relPath.substring(1));
-        } else if (relPath.equals("..")) {
-            if (parent != null) {
-                return parent;
+        int slash = relPath.indexOf('/');
+        if (slash != -1) {
+            getNode(relPath.substring(0, slash)).getNode(relPath.substring(slash + 1));
+        }
+        // TODO: Support relative paths
+        synchronized (session) {
+            NodeState state = getNodeState().getNodes().get(relPath);
+            if (state != null && state != PersistentNodeState.DEL) {
+                return new NodeImpl(session, this, relPath);
             } else {
                 throw new PathNotFoundException(relPath);
             }
-        } else if (relPath.equals(".")) {
-            return this;
-        } else {
-            synchronized (session) {
-                NodeState child = state.getNodes().get(relPath);
-                if (child != null) {
-                    return new NodeImpl(session, this, relPath, child);
-                } else {
-                    throw new PathNotFoundException(relPath);
-                }
-            }
         }
     }
 
     public Node addNode(String relPath) throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        // TODO: Support relative paths
+        synchronized (session) {
+            NodeState state = getNodeState().getNodes().get(relPath);
+            if (state != null && state != PersistentNodeState.DEL) {
+                throw new RepositoryException(); // TODO
+            }
+            state = new TransientNodeState(PersistentNodeState.NEW);
+            ((TransientNodeState) state).setProperty(
+                    "jcr:primaryType", "nt:unstructured");
+            getTransientNodeState().setNode(relPath, state);
+            return new NodeImpl(session, this, relPath);
+        }
     }
 
-    public void addMixin(String mixinName) throws NoSuchNodeTypeException,
-            VersionException, ConstraintViolationException, LockException,
-            RepositoryException {
-        // TODO Auto-generated method stub
+    public Node addNode(String relPath, String primaryNodeTypeName)
+            throws RepositoryException {
+        return addNode(relPath); // TODO: Support node types
+    }
 
+    public void remove() throws RepositoryException {
+        if (parent == null) {
+            throw new RepositoryException("Can not remove the root node");
+        }
+        synchronized (session) {
+            parent.getTransientNodeState().setNode(
+                    name, PersistentNodeState.DEL);
+        }
     }
 
-    public Node addNode(String relPath, String primaryNodeTypeName)
-            throws ItemExistsException, PathNotFoundException,
-            NoSuchNodeTypeException, LockException, VersionException,
-            ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+    public void addMixin(String mixinName) throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
     }
 
-    public boolean canAddMixin(String mixinName)
-            throws NoSuchNodeTypeException, RepositoryException {
-        // TODO Auto-generated method stub
+    public boolean canAddMixin(String mixinName) throws RepositoryException {
+        // TODO: Support mixin types
         return false;
     }
 
-    public void cancelMerge(Version version) throws VersionException,
-            InvalidItemStateException, UnsupportedRepositoryOperationException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-
+    public void cancelMerge(Version version) throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
     }
 
-    public Version checkin() throws VersionException,
-            UnsupportedRepositoryOperationException, InvalidItemStateException,
-            LockException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+    public Version checkin() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
     }
 
-    public void checkout() throws UnsupportedRepositoryOperationException,
-            LockException, RepositoryException {
-        // TODO Auto-generated method stub
-
+    public void checkout() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
     }
 
-    public void doneMerge(Version version) throws VersionException,
-            InvalidItemStateException, UnsupportedRepositoryOperationException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-
+    public void doneMerge(Version version) throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
     }
 
-    public Version getBaseVersion()
-            throws UnsupportedRepositoryOperationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+    public Version getBaseVersion() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
     }
 
     public String getCorrespondingNodePath(String workspaceName)
-            throws ItemNotFoundException, NoSuchWorkspaceException,
-            AccessDeniedException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+            throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
     }
 
     public NodeDefinition getDefinition() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Lock getLock() throws UnsupportedRepositoryOperationException,
-            LockException, AccessDeniedException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        return new NodeDefinitionImpl();
     }
 
-    public NodeIterator getNodes(String namePattern) throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+    public Lock getLock() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
     }
 
-    public Item getPrimaryItem() throws ItemNotFoundException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+    public NodeIterator getNodes(String namePattern)
+            throws RepositoryException {
+        // TODO: Support name patterns
+        if (namePattern.equals("*")) {
+            return getNodes();
+        }
+        Collection<Node> nodes = new ArrayList<Node>();
+        for (String name : new HashSet<String>(Arrays.asList(namePattern.split("\\|")))) {
+            try {
+                nodes.add(getNode(name));
+            } catch (PathNotFoundException e) {
+            }
+        }
+        return new NodeIteratorAdapter(nodes);
     }
 
-    public PropertyIterator getProperties() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+    public Item getPrimaryItem() throws RepositoryException {
+        // TODO: Support primary items
+        throw new ItemNotFoundException();
     }
 
     public PropertyIterator getProperties(String namePattern)
             throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        // TODO: Support name patterns
+        if (namePattern.equals("*")) {
+            return getProperties();
+        }
+        Collection<Property> properties = new ArrayList<Property>(1);
+        for (String name : new HashSet<String>(Arrays.asList(namePattern.split("\\|")))) {
+            try {
+                properties.add(getProperty(name));
+            } catch (PathNotFoundException e) {
+            }
+        }
+        return new PropertyIteratorAdapter(properties);
     }
 
     public PropertyIterator getReferences() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        throw new UnsupportedRepositoryOperationException();
     }
 
     public Lock lock(boolean isDeep, boolean isSessionScoped)
-            throws UnsupportedRepositoryOperationException, LockException,
-            AccessDeniedException, InvalidItemStateException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+            throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
     }
 
     public NodeIterator merge(String srcWorkspace, boolean bestEffort)
-            throws NoSuchWorkspaceException, AccessDeniedException,
-            MergeException, LockException, InvalidItemStateException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+            throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
     }
 
     public void orderBefore(String srcChildRelPath, String destChildRelPath)
-            throws UnsupportedRepositoryOperationException, VersionException,
-            ConstraintViolationException, ItemNotFoundException, LockException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-
+            throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
     }
 
-    public void removeMixin(String mixinName) throws NoSuchNodeTypeException,
-            VersionException, ConstraintViolationException, LockException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-
+    public void removeMixin(String mixinName) throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
     }
 
     public void restore(Version version, String relPath, boolean removeExisting)
-            throws PathNotFoundException, ItemExistsException,
-            VersionException, ConstraintViolationException,
-            UnsupportedRepositoryOperationException, LockException,
-            InvalidItemStateException, RepositoryException {
-        // TODO Auto-generated method stub
-
-    }
-
-    public Property setProperty(String name, Value value)
-            throws ValueFormatException, VersionException, LockException,
-            ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Property setProperty(String name, Value[] values)
-            throws ValueFormatException, VersionException, LockException,
-            ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+            throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
     }
 
-    public void unlock() throws UnsupportedRepositoryOperationException,
-            LockException, AccessDeniedException, InvalidItemStateException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-
+    public void unlock() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
     }
 
-    public void update(String srcWorkspaceName)
-            throws NoSuchWorkspaceException, AccessDeniedException,
-            LockException, InvalidItemStateException, RepositoryException {
-        // TODO Auto-generated method stub
-
+    public void update(String srcWorkspaceName) throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
     }
 
     public boolean isSame(Item otherItem) throws RepositoryException {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    public void remove() throws VersionException, LockException,
-            ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-
+        if (!otherItem.isNode() || !name.equals(otherItem.getName())) {
+            return false;
+        } if (otherItem.getDepth() == 0) {
+            return parent == null;
+        } else {
+            return parent != null && parent.isSame(otherItem.getParent());
+        }
     }
 
-    public void save() throws AccessDeniedException, ItemExistsException,
-            ConstraintViolationException, InvalidItemStateException,
-            ReferentialIntegrityException, VersionException, LockException,
-            NoSuchNodeTypeException, RepositoryException {
-        // TODO Auto-generated method stub
-
+    public void save() throws RepositoryException {
+        // TODO: item saves
+        session.save();
     }
 
 }

Added: jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/PropertyImpl.java?rev=657756&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/PropertyImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/PropertyImpl.java Mon May 19 01:43:27 2008
@@ -0,0 +1,98 @@
+/*
+ * 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.jackrabbit.ngp;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+import javax.jcr.nodetype.PropertyDefinition;
+
+import org.apache.jackrabbit.commons.AbstractProperty;
+import org.apache.jackrabbit.ngp.nodetype.PropertyDefinitionImpl;
+
+public class PropertyImpl extends AbstractProperty {
+
+    private final SessionImpl session;
+
+    private final NodeImpl parent;
+
+    private final String name;
+
+    public PropertyImpl(SessionImpl session, NodeImpl parent, String name) {
+        this.session = session;
+        this.parent = parent;
+        this.name = name;
+    }
+
+    public Session getSession() {
+        return session;
+    }
+
+    public Node getParent() {
+        return parent;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public boolean isModified() {
+        synchronized (session) {
+            return parent.getNodeState().isModified(name);
+        }
+    }
+
+    public boolean isNew() {
+        synchronized (session) {
+            return parent.getNodeState().isModified(name);
+        }
+    }
+
+    public boolean isSame(Item otherItem) throws RepositoryException {
+        return !otherItem.isNode()
+            && name.equals(otherItem.getName())
+            && parent.isSame(otherItem.getParent());
+    }
+
+    public void refresh(boolean keepChanges) throws RepositoryException {
+        session.refresh(keepChanges);
+    }
+
+    public void save() throws RepositoryException {
+        // TODO: item saves
+        session.save();
+    }
+
+    public PropertyDefinition getDefinition() {
+        return new PropertyDefinitionImpl();
+    }
+
+    public Value getValue() throws RepositoryException {
+        synchronized (session) {
+            return session.getValueFactory().createValue(
+                    parent.getNodeState().getProperties().get(name));
+        }
+    }
+
+    public Value[] getValues() throws RepositoryException {
+        throw new ValueFormatException("Not a multi-valued property: " + name);
+    }
+
+}

Modified: jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/RepositoryImpl.java?rev=657756&r1=657755&r2=657756&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/RepositoryImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/RepositoryImpl.java Mon May 19 01:43:27 2008
@@ -1,4 +1,4 @@
-/**
+/*
  * 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.
@@ -16,18 +16,17 @@
  */
 package org.apache.jackrabbit.ngp;
 
-import java.io.File;
 import java.util.HashMap;
 import java.util.Map;
 
 import javax.jcr.Credentials;
+import javax.jcr.NamespaceRegistry;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Workspace;
 
 import org.apache.jackrabbit.commons.AbstractRepository;
-import org.apache.jackrabbit.ngp.journal.FileJournal;
-import org.apache.jackrabbit.ngp.journal.Journal;
+import org.apache.jackrabbit.ngp.state.PersistentNodeState;
 
 public class RepositoryImpl extends AbstractRepository {
 
@@ -46,26 +45,20 @@
         DESCRIPTORS.put(REP_VENDOR_DESC, "Apache Software Foundation");
         DESCRIPTORS.put(REP_VENDOR_URL_DESC, "http://jackrabbit.apache.org/");
 
-        // DESCRIPTORS.put(LEVEL_1_SUPPORTED, Boolean.TRUE.toString());
-        // DESCRIPTORS.put(LEVEL_2_SUPPORTED, Boolean.TRUE.toString());
-        // DESCRIPTORS.put(OPTION_LOCKING_SUPPORTED, Boolean.TRUE.toString());
-        // DESCRIPTORS.put(OPTION_OBSERVATION_SUPPORTED, Boolean.TRUE.toString());
-        // DESCRIPTORS.put(OPTION_QUERY_SQL_SUPPORTED, Boolean.TRUE.toString());
-        // DESCRIPTORS.put(OPTION_TRANSACTIONS_SUPPORTED, Boolean.TRUE.toString());
-        // DESCRIPTORS.put(OPTION_VERSIONING_SUPPORTED, Boolean.TRUE.toString());
-        // DESCRIPTORS.put(QUERY_XPATH_DOC_ORDER, Boolean.TRUE.toString());
-        // DESCRIPTORS.put(QUERY_XPATH_POS_INDEX, Boolean.TRUE.toString());
+        DESCRIPTORS.put(LEVEL_1_SUPPORTED, Boolean.TRUE.toString());
+        DESCRIPTORS.put(LEVEL_2_SUPPORTED, Boolean.TRUE.toString());
+        DESCRIPTORS.put(OPTION_LOCKING_SUPPORTED, Boolean.FALSE.toString());
+        DESCRIPTORS.put(OPTION_OBSERVATION_SUPPORTED, Boolean.FALSE.toString());
+        DESCRIPTORS.put(OPTION_QUERY_SQL_SUPPORTED, Boolean.FALSE.toString());
+        DESCRIPTORS.put(OPTION_TRANSACTIONS_SUPPORTED, Boolean.FALSE.toString());
+        DESCRIPTORS.put(OPTION_VERSIONING_SUPPORTED, Boolean.FALSE.toString());
+        DESCRIPTORS.put(QUERY_XPATH_DOC_ORDER, Boolean.FALSE.toString());
+        DESCRIPTORS.put(QUERY_XPATH_POS_INDEX, Boolean.FALSE.toString());
     }
 
-    private final Journal journal;
+    private final NamespaceRegistry registry = new NamespaceRegistryImpl();
 
-    public RepositoryImpl(Journal journal) {
-        this.journal = journal;
-    }
-
-    public RepositoryImpl(File directory) throws RepositoryException {
-        this(new FileJournal(directory));
-    }
+    private PersistentNodeState root = PersistentNodeState.ROOT;
 
     public String getDescriptor(String key) {
         return DESCRIPTORS.get(key);
@@ -88,7 +81,18 @@
         attributes.put(Credentials.class.getName(), credentials);
         attributes.put(Workspace.class.getName(), workspaceName);
 
-        return new SessionImpl(this, attributes, journal);
+        return new SessionImpl(this, attributes, registry);
+    }
+
+    //----------------------------------------------------< RepositoryImp >--
+
+    PersistentNodeState getRoot() {
+        return root;
+    }
+
+    void setRoot(PersistentNodeState root) {
+        assert root != null;
+        this.root = root;
     }
 
 }

Modified: jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/SessionImpl.java?rev=657756&r1=657755&r2=657756&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/SessionImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/SessionImpl.java Mon May 19 01:43:27 2008
@@ -1,4 +1,4 @@
-/**
+/*
  * 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.
@@ -19,43 +19,50 @@
 import java.util.Map;
 
 import javax.jcr.Credentials;
-import javax.jcr.NamespaceException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.NamespaceRegistry;
 import javax.jcr.Node;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.SimpleCredentials;
+import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.ValueFactory;
 import javax.jcr.Workspace;
 
 import org.apache.jackrabbit.commons.AbstractSession;
-import org.apache.jackrabbit.ngp.journal.Journal;
-import org.apache.jackrabbit.ngp.session.SessionState;
+import org.apache.jackrabbit.ngp.state.NodeState;
+import org.apache.jackrabbit.ngp.state.TransientNodeState;
+import org.apache.jackrabbit.value.ValueFactoryImpl;
 import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
 
 public class SessionImpl extends AbstractSession {
 
-    private final Repository repository;
+    private final RepositoryImpl repository;
 
     private final Map<String, Object> attributes;
 
-    private SessionState state;
+    private final NamespaceRegistry registry;
+
+    private NodeState root;
+
+    private boolean live = true;
 
     SessionImpl(
-            Repository repository, Map<String, Object> attributes,
-            Journal journal) throws RepositoryException {
+            RepositoryImpl repository, Map<String, Object> attributes,
+            NamespaceRegistry registry)
+            throws RepositoryException {
         this.repository = repository;
         this.attributes = attributes;
-        this.state = new SessionState(journal);
+        this.root = repository.getRoot();
+        this.registry = registry;
     }
 
-    private SessionState getState() throws RepositoryException {
-        SessionState state = this.state;
-        if (state != null) {
-            return state;
-        } else {
-            throw new RepositoryException("This session has been closed");
-        }
+    NodeState getRoot() {
+        return root;
+    }
+
+    void setRoot(NodeState root) {
+        this.root = root;
     }
 
     /**
@@ -67,6 +74,14 @@
         return repository;
     }
 
+    public Workspace getWorkspace() {
+        return new WorkspaceImpl(this, registry);
+    }
+
+    public ValueFactory getValueFactory() {
+        return ValueFactoryImpl.getInstance();
+    }
+
     /**
      * Returns the names of all the attributes associated with this session.
      *
@@ -103,10 +118,11 @@
     }
 
     /**
-     * Closes this session. Any unsaved state is discarded.
+     * Closes this session.
      */
     public void logout() {
-        state = null;
+        live = false;
+        super.logout();
     }
 
     /**
@@ -115,7 +131,7 @@
      * @return state of this session
      */
     public boolean isLive() {
-        return state != null;
+        return live;
     }
 
     /**
@@ -126,108 +142,51 @@
      */
     public synchronized void refresh(boolean keepChanges)
             throws RepositoryException {
-        getState().refresh(keepChanges);
-    }
-
-    public synchronized Node getRootNode() throws RepositoryException {
-        return new NodeImpl(this, null, "", getState().getRootNode());
+        if (!keepChanges || !root.isModified()) {
+            root = repository.getRoot();
+        } else if (
+                ((TransientNodeState) root).getBase() != repository.getRoot()) {
+            throw new UnsupportedRepositoryOperationException();
+        }
     }
 
-    public void addLockToken(String lt) {
-        // TODO Auto-generated method stub
-
+    public Node getRootNode() {
+        return new NodeImpl(this, null, "");
     }
 
     public void checkPermission(String absPath, String actions)
             throws RepositoryException {
-        // TODO Auto-generated method stub
-
-    }
-
-    public void exportDocumentView(
-            String absPath, ContentHandler contentHandler,
-            boolean skipBinary, boolean noRecurse)
-            throws SAXException, RepositoryException {
-        // TODO Auto-generated method stub
-
-    }
-
-    public void exportSystemView(
-            String absPath, ContentHandler contentHandler,
-            boolean skipBinary, boolean noRecurse)
-            throws SAXException, RepositoryException {
-        // TODO Auto-generated method stub
-
+        throw new UnsupportedRepositoryOperationException();
     }
 
     public ContentHandler getImportContentHandler(
             String parentAbsPath, int uuidBehavior)
             throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public String[] getLockTokens() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public String getNamespacePrefix(String uri) throws NamespaceException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public String[] getNamespacePrefixes() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public String getNamespaceURI(String prefix) throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        throw new UnsupportedRepositoryOperationException();
     }
 
     public Node getNodeByUUID(String uuid) throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public ValueFactory getValueFactory() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        // TODO: Support mix:referenceable
+        throw new ItemNotFoundException();
     }
 
-    public Workspace getWorkspace() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public boolean hasPendingChanges() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return false;
+    public boolean hasPendingChanges() {
+        return root.isTransient();
     }
 
     public void move(String srcAbsPath, String destAbsPath)
             throws RepositoryException {
-        // TODO Auto-generated method stub
-
-    }
-
-    public void removeLockToken(String lt) {
-        // TODO Auto-generated method stub
-
+        throw new UnsupportedRepositoryOperationException();
     }
 
-    public void save() throws RepositoryException {
-        // TODO Auto-generated method stub
-
-    }
-
-    public void setNamespacePrefix(String prefix, String uri)
-            throws RepositoryException {
-        // TODO Auto-generated method stub
-
+    public synchronized void save() throws RepositoryException {
+        synchronized (repository) {
+            refresh(true);
+            if (hasPendingChanges()) {
+                repository.setRoot(root.persist());
+            }
+            refresh(false);
+        }
     }
 
 }

Added: jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/WorkspaceImpl.java?rev=657756&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/WorkspaceImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/WorkspaceImpl.java Mon May 19 01:43:27 2008
@@ -0,0 +1,104 @@
+/*
+ * 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.jackrabbit.ngp;
+
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.observation.ObservationManager;
+import javax.jcr.query.QueryManager;
+import javax.jcr.version.Version;
+
+import org.apache.jackrabbit.commons.AbstractWorkspace;
+import org.apache.jackrabbit.ngp.nodetype.NodeTypeManagerImpl;
+import org.xml.sax.ContentHandler;
+
+public class WorkspaceImpl extends AbstractWorkspace {
+
+    private final SessionImpl session;
+
+    private final NamespaceRegistry registry;
+
+    public WorkspaceImpl(SessionImpl session, NamespaceRegistry registry) {
+        this.session = session;
+        this.registry = registry;
+    }
+
+    public Session getSession() {
+        return session;
+    }
+
+    public String getName() {
+        return "default";
+    }
+
+    public String[] getAccessibleWorkspaceNames() throws RepositoryException {
+        return new String[] { "default" };
+    }
+
+    public NamespaceRegistry getNamespaceRegistry() {
+        return registry;
+    }
+
+    public void clone(
+            String srcWorkspace, String srcAbsPath,
+            String destAbsPath, boolean removeExisting)
+            throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    public void copy(String srcAbsPath, String destAbsPath)
+            throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    public void copy(String srcWorkspace, String srcAbsPath, String destAbsPath)
+            throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    public ContentHandler getImportContentHandler(
+            String parentAbsPath, int uuidBehavior) throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    public NodeTypeManager getNodeTypeManager() throws RepositoryException {
+        return new NodeTypeManagerImpl();
+    }
+
+    public ObservationManager getObservationManager()
+            throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    public QueryManager getQueryManager() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    public void move(String srcAbsPath, String destAbsPath)
+            throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    public void restore(Version[] versions, boolean removeExisting)
+            throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/NodeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/NodeDefinitionImpl.java?rev=657756&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/NodeDefinitionImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/NodeDefinitionImpl.java Mon May 19 01:43:27 2008
@@ -0,0 +1,62 @@
+/*
+ * 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.jackrabbit.ngp.nodetype;
+
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.version.OnParentVersionAction;
+
+
+public class NodeDefinitionImpl implements NodeDefinition {
+
+    public boolean allowsSameNameSiblings() {
+        return false;
+    }
+
+    public NodeType getDefaultPrimaryType() {
+        return new NodeTypeImpl();
+    }
+
+    public NodeType[] getRequiredPrimaryTypes() {
+        return new NodeType[] {new NodeTypeImpl() };
+    }
+
+    public NodeType getDeclaringNodeType() {
+        return new NodeTypeImpl();
+    }
+
+    public String getName() {
+        return "*";
+    }
+
+    public int getOnParentVersion() {
+        return OnParentVersionAction.COPY;
+    }
+
+    public boolean isAutoCreated() {
+        return false;
+    }
+
+    public boolean isMandatory() {
+        return false;
+    }
+
+    public boolean isProtected() {
+        return false;
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/NodeTypeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/NodeTypeImpl.java?rev=657756&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/NodeTypeImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/NodeTypeImpl.java Mon May 19 01:43:27 2008
@@ -0,0 +1,91 @@
+/*
+ * 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.jackrabbit.ngp.nodetype;
+
+import javax.jcr.Value;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.PropertyDefinition;
+
+
+public class NodeTypeImpl implements NodeType {
+
+    public boolean canAddChildNode(String childNodeName) {
+        return true;
+    }
+
+    public boolean canAddChildNode(String childNodeName, String nodeTypeName) {
+        return true;
+    }
+
+    public boolean canRemoveItem(String itemName) {
+        return !itemName.equals("jcr:primaryType");
+    }
+
+    public boolean canSetProperty(String propertyName, Value value) {
+        return !propertyName.equals("jcr:primaryType");
+    }
+
+    public boolean canSetProperty(String propertyName, Value[] values) {
+        return false;
+    }
+
+    public NodeDefinition[] getChildNodeDefinitions() {
+        return new NodeDefinition[] { new NodeDefinitionImpl() };
+    }
+
+    public NodeDefinition[] getDeclaredChildNodeDefinitions() {
+        return new NodeDefinition[] { new NodeDefinitionImpl() };
+    }
+
+    public PropertyDefinition[] getDeclaredPropertyDefinitions() {
+        return new PropertyDefinition[] { new PropertyDefinitionImpl() };
+    }
+
+    public NodeType[] getDeclaredSupertypes() {
+        return new NodeType[0];
+    }
+
+    public String getName() {
+        return "nt:unstructured";
+    }
+
+    public String getPrimaryItemName() {
+        return null;
+    }
+
+    public PropertyDefinition[] getPropertyDefinitions() {
+        return new PropertyDefinition[] { new PropertyDefinitionImpl() };
+    }
+
+    public NodeType[] getSupertypes() {
+        return new NodeType[0];
+    }
+
+    public boolean hasOrderableChildNodes() {
+        return false;
+    }
+
+    public boolean isMixin() {
+        return false;
+    }
+
+    public boolean isNodeType(String nodeTypeName) {
+        return getName().equals(nodeTypeName);
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/NodeTypeManagerImpl.java?rev=657756&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/NodeTypeManagerImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/NodeTypeManagerImpl.java Mon May 19 01:43:27 2008
@@ -0,0 +1,52 @@
+/*
+ * 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.jackrabbit.ngp.nodetype;
+
+import java.util.Collections;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeIterator;
+import javax.jcr.nodetype.NodeTypeManager;
+
+import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
+
+public class NodeTypeManagerImpl implements NodeTypeManager {
+
+    public NodeTypeIterator getAllNodeTypes() throws RepositoryException {
+        return new NodeTypeIteratorAdapter(Collections.singleton(new NodeTypeImpl()));
+    }
+
+    public NodeTypeIterator getMixinNodeTypes() throws RepositoryException {
+        return new NodeTypeIteratorAdapter(Collections.EMPTY_LIST);
+    }
+
+    public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException {
+        return new NodeTypeIteratorAdapter(Collections.singleton(new NodeTypeImpl()));
+    }
+
+    public NodeType getNodeType(String nodeTypeName)
+            throws NoSuchNodeTypeException, RepositoryException {
+        if (nodeTypeName.equals("nt:unstructured")) {
+            return new NodeTypeImpl();
+        } else {
+            throw new NoSuchNodeTypeException(nodeTypeName);
+        }
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/PropertyDefinitionImpl.java?rev=657756&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/PropertyDefinitionImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/nodetype/PropertyDefinitionImpl.java Mon May 19 01:43:27 2008
@@ -0,0 +1,67 @@
+/*
+ * 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.jackrabbit.ngp.nodetype;
+
+import javax.jcr.PropertyType;
+import javax.jcr.Value;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.version.OnParentVersionAction;
+
+public class PropertyDefinitionImpl implements PropertyDefinition {
+
+    public Value[] getDefaultValues() {
+        return null;
+    }
+
+    public int getRequiredType() {
+        return PropertyType.STRING;
+    }
+
+    public String[] getValueConstraints() {
+        return null;
+    }
+
+    public boolean isMultiple() {
+        return false;
+    }
+
+    public NodeType getDeclaringNodeType() {
+        return null;
+    }
+
+    public String getName() {
+        return "*";
+    }
+
+    public int getOnParentVersion() {
+        return OnParentVersionAction.COPY;
+    }
+
+    public boolean isAutoCreated() {
+        return false;
+    }
+
+    public boolean isMandatory() {
+        return false;
+    }
+
+    public boolean isProtected() {
+        return false;
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/state/NodeState.java?rev=657756&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/state/NodeState.java (added)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/state/NodeState.java Mon May 19 01:43:27 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.jackrabbit.ngp.state;
+
+import java.util.Map;
+
+
+public interface NodeState {
+
+    boolean isTransient();
+
+    boolean isModified();
+
+    boolean isModified(String property);
+
+    boolean isNew();
+
+    boolean isNew(String property);
+
+    PersistentNodeState persist();
+
+    NodeState refresh(PersistentNodeState state);
+
+    Map<String, String> getProperties();
+
+    Map<String, NodeState> getNodes();
+
+}

Added: jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/state/PersistentNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/state/PersistentNodeState.java?rev=657756&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/state/PersistentNodeState.java (added)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/state/PersistentNodeState.java Mon May 19 01:43:27 2008
@@ -0,0 +1,92 @@
+/*
+ * 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.jackrabbit.ngp.state;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class PersistentNodeState implements NodeState {
+
+    public static final PersistentNodeState ROOT = new PersistentNodeState(
+            Collections.singletonMap("jcr:primaryType", "nt:unstructured"),
+            new HashMap<String, NodeState>());
+
+    public static final PersistentNodeState NEW = new PersistentNodeState(
+            new HashMap<String, String>(), new HashMap<String, NodeState>());
+
+    public static final PersistentNodeState DEL = new PersistentNodeState(
+            new HashMap<String, String>(), new HashMap<String, NodeState>());
+
+    private final Map<String, String> properties;
+
+    private final Map<String, NodeState> nodes;
+
+    public PersistentNodeState(
+            Map<String, String> properties, Map<String, NodeState> nodes) {
+        assert properties != null;
+        assert nodes != null;
+        for (NodeState node : nodes.values()) {
+            assert !node.isTransient();
+        }
+
+        this.properties = Collections.unmodifiableMap(
+                new HashMap<String, String>(properties));
+        this.nodes = Collections.unmodifiableMap(
+                new HashMap<String, NodeState>(nodes));
+    }
+
+    //---------------------------------------------------------< NodeState >--
+
+    public boolean isTransient() {
+        return false;
+    }
+
+    public boolean isModified() {
+        return false;
+    }
+
+    public boolean isModified(String property) {
+        return false;
+    }
+
+    public boolean isNew() {
+        return false;
+    }
+
+    public boolean isNew(String property) {
+        return false;
+    }
+
+    public PersistentNodeState persist() {
+        return this;
+    }
+
+    public NodeState refresh(PersistentNodeState state) {
+        return state;
+    }
+
+    public Map<String, String> getProperties() {
+        return properties;
+    }
+
+    public Map<String, NodeState> getNodes() {
+        return nodes;
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/state/TransientNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/state/TransientNodeState.java?rev=657756&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/state/TransientNodeState.java (added)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/state/TransientNodeState.java Mon May 19 01:43:27 2008
@@ -0,0 +1,142 @@
+/*
+ * 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.jackrabbit.ngp.state;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class TransientNodeState implements NodeState {
+
+    private final PersistentNodeState base;
+
+    private final Map<String, String> properties =
+        new HashMap<String, String>();
+
+    private final Map<String, NodeState> nodes =
+        new HashMap<String, NodeState>();
+
+    public TransientNodeState(PersistentNodeState base) {
+        assert base != null;
+        this.base = base;
+    }
+
+    //---------------------------------------------------------< NodeState >--
+
+    public boolean isTransient() {
+        return true;
+    }
+
+    public boolean isModified() {
+        // TODO: Is this just a transient parent entry?
+        return !properties.isEmpty() || !nodes.isEmpty();
+    }
+
+    public boolean isModified(String property) {
+        return properties.containsKey(property);
+    }
+
+    public boolean isNew() {
+        return base == PersistentNodeState.NEW;
+    }
+
+    public boolean isNew(String property) {
+        return properties.containsKey(property)
+            && !base.getProperties().containsKey(property);
+    }
+
+    public PersistentNodeState persist() {
+        Map<String, NodeState> result = base.getNodes();
+        if (!nodes.isEmpty()) {
+            result = new HashMap<String, NodeState>(result);
+            for (Map.Entry<String, NodeState> entry : nodes.entrySet()) {
+                if (entry.getValue() != null) {
+                    result.put(entry.getKey(), entry.getValue().persist());
+                } else {
+                    result.remove(entry.getKey());
+                }
+            }
+        }
+        return new PersistentNodeState(getProperties(), result);
+    }
+
+    public NodeState refresh(PersistentNodeState state) {
+        if (!state.equals(base)) {
+            for (Map.Entry<String, NodeState> entry : getNodes().entrySet()) {
+                NodeState child = state.getNodes().get(entry.getKey());
+                if (child == null) {
+                    
+                }
+              
+            }
+        }
+        return this;
+    }
+
+    public Map<String, String> getProperties() {
+        Map<String, String> result = base.getProperties();
+        if (!properties.isEmpty()) {
+            result = new HashMap<String, String>(result);
+            for (Map.Entry<String, String> entry : properties.entrySet()) {
+                if (entry.getValue() != null) {
+                    result.put(entry.getKey(), entry.getValue());
+                } else {
+                    result.remove(entry.getKey());
+                }
+            }
+        }
+        return result;
+    }
+
+    public Map<String, NodeState> getNodes() {
+        Map<String, NodeState> result = base.getNodes();
+        if (!nodes.isEmpty()) {
+            result = new HashMap<String, NodeState>(result);
+            for (Map.Entry<String, NodeState> entry : nodes.entrySet()) {
+                if (entry.getValue() != null) {
+                    result.put(entry.getKey(), entry.getValue());
+                } else {
+                    result.remove(entry.getKey());
+                }
+            }
+        }
+        return result;
+    }
+
+    //------------------------------------------------< TransientNodeState >--
+
+    public PersistentNodeState getBase() {
+        return base;
+    }
+
+    public void setProperty(String name, String value) {
+        if (value != null || base.getProperties().containsKey(name)) {
+            properties.put(name, value);
+        } else {
+            properties.remove(value);
+        }
+    }
+
+    public void setNode(String name, NodeState value) {
+        if (value != null || base.getNodes().containsKey(name)) {
+            nodes.put(name, value);
+        } else {
+            nodes.remove(value);
+        }
+    }
+
+}

Modified: jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/AbstractRepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/AbstractRepositoryTest.java?rev=657756&r1=657755&r2=657756&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/AbstractRepositoryTest.java (original)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/AbstractRepositoryTest.java Mon May 19 01:43:27 2008
@@ -16,8 +16,6 @@
  */
 package org.apache.jackrabbit.ngp;
 
-import java.io.File;
-
 import javax.jcr.Repository;
 
 import org.junit.After;
@@ -25,32 +23,15 @@
 
 public class AbstractRepositoryTest {
 
-    private File directory;
-
     protected Repository repository;
 
     @Before
     public void setUp() throws Exception {
-        directory = File.createTempFile("jackrabbit-ngp", "test");
-        directory.delete();
-        directory.mkdir();
-
-        repository = new RepositoryImpl(directory);
+        repository = new RepositoryImpl();
     }
 
     @After
     public void tearDown() {
-        delete(directory);
-    }
-
-    private void delete(File file) {
-        File[] children = file.listFiles();
-        if (children != null) {
-            for (File child : children) {
-                delete(child);
-            }
-        }
-        file.delete();
     }
 
 }

Added: jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/JCRAPITest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/JCRAPITest.java?rev=657756&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/JCRAPITest.java (added)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/JCRAPITest.java Mon May 19 01:43:27 2008
@@ -0,0 +1,32 @@
+/*
+ * 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.jackrabbit.ngp;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import org.apache.jackrabbit.test.JCRTestSuite;
+
+/**
+ * Test suite that includes all test suites from jackrabbit-jcr-tests.
+ */
+public class JCRAPITest extends TestCase {
+
+    public static Test suite() {
+        return new JCRTestSuite();
+    }
+
+}

Modified: jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/NodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/NodeTest.java?rev=657756&r1=657755&r2=657756&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/NodeTest.java (original)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/NodeTest.java Mon May 19 01:43:27 2008
@@ -67,6 +67,8 @@
             fail("Root node has a parent");
         } catch (ItemNotFoundException expected) {
         }
+
+        assertEquals(1, root.getNodes().getSize());
     }
 
 }

Added: jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/RepositoryStubImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/RepositoryStubImpl.java?rev=657756&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/RepositoryStubImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/RepositoryStubImpl.java Mon May 19 01:43:27 2008
@@ -0,0 +1,193 @@
+/*
+ * 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.jackrabbit.ngp;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Calendar;
+import java.util.Properties;
+
+import javax.jcr.LoginException;
+import javax.jcr.Node;
+import javax.jcr.PropertyType;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.test.RepositoryStub;
+import org.apache.jackrabbit.test.RepositoryStubException;
+
+public class RepositoryStubImpl extends RepositoryStub {
+
+    private final Repository repository = new RepositoryImpl();
+
+    public RepositoryStubImpl(Properties env) throws RepositoryException {
+        super(env);
+
+        Session session = repository.login();
+        try {
+            Node data = session.getRootNode().addNode("testdata");
+            addPropertyTestData(data.addNode("property"));
+            addQueryTestData(data.addNode("query"));
+            addNodeTestData(data.addNode("node"));
+            addExportTestData(data.addNode("docViewTest"));
+            session.save();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            session.logout();
+        }
+    }
+
+    /**
+     * Creates a test node at {@link #TEST_DATA_PATH} with a boolean,
+     * double, long, calendar and a path property.
+     */
+    private void addPropertyTestData(Node node) throws RepositoryException {
+        node.setProperty("boolean", true);
+        node.setProperty("double", Math.PI);
+        node.setProperty("long", 90834953485278298l);
+        Calendar c = Calendar.getInstance();
+        c.set(2005, 6, 18, 17, 30);
+        node.setProperty("calendar", c);
+        ValueFactory factory = node.getSession().getValueFactory();
+        node.setProperty("path", factory.createValue("/", PropertyType.PATH));
+        // TODO: node.setProperty("multi", new String[] { "one", "two", "three" });
+    }
+
+    /**
+     * Creates four nodes under the given node. Each node has a String
+     * property named "prop1" with some content set.
+     */
+    private void addQueryTestData(Node node) throws RepositoryException {
+        Node node1 = node.addNode("node1");
+        node1.setProperty(
+                "prop1", "You can have it good, cheap, or fast. Any two.");
+        node1.setProperty("prop1", "foo bar");
+        node1.setProperty("prop1", "Hello world!");
+
+        node.addNode("node2").setProperty("prop1", "Apache Jackrabbit");
+    }
+
+
+    /**
+     * Creates three nodes under the given node: one of type nt:resource
+     * and the other nodes referencing it.
+     */
+    private void addNodeTestData(Node node) throws RepositoryException, IOException {
+        Node resource = node.addNode("myResource", "nt:resource");
+        resource.setProperty("jcr:encoding", "UTF-8");
+        resource.setProperty("jcr:mimeType", "text/plain");
+        resource.setProperty(
+                "jcr:data",
+                new ByteArrayInputStream("Hello w\u00F6rld.".getBytes("UTF-8")));
+        resource.setProperty("jcr:lastModified", Calendar.getInstance());
+
+        Node resReference = node.addNode("reference");
+        // TODO: resReference.setProperty("ref", resource);
+        // make this node itself referenceable
+        // TODO: resReference.addMixin("mix:referenceable");
+
+        Node multiReference = node.addNode("multiReference");
+        ValueFactory factory = node.getSession().getValueFactory();
+        // TODO: multiReference.setProperty("ref", new Value[] {
+        //        factory.createValue(resource),
+        //        factory.createValue(resReference)
+        // });
+    }
+
+    private void addExportTestData(Node node) throws RepositoryException, IOException {
+        node.addNode("invalidXmlName").setProperty("propName", "some text");
+
+        // three nodes which should be serialized as xml text in docView export
+        // separated with spaces
+        /* TODO:
+        node.addNode("jcr:xmltext").setProperty(
+                "jcr:xmlcharacters", "A text without any special character.");
+        node.addNode("some-element");
+        node.addNode("jcr:xmltext").setProperty(
+                "jcr:xmlcharacters",
+                " The entity reference characters: <, ', ,&, >,  \" should"
+                + " be escaped in xml export. ");
+        node.addNode("some-element");
+        node.addNode("jcr:xmltext").setProperty(
+                "jcr:xmlcharacters", "A text without any special character.");
+        */
+
+        Node big = node.addNode("bigNode");
+        // TODO: big.setProperty(
+        //         "propName0",
+        //         "SGVsbG8gd8O2cmxkLg==;SGVsbG8gd8O2cmxkLg==".split(";"),
+        //         PropertyType.BINARY);
+        big.setProperty("propName1", "text 1");
+        // TODO: big.setProperty(
+        //         "propName2",
+        //         "multival text 1;multival text 2;multival text 3".split(";"));
+        big.setProperty("propName3", "text 1");
+
+        addExportValues(node, "propName");
+        addExportValues(node, "Prop<>prop");
+    }
+
+    /**
+     * create nodes with following properties
+     * binary & single
+     * binary & multival
+     * notbinary & single
+     * notbinary & multival
+     */
+    private void addExportValues(Node node, String name)
+            throws RepositoryException, IOException {
+        String prefix = "valid";
+        if (name.indexOf('<') != -1) {
+            prefix = "invalid";
+        }
+        node = node.addNode(prefix + "Names");
+
+        /* TODO:
+        String[] texts = new String[] {
+                "multival text 1", "multival text 2", "multival text 3" };
+        node.addNode(prefix + "MultiNoBin").setProperty(name, texts);
+        */
+
+        /* TODO:
+        Node resource = node.addNode(prefix + "MultiBin");
+        resource.setProperty("jcr:encoding", "UTF-8");
+        resource.setProperty("jcr:mimeType", "text/plain");
+        String[] values =
+            new String[] { "SGVsbG8gd8O2cmxkLg==", "SGVsbG8gd8O2cmxkLg==" };
+        resource.setProperty(name, values, PropertyType.BINARY);
+        resource.setProperty("jcr:lastModified", Calendar.getInstance());
+        */
+
+        node.addNode(prefix + "NoBin").setProperty(name,  "text 1");
+
+        Node resource = node.addNode("invalidBin");
+        resource.setProperty("jcr:encoding", "UTF-8");
+        resource.setProperty("jcr:mimeType", "text/plain");
+        byte[] bytes = "Hello w\u00F6rld.".getBytes("UTF-8");
+        resource.setProperty(name, new ByteArrayInputStream(bytes));
+        resource.setProperty("jcr:lastModified", Calendar.getInstance());
+    }
+
+    public Repository getRepository() throws RepositoryStubException {
+        return repository;
+    }
+
+}

Modified: jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/RepositoryTest.java?rev=657756&r1=657755&r2=657756&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/RepositoryTest.java (original)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/RepositoryTest.java Mon May 19 01:43:27 2008
@@ -1,4 +1,4 @@
-/**
+/*
  * 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.

Modified: jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/SessionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/SessionTest.java?rev=657756&r1=657755&r2=657756&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/SessionTest.java (original)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/test/java/org/apache/jackrabbit/ngp/SessionTest.java Mon May 19 01:43:27 2008
@@ -67,6 +67,8 @@
             fail("Root node has a parent");
         } catch (ItemNotFoundException expected) {
         }
+
+        assertEquals(0, root.getNodes().getSize());
     }
 
 }



Mime
View raw message