jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1298011 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk: ./ model/ store/ store/pm/
Date Wed, 07 Mar 2012 16:30:47 GMT
Author: stefan
Date: Wed Mar  7 16:30:46 2012
New Revision: 1298011

URL: http://svn.apache.org/viewvc?rev=1298011&view=rev
Log:
refactor String id's in Id instances

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/Id.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/Repository.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/AbstractCommit.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesMap.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesTree.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntry.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/Commit.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/MutableCommit.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/NodeDelta.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/NodeDiffHandler.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/NodeProxy.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/StoredCommit.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/StoredNode.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/TraversingNodeDiffHandler.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/CopyingGC.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/DefaultRevisionStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/RevisionProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/RevisionStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/BDbPersistenceManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/FSPersistenceManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/H2PersistenceManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/InMemPersistenceManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/MongoPersistenceManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/PersistenceManager.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java Wed Mar  7 16:30:46 2012
@@ -23,6 +23,7 @@ import org.apache.jackrabbit.mk.json.Jso
 import org.apache.jackrabbit.mk.model.ChildNodeEntry;
 import org.apache.jackrabbit.mk.model.Commit;
 import org.apache.jackrabbit.mk.model.CommitBuilder;
+import org.apache.jackrabbit.mk.model.Id;
 import org.apache.jackrabbit.mk.model.StoredCommit;
 import org.apache.jackrabbit.mk.model.StoredNode;
 import org.apache.jackrabbit.mk.model.TraversingNodeDiffHandler;
@@ -209,8 +210,8 @@ public class MicroKernelImpl implements 
             // maps (key: id of target node, value: path/to/target)
             // for tracking added/removed nodes; this allows us
             // to detect 'move' operations
-            final HashMap<String, String> addedNodes = new HashMap<String, String>();
-            final HashMap<String, String> removedNodes = new HashMap<String, String>();
+            final HashMap<Id, String> addedNodes = new HashMap<Id, String>();
+            final HashMap<Id, String> removedNodes = new HashMap<Id, String>();
             StoredNode node1, node2;
             try {
                 node1 = rep.getNode(fromRevisionId, path);
@@ -361,7 +362,7 @@ public class MicroKernelImpl implements 
                 diffHandler.start(node1, node2, path);
 
                 // finally process moved nodes
-                for (Map.Entry<String, String> entry : addedNodes.entrySet()) {
+                for (Map.Entry<Id, String> entry : addedNodes.entrySet()) {
                     buff.tag('>').
                             // path/to/deleted/node
                             key(removedNodes.get(entry.getKey())).

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/Repository.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/Repository.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/Repository.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/Repository.java Wed Mar  7 16:30:46 2012
@@ -22,6 +22,7 @@ import java.io.File;
 import org.apache.jackrabbit.mk.model.ChildNodeEntry;
 import org.apache.jackrabbit.mk.model.Commit;
 import org.apache.jackrabbit.mk.model.CommitBuilder;
+import org.apache.jackrabbit.mk.model.Id;
 import org.apache.jackrabbit.mk.model.Node;
 import org.apache.jackrabbit.mk.model.StoredCommit;
 import org.apache.jackrabbit.mk.model.StoredNode;
@@ -134,7 +135,7 @@ public class Repository {
         }
 
         //return root.getNode(path.substring(1), pm);
-        String[] ids = resolvePath(revId, path);
+        Id[] ids = resolvePath(revId, path);
         return rs.getNode(ids[ids.length - 1]);
     }
 
@@ -177,7 +178,7 @@ public class Repository {
      * @throws NotFoundException if either path or revision doesn't exist
      * @throws Exception if another error occurs
      */
-    String[] /* array of node id's */ resolvePath(String revId, String nodePath) throws Exception {
+    Id[] /* array of node id's */ resolvePath(String revId, String nodePath) throws Exception {
         if (!PathUtils.isAbsolute(nodePath)) {
             throw new IllegalArgumentException("illegal path");
         }
@@ -185,10 +186,10 @@ public class Repository {
         Commit commit = rs.getCommit(revId);
 
         if (PathUtils.denotesRoot(nodePath)) {
-            return new String[]{commit.getRootNodeId()};
+            return new Id[]{commit.getRootNodeId()};
         }
         String[] names = PathUtils.split(nodePath);
-        String[] ids = new String[names.length + 1];
+        Id[] ids = new Id[names.length + 1];
 
         // get root node
         ids[0] = commit.getRootNodeId();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/AbstractCommit.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/AbstractCommit.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/AbstractCommit.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/AbstractCommit.java Wed Mar  7 16:30:46 2012
@@ -24,7 +24,7 @@ import org.apache.jackrabbit.mk.store.Bi
 public abstract class AbstractCommit implements Commit {
 
     // id of root node associated with this commit
-    protected String rootNodeId;
+    protected Id rootNodeId;
 
     // commit timestamp
     protected long commitTS;
@@ -49,7 +49,7 @@ public abstract class AbstractCommit imp
         return parentId;
     }
 
-    public String getRootNodeId() {
+    public Id getRootNodeId() {
         return rootNodeId;
     }
 
@@ -62,7 +62,7 @@ public abstract class AbstractCommit imp
     }
 
     public void serialize(Binding binding) throws Exception {
-        binding.write("rootNodeId", rootNodeId);
+        binding.write("rootNodeId", rootNodeId.getBytes());
         binding.write("commitTS", commitTS);
         binding.write("msg", msg == null ? "" : msg);
         binding.write("parentId", parentId == null ? "" : parentId);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesMap.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesMap.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesMap.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesMap.java Wed Mar  7 16:30:46 2012
@@ -20,7 +20,6 @@ import org.apache.jackrabbit.mk.store.Bi
 import org.apache.jackrabbit.mk.util.AbstractFilteringIterator;
 import org.apache.jackrabbit.mk.util.EmptyIterator;
 import org.apache.jackrabbit.mk.util.RangeIterator;
-import org.apache.jackrabbit.mk.util.StringUtils;
 
 import java.util.HashMap;
 import java.util.Iterator;
@@ -230,7 +229,7 @@ public class ChildNodeEntriesMap impleme
                     @Override
                     public Binding.BytesEntry next() {
                         ChildNodeEntry cne = iter.next();
-                        return new Binding.BytesEntry(cne.getName(), StringUtils.convertHexToBytes(cne.getId()));
+                        return new Binding.BytesEntry(cne.getName(), cne.getId().getBytes());
                     }
                     @Override
                     public void remove() {
@@ -245,7 +244,7 @@ public class ChildNodeEntriesMap impleme
         Binding.BytesEntryIterator iter = binding.readBytesMap(":children");
         while (iter.hasNext()) {
             Binding.BytesEntry entry = iter.next();
-            newInstance.add(new ChildNodeEntry(entry.getKey(), StringUtils.convertBytesToHex(entry.getValue())));
+            newInstance.add(new ChildNodeEntry(entry.getKey(), new Id(entry.getValue())));
         }
         return newInstance;
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesTree.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesTree.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesTree.java Wed Mar  7 16:30:46 2012
@@ -515,7 +515,7 @@ public class ChildNodeEntriesTree implem
             if (index[i] instanceof Bucket) {
                 // dirty bucket
                 Bucket bucket = (Bucket) index[i];
-                String id = store.putCNEMap(bucket);
+                Id id = store.putCNEMap(bucket);
                 index[i] = new BucketInfo(id, bucket.getSize());
             }
         }
@@ -527,7 +527,7 @@ public class ChildNodeEntriesTree implem
         return (hash & 0x7FFFFFFF) % index.length;
     }
 
-    protected ChildNodeEntriesMap retrieveBucket(String id) {
+    protected ChildNodeEntriesMap retrieveBucket(Id id) {
         try {
             return revProvider.getCNEMap(id);
         } catch (Exception e) {
@@ -539,6 +539,7 @@ public class ChildNodeEntriesTree implem
     //------------------------------------------------< serialization support >
 
     public void serialize(Binding binding) throws Exception {
+        // TODO use binary instead of string serialization
         binding.write(":count", count);
         binding.writeMap(":index", index.length, new Binding.StringEntryIterator() {
             int pos = -1;
@@ -578,6 +579,7 @@ public class ChildNodeEntriesTree implem
     }
 
     static ChildNodeEntriesTree deserialize(RevisionProvider provider, Binding binding) throws Exception {
+        // TODO use binary instead of string serialization
         ChildNodeEntriesTree newInstance = new ChildNodeEntriesTree(provider);
         newInstance.count = binding.readIntValue(":count");
         Binding.StringEntryIterator iter = binding.readStringMap(":index");
@@ -596,14 +598,14 @@ public class ChildNodeEntriesTree implem
                 int i = value.indexOf(':');
                 String id = value.substring(0, i);
                 String name = value.substring(i + 1);
-                newInstance.index[pos] = new NodeInfo(name, id);
+                newInstance.index[pos] = new NodeInfo(name, Id.fromString(id));
             } else {
                 // "b<id>:<count>"
                 String value = entry.getValue().substring(1);
                 int i = value.indexOf(':');
                 String id = value.substring(0, i);
                 int count = Integer.parseInt(value.substring(i + 1));
-                newInstance.index[pos] = new BucketInfo(id, count);
+                newInstance.index[pos] = new BucketInfo(Id.fromString(id), count);
             }
         }
         return newInstance;
@@ -619,17 +621,17 @@ public class ChildNodeEntriesTree implem
     protected static class BucketInfo implements IndexEntry {
 
         // bucket id
-        private final String id;
+        private final Id id;
 
         // number of bucket entries
         private final int size;
 
-        protected BucketInfo(String id, int size) {
+        protected BucketInfo(Id id, int size) {
             this.id = id;
             this.size = size;
         }
 
-        public String getId() {
+        public Id getId() {
             return id;
         }
 
@@ -679,7 +681,7 @@ public class ChildNodeEntriesTree implem
 
     protected static class NodeInfo extends ChildNodeEntry implements IndexEntry {
 
-        public NodeInfo(String name, String id) {
+        public NodeInfo(String name, Id id) {
             super(name, id);
         }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntry.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntry.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntry.java Wed Mar  7 16:30:46 2012
@@ -22,9 +22,9 @@ package org.apache.jackrabbit.mk.model;
 public class ChildNodeEntry {
 
     private final String name;
-    private final String id;
+    private final Id id;
 
-    public ChildNodeEntry(String name, String id) {
+    public ChildNodeEntry(String name, Id id) {
         this.name = name;
         this.id = id;
     }
@@ -33,7 +33,7 @@ public class ChildNodeEntry {
         return name;
     }
 
-    public String getId() {
+    public Id getId() {
         return id;
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/Commit.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/Commit.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/Commit.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/Commit.java Wed Mar  7 16:30:46 2012
@@ -23,7 +23,7 @@ import org.apache.jackrabbit.mk.store.Bi
  */
 public interface Commit {
     
-    String getRootNodeId();
+    Id getRootNodeId();
 
     public String getParentId();
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java Wed Mar  7 16:30:46 2012
@@ -64,7 +64,7 @@ public class CommitBuilder {
         newChild.getProperties().putAll(properties);
 
         // id will be computed on commit
-        modParent.add(new ChildNodeEntry(nodeName, ""));
+        modParent.add(new ChildNodeEntry(nodeName, null));
         String newPath = PathUtils.concat(parentNodePath, nodeName);
         staged.put(newPath, newChild);
         // update change log
@@ -191,7 +191,7 @@ public class CommitBuilder {
             }
         }
 
-        String rootNodeId = persistStagedNodes();
+        Id rootNodeId = persistStagedNodes();
 
         String newRevId;
         store.lockHead();
@@ -283,7 +283,7 @@ public class CommitBuilder {
         }
     }
 
-    String /* new id of root node */ persistStagedNodes() throws Exception {
+    Id /* new id of root node */ persistStagedNodes() throws Exception {
         // sort paths in in depth-descending order
         ArrayList<String> orderedPaths = new ArrayList<String>(staged.keySet());
         Collections.sort(orderedPaths, new Comparator<String>() {
@@ -298,10 +298,10 @@ public class CommitBuilder {
             }
         });
         // iterate over staged entries in depth-descending order
-        String rootNodeId = null;
+        Id rootNodeId = null;
         for (String path : orderedPaths) {
             // persist node
-            String id = store.putNode(staged.get(path));
+            Id id = store.putNode(staged.get(path));
             if (PathUtils.denotesRoot(path)) {
                 rootNodeId = id;
             } else {
@@ -324,7 +324,7 @@ public class CommitBuilder {
      * @return id of merged root node
      * @throws Exception
      */
-    String /* id of merged root node */ mergeTree(StoredNode baseRoot, StoredNode ourRoot, StoredNode theirRoot) throws Exception {
+    Id /* id of merged root node */ mergeTree(StoredNode baseRoot, StoredNode ourRoot, StoredNode theirRoot) throws Exception {
         // as we're going to use the staging area for the merge process,
         // we need to clear it first
         staged.clear();
@@ -349,10 +349,10 @@ public class CommitBuilder {
             mergedNode.getProperties().remove(name);
         }
 
-        for (Map.Entry<String, String> entry : ourChanges.getAddedChildNodes ().entrySet()) {
+        for (Map.Entry<String, Id> entry : ourChanges.getAddedChildNodes ().entrySet()) {
             mergedNode.add(new ChildNodeEntry(entry.getKey(), entry.getValue()));
         }
-        for (Map.Entry<String, String> entry : ourChanges.getChangedChildNodes ().entrySet()) {
+        for (Map.Entry<String, Id> entry : ourChanges.getChangedChildNodes ().entrySet()) {
             mergedNode.add(new ChildNodeEntry(entry.getKey(), entry.getValue()));
         }
         for (String name : ourChanges.getRemovedChildNodes().keySet()) {

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/Id.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/Id.java?rev=1298011&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/Id.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/Id.java Wed Mar  7 16:30:46 2012
@@ -0,0 +1,73 @@
+/*
+ * 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.mk.model;
+
+import org.apache.jackrabbit.mk.util.StringUtils;
+
+import java.util.Arrays;
+
+/**
+ *
+ */
+public class Id {
+
+    private final byte[] raw;
+
+    public Id(byte[] raw) {
+        this.raw = raw;
+    }
+
+    /**
+     * Creates an <code>Id</code> instance from its
+     * string representation as returned by {@link #toString()}.
+     * <p/>
+     * The following condition holds true:
+     * <pre>
+     * Id someId = ...;
+     * assert(Id.fromString(someId.toString()).equals(someId));
+     * </pre>
+     *
+     * @param s a string representation of an <code>Id</code>
+     * @return an <code>Id</code> instance
+     */
+    public static Id fromString(String s) {
+        return new Id(StringUtils.convertHexToBytes(s));
+    }
+
+    @Override
+    public int hashCode() {
+        return Arrays.hashCode(raw);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj instanceof Id) {
+            Id other = (Id) obj;
+            return Arrays.equals(raw, other.raw);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return StringUtils.convertBytesToHex(raw);
+    }
+
+    public byte[] getBytes() {
+        return raw;
+    }
+}

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/MutableCommit.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/MutableCommit.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/MutableCommit.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/MutableCommit.java Wed Mar  7 16:30:46 2012
@@ -46,7 +46,7 @@ public class MutableCommit extends Abstr
         this.parentId = parentId;
     }
 
-    public void setRootNodeId(String rootNodeId) {
+    public void setRootNodeId(Id rootNodeId) {
         this.rootNodeId = rootNodeId;
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/NodeDelta.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/NodeDelta.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/NodeDelta.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/NodeDelta.java Wed Mar  7 16:30:46 2012
@@ -54,9 +54,9 @@ public class NodeDelta implements NodeDi
     Map<String, String> removedProperties = new HashMap<String, String>();
     Map<String, String> changedProperties = new HashMap<String, String>();
 
-    Map<String, String> addedChildNodes = new HashMap<String, String>();
-    Map<String, String> removedChildNodes = new HashMap<String, String>();
-    Map<String, String> changedChildNodes = new HashMap<String, String>();
+    Map<String, Id> addedChildNodes = new HashMap<String, Id>();
+    Map<String, Id> removedChildNodes = new HashMap<String, Id>();
+    Map<String, Id> changedChildNodes = new HashMap<String, Id>();
 
     public NodeDelta(StoredNode node1, StoredNode node2) throws Exception {
         this.node1 = node1;
@@ -77,15 +77,15 @@ public class NodeDelta implements NodeDi
         return changedProperties;
     }
 
-    public Map<String, String> getAddedChildNodes() {
+    public Map<String, Id> getAddedChildNodes() {
         return addedChildNodes;
     }
 
-    public Map<String, String> getRemovedChildNodes() {
+    public Map<String, Id> getRemovedChildNodes() {
         return removedChildNodes;
     }
 
-    public Map<String, String> getChangedChildNodes() {
+    public Map<String, Id> getChangedChildNodes() {
         return changedChildNodes;
     }
 
@@ -103,31 +103,31 @@ public class NodeDelta implements NodeDi
 
         // properties
 
-        Map<String, String> otherAdded = other.getAddedProperties();
+        Map<String, String> otherAddedProps = other.getAddedProperties();
         for (Map.Entry<String, String> added : addedProperties.entrySet()) {
-            String otherValue = otherAdded.get(added.getKey());
+            String otherValue = otherAddedProps.get(added.getKey());
             if (otherValue != null && !added.getValue().equals(otherValue)) {
                 // same property added with conflicting values
                 conflicts.add(new Conflict(ConflictType.PROPERTY_VALUE_CONFLICT, added.getKey()));
             }
         }
 
-        Map<String, String> otherChanged = other.getChangedProperties();
-        Map<String, String> otherRemoved = other.getRemovedProperties();
+        Map<String, String> otherChangedProps = other.getChangedProperties();
+        Map<String, String> otherRemovedProps = other.getRemovedProperties();
         for (Map.Entry<String, String> changed : changedProperties.entrySet()) {
-            String otherValue = otherChanged.get(changed.getKey());
+            String otherValue = otherChangedProps.get(changed.getKey());
             if (otherValue != null && !changed.getValue().equals(otherValue)) {
                 // same property changed with conflicting values
                 conflicts.add(new Conflict(ConflictType.PROPERTY_VALUE_CONFLICT, changed.getKey()));
             }
-            if (otherRemoved.containsKey(changed.getKey())) {
+            if (otherRemovedProps.containsKey(changed.getKey())) {
                 // changed property has been removed
                 conflicts.add(new Conflict(ConflictType.REMOVED_DIRTY_PROPERTY_CONFLICT, changed.getKey()));
             }
         }
 
         for (Map.Entry<String, String> removed : removedProperties.entrySet()) {
-            if (otherChanged.containsKey(removed.getKey())) {
+            if (otherChangedProps.containsKey(removed.getKey())) {
                 // removed property has been changed
                 conflicts.add(new Conflict(ConflictType.REMOVED_DIRTY_PROPERTY_CONFLICT, removed.getKey()));
             }
@@ -135,31 +135,31 @@ public class NodeDelta implements NodeDi
 
         // child node entries
 
-        otherAdded = other.getAddedChildNodes();
-        for (Map.Entry<String, String> added : addedChildNodes.entrySet()) {
-            String otherValue = otherAdded.get(added.getKey());
+        Map<String, Id> otherAddedChildNodes = other.getAddedChildNodes();
+        for (Map.Entry<String, Id> added : addedChildNodes.entrySet()) {
+            Id otherValue = otherAddedChildNodes.get(added.getKey());
             if (otherValue != null && !added.getValue().equals(otherValue)) {
                 // same child node entry added with different target id's
                 conflicts.add(new Conflict(ConflictType.NODE_CONTENT_CONFLICT, added.getKey()));
             }
         }
 
-        otherChanged = other.getChangedChildNodes();
-        otherRemoved = other.getRemovedChildNodes();
-        for (Map.Entry<String, String> changed : changedChildNodes.entrySet()) {
-            String otherValue = otherChanged.get(changed.getKey());
+        Map<String, Id> otherChangedChildNodes = other.getChangedChildNodes();
+        Map<String, Id> otherRemovedChildNodes = other.getRemovedChildNodes();
+        for (Map.Entry<String, Id> changed : changedChildNodes.entrySet()) {
+            Id otherValue = otherChangedChildNodes.get(changed.getKey());
             if (otherValue != null && !changed.getValue().equals(otherValue)) {
                 // same child node entry changed with different target id's
                 conflicts.add(new Conflict(ConflictType.NODE_CONTENT_CONFLICT, changed.getKey()));
             }
-            if (otherRemoved.containsKey(changed.getKey())) {
+            if (otherRemovedChildNodes.containsKey(changed.getKey())) {
                 // changed child node entry has been removed
                 conflicts.add(new Conflict(ConflictType.REMOVED_DIRTY_NODE_CONFLICT, changed.getKey()));
             }
         }
 
-        for (Map.Entry<String, String> removed : removedChildNodes.entrySet()) {
-            if (otherChanged.containsKey(removed.getKey())) {
+        for (Map.Entry<String, Id> removed : removedChildNodes.entrySet()) {
+            if (otherChangedChildNodes.containsKey(removed.getKey())) {
                 // removed child node entry has been changed
                 conflicts.add(new Conflict(ConflictType.REMOVED_DIRTY_NODE_CONFLICT, removed.getKey()));
             }
@@ -190,7 +190,7 @@ public class NodeDelta implements NodeDi
         removedChildNodes.put(deleted.getName(), deleted.getId());
     }
 
-    public void childNodeChanged(ChildNodeEntry changed, String newId) {
+    public void childNodeChanged(ChildNodeEntry changed, Id newId) {
         changedChildNodes.put(changed.getName(), newId);
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/NodeDiffHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/NodeDiffHandler.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/NodeDiffHandler.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/NodeDiffHandler.java Wed Mar  7 16:30:46 2012
@@ -31,5 +31,5 @@ public interface NodeDiffHandler {
 
     void childNodeDeleted(ChildNodeEntry deleted);
 
-    void childNodeChanged(ChildNodeEntry changed, String newId);
+    void childNodeChanged(ChildNodeEntry changed, Id newId);
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/NodeProxy.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/NodeProxy.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/NodeProxy.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/NodeProxy.java Wed Mar  7 16:30:46 2012
@@ -24,10 +24,10 @@ import org.apache.jackrabbit.mk.store.No
  */
 public final class NodeProxy {
 
-    private final String id;
+    private final Id id;
     private final Node node;
 
-    public NodeProxy(String id) {
+    public NodeProxy(Id id) {
         this.id = id;
         this.node = null;
     }
@@ -37,7 +37,7 @@ public final class NodeProxy {
         this.id = null;
     }
 
-    public String getId() {
+    public Id getId() {
         return id;
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/StoredCommit.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/StoredCommit.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/StoredCommit.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/StoredCommit.java Wed Mar  7 16:30:46 2012
@@ -26,14 +26,14 @@ public class StoredCommit extends Abstra
     private final String id;
 
     public static StoredCommit deserialize(String id, Binding binding) throws Exception {
-        String rootNodeId = binding.readStringValue("rootNodeId");
+        Id rootNodeId = new Id(binding.readBytesValue("rootNodeId"));
         long commitTS = binding.readLongValue("commitTS");
         String msg = binding.readStringValue("msg");
         String parentId = binding.readStringValue("parentId");
         return new StoredCommit(id, "".equals(parentId) ? null : parentId, commitTS, rootNodeId, "".equals(msg) ? null : msg);
     }
 
-    public StoredCommit(String id, String parentId, long commitTS, String rootNodeId, String msg) {
+    public StoredCommit(String id, String parentId, long commitTS, Id rootNodeId, String msg) {
         this.id = id;
         this.parentId = parentId;
         this.commitTS = commitTS;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/StoredNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/StoredNode.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/StoredNode.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/StoredNode.java Wed Mar  7 16:30:46 2012
@@ -30,9 +30,9 @@ import java.util.Map;
  */
 public class StoredNode extends AbstractNode {
 
-    private final String id;
+    private final Id id;
 
-    public static StoredNode deserialize(String id, RevisionProvider provider, Binding binding) throws Exception {
+    public static StoredNode deserialize(Id id, RevisionProvider provider, Binding binding) throws Exception {
         StoredNode newInstance = new StoredNode(id, provider);
         Binding.StringEntryIterator iter = binding.readStringMap(":props");
         while (iter.hasNext()) {
@@ -48,12 +48,12 @@ public class StoredNode extends Abstract
         return newInstance;
     }
 
-    private StoredNode(String id, RevisionProvider provider) {
+    private StoredNode(Id id, RevisionProvider provider) {
         super(provider);
         this.id = id;
     }
     
-    public StoredNode(String id, RevisionProvider provider, Map<String, String> properties, Iterator<ChildNodeEntry> cneIt) {
+    public StoredNode(Id id, RevisionProvider provider, Map<String, String> properties, Iterator<ChildNodeEntry> cneIt) {
         super(provider);
         this.id = id;
         this.properties.putAll(properties);
@@ -62,12 +62,12 @@ public class StoredNode extends Abstract
         }
     }
 
-    public StoredNode(String id, Node node, RevisionProvider provider) {
+    public StoredNode(Id id, Node node, RevisionProvider provider) {
         super(node, provider);
         this.id = id;
     }
 
-    public String getId() {
+    public Id getId() {
         return id;
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/TraversingNodeDiffHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/TraversingNodeDiffHandler.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/TraversingNodeDiffHandler.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/TraversingNodeDiffHandler.java Wed Mar  7 16:30:46 2012
@@ -71,7 +71,7 @@ public abstract class TraversingNodeDiff
     public void childNodeDeleted(ChildNodeEntry deleted) {
     }
 
-    public void childNodeChanged(ChildNodeEntry changed, String newId) {
+    public void childNodeChanged(ChildNodeEntry changed, Id newId) {
         paths.push(PathUtils.concat(getCurrentPath(), changed.getName()));
         try {
             store.getNode(changed.getId()).diff(store.getNode(newId), this);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/CopyingGC.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/CopyingGC.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/CopyingGC.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/CopyingGC.java Wed Mar  7 16:30:46 2012
@@ -22,6 +22,7 @@ import java.util.Iterator;
 
 import org.apache.jackrabbit.mk.model.ChildNode;
 import org.apache.jackrabbit.mk.model.ChildNodeEntriesMap;
+import org.apache.jackrabbit.mk.model.Id;
 import org.apache.jackrabbit.mk.model.MutableCommit;
 import org.apache.jackrabbit.mk.model.MutableNode;
 import org.apache.jackrabbit.mk.model.StoredCommit;
@@ -99,8 +100,7 @@ public class CopyingGC implements Revisi
     /**
      * Copy a commit and all the nodes belonging to it, starting at the root node.
      * 
-     * @param from source provider
-     * @param to target store
+     * @param commit commit to be copied
      * @throws Exception if an error occurs
      */
     public void copy(StoredCommit commit) throws Exception {
@@ -117,7 +117,6 @@ public class CopyingGC implements Revisi
     /**
      * Copy a node and all its descendants into a target store
      * @param node source node
-     * @param store target store
      * @throws Exception if an error occurs
      */
     private void copy(StoredNode node) throws Exception {
@@ -142,7 +141,7 @@ public class CopyingGC implements Revisi
         return new StoredNodeAsState(node, this);
     }
 
-    public StoredNode getNode(String id) throws NotFoundException, Exception {
+    public StoredNode getNode(Id id) throws NotFoundException, Exception {
         if (running) {
             try {
                 return rsTo.getNode(id);
@@ -172,7 +171,7 @@ public class CopyingGC implements Revisi
         return rsTo.getCommit(id);
     }
 
-    public ChildNodeEntriesMap getCNEMap(String id) throws NotFoundException,
+    public ChildNodeEntriesMap getCNEMap(Id id) throws NotFoundException,
             Exception {
         
         if (running) {
@@ -206,7 +205,7 @@ public class CopyingGC implements Revisi
         return running ? rsTo.getHeadCommitId() : rsFrom.getHeadCommitId();
     }
 
-    public String putNode(MutableNode node) throws Exception {
+    public Id putNode(MutableNode node) throws Exception {
         return running ? rsTo.putNode(node) : rsFrom.putNode(node);
     }
 
@@ -214,7 +213,7 @@ public class CopyingGC implements Revisi
         return running ? rsTo.putCommit(commit) : rsFrom.putCommit(commit);
     }
 
-    public String putCNEMap(ChildNodeEntriesMap map) throws Exception {
+    public Id putCNEMap(ChildNodeEntriesMap map) throws Exception {
         return running ? rsTo.putCNEMap(map) : rsFrom.putCNEMap(map);
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/DefaultRevisionStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/DefaultRevisionStore.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/DefaultRevisionStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/DefaultRevisionStore.java Wed Mar  7 16:30:46 2012
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.mk.store;
 import org.apache.jackrabbit.mk.blobs.BlobStore;
 import org.apache.jackrabbit.mk.blobs.FileBlobStore;
 import org.apache.jackrabbit.mk.model.ChildNodeEntriesMap;
+import org.apache.jackrabbit.mk.model.Id;
 import org.apache.jackrabbit.mk.model.MutableCommit;
 import org.apache.jackrabbit.mk.model.MutableNode;
 import org.apache.jackrabbit.mk.model.StoredCommit;
@@ -54,14 +55,14 @@ public class DefaultRevisionStore implem
     private BlobStore blobStore;
     private boolean blobStoreNeedsClose;
 
-    private Map<String, Object> cache;
+    private Map<Id, Object> cache;
 
     public void initialize(File homeDir) throws Exception {
         if (initialized) {
             throw new IllegalStateException("already initialized");
         }
 
-        cache = Collections.synchronizedMap(SimpleLRUCache.<String, Object>newInstance(determineInitialCacheSize()));
+        cache = Collections.synchronizedMap(SimpleLRUCache.<Id, Object>newInstance(determineInitialCacheSize()));
 
         pm = new H2PersistenceManager();
         //pm = new InMemPersistenceManager();
@@ -84,7 +85,7 @@ public class DefaultRevisionStore implem
             byte[] rawHeadId = longToBytes(++headCounter);
             headId = StringUtils.convertBytesToHex(rawHeadId);
             
-            String rootNodeId = pm.writeNode(new MutableNode(this));
+            Id rootNodeId = pm.writeNode(new MutableNode(this));
             MutableCommit initialCommit = new MutableCommit();
             initialCommit.setCommitTS(System.currentTimeMillis());
             initialCommit.setRootNodeId(rootNodeId);
@@ -158,7 +159,7 @@ public class DefaultRevisionStore implem
     
     //--------------------------------------------------------< RevisionStore >
 
-    public String putNode(MutableNode node) throws Exception {
+    public Id putNode(MutableNode node) throws Exception {
         verifyInitialized();
 
         PersistHook callback = null;
@@ -167,7 +168,7 @@ public class DefaultRevisionStore implem
             callback.prePersist(this);
         }
 
-        String id = pm.writeNode(node);
+        Id id = pm.writeNode(node);
         
         if (callback != null)  {
             callback.postPersist(this);
@@ -178,7 +179,7 @@ public class DefaultRevisionStore implem
         return id;
     }
 
-    public String putCNEMap(ChildNodeEntriesMap map) throws Exception {
+    public Id putCNEMap(ChildNodeEntriesMap map) throws Exception {
         verifyInitialized();
 
         PersistHook callback = null;
@@ -187,7 +188,7 @@ public class DefaultRevisionStore implem
             callback.prePersist(this);
         }
 
-       String id = pm.writeCNEMap(map);
+       Id id = pm.writeCNEMap(map);
 
         if (callback != null)  {
             callback.postPersist(this);
@@ -223,7 +224,8 @@ public class DefaultRevisionStore implem
             callback.postPersist(this);
         }
 
-        cache.put(id, new StoredCommit(id, commit));
+        // TODO fixme, String -> Id
+        cache.put(Id.fromString(id), new StoredCommit(id, commit));
 
         return id;
     }
@@ -260,7 +262,7 @@ public class DefaultRevisionStore implem
         return new StoredNodeAsState(node, this);
     }
 
-    public StoredNode getNode(String id) throws NotFoundException, Exception {
+    public StoredNode getNode(Id id) throws NotFoundException, Exception {
         verifyInitialized();
 
         StoredNode node = (StoredNode) cache.get(id);
@@ -276,7 +278,7 @@ public class DefaultRevisionStore implem
         return node;
     }
 
-    public ChildNodeEntriesMap getCNEMap(String id) throws NotFoundException, Exception {
+    public ChildNodeEntriesMap getCNEMap(Id id) throws NotFoundException, Exception {
         verifyInitialized();
 
         ChildNodeEntriesMap map = (ChildNodeEntriesMap) cache.get(id);
@@ -294,13 +296,14 @@ public class DefaultRevisionStore implem
     public StoredCommit getCommit(String id) throws NotFoundException, Exception {
         verifyInitialized();
 
-        StoredCommit commit = (StoredCommit) cache.get(id);
+        // TODO fixme, String -> Id
+        StoredCommit commit = (StoredCommit) cache.get(Id.fromString(id));
         if (commit != null) {
             return commit;
         }
 
         commit = pm.readCommit(id);
-        cache.put(id, commit);
+        cache.put(Id.fromString(id), commit);
 
         return commit;
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/RevisionProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/RevisionProvider.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/RevisionProvider.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/RevisionProvider.java Wed Mar  7 16:30:46 2012
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.mk.store;
 
 import org.apache.jackrabbit.mk.model.ChildNodeEntriesMap;
+import org.apache.jackrabbit.mk.model.Id;
 import org.apache.jackrabbit.mk.model.StoredCommit;
 import org.apache.jackrabbit.mk.model.StoredNode;
 import org.apache.jackrabbit.oak.model.NodeState;
@@ -35,9 +36,9 @@ public interface RevisionProvider {
      */
     NodeState getNodeState(StoredNode node);
 
-    StoredNode getNode(String id) throws NotFoundException, Exception;
+    StoredNode getNode(Id id) throws NotFoundException, Exception;
     StoredCommit getCommit(String id) throws NotFoundException, Exception;
-    ChildNodeEntriesMap getCNEMap(String id) throws NotFoundException, Exception;
+    ChildNodeEntriesMap getCNEMap(Id id) throws NotFoundException, Exception;
     StoredNode getRootNode(String commitId) throws NotFoundException, Exception;
     StoredCommit getHeadCommit() throws Exception;
     String getHeadCommitId() throws Exception;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/RevisionStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/RevisionStore.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/RevisionStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/RevisionStore.java Wed Mar  7 16:30:46 2012
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.mk.store;
 
 import org.apache.jackrabbit.mk.model.ChildNodeEntriesMap;
+import org.apache.jackrabbit.mk.model.Id;
 import org.apache.jackrabbit.mk.model.MutableCommit;
 import org.apache.jackrabbit.mk.model.MutableNode;
 
@@ -27,9 +28,9 @@ import java.io.InputStream;
  */
 public interface RevisionStore extends RevisionProvider {
 
-    String /*id*/ putNode(MutableNode node) throws Exception;
+    Id /*id*/ putNode(MutableNode node) throws Exception;
     String /*id*/ putCommit(MutableCommit commit) throws Exception;
-    String /*id*/ putCNEMap(ChildNodeEntriesMap map) throws Exception;
+    Id /*id*/ putCNEMap(ChildNodeEntriesMap map) throws Exception;
     void setHeadCommitId(String commitId) throws Exception;
     void lockHead();
     void unlockHead();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/BDbPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/BDbPersistenceManager.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/BDbPersistenceManager.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/BDbPersistenceManager.java Wed Mar  7 16:30:46 2012
@@ -22,6 +22,7 @@ import java.io.File;
 
 import org.apache.jackrabbit.mk.model.ChildNodeEntriesMap;
 import org.apache.jackrabbit.mk.model.Commit;
+import org.apache.jackrabbit.mk.model.Id;
 import org.apache.jackrabbit.mk.model.Node;
 import org.apache.jackrabbit.mk.model.StoredCommit;
 import org.apache.jackrabbit.mk.store.BinaryBinding;
@@ -119,24 +120,25 @@ public class BDbPersistenceManager imple
         head.put(null, key, data);
     }
 
-    public Binding readNodeBinding(String id) throws NotFoundException, Exception {
-        DatabaseEntry key = new DatabaseEntry(StringUtils.convertHexToBytes(id));
+    public Binding readNodeBinding(Id id) throws NotFoundException, Exception {
+        DatabaseEntry key = new DatabaseEntry(id.getBytes());
         DatabaseEntry data = new DatabaseEntry();
 
         if (db.get(null, key, data, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
             ByteArrayInputStream in = new ByteArrayInputStream(data.getData());
             return new BinaryBinding(in);
         } else {
-            throw new NotFoundException(id);
+            throw new NotFoundException(id.toString());
         }
     }
 
-    public String writeNode(Node node) throws Exception {
+    public Id writeNode(Node node) throws Exception {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         node.serialize(new BinaryBinding(out));
         byte[] bytes = out.toByteArray();
-        byte[] rawId = idFactory.createContentId(bytes);
-        return persist(bytes, rawId);
+        Id id = new Id(idFactory.createContentId(bytes));
+        persist(id.getBytes(), bytes);
+        return id;
     }
 
     public StoredCommit readCommit(String id) throws NotFoundException, Exception {
@@ -155,39 +157,36 @@ public class BDbPersistenceManager imple
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         commit.serialize(new BinaryBinding(out));
         byte[] bytes = out.toByteArray();
-        persist(bytes, rawId);
+        persist(rawId, bytes);
     }
 
-    public ChildNodeEntriesMap readCNEMap(String id) throws NotFoundException, Exception {
-        DatabaseEntry key = new DatabaseEntry(StringUtils.convertHexToBytes(id));
+    public ChildNodeEntriesMap readCNEMap(Id id) throws NotFoundException, Exception {
+        DatabaseEntry key = new DatabaseEntry(id.getBytes());
         DatabaseEntry data = new DatabaseEntry();
 
         if (db.get(null, key, data, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
             ByteArrayInputStream in = new ByteArrayInputStream(data.getData());
             return ChildNodeEntriesMap.deserialize(new BinaryBinding(in));
         } else {
-            throw new NotFoundException(id);
+            throw new NotFoundException(id.toString());
         }
     }
 
-    public String writeCNEMap(ChildNodeEntriesMap map) throws Exception {
+    public Id writeCNEMap(ChildNodeEntriesMap map) throws Exception {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         map.serialize(new BinaryBinding(out));
         byte[] bytes = out.toByteArray();
-        byte[] rawId = idFactory.createContentId(bytes);
-        return persist(bytes, rawId);
+        Id id = new Id(idFactory.createContentId(bytes));
+        persist(id.getBytes(), bytes);
+        return id;
     }
 
     //-------------------------------------------------------< implementation >
 
-    protected String persist(byte[] bytes, byte[] rawId) throws Exception {
-        String id = StringUtils.convertBytesToHex(rawId);
-
+    protected void persist(byte[] rawId, byte[] bytes) throws Exception {
         DatabaseEntry key = new DatabaseEntry(rawId);
         DatabaseEntry data = new DatabaseEntry(bytes);
 
         db.put(null, key, data);
-
-        return id;
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/FSPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/FSPersistenceManager.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/FSPersistenceManager.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/FSPersistenceManager.java Wed Mar  7 16:30:46 2012
@@ -24,6 +24,7 @@ import java.io.FileOutputStream;
 
 import org.apache.jackrabbit.mk.model.ChildNodeEntriesMap;
 import org.apache.jackrabbit.mk.model.Commit;
+import org.apache.jackrabbit.mk.model.Id;
 import org.apache.jackrabbit.mk.model.Node;
 import org.apache.jackrabbit.mk.model.StoredCommit;
 import org.apache.jackrabbit.mk.store.BinaryBinding;
@@ -76,7 +77,7 @@ public class FSPersistenceManager implem
         }
     }
 
-    public Binding readNodeBinding(String id) throws NotFoundException, Exception {
+    public Binding readNodeBinding(Id id) throws NotFoundException, Exception {
         File f = getFile(id);
         if (f.exists()) {
             BufferedInputStream in = new BufferedInputStream(new FileInputStream(f));
@@ -86,20 +87,21 @@ public class FSPersistenceManager implem
                 in.close();
             }
         } else {
-            throw new NotFoundException(id);
+            throw new NotFoundException(id.toString());
         }
     }
 
-    public String writeNode(Node node) throws Exception {
+    public Id writeNode(Node node) throws Exception {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         node.serialize(new BinaryBinding(out));
         byte[] bytes = out.toByteArray();
-        byte[] rawId = idFactory.createContentId(bytes);
-        return writeFile(bytes, rawId);
+        Id id = new Id(idFactory.createContentId(bytes));
+        writeFile(id, bytes);
+        return id;
     }
 
     public StoredCommit readCommit(String id) throws NotFoundException, Exception {
-        File f = getFile(id);
+        File f = getFile(Id.fromString(id));
         if (f.exists()) {
             BufferedInputStream in = new BufferedInputStream(new FileInputStream(f));
             try {
@@ -116,10 +118,10 @@ public class FSPersistenceManager implem
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         commit.serialize(new BinaryBinding(out));
         byte[] bytes = out.toByteArray();
-        writeFile(bytes, rawId);
+        writeFile(new Id(rawId), bytes);
     }
 
-    public ChildNodeEntriesMap readCNEMap(String id) throws NotFoundException, Exception {
+    public ChildNodeEntriesMap readCNEMap(Id id) throws NotFoundException, Exception {
         File f = getFile(id);
         if (f.exists()) {
             BufferedInputStream in = new BufferedInputStream(new FileInputStream(f));
@@ -129,28 +131,30 @@ public class FSPersistenceManager implem
                 in.close();
             }
         } else {
-            throw new NotFoundException(id);
+            throw new NotFoundException(id.toString());
         }
     }
 
-    public String writeCNEMap(ChildNodeEntriesMap map) throws Exception {
+    public Id writeCNEMap(ChildNodeEntriesMap map) throws Exception {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         map.serialize(new BinaryBinding(out));
         byte[] bytes = out.toByteArray();
-        byte[] rawId = idFactory.createContentId(bytes);
-        return writeFile(bytes, rawId);
+        Id id = new Id(idFactory.createContentId(bytes));
+        writeFile(id, bytes);
+        return id;
     }
 
     //-------------------------------------------------------< implementation >
 
-    private File getFile(String id) {
-        StringBuilder buf = new StringBuilder(id.substring(0, 2));
+    private File getFile(Id id) {
+        String sId = id.toString();
+        StringBuilder buf = new StringBuilder(sId.substring(0, 2));
         buf.append('/');
-        buf.append(id.substring(2));
+        buf.append(sId.substring(2));
         return new File(dataDir, buf.toString());
     }
 
-    private String writeFile(byte[] data, byte[] rawId) throws Exception {
+    private void writeFile(Id id, byte[] data) throws Exception {
         File tmp = File.createTempFile("tmp", null, dataDir);
 
         try {
@@ -163,21 +167,20 @@ public class FSPersistenceManager implem
                 fos.close();
             }
 
-            String id = StringUtils.convertBytesToHex(rawId);
             File dst = getFile(id);
             if (dst.exists()) {
                 // already exists
-                return id;
+                return;
             }
             // move tmp file
             tmp.setReadOnly();
             if (tmp.renameTo(dst)) {
-                return id;
+                return;
             }
             // make sure parent dir exists and try again
             dst.getParentFile().mkdir();
             if (tmp.renameTo(dst)) {
-                return id;
+                return;
             }
             throw new Exception("failed to create " + dst);
         } finally {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/H2PersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/H2PersistenceManager.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/H2PersistenceManager.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/H2PersistenceManager.java Wed Mar  7 16:30:46 2012
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.mk.store.p
 
 import org.apache.jackrabbit.mk.model.ChildNodeEntriesMap;
 import org.apache.jackrabbit.mk.model.Commit;
+import org.apache.jackrabbit.mk.model.Id;
 import org.apache.jackrabbit.mk.model.Node;
 import org.apache.jackrabbit.mk.model.StoredCommit;
 import org.apache.jackrabbit.mk.store.BinaryBinding;
@@ -110,18 +111,18 @@ public class H2PersistenceManager implem
         }
     }
 
-    public Binding readNodeBinding(String id) throws NotFoundException, Exception {
+    public Binding readNodeBinding(Id id) throws NotFoundException, Exception {
         Connection con = cp.getConnection();
         try {
             PreparedStatement stmt = con.prepareStatement("select DATA from REVS where ID = ?");
             try {
-                stmt.setBytes(1, StringUtils.convertHexToBytes(id));
+                stmt.setBytes(1, id.getBytes());
                 ResultSet rs = stmt.executeQuery();
                 if (rs.next()) {
                     ByteArrayInputStream in = new ByteArrayInputStream(rs.getBytes(1));
                     return new BinaryBinding(in);
                 } else {
-                    throw new NotFoundException(id);
+                    throw new NotFoundException(id.toString());
                 }
             } finally {
                 stmt.close();
@@ -131,12 +132,12 @@ public class H2PersistenceManager implem
         }
     }
 
-    public String writeNode(Node node) throws Exception {
+    public Id writeNode(Node node) throws Exception {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         node.serialize(new BinaryBinding(out));
         byte[] bytes = out.toByteArray();
         byte[] rawId = idFactory.createContentId(bytes);
-        String id = StringUtils.convertBytesToHex(rawId);
+        //String id = StringUtils.convertBytesToHex(rawId);
 
         Connection con = cp.getConnection();
         try {
@@ -154,7 +155,7 @@ public class H2PersistenceManager implem
         } finally {
             con.close();
         }
-        return id;
+        return new Id(rawId);
     }
 
     public StoredCommit readCommit(String id) throws NotFoundException, Exception {
@@ -201,18 +202,18 @@ public class H2PersistenceManager implem
         }
     }
 
-    public ChildNodeEntriesMap readCNEMap(String id) throws NotFoundException, Exception {
+    public ChildNodeEntriesMap readCNEMap(Id id) throws NotFoundException, Exception {
         Connection con = cp.getConnection();
         try {
             PreparedStatement stmt = con.prepareStatement("select DATA from REVS where ID = ?");
             try {
-                stmt.setBytes(1, StringUtils.convertHexToBytes(id));
+                stmt.setBytes(1, id.getBytes());
                 ResultSet rs = stmt.executeQuery();
                 if (rs.next()) {
                     ByteArrayInputStream in = new ByteArrayInputStream(rs.getBytes(1));
                     return ChildNodeEntriesMap.deserialize(new BinaryBinding(in));
                 } else {
-                    throw new NotFoundException(id);
+                    throw new NotFoundException(id.toString());
                 }
             } finally {
                 stmt.close();
@@ -222,12 +223,11 @@ public class H2PersistenceManager implem
         }
     }
 
-    public String writeCNEMap(ChildNodeEntriesMap map) throws Exception {
+    public Id writeCNEMap(ChildNodeEntriesMap map) throws Exception {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         map.serialize(new BinaryBinding(out));
         byte[] bytes = out.toByteArray();
         byte[] rawId = idFactory.createContentId(bytes);
-        String id = StringUtils.convertBytesToHex(rawId);
 
         Connection con = cp.getConnection();
         try {
@@ -245,6 +245,6 @@ public class H2PersistenceManager implem
         } finally {
             con.close();
         }
-        return id;
+        return new Id(rawId);
     }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/InMemPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/InMemPersistenceManager.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/InMemPersistenceManager.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/InMemPersistenceManager.java Wed Mar  7 16:30:46 2012
@@ -28,6 +28,7 @@ import org.apache.jackrabbit.mk.blobs.Bl
 import org.apache.jackrabbit.mk.blobs.MemoryBlobStore;
 import org.apache.jackrabbit.mk.model.ChildNodeEntriesMap;
 import org.apache.jackrabbit.mk.model.Commit;
+import org.apache.jackrabbit.mk.model.Id;
 import org.apache.jackrabbit.mk.model.Node;
 import org.apache.jackrabbit.mk.model.StoredCommit;
 import org.apache.jackrabbit.mk.store.BinaryBinding;
@@ -41,9 +42,9 @@ import org.apache.jackrabbit.mk.util.Str
  */
 public class InMemPersistenceManager implements PersistenceManager, BlobStore {
 
-    private final Map<String, byte[]> nodes = Collections.synchronizedMap(new HashMap<String, byte[]>());
+    private final Map<Id, byte[]> nodes = Collections.synchronizedMap(new HashMap<Id, byte[]>());
     private final Map<String, StoredCommit> commits = Collections.synchronizedMap(new HashMap<String, StoredCommit>());
-    private final Map<String, ChildNodeEntriesMap> cneMaps = Collections.synchronizedMap(new HashMap<String, ChildNodeEntriesMap>());
+    private final Map<Id, ChildNodeEntriesMap> cneMaps = Collections.synchronizedMap(new HashMap<Id, ChildNodeEntriesMap>());
     private final BlobStore blobs = new MemoryBlobStore();
 
     private String head;
@@ -66,20 +67,20 @@ public class InMemPersistenceManager imp
         head = id;
     }
 
-    public Binding readNodeBinding(String id) throws NotFoundException, Exception {
+    public Binding readNodeBinding(Id id) throws NotFoundException, Exception {
         byte[] bytes = nodes.get(id);
         if (bytes != null) {
             return new BinaryBinding(new ByteArrayInputStream(bytes));
         } else {
-            throw new NotFoundException(id);
+            throw new NotFoundException(id.toString());
         }
     }
 
-    public String writeNode(Node node) throws Exception {
+    public Id writeNode(Node node) throws Exception {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         node.serialize(new BinaryBinding(out));
         byte[] bytes = out.toByteArray();
-        String id = StringUtils.convertBytesToHex(idFactory.createContentId(bytes));
+        Id id = new Id(idFactory.createContentId(bytes));
 
         if (!nodes.containsKey(id)) {
             nodes.put(id, bytes);
@@ -108,20 +109,20 @@ public class InMemPersistenceManager imp
         }
     }
 
-    public ChildNodeEntriesMap readCNEMap(String id) throws NotFoundException, Exception {
+    public ChildNodeEntriesMap readCNEMap(Id id) throws NotFoundException, Exception {
         ChildNodeEntriesMap map = cneMaps.get(id);
         if (map != null) {
             return map;
         } else {
-            throw new NotFoundException(id);
+            throw new NotFoundException(id.toString());
         }
     }
 
-    public String writeCNEMap(ChildNodeEntriesMap map) throws Exception {
+    public Id writeCNEMap(ChildNodeEntriesMap map) throws Exception {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         map.serialize(new BinaryBinding(out));
         byte[] bytes = out.toByteArray();
-        String id = StringUtils.convertBytesToHex(idFactory.createContentId(bytes));
+        Id id = new Id(idFactory.createContentId(bytes));
 
         if (!cneMaps.containsKey(id)) {
             cneMaps.put(id, ChildNodeEntriesMap.deserialize(new BinaryBinding(new ByteArrayInputStream(bytes))));

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/MongoPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/MongoPersistenceManager.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/MongoPersistenceManager.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/MongoPersistenceManager.java Wed Mar  7 16:30:46 2012
@@ -26,6 +26,7 @@ import org.apache.jackrabbit.mk.blobs.Bl
 import org.apache.jackrabbit.mk.fs.FilePath;
 import org.apache.jackrabbit.mk.model.ChildNodeEntriesMap;
 import org.apache.jackrabbit.mk.model.Commit;
+import org.apache.jackrabbit.mk.model.Id;
 import org.apache.jackrabbit.mk.model.Node;
 import org.apache.jackrabbit.mk.model.StoredCommit;
 import org.apache.jackrabbit.mk.store.BinaryBinding;
@@ -121,16 +122,15 @@ public class MongoPersistenceManager imp
         db.getCollection(HEAD_COLLECTION).insert(new BasicDBObject(ID_FIELD, id));
     }
 
-    public Binding readNodeBinding(String id) throws NotFoundException, Exception {
+    public Binding readNodeBinding(Id id) throws NotFoundException, Exception {
         BasicDBObject key = new BasicDBObject();
         if (BINARY_FORMAT) {
-            key.put(ID_FIELD, StringUtils.convertHexToBytes(id));
+            key.put(ID_FIELD, id.getBytes());
         } else {
-            key.put(ID_FIELD, id);
+            key.put(ID_FIELD, id.toString());
         }
         final BasicDBObject nodeObject = (BasicDBObject) nodes.findOne(key);
         if (nodeObject != null) {
-            // todo support partitioned child node lists
             if (BINARY_FORMAT) {
                 byte[] bytes = (byte[]) nodeObject.get(DATA_FIELD);
                 return new BinaryBinding(new ByteArrayInputStream(bytes));
@@ -138,23 +138,21 @@ public class MongoPersistenceManager imp
                 return new DBObjectBinding(nodeObject);
             }
         } else {
-            throw new NotFoundException(id);
+            throw new NotFoundException(id.toString());
         }
     }
     
-    public String writeNode(Node node) throws Exception {
+    public Id writeNode(Node node) throws Exception {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         node.serialize(new BinaryBinding(out));
         byte[] bytes = out.toByteArray();
-        byte[] key = idFactory.createContentId(bytes);
-        String id = StringUtils.convertBytesToHex(key);
+        Id id = new Id(idFactory.createContentId(bytes));
 
-        // todo support partitioned child node lists
         BasicDBObject nodeObject;
         if (BINARY_FORMAT) {
-            nodeObject = new BasicDBObject(ID_FIELD, key).append(DATA_FIELD, bytes);
+            nodeObject = new BasicDBObject(ID_FIELD, id.getBytes()).append(DATA_FIELD, bytes);
         } else {
-            nodeObject = new BasicDBObject(ID_FIELD, id);
+            nodeObject = new BasicDBObject(ID_FIELD, id.toString());
             node.serialize(new DBObjectBinding(nodeObject));
         }
         try {
@@ -206,12 +204,12 @@ public class MongoPersistenceManager imp
         }
     }
 
-    public ChildNodeEntriesMap readCNEMap(String id) throws NotFoundException, Exception {
+    public ChildNodeEntriesMap readCNEMap(Id id) throws NotFoundException, Exception {
         BasicDBObject key = new BasicDBObject();
         if (BINARY_FORMAT) {
-            key.put(ID_FIELD, StringUtils.convertHexToBytes(id));
+            key.put(ID_FIELD, id.getBytes());
         } else {
-            key.put(ID_FIELD, id);
+            key.put(ID_FIELD, id.toString());
         }
         BasicDBObject mapObject = (BasicDBObject) cneMaps.findOne(key);
         if (mapObject != null) {
@@ -222,22 +220,21 @@ public class MongoPersistenceManager imp
                 return ChildNodeEntriesMap.deserialize(new DBObjectBinding(mapObject));
             }
         } else {
-            throw new NotFoundException(id);
+            throw new NotFoundException(id.toString());
         }
     }
 
-    public String writeCNEMap(ChildNodeEntriesMap map) throws Exception {
+    public Id writeCNEMap(ChildNodeEntriesMap map) throws Exception {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         map.serialize(new BinaryBinding(out));
         byte[] bytes = out.toByteArray();
-        byte[] key = idFactory.createContentId(bytes);
-        String id = StringUtils.convertBytesToHex(key);
+        Id id = new Id(idFactory.createContentId(bytes));
 
         BasicDBObject mapObject;
         if (BINARY_FORMAT) {
-            mapObject = new BasicDBObject(ID_FIELD, key).append(DATA_FIELD, bytes);
+            mapObject = new BasicDBObject(ID_FIELD, id.getBytes()).append(DATA_FIELD, bytes);
         } else {
-            mapObject = new BasicDBObject(ID_FIELD, id);
+            mapObject = new BasicDBObject(ID_FIELD, id.toString());
             map.serialize(new DBObjectBinding(mapObject));
         }
         try {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/PersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/PersistenceManager.java?rev=1298011&r1=1298010&r2=1298011&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/PersistenceManager.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/pm/PersistenceManager.java Wed Mar  7 16:30:46 2012
@@ -20,6 +20,7 @@ import java.io.File;
 
 import org.apache.jackrabbit.mk.model.ChildNodeEntriesMap;
 import org.apache.jackrabbit.mk.model.Commit;
+import org.apache.jackrabbit.mk.model.Id;
 import org.apache.jackrabbit.mk.model.Node;
 import org.apache.jackrabbit.mk.model.StoredCommit;
 import org.apache.jackrabbit.mk.store.Binding;
@@ -42,13 +43,13 @@ public interface PersistenceManager {
 
     void writeHead(String id) throws Exception;
 
-    Binding readNodeBinding(String id) throws NotFoundException, Exception;
+    Binding readNodeBinding(Id id) throws NotFoundException, Exception;
 
-    String writeNode(Node node) throws Exception;
+    Id writeNode(Node node) throws Exception;
 
-    ChildNodeEntriesMap readCNEMap(String id) throws NotFoundException, Exception;
+    ChildNodeEntriesMap readCNEMap(Id id) throws NotFoundException, Exception;
 
-    String writeCNEMap(ChildNodeEntriesMap map) throws Exception;
+    Id writeCNEMap(ChildNodeEntriesMap map) throws Exception;
 
     StoredCommit readCommit(String id) throws NotFoundException, Exception;
 



Mime
View raw message