jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r793613 [3/8] - in /jackrabbit/sandbox/JCR-1456: ./ jackrabbit-core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ jackrabbit-core/src/main/java/org/apache/jackra...
Date Mon, 13 Jul 2009 15:56:03 GMT
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java Mon Jul 13 15:55:55 2009
@@ -23,12 +23,14 @@
 
 import javax.jcr.PropertyType;
 
-import org.apache.jackrabbit.core.ItemId;
-import org.apache.jackrabbit.core.NamespaceRegistryImpl;
-import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.PropertyId;
-import org.apache.jackrabbit.core.fs.FileSystem;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
+import org.apache.jackrabbit.core.fs.FileSystem;
+import org.apache.jackrabbit.core.NamespaceRegistryImpl;
+import org.apache.jackrabbit.core.id.ItemId;
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.core.persistence.IterablePersistenceManager;
 import org.apache.jackrabbit.core.persistence.PMContext;
@@ -38,14 +40,15 @@
 import org.apache.jackrabbit.core.persistence.bundle.util.HashMapIndex;
 import org.apache.jackrabbit.core.persistence.bundle.util.LRUNodeIdCache;
 import org.apache.jackrabbit.core.persistence.bundle.util.NodePropBundle;
-import org.apache.jackrabbit.core.state.ChangeLog;
 import org.apache.jackrabbit.core.state.ItemState;
+import org.apache.jackrabbit.core.state.ChangeLog;
 import org.apache.jackrabbit.core.state.ItemStateException;
-import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.NodeReferences;
-import org.apache.jackrabbit.core.state.NodeReferencesId;
-import org.apache.jackrabbit.core.state.NodeState;
+import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.PropertyState;
+import org.apache.jackrabbit.core.state.NodeState;
+import org.apache.jackrabbit.core.state.ChangeLog;
+import org.apache.jackrabbit.core.state.NodeReferences;
 import org.apache.jackrabbit.core.util.StringIndex;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
@@ -177,7 +180,7 @@
         if (buf == null) {
             buf = new StringBuffer();
         }
-        char[] chars = id.getUUID().toString().toCharArray();
+        char[] chars = id.toString().toCharArray();
         int cnt = 0;
         for (int i = 0; i < chars.length; i++) {
             if (chars[i] == '-') {
@@ -259,12 +262,12 @@
      * @param id the id of the node
      * @return the buffer with the appended data.
      */
-    protected StringBuffer buildNodeReferencesFilePath(StringBuffer buf,
-                                                       NodeReferencesId id) {
+    protected StringBuffer buildNodeReferencesFilePath(
+            StringBuffer buf, NodeId id) {
         if (buf == null) {
             buf = new StringBuffer();
         }
-        buildNodeFolderPath(buf, id.getTargetId());
+        buildNodeFolderPath(buf, id);
         buf.append(FileSystem.SEPARATOR);
         buf.append(NODEREFSFILENAME);
         return buf;
@@ -318,27 +321,21 @@
      * {@inheritDoc}
      */
     public synchronized void onExternalUpdate(ChangeLog changes) {
-        Iterator<ItemState> iter = changes.modifiedStates();
-        while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+        for (ItemState state : changes.modifiedStates()) {
             if (state.isNode()) {
                 bundles.remove((NodeId) state.getId());
             } else {
                 bundles.remove(state.getParentId());
             }
         }
-        iter = changes.deletedStates();
-        while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+        for (ItemState state : changes.deletedStates()) {
             if (state.isNode()) {
                 bundles.remove((NodeId) state.getId());
             } else {
                 bundles.remove(state.getParentId());
             }
         }
-        iter = changes.addedStates();
-        while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+        for (ItemState state : changes.addedStates()) {
             if (state.isNode()) {
                 missing.remove((NodeId) state.getId());
             } else {
@@ -391,12 +388,6 @@
             throws ItemStateException;
 
     /**
-     * {@inheritDoc}
-     */
-    public abstract NodeReferences load(NodeReferencesId targetId)
-            throws NoSuchItemStateException, ItemStateException;
-
-    /**
      * Deletes the node references from the underlying system.
      *
      * @param refs the node references to destroy.
@@ -485,40 +476,40 @@
             throws NoSuchItemStateException, ItemStateException {
     	Context context = createContext();
     	try {
-	        NodePropBundle bundle = getBundle(id.getParentId(), context);
-	        if (bundle == null) {
-	            throw new NoSuchItemStateException(id.toString());
-	        }
-	        PropertyState state = bundle.createPropertyState(this, id.getName());
-	        if (state == null) {
-	            // check if autocreated property state
-	            if (id.getName().equals(NameConstants.JCR_UUID)) {
-	                state = createNew(id);
-	                state.setType(PropertyType.STRING);
-	                state.setDefinitionId(idJcrUUID);
-	                state.setMultiValued(false);
-	                state.setValues(new InternalValue[]{InternalValue.create(id.getParentId().getUUID().toString())});
-	            } else if (id.getName().equals(NameConstants.JCR_PRIMARYTYPE)) {
-	                state = createNew(id);
-	                state.setType(PropertyType.NAME);
-	                state.setDefinitionId(idJcrPrimaryType);
-	                state.setMultiValued(false);
-	                state.setValues(new InternalValue[]{InternalValue.create(bundle.getNodeTypeName())});
-	            } else if (id.getName().equals(NameConstants.JCR_MIXINTYPES)) {
-	                Set<Name> mixins = bundle.getMixinTypeNames();
-	                state = createNew(id);
-	                state.setType(PropertyType.NAME);
-	                state.setDefinitionId(idJcrMixinTypes);
-	                state.setMultiValued(true);
-	                state.setValues(InternalValue.create((Name[]) mixins.toArray(new Name[mixins.size()])));
-	            } else {
-	                throw new NoSuchItemStateException(id.toString());
-	            }
-	            bundle.addProperty(state);
-	        }
-	        return state;
+            NodePropBundle bundle = getBundle(id.getParentId(), context);
+            if (bundle == null) {
+                throw new NoSuchItemStateException(id.toString());
+            }
+            PropertyState state = bundle.createPropertyState(this, id.getName());
+            if (state == null) {
+                // check if autocreated property state
+                if (id.getName().equals(NameConstants.JCR_UUID)) {
+                    state = createNew(id);
+                    state.setType(PropertyType.STRING);
+                    state.setDefinitionId(idJcrUUID);
+                    state.setMultiValued(false);
+                    state.setValues(new InternalValue[]{InternalValue.create(id.getParentId().toString())});
+                } else if (id.getName().equals(NameConstants.JCR_PRIMARYTYPE)) {
+                    state = createNew(id);
+                    state.setType(PropertyType.NAME);
+                    state.setDefinitionId(idJcrPrimaryType);
+                    state.setMultiValued(false);
+                    state.setValues(new InternalValue[]{InternalValue.create(bundle.getNodeTypeName())});
+                } else if (id.getName().equals(NameConstants.JCR_MIXINTYPES)) {
+                    Set<Name> mixins = bundle.getMixinTypeNames();
+                    state = createNew(id);
+                    state.setType(PropertyType.NAME);
+                    state.setDefinitionId(idJcrMixinTypes);
+                    state.setMultiValued(true);
+                    state.setValues(InternalValue.create((Name[]) mixins.toArray(new Name[mixins.size()])));
+                } else {
+                    throw new NoSuchItemStateException(id.toString());
+                }
+                bundle.addProperty(state);
+            }
+            return state;
     	} finally {
-    		context.closeSilently();
+    	    context.closeSilently();
     	}
     }
 
@@ -613,9 +604,7 @@
             throws ItemStateException {
         // delete bundles
         HashSet<ItemId> deleted = new HashSet<ItemId>();
-        Iterator<ItemState> iter = changeLog.deletedStates();
-        while (iter.hasNext()) {
-            ItemState state = iter.next();
+        for (ItemState state : changeLog.deletedStates()) {
             if (state.isNode()) {
                 NodePropBundle bundle = getBundle((NodeId) state.getId(), context);
                 if (bundle == null) {
@@ -627,18 +616,14 @@
         }
         // gather added node states
         HashMap<ItemId, NodePropBundle> modified = new HashMap<ItemId, NodePropBundle>();
-        iter = changeLog.addedStates();
-        while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+        for (ItemState state : changeLog.addedStates()) {
             if (state.isNode()) {
                 NodePropBundle bundle = new NodePropBundle(getBinding(), (NodeState) state);
                 modified.put(state.getId(), bundle);
             }
         }
         // gather modified node states
-        iter = changeLog.modifiedStates();
-        while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+        for (ItemState state : changeLog.modifiedStates()) {
             if (state.isNode()) {
                 NodeId nodeId = (NodeId) state.getId();
                 NodePropBundle bundle = (NodePropBundle) modified.get(nodeId);
@@ -671,9 +656,7 @@
             }
         }
         // add removed properties
-        iter = changeLog.deletedStates();
-        while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+        for (ItemState state : changeLog.deletedStates()) {
             if (state.isNode()) {
                 // check consistency
                 NodeId parentId = state.getParentId();
@@ -699,9 +682,7 @@
             }
         }
         // add added properties
-        iter = changeLog.addedStates();
-        while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+        for (ItemState state : changeLog.addedStates()) {
             if (!state.isNode()) {
                 PropertyId id = (PropertyId) state.getId();
                 // skip primaryType pr mixinTypes properties
@@ -731,9 +712,7 @@
         }
 
         // store the refs
-        Iterator<NodeReferences> itMod = changeLog.modifiedRefs();
-        while (itMod.hasNext()) {
-            NodeReferences refs = itMod.next();
+        for (NodeReferences refs : changeLog.modifiedRefs()) {
             if (refs.hasReferences()) {
                 store(refs, context);
             } else {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java Mon Jul 13 15:55:55 2009
@@ -36,15 +36,13 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
-import java.util.NoSuchElementException;
 
 import javax.jcr.RepositoryException;
 import javax.sql.DataSource;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.NodeIdIterator;
-import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
 import org.apache.jackrabbit.core.fs.local.LocalFileSystem;
@@ -63,7 +61,6 @@
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.NodeReferences;
-import org.apache.jackrabbit.core.state.NodeReferencesId;
 import org.apache.jackrabbit.core.util.StringIndex;
 import org.apache.jackrabbit.util.Text;
 import org.apache.jackrabbit.uuid.UUID;
@@ -615,7 +612,7 @@
                 }                
             } 
         } while(blockOnConnectionLoss || trials > 0);
-        throw new ItemStateException(lastException.getMessage());
+        throw new ItemStateException(lastException.getMessage(), lastException);
     }
 
     /**
@@ -766,6 +763,12 @@
                                           BundleDbContext context) {
         //log.info(name + ": checking bundle '" + id + "'");
 
+        // skip all system nodes except root node
+        if (id.toString().endsWith("babecafebabe")
+                && !id.toString().equals("cafebabe-cafe-babe-cafe-babecafebabe")) {
+            return;
+        }
+
         // look at the node's children
         Collection<NodePropBundle.ChildNodeEntry> missingChildren = new ArrayList<NodePropBundle.ChildNodeEntry>();
         for (NodePropBundle.ChildNodeEntry entry : bundle.getChildNodeEntries()) {
@@ -774,9 +777,6 @@
             if (entry.getId().toString().endsWith("babecafebabe")) {
                 continue;
             }
-            if (id.toString().endsWith("babecafebabe")) {
-                continue;
-            }
 
             try {
                 // analyze child node bundles
@@ -855,16 +855,16 @@
                 while (rs.next()) {
                     NodeId id;
                     if (getStorageModel() == SM_BINARY_KEYS) {
-                        id = new NodeId(new UUID(rs.getBytes(1)));
+                        id = new NodeId(rs.getBytes(1));
                     } else {
-                        id = new NodeId(new UUID(rs.getLong(1), rs.getLong(2)));
+                        id = new NodeId(rs.getLong(1), rs.getLong(2));
                     }
 
                     // issuing 2nd statement to circumvent issue JCR-1474
                     ResultSet bRs = null;
                     byte[] data = null;
                     try {
-                        Statement bSmt = context.getConnectionHelper().executeStmt(bundleSelectSQL, getKey(id.getUUID()));
+                        Statement bSmt = context.getConnectionHelper().executeStmt(bundleSelectSQL, getKey(id));
                         bRs = bSmt.getResultSet();
                         if (!bRs.next()) {
                             throw new SQLException("bundle cannot be retrieved?");
@@ -911,26 +911,25 @@
             //     b) check bundle, store any bundle-to-be-modified in collection
             //     c) if recursive, add child uuids to list of uuids
 
-            List<UUID> uuidList = new ArrayList<UUID>(uuids.length);
+            List<NodeId> idList = new ArrayList<NodeId>(uuids.length);
             // convert uuid string array to list of UUID objects
             for (int i = 0; i < uuids.length; i++) {
                 try {
-                    uuidList.add(new UUID(uuids[i]));
+                    idList.add(new NodeId(uuids[i]));
                 } catch (IllegalArgumentException e) {
                     log.error("Invalid uuid for consistency check, skipping: '" + uuids[i] + "': " + e);
                 }
             }
             
             // iterate over UUIDs (including ones that are newly added inside the loop!)
-            for (int i = 0; i < uuidList.size(); i++) {
-                final UUID uuid = (UUID) uuidList.get(i);
+            for (int i = 0; i < idList.size(); i++) {
+                NodeId id = idList.get(i);
                 try {
                     // load the node from the database
-                    NodeId id = new NodeId(uuid);
                     NodePropBundle bundle = loadBundle(id, true, context);
 
                     if (bundle == null) {
-                        log.error("No bundle found for uuid '" + uuid + "'");
+                        log.error("No bundle found for uuid '" + id + "'");
                         continue;
                     }
 
@@ -938,20 +937,20 @@
 
                     if (recursive) {
                         for (NodePropBundle.ChildNodeEntry entry : bundle.getChildNodeEntries()) {
-                            uuidList.add(entry.getId().getUUID());
+                            idList.add(entry.getId());
                         }
                     }
 
                     count++;
                     if (count % 1000 == 0) {
-                        log.info(name + ": checked " + count + "/" + uuidList.size() + " bundles...");
+                        log.info(name + ": checked " + count + "/" + idList.size() + " bundles...");
                     }
                 } catch (ItemStateException e) {
                     // problem already logged (loadBundle called with logDetailedErrors=true)
                 }
             }
 
-            total = uuidList.size();
+            total = idList.size();
         }
 
         // repair collected broken bundles
@@ -1064,38 +1063,38 @@
 
     /**
      * Constructs a parameter list for a PreparedStatement
-     * for the given UUID.
+     * for the given node identifier.
      *
-     * @param uuid the uuid
+     * @param id the node id
      * @return a list of Objects
      */
-    protected Object[] getKey(UUID uuid) {
+    protected Object[] getKey(NodeId id) {
         if (getStorageModel() == SM_BINARY_KEYS) {
-            return new Object[]{uuid.getRawBytes()};
+            return new Object[] { id.getRawBytes() };
         } else {
-            return new Object[]{new Long(uuid.getMostSignificantBits()),
-                    new Long(uuid.getLeastSignificantBits())};
+            return new Object[] {
+                    id.getMostSignificantBits(), id.getLeastSignificantBits() };
         }
     }
 
     /**
      * Creates a parameter array for an SQL statement that needs
-     * (i) a UUID, and (2) another parameter.
+     * (i) a node identifier, and (2) another parameter.
      *
-     * @param uuid the UUID
+     * @param id the node id
      * @param p the other parameter
      * @param before whether the other parameter should be before the uuid parameter
      * @return an Object array that represents the parameters
      */
-    protected Object[] createParams(UUID uuid, Object p, boolean before) {
+    protected Object[] createParams(NodeId id, Object p, boolean before) {
 
         // Create the key
         List<Object> key = new ArrayList<Object>();
         if (getStorageModel() == SM_BINARY_KEYS) {
-            key.add(uuid.getRawBytes());
+            key.add(id.getRawBytes());
         } else {
-            key.add(new Long(uuid.getMostSignificantBits()));
-            key.add(new Long(uuid.getLeastSignificantBits()));
+            key.add(id.getMostSignificantBits());
+            key.add(id.getLeastSignificantBits());
         }
 
         // Create the parameters
@@ -1114,22 +1113,18 @@
     /**
      * {@inheritDoc}
      */
-    public synchronized NodeIdIterator getAllNodeIds(NodeId bigger, int maxCount)
+    public synchronized Iterable<NodeId> getAllNodeIds(NodeId bigger, int maxCount)
             throws ItemStateException, RepositoryException {
         ResultSet rs = null;
         BundleDbContext context = createContext();
         try {
-            UUID lowUuid;
-            Object[] keys;
-            String sql;
-            if (bigger == null) {
-                sql = bundleSelectAllIdsSQL;
-                lowUuid = null;
-                keys = new Object[0];
-            } else {
+            String sql = bundleSelectAllIdsSQL;
+            NodeId lowId = null;
+            Object[] keys = new Object[0];
+            if (bigger != null) {
                 sql = bundleSelectAllIdsFromSQL;
-                lowUuid = bigger.getUUID();
-                keys = getKey(lowUuid);
+                lowId = bigger;
+                keys = getKey(bigger);
             }
             if (maxCount > 0) {
                 // get some more rows, in case the first row is smaller
@@ -1140,25 +1135,25 @@
             }
             Statement stmt = context.getConnectionHelper().executeStmt(sql, keys, false, maxCount);
             rs = stmt.getResultSet();
-            ArrayList<UUID> result = new ArrayList<UUID>();
+            ArrayList<NodeId> result = new ArrayList<NodeId>();
             while ((maxCount == 0 || result.size() < maxCount) && rs.next()) {
-                UUID current;
+                NodeId current;
                 if (getStorageModel() == SM_BINARY_KEYS) {
-                    current = new UUID(rs.getBytes(1));
+                    current = new NodeId(rs.getBytes(1));
                 } else {
                     long high = rs.getLong(1);
                     long low = rs.getLong(2);
-                    current = new UUID(high, low);
+                    current = new NodeId(high, low);
                 }
-                if (lowUuid != null) {
+                if (lowId != null) {
                     // skip the keys that are smaller or equal (see above, maxCount += 10)
-                    if (current.compareTo(lowUuid) <= 0) {
+                    if (current.compareTo(lowId) <= 0) {
                         continue;
                     }
                 }
                 result.add(current);
             }
-            return new ListNodeIdIterator(result);
+            return result;
         } catch (SQLException e) {
             String msg = "getAllNodeIds failed.";
             log.error(msg, e);
@@ -1217,7 +1212,7 @@
         ResultSet rs = null;
         
         try {
-            Statement stmt = context.getConnectionHelper().executeStmt(bundleSelectSQL, getKey(id.getUUID()));
+            Statement stmt = context.getConnectionHelper().executeStmt(bundleSelectSQL, getKey(id));
             rs = stmt.getResultSet();
             if (!rs.next()) {
                 return null;
@@ -1254,8 +1249,8 @@
     protected synchronized boolean existsBundle(NodeId id, Context context) throws ItemStateException {
         ResultSet rs = null;
         try {
-        	ConnectionHelper helper = ((BundleDbContext)context).getConnectionHelper();
-            Statement stmt = helper.executeStmt(bundleSelectSQL, getKey(id.getUUID()));
+            ConnectionHelper helper = ((BundleDbContext)context).getConnectionHelper();
+            Statement stmt = helper.executeStmt(bundleSelectSQL, getKey(id));
             rs = stmt.getResultSet();
             // a bundle exists, if the result has at least one entry
             return rs.next();
@@ -1279,7 +1274,7 @@
             dout.close();
 
             String sql = bundle.isNew() ? bundleInsertSQL : bundleUpdateSQL;
-            Object[] params = createParams(bundle.getId().getUUID(), out.toByteArray(), true);
+            Object[] params = createParams(bundle.getId(), out.toByteArray(), true);
             ((BundleDbContext)context).getConnectionHelper().executeStmt(sql, params);
         } catch (Exception e) {
             String msg = "failed to write bundle: " + bundle.getId();
@@ -1293,8 +1288,8 @@
      */
     protected synchronized void destroyBundle(NodePropBundle bundle, Context context) throws ItemStateException {
         try {
-        	ConnectionHelper helper = ((BundleDbContext)context).getConnectionHelper(); 
-        	helper.executeStmt(bundleDeleteSQL, getKey(bundle.getId().getUUID()));
+            ConnectionHelper helper = ((BundleDbContext)context).getConnectionHelper(); 
+            helper.executeStmt(bundleDeleteSQL, getKey(bundle.getId()));
         } catch (Exception e) {
             if (e instanceof NoSuchItemStateException) {
                 throw (NoSuchItemStateException) e;
@@ -1308,7 +1303,7 @@
     /**
      * {@inheritDoc}
      */
-    public synchronized NodeReferences load(NodeReferencesId targetId)
+    public synchronized NodeReferences loadReferencesTo(NodeId targetId)
             throws NoSuchItemStateException, ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
@@ -1319,7 +1314,7 @@
         BundleDbContext context = createContext();
         try {
             Statement stmt = context.getConnectionHelper().executeStmt(
-                    nodeReferenceSelectSQL, getKey(targetId.getTargetId().getUUID()));
+                    nodeReferenceSelectSQL, getKey(targetId));
             rs = stmt.getResultSet();
             if (!rs.next()) {
                 throw new NoSuchItemStateException(targetId.toString());
@@ -1359,7 +1354,7 @@
         }
 
         // check if insert or update
-        boolean update = exists(refs.getId());
+        boolean update = existsReferencesTo(refs.getTargetId());
         String sql = (update) ? nodeReferenceUpdateSQL : nodeReferenceInsertSQL;
 
         try {
@@ -1368,13 +1363,13 @@
             // serialize references
             Serializer.serialize(refs, out);
 
-            Object[] params = createParams(refs.getTargetId().getUUID(), out.toByteArray(), true);
+            Object[] params = createParams(refs.getTargetId(), out.toByteArray(), true);
             ((BundleDbContext)context).getConnectionHelper().executeStmt(sql, params);
 
             // there's no need to close a ByteArrayOutputStream
             //out.close();
         } catch (Exception e) {
-            String msg = "failed to write node references: " + refs.getId();
+            String msg = "failed to write " + refs;
             log.error(msg, e);
             throw new ItemStateException(msg, e);
         }
@@ -1391,12 +1386,12 @@
         try {
         	ConnectionHelper helper = ((BundleDbContext)context).getConnectionHelper();
             helper.executeStmt(nodeReferenceDeleteSQL,
-                    getKey(refs.getTargetId().getUUID()));
+                    getKey(refs.getTargetId()));
         } catch (Exception e) {
             if (e instanceof NoSuchItemStateException) {
                 throw (NoSuchItemStateException) e;
             }
-            String msg = "failed to delete references: " + refs.getTargetId();
+            String msg = "failed to delete " + refs;
             log.error(msg, e);
             throw new ItemStateException(msg, e);
         }
@@ -1405,7 +1400,7 @@
     /**
      * {@inheritDoc}
      */
-    public synchronized boolean exists(NodeReferencesId targetId) throws ItemStateException {
+    public synchronized boolean existsReferencesTo(NodeId targetId) throws ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
@@ -1413,9 +1408,9 @@
         ResultSet rs = null;
         BundleDbContext context = createContext();
         try {
-        	ConnectionHelper helper = context.getConnectionHelper();
-            Statement stmt = helper.executeStmt(nodeReferenceSelectSQL,
-                    getKey(targetId.getTargetId().getUUID()));
+            ConnectionHelper helper = context.getConnectionHelper();
+            Statement stmt = helper.executeStmt(
+                    nodeReferenceSelectSQL, getKey(targetId));
             rs = stmt.getResultSet();
 
             // a reference exists if the result has at least one entry
@@ -1696,38 +1691,4 @@
         }
     }
 
-    /**
-     * Iterator over an in-memory list of node ids.
-     * This helper class is used by {@link BundleDbPersistenceManager#getAllNodeIds}.
-     */
-    private class ListNodeIdIterator implements NodeIdIterator {
-
-        private final ArrayList<UUID> list;
-        private int pos;
-
-        ListNodeIdIterator(ArrayList<UUID> list) {
-            this.list = list;
-        }
-
-        public NodeId nextNodeId() throws NoSuchElementException {
-            if (!hasNext()) {
-                throw new NoSuchElementException();
-            }
-            return new NodeId(list.get(pos++));
-        }
-
-        public boolean hasNext() {
-            return pos < list.size();
-        }
-
-        public Object next() {
-            return nextNodeId();
-        }
-
-        public void remove() {
-            throw new UnsupportedOperationException();
-        }
-
-    }
-
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java Mon Jul 13 15:55:55 2009
@@ -31,14 +31,11 @@
 import org.apache.jackrabbit.core.persistence.util.Serializer;
 import org.apache.jackrabbit.core.persistence.util.BLOBStore;
 import org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore;
-import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.NodeIdIterator;
-import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.state.ItemStateException;
-import org.apache.jackrabbit.core.state.NodeReferencesId;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.NodeReferences;
-import org.apache.jackrabbit.uuid.UUID;
 
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
@@ -48,7 +45,6 @@
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.NoSuchElementException;
 
 /**
  * This is a generic persistence manager that stores the {@link NodePropBundle}s
@@ -307,12 +303,12 @@
      * @param id the id of the node
      * @return the buffer with the appended data.
      */
-    protected StringBuffer buildNodeReferencesFilePath(StringBuffer buf,
-                                                       NodeReferencesId id) {
+    protected StringBuffer buildNodeReferencesFilePath(
+            StringBuffer buf, NodeId id) {
         if (buf == null) {
             buf = new StringBuffer();
         }
-        buildNodeFolderPath(buf, id.getTargetId());
+        buildNodeFolderPath(buf, id);
         buf.append('.');
         buf.append(NODEREFSFILENAME);
         return buf;
@@ -362,7 +358,7 @@
     /**
      * {@inheritDoc}
      */
-    public synchronized NodeReferences load(NodeReferencesId targetId)
+    public synchronized NodeReferences loadReferencesTo(NodeId targetId)
             throws NoSuchItemStateException, ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
@@ -410,7 +406,7 @@
             Serializer.serialize(refs, out);
             out.close();
         } catch (Exception e) {
-            String msg = "failed to write property state: " + refs.getTargetId();
+            String msg = "failed to write " + refs;
             BundleFsPersistenceManager.log.error(msg, e);
             throw new ItemStateException(msg, e);
         }
@@ -424,13 +420,13 @@
             throw new IllegalStateException("not initialized");
         }
         try {
-            StringBuffer buf = buildNodeReferencesFilePath(null, refs.getId());
+            StringBuffer buf = buildNodeReferencesFilePath(null, refs.getTargetId());
             itemFs.deleteFile(buf.toString());
         } catch (Exception e) {
             if (e instanceof NoSuchItemStateException) {
                 throw (NoSuchItemStateException) e;
             }
-            String msg = "failed to delete references: " + refs.getTargetId();
+            String msg = "failed to delete " + refs;
             BundleFsPersistenceManager.log.error(msg, e);
             throw new ItemStateException(msg, e);
         }
@@ -439,7 +435,7 @@
     /**
      * {@inheritDoc}
      */
-    public synchronized boolean exists(NodeReferencesId targetId) throws ItemStateException {
+    public synchronized boolean existsReferencesTo(NodeId targetId) throws ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
@@ -512,12 +508,12 @@
     /**
      * {@inheritDoc}
      */
-    public NodeIdIterator getAllNodeIds(NodeId bigger, int maxCount)
+    public Iterable<NodeId> getAllNodeIds(NodeId bigger, int maxCount)
             throws ItemStateException {
         ArrayList<NodeId> list = new ArrayList<NodeId>();
         try {
-            getListRecursive(list, "", bigger == null ? null : bigger.getUUID(), maxCount);
-            return new FileNodeIdIterator(list);
+            getListRecursive(list, "", bigger == null ? null : bigger, maxCount);
+            return list;
         } catch (FileSystemException e) {
             String msg = "failed to read node list: " + bigger + ": " + e;
             log.error(msg);
@@ -528,7 +524,7 @@
     /**
      * {@inheritDoc}
      */
-    protected UUID getUUIDFromFileName(String fileName) {
+    protected NodeId getIdFromFileName(String fileName) {
         StringBuffer buff = new StringBuffer(35);
         if (!fileName.endsWith("." + NODEFILENAME)) {
             return null;
@@ -546,12 +542,12 @@
                 }
             }
         }
-        String u = buff.toString();
-        return new UUID(u);
+        return new NodeId(buff.toString());
     }
 
-    private void getListRecursive(ArrayList<NodeId> list, String path, UUID bigger,
-            int maxCount) throws FileSystemException {
+    private void getListRecursive(
+            ArrayList<NodeId> list, String path, NodeId bigger, int maxCount)
+            throws FileSystemException {
         if (maxCount > 0 && list.size() >= maxCount) {
             return;
         }
@@ -559,14 +555,13 @@
         Arrays.sort(files);
         for (int i = 0; i < files.length; i++) {
             String f = files[i];
-            UUID u = getUUIDFromFileName(path + FileSystem.SEPARATOR + f);
-            if (u == null) {
+            NodeId n = getIdFromFileName(path + FileSystem.SEPARATOR + f);
+            if (n == null) {
                 continue;
             }
-            if (bigger != null && bigger.toString().compareTo(u.toString()) >= 0) {
+            if (bigger != null && bigger.toString().compareTo(n.toString()) >= 0) {
                 continue;
             }
-            NodeId n = new NodeId(u);
             list.add(n);
             if (maxCount > 0 && list.size() >= maxCount) {
                 return;
@@ -580,37 +575,4 @@
         }
     }
 
-    /**
-     * Iterator over all node ids in this persistence manager.
-     */
-    private static class FileNodeIdIterator implements NodeIdIterator {
-
-        private final ArrayList<NodeId> list;
-        private int pos;
-
-        FileNodeIdIterator(ArrayList<NodeId> list) {
-            this.list = list;
-        }
-
-        public NodeId nextNodeId() throws NoSuchElementException {
-            if (pos < list.size()) {
-                return (NodeId) list.get(pos++);
-            }
-            throw new NoSuchElementException();
-        }
-
-        public boolean hasNext() {
-            return pos < list.size();
-        }
-
-        public Object next() {
-            return nextNodeId();
-        }
-
-        public void remove() {
-            throw new UnsupportedOperationException();
-        }
-
-    }
-
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/Oracle9PersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/Oracle9PersistenceManager.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/Oracle9PersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/Oracle9PersistenceManager.java Mon Jul 13 15:55:55 2009
@@ -124,7 +124,7 @@
 
             String sql = bundle.isNew() ? bundleInsertSQL : bundleUpdateSQL;
             blob = createTemporaryBlob(new ByteArrayInputStream(out.toByteArray()), (BundleDbContext)context);
-            Object[] params = createParams(bundle.getId().getUUID(), blob, true);
+            Object[] params = createParams(bundle.getId(), blob, true);
             ((BundleDbContext)context).getConnectionHelper().executeStmt(sql, params);
         } catch (Exception e) {
             String msg = "failed to write bundle: " + bundle.getId();
@@ -152,7 +152,7 @@
         Blob blob = null;
         try {
             // check if insert or update
-            boolean update = exists(refs.getId());
+            boolean update = existsReferencesTo(refs.getTargetId());
             String sql = (update) ? nodeReferenceUpdateSQL : nodeReferenceInsertSQL;
 
             ByteArrayOutputStream out = new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
@@ -163,13 +163,13 @@
             // not have to additionally synchronize on the preparedStatement
 
             blob = createTemporaryBlob(new ByteArrayInputStream(out.toByteArray()), (BundleDbContext) context);
-            Object[] params = createParams(refs.getTargetId().getUUID(), blob, true);
+            Object[] params = createParams(refs.getTargetId(), blob, true);
             ((BundleDbContext)context).getConnectionHelper().executeStmt(sql, params);
 
             // there's no need to close a ByteArrayOutputStream
             //out.close();
         } catch (Exception e) {
-            String msg = "failed to write property state: " + refs.getTargetId();
+            String msg = "failed to write " + refs;
             log.error(msg, e);
             throw new ItemStateException(msg, e);
         } finally {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/PostgreSQLPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/PostgreSQLPersistenceManager.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/PostgreSQLPersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/PostgreSQLPersistenceManager.java Mon Jul 13 15:55:55 2009
@@ -22,7 +22,7 @@
 import java.sql.SQLException;
 import java.sql.Statement;
 
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.persistence.PMContext;
 import org.apache.jackrabbit.core.persistence.bundle.util.DbNameIndex;
 import org.apache.jackrabbit.core.persistence.bundle.util.NodePropBundle;
@@ -92,7 +92,7 @@
             throws ItemStateException {
     	BundleDbContext context = createContext();
         try {        	
-            Statement stmt = context.getConnectionHelper().executeStmt(bundleSelectSQL, getKey(id.getUUID()));
+            Statement stmt = context.getConnectionHelper().executeStmt(bundleSelectSQL, getKey(id));
             ResultSet rs = stmt.getResultSet();
             try {
                 if (rs.next()) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java Mon Jul 13 15:55:55 2009
@@ -21,15 +21,14 @@
 import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.persistence.util.BLOBStore;
 import org.apache.jackrabbit.core.persistence.util.ResourceBasedBLOBStore;
-import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.util.StringIndex;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 
@@ -187,8 +186,8 @@
             return false;
         }
         try {
-            UUID parentUuid = readUUID(in);
-            log.debug("ParentUUID: " + parentUuid);
+            NodeId parentId = readID(in);
+            log.debug("ParentUUID: " + parentId);
         } catch (IOException e) {
             log.error("Error while reading ParentUUID: " + e);
             return false;
@@ -231,11 +230,11 @@
             return false;
         }
         try {
-            UUID cneUUID = readUUID(in);
-            while (cneUUID != null) {
+            NodeId cneId = readID(in);
+            while (cneId != null) {
                 Name cneName = readQName(in);
-                log.debug("ChildNodentry: " + cneUUID + ":" + cneName);
-                cneUUID = readUUID(in);
+                log.debug("ChildNodentry: " + cneId + ":" + cneName);
+                cneId = readID(in);
             }
         } catch (IOException e) {
             log.error("Error while reading child node entry: " + e);
@@ -397,7 +396,7 @@
                     break;
                 case PropertyType.WEAKREFERENCE:
                 case PropertyType.REFERENCE:
-                    val = InternalValue.create(readUUID(in));
+                    val = InternalValue.create(readID(in));
                     break;
                 default:
                     // because writeUTF(String) has a size limit of 64k,
@@ -548,8 +547,8 @@
                 case PropertyType.WEAKREFERENCE:
                 case PropertyType.REFERENCE:
                     try {
-                        UUID uuid = readUUID(in);
-                        log.debug("  reference: " + uuid);
+                        NodeId id = readID(in);
+                        log.debug("  reference: " + id);
                     } catch (IOException e) {
                         log.error("Error while reading reference value: " + e);
                         return false;
@@ -721,7 +720,7 @@
                     break;
                 case PropertyType.WEAKREFERENCE:
                 case PropertyType.REFERENCE:
-                    writeUUID(out, val.getUUID());
+                    writeID(out, val.getNodeId());
                     break;
                 default:
                     // because writeUTF(String) has a size limit of 64k,

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleCache.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleCache.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleCache.java Mon Jul 13 15:55:55 2009
@@ -17,7 +17,7 @@
 package org.apache.jackrabbit.core.persistence.bundle.util;
 
 import org.apache.commons.collections.map.LinkedMap;
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java Mon Jul 13 15:55:55 2009
@@ -18,17 +18,14 @@
 
 import org.apache.jackrabbit.core.persistence.util.BLOBStore;
 import org.apache.jackrabbit.core.persistence.PersistenceManager;
-import org.apache.jackrabbit.core.state.NodeReferencesId;
-import org.apache.jackrabbit.core.state.NodeReferences;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.ChildNodeEntry;
 import org.apache.jackrabbit.core.util.StringIndex;
-import org.apache.jackrabbit.core.PropertyId;
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.PropertyId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 
 import java.io.DataInputStream;
@@ -139,46 +136,6 @@
     }
 
     /**
-     * Deserializes a <code>NodeReferences</code> from the data input stream.
-     *
-     * @param in the input stream
-     * @param id the id of the nodereference to deserialize
-     * @param pMgr the persistence manager
-     * @return the node references
-     * @throws IOException in an I/O error occurs.
-     */
-    public NodeReferences readState(DataInputStream in, NodeReferencesId id,
-                                    PersistenceManager pMgr)
-            throws IOException {
-        NodeReferences state = new NodeReferences(id);
-        int count = in.readInt();   // count & version
-        // int version = (count >> 24) | 0x0ff;
-        count &= 0x00ffffff;
-        for (int i = 0; i < count; i++) {
-            state.addReference(readPropertyId(in));    // propertyId
-        }
-        return state;
-    }
-
-    /**
-     * Serializes a <code>NodeReferences</code> to the data output stream.
-     *
-     * @param out the output stream
-     * @param state the state to write.
-     * @throws IOException in an I/O error occurs.
-     */
-    public void writeState(DataOutputStream out, NodeReferences state)
-            throws IOException {
-        // references
-        Collection<PropertyId> c = state.getReferences();
-        out.writeInt(c.size() | (VERSION_CURRENT << 24)); // count
-        for (Iterator<PropertyId> iter = c.iterator(); iter.hasNext();) {
-            PropertyId propId = iter.next();
-            writePropertyId(out, propId);
-        }
-    }
-
-    /**
      * Deserializes a <code>NodeState</code> from the data input stream.
      *
      * @param in the input streaam
@@ -286,33 +243,33 @@
     }
 
     /**
-     * Deserializes a UUID
+     * Deserializes a node identifier
      * @param in the input stream
-     * @return the uuid
+     * @return the node id
      * @throws IOException in an I/O error occurs.
      */
-    public UUID readUUID(DataInputStream in) throws IOException {
+    public NodeId readNodeId(DataInputStream in) throws IOException {
         if (in.readBoolean()) {
             byte[] bytes = new byte[16];
             in.readFully(bytes);
-            return new UUID(bytes);
+            return new NodeId(bytes);
         } else {
             return null;
         }
     }
 
     /**
-     * Serializes a UUID
+     * Serializes a node identifier
      * @param out the output stream
-     * @param uuid the uuid
+     * @param uuid the node id
      * @throws IOException in an I/O error occurs.
      */
-    public void writeUUID(DataOutputStream out, String uuid) throws IOException {
-        if (uuid == null) {
+    public void writeNodeId(DataOutputStream out, String id) throws IOException {
+        if (id == null) {
             out.writeBoolean(false);
         } else {
             out.writeBoolean(true);
-            out.write(UUID.fromString(uuid).getRawBytes());
+            out.write(new NodeId(id).getRawBytes());
         }
     }
 
@@ -360,7 +317,7 @@
             while (pos < 16) {
                 pos += in.read(bytes, pos, 16 - pos);
             }
-            return new NodeId(new UUID(bytes));
+            return new NodeId(bytes);
         } else {
             return null;
         }
@@ -377,22 +334,7 @@
             out.writeBoolean(false);
         } else {
             out.writeBoolean(true);
-            out.write(id.getUUID().getRawBytes());
-        }
-    }
-
-    /**
-     * Serializes a UUID
-     * @param out the output stream
-     * @param uuid the uuid
-     * @throws IOException in an I/O error occurs.
-     */
-    public void writeUUID(DataOutputStream out, UUID uuid) throws IOException {
-        if (uuid == null) {
-            out.writeBoolean(false);
-        } else {
-            out.writeBoolean(true);
-            out.write(uuid.getRawBytes());
+            out.write(id.getRawBytes());
         }
     }
 
@@ -489,8 +431,9 @@
      * @throws IOException in an I/O error occurs.
      */
     public PropertyId readPropertyId(DataInputStream in) throws IOException {
-        UUID uuid = readUUID(in);
+        NodeId id = readNodeId(in);
         Name name = readQName(in);
-        return new PropertyId(new NodeId(uuid), name);
+        return new PropertyId(id, name);
     }
+
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/LRUNodeIdCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/LRUNodeIdCache.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/LRUNodeIdCache.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/LRUNodeIdCache.java Mon Jul 13 15:55:55 2009
@@ -17,7 +17,7 @@
 package org.apache.jackrabbit.core.persistence.bundle.util;
 
 import org.apache.commons.collections.map.LinkedMap;
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java Mon Jul 13 15:55:55 2009
@@ -25,8 +25,8 @@
 
 import javax.jcr.PropertyType;
 
-import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.persistence.PersistenceManager;
 import org.apache.jackrabbit.core.persistence.util.BLOBStore;
 import org.apache.jackrabbit.core.value.InternalValue;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java Mon Jul 13 15:55:55 2009
@@ -17,8 +17,8 @@
 package org.apache.jackrabbit.core.persistence.db;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.local.LocalFileSystem;
 import org.apache.jackrabbit.core.persistence.AbstractPersistenceManager;
@@ -31,7 +31,6 @@
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.NodeReferences;
-import org.apache.jackrabbit.core.state.NodeReferencesId;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.value.InternalValue;
@@ -560,7 +559,7 @@
     /**
      * {@inheritDoc}
      */
-    public NodeReferences load(NodeReferencesId targetId)
+    public NodeReferences loadReferencesTo(NodeId targetId)
             throws NoSuchItemStateException, ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
@@ -612,7 +611,7 @@
         }
 
         // check if insert or update
-        boolean update = exists(refs.getId());
+        boolean update = existsReferencesTo(refs.getTargetId());
         String sql = (update) ? nodeReferenceUpdateSQL : nodeReferenceInsertSQL;
 
         try {
@@ -623,12 +622,12 @@
 
             // we are synchronized on this instance, therefore we do not
             // not have to additionally synchronize on the sql statement
-            executeStmt(sql, new Object[]{out.toByteArray(), refs.getId().toString()});
+            executeStmt(sql, new Object[]{out.toByteArray(), refs.getTargetId().toString()});
 
             // there's no need to close a ByteArrayOutputStream
             //out.close();
         } catch (Exception e) {
-            String msg = "failed to write node references: " + refs.getId();
+            String msg = "failed to write " + refs;
             log.error(msg, e);
             throw new ItemStateException(msg, e);
         }
@@ -646,9 +645,9 @@
         try {
             // we are synchronized on this instance, therefore we do not
             // not have to additionally synchronize on the sql statement
-            executeStmt(nodeReferenceDeleteSQL, new Object[]{refs.getId().toString()});
+            executeStmt(nodeReferenceDeleteSQL, new Object[]{refs.getTargetId().toString()});
         } catch (Exception e) {
-            String msg = "failed to delete node references: " + refs.getId();
+            String msg = "failed to delete " + refs;
             log.error(msg, e);
             throw new ItemStateException(msg, e);
         }
@@ -710,7 +709,7 @@
     /**
      * {@inheritDoc}
      */
-    public boolean exists(NodeReferencesId targetId) throws ItemStateException {
+    public boolean existsReferencesTo(NodeId targetId) throws ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
@@ -1018,7 +1017,7 @@
                     // Skip comments and empty lines
                     if (!sql.startsWith("#") && sql.length() > 0) {
                         // replace prefix variable
-                        sql = Text.replace(sql, SCHEMA_OBJECT_PREFIX_VARIABLE, schemaObjectPrefix);
+                        sql = createSchemaSql(sql);
                         // execute sql stmt
                         stmt.executeUpdate(sql);
                     }
@@ -1035,6 +1034,17 @@
     }
 
     /**
+     * Replace wildcards and return the expanded SQL statement.
+     *
+     * @param sql The SQL with embedded wildcards.
+     * @return The SQL with no wildcards present.
+     */
+    protected String createSchemaSql(String sql) {
+       // replace prefix variable
+        return Text.replace(sql, SCHEMA_OBJECT_PREFIX_VARIABLE, schemaObjectPrefix);
+    }
+
+    /**
      * Returns an input stream to the schema DDL resource.
      * @return an input stream to the schema DDL resource.
      */

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/OraclePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/OraclePersistenceManager.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/OraclePersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/OraclePersistenceManager.java Mon Jul 13 15:55:55 2009
@@ -88,7 +88,7 @@
      */
     private static Logger log = LoggerFactory.getLogger(OraclePersistenceManager.class);
 
-    private Class blobClass;
+    private Class<?> blobClass;
     private Integer durationSessionConstant;
     private Integer modeReadWriteConstant;
 
@@ -252,7 +252,7 @@
         }
 
         // check if insert or update
-        boolean update = exists(refs.getId());
+        boolean update = existsReferencesTo(refs.getTargetId());
         String sql = (update) ? nodeReferenceUpdateSQL : nodeReferenceInsertSQL;
 
         Blob blob = null;
@@ -265,12 +265,12 @@
             // we are synchronized on this instance, therefore we do not
             // not have to additionally synchronize on the sql statement
             blob = createTemporaryBlob(new ByteArrayInputStream(out.toByteArray()));
-            executeStmt(sql, new Object[]{blob, refs.getId().toString()});
+            executeStmt(sql, new Object[]{blob, refs.getTargetId().toString()});
 
             // there's no need to close a ByteArrayOutputStream
             //out.close();
         } catch (Exception e) {
-            String msg = "failed to write node references: " + refs.getId();
+            String msg = "failed to write " + refs;
             log.error(msg, e);
             throw new ItemStateException(msg, e);
         } finally {
@@ -376,7 +376,7 @@
         open.invoke(blob, new Object[]{modeReadWriteConstant});
         Method getBinaryOutputStream =
                 blobClass.getMethod("getBinaryOutputStream", new Class[0]);
-        OutputStream out = (OutputStream) getBinaryOutputStream.invoke(blob, null);
+        OutputStream out = (OutputStream) getBinaryOutputStream.invoke(blob);
         try {
             IOUtils.copy(in, out);
         } finally {
@@ -387,7 +387,7 @@
             out.close();
         }
         Method close = blobClass.getMethod("close", new Class[0]);
-        close.invoke(blob, null);
+        close.invoke(blob);
         return (Blob) blob;
     }
 
@@ -397,7 +397,7 @@
     protected void freeTemporaryBlob(Object blob) throws Exception {
         // blob.freeTemporary();
         Method freeTemporary = blobClass.getMethod("freeTemporary", new Class[0]);
-        freeTemporary.invoke(blob, null);
+        freeTemporary.invoke(blob);
     }
 
     //--------------------------------------------------------< inner classes >

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/SimpleDbPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/SimpleDbPersistenceManager.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/SimpleDbPersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/SimpleDbPersistenceManager.java Mon Jul 13 15:55:55 2009
@@ -96,6 +96,18 @@
  *       &lt;param name="externalBLOBs" value="false"/&gt;
  *   &lt;/PersistenceManager&gt;
  * </pre>
+ * The following is a fragment from a sample configuration using Ingres:
+ * <pre>
+ *   &lt;PersistenceManager class="org.apache.jackrabbit.core.persistence.db.SimpleDbPersistenceManager"&gt;
+ *       &lt;param name="driver" value="com.ingres.jdbc.IngresDriver"/&gt;
+ *       &lt;param name="url" value="jdbc:ingres://localhost:II7/test"/&gt;
+ *       &lt;param name="schema" value="ingres"/&gt;
+ *       &lt;param name="user" value="ingres"/&gt;
+ *       &lt;param name="password" value="ingres"/&gt;
+ *       &lt;param name="schemaObjectPrefix" value="${wsp.name}_"/&gt;
+ *       &lt;param name="externalBLOBs" value="false"/&gt;
+ *   &lt;/PersistenceManager&gt;
+ * </pre>
  * The following is a fragment from a sample configuration using PostgreSQL:
  * <pre>
  *   &lt;PersistenceManager class="org.apache.jackrabbit.core.persistence.db.SimpleDbPersistenceManager"&gt;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/mem/InMemPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/mem/InMemPersistenceManager.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/mem/InMemPersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/mem/InMemPersistenceManager.java Mon Jul 13 15:55:55 2009
@@ -16,9 +16,9 @@
  */
 package org.apache.jackrabbit.core.persistence.mem;
 
-import org.apache.jackrabbit.core.ItemId;
-import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.id.ItemId;
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemPathUtil;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
@@ -29,7 +29,6 @@
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.NodeReferences;
-import org.apache.jackrabbit.core.state.NodeReferencesId;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore;
@@ -72,7 +71,7 @@
     protected boolean initialized;
 
     protected Map<ItemId, byte[]> stateStore;
-    protected Map<NodeReferencesId, byte[]> refsStore;
+    protected Map<NodeId, byte[]> refsStore;
 
     // initial size of buffer used to serialize objects
     protected static final int INITIAL_BUFFER_SIZE = 1024;
@@ -214,7 +213,7 @@
             int n = in.readInt();   // number of entries
             while (n-- > 0) {
                 String s = in.readUTF();    // target id
-                NodeReferencesId id = NodeReferencesId.valueOf(s);
+                NodeId id = NodeId.valueOf(s);
                 int length = in.readInt();  // data length
                 byte[] data = new byte[length];
                 in.readFully(data);  // data
@@ -266,7 +265,7 @@
         try {
             out.writeInt(refsStore.size()); // number of entries
             // entries
-            for (NodeReferencesId id : refsStore.keySet()) {
+            for (NodeId id : refsStore.keySet()) {
                 out.writeUTF(id.toString());    // target id
                 byte[] data = refsStore.get(id);
                 out.writeInt(data.length);  // data length
@@ -287,7 +286,7 @@
         }
 
         stateStore = new HashMap<ItemId, byte[]>(initialCapacity, loadFactor);
-        refsStore = new HashMap<NodeReferencesId, byte[]>(initialCapacity, loadFactor);
+        refsStore = new HashMap<NodeId, byte[]>(initialCapacity, loadFactor);
 
         wspFS = context.getFileSystem();
 
@@ -492,7 +491,7 @@
     /**
      * {@inheritDoc}
      */
-    public synchronized NodeReferences load(NodeReferencesId id)
+    public synchronized NodeReferences loadReferencesTo(NodeId id)
             throws NoSuchItemStateException, ItemStateException {
 
         if (!initialized) {
@@ -531,11 +530,11 @@
             Serializer.serialize(refs, out);
 
             // store in serialized format in map for better memory efficiency
-            refsStore.put(refs.getId(), out.toByteArray());
+            refsStore.put(refs.getTargetId(), out.toByteArray());
             // there's no need to close a ByteArrayOutputStream
             //out.close();
         } catch (Exception e) {
-            String msg = "failed to store references: " + refs.getId();
+            String msg = "failed to store " + refs;
             log.debug(msg);
             throw new ItemStateException(msg, e);
         }
@@ -550,7 +549,7 @@
         }
 
         // remove node references
-        refsStore.remove(refs.getId());
+        refsStore.remove(refs.getTargetId());
     }
 
     /**
@@ -576,7 +575,7 @@
     /**
      * {@inheritDoc}
      */
-    public boolean exists(NodeReferencesId id) throws ItemStateException {
+    public boolean existsReferencesTo(NodeId id) throws ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/obj/ObjectPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/obj/ObjectPersistenceManager.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/obj/ObjectPersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/obj/ObjectPersistenceManager.java Mon Jul 13 15:55:55 2009
@@ -16,8 +16,8 @@
  */
 package org.apache.jackrabbit.core.persistence.obj;
 
-import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.fs.BasedFileSystem;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
@@ -31,7 +31,6 @@
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.NodeReferences;
-import org.apache.jackrabbit.core.state.NodeReferencesId;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.value.InternalValue;
@@ -82,7 +81,7 @@
 
     private static String buildNodeFolderPath(NodeId id) {
         StringBuffer sb = new StringBuffer();
-        char[] chars = id.getUUID().toString().toCharArray();
+        char[] chars = id.toString().toCharArray();
         int cnt = 0;
         for (int i = 0; i < chars.length; i++) {
             if (chars[i] == '-') {
@@ -124,8 +123,8 @@
         return buildNodeFolderPath(id) + FileSystem.SEPARATOR + NODEFILENAME;
     }
 
-    private static String buildNodeReferencesFilePath(NodeReferencesId id) {
-        return buildNodeFolderPath(id.getTargetId()) + FileSystem.SEPARATOR + NODEREFSFILENAME;
+    private static String buildNodeReferencesFilePath(NodeId id) {
+        return buildNodeFolderPath(id) + FileSystem.SEPARATOR + NODEREFSFILENAME;
     }
 
     //---------------------------------------------------< PersistenceManager >
@@ -205,7 +204,7 @@
                 Serializer.deserialize(state, in);
                 return state;
             } catch (Exception e) {
-                String msg = "failed to read node state: " + id.getUUID();
+                String msg = "failed to read node state: " + id;
                 log.debug(msg);
                 throw new ItemStateException(msg, e);
             } finally {
@@ -259,7 +258,7 @@
     /**
      * {@inheritDoc}
      */
-    public synchronized NodeReferences load(NodeReferencesId id)
+    public synchronized NodeReferences loadReferencesTo(NodeId id)
             throws NoSuchItemStateException, ItemStateException {
 
         if (!initialized) {
@@ -355,7 +354,7 @@
             throw new IllegalStateException("not initialized");
         }
 
-        String refsFilePath = buildNodeReferencesFilePath(refs.getId());
+        String refsFilePath = buildNodeReferencesFilePath(refs.getTargetId());
         FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath);
         try {
             refsFile.makeParentDirs();
@@ -366,7 +365,7 @@
                 out.close();
             }
         } catch (Exception e) {
-            String msg = "failed to store references: " + refs.getId();
+            String msg = "failed to store " + refs;
             log.debug(msg);
             throw new ItemStateException(msg, e);
         }
@@ -435,7 +434,7 @@
             throw new IllegalStateException("not initialized");
         }
 
-        String refsFilePath = buildNodeReferencesFilePath(refs.getId());
+        String refsFilePath = buildNodeReferencesFilePath(refs.getTargetId());
         FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath);
         try {
             if (refsFile.exists()) {
@@ -443,7 +442,7 @@
                 refsFile.delete(true);
             }
         } catch (FileSystemException fse) {
-            String msg = "failed to delete node references: " + refs.getId();
+            String msg = "failed to delete " + refs;
             log.debug(msg);
             throw new ItemStateException(msg, fse);
         }
@@ -490,7 +489,7 @@
     /**
      * {@inheritDoc}
      */
-    public synchronized boolean exists(NodeReferencesId id)
+    public synchronized boolean existsReferencesTo(NodeId id)
             throws ItemStateException {
 
         if (!initialized) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BLOBStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BLOBStore.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BLOBStore.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BLOBStore.java Mon Jul 13 15:55:55 2009
@@ -16,7 +16,7 @@
  */
 package org.apache.jackrabbit.core.persistence.util;
 
-import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.id.PropertyId;
 
 import java.io.InputStream;
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/FileSystemBLOBStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/FileSystemBLOBStore.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/FileSystemBLOBStore.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/FileSystemBLOBStore.java Mon Jul 13 15:55:55 2009
@@ -17,7 +17,7 @@
 package org.apache.jackrabbit.core.persistence.util;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemPathUtil;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
@@ -55,7 +55,7 @@
         // the blobId is an absolute file system path
         StringBuffer sb = new StringBuffer();
         sb.append(FileSystem.SEPARATOR_CHAR);
-        char[] chars = id.getParentId().getUUID().toString().toCharArray();
+        char[] chars = id.getParentId().toString().toCharArray();
         int cnt = 0;
         for (int i = 0; i < chars.length; i++) {
             if (chars[i] == '-') {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java Mon Jul 13 15:55:55 2009
@@ -17,8 +17,8 @@
 package org.apache.jackrabbit.core.persistence.util;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
 import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.core.nodetype.PropDefId;
@@ -80,7 +80,7 @@
         if (state.getParentId() == null) {
             out.write(NULL_UUID_PLACEHOLDER_BYTES);
         } else {
-            out.write(state.getParentId().getUUID().getRawBytes());
+            out.write(state.getParentId().getRawBytes());
         }
         // definitionId
         out.writeUTF(state.getDefinitionId().toString());
@@ -105,7 +105,7 @@
         for (Iterator<ChildNodeEntry> iter = collChildren.iterator(); iter.hasNext();) {
             ChildNodeEntry entry = iter.next();
             out.writeUTF(entry.getName().toString());   // name
-            out.write(entry.getId().getUUID().getRawBytes());    // uuid
+            out.write(entry.getId().getRawBytes());    // uuid
         }
     }
 
@@ -129,7 +129,7 @@
         byte[] uuidBytes = new byte[UUID.UUID_BYTE_LENGTH];
         in.readFully(uuidBytes);
         if (!Arrays.equals(uuidBytes, NULL_UUID_PLACEHOLDER_BYTES)) {
-            state.setParentId(new NodeId(new UUID(uuidBytes)));
+            state.setParentId(new NodeId(uuidBytes));
         }
         // definitionId
         s = in.readUTF();
@@ -157,7 +157,7 @@
             Name name = NameFactoryImpl.getInstance().create(in.readUTF());    // name
             // uuid
             in.readFully(uuidBytes);
-            state.addChildNodeEntry(name, new NodeId(new UUID(uuidBytes)));
+            state.addChildNodeEntry(name, new NodeId(uuidBytes));
         }
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java Mon Jul 13 15:55:55 2009
@@ -17,8 +17,8 @@
 package org.apache.jackrabbit.core.persistence.xml;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.fs.BasedFileSystem;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
@@ -30,7 +30,6 @@
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.NodeReferences;
-import org.apache.jackrabbit.core.state.NodeReferencesId;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.persistence.PMContext;
 import org.apache.jackrabbit.core.state.PropertyState;
@@ -60,7 +59,6 @@
 import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Set;
 
 /**
@@ -169,7 +167,7 @@
      */
     private String buildNodeFolderPath(NodeId id) {
         StringBuffer sb = new StringBuffer();
-        char[] chars = id.getUUID().toString().toCharArray();
+        char[] chars = id.toString().toCharArray();
         int cnt = 0;
         for (int i = 0; i < nodePathTemplate.length(); i++) {
             char ch = nodePathTemplate.charAt(i);
@@ -210,8 +208,8 @@
         return buildNodeFolderPath(id) + "/" + NODEFILENAME;
     }
 
-    private String buildNodeReferencesFilePath(NodeReferencesId id) {
-        return buildNodeFolderPath(id.getTargetId()) + "/" + NODEREFSFILENAME;
+    private String buildNodeReferencesFilePath(NodeId id) {
+        return buildNodeFolderPath(id) + "/" + NODEREFSFILENAME;
     }
 
     private void readState(DOMWalker walker, NodeState state)
@@ -224,7 +222,7 @@
             throw new ItemStateException(msg);
         }
         // check uuid
-        if (!state.getNodeId().getUUID().toString().equals(walker.getAttribute(UUID_ATTRIBUTE))) {
+        if (!state.getNodeId().toString().equals(walker.getAttribute(UUID_ATTRIBUTE))) {
             String msg = "invalid serialized state: uuid mismatch";
             log.debug(msg);
             throw new ItemStateException(msg);
@@ -255,7 +253,7 @@
 
         // mixin types
         if (walker.enterElement(MIXINTYPES_ELEMENT)) {
-            Set mixins = new HashSet();
+            Set<Name> mixins = new HashSet<Name>();
             while (walker.iterateElements(MIXINTYPE_ELEMENT)) {
                 mixins.add(factory.create(walker.getAttribute(NAME_ATTRIBUTE)));
             }
@@ -335,7 +333,7 @@
         state.setModCount(Short.parseShort(modCount));
 
         // values
-        ArrayList values = new ArrayList();
+        ArrayList<InternalValue> values = new ArrayList<InternalValue>();
         if (walker.enterElement(VALUES_ELEMENT)) {
             while (walker.iterateElements(VALUE_ELEMENT)) {
                 // read serialized value
@@ -395,7 +393,7 @@
             throw new ItemStateException(msg);
         }
         // check targetId
-        if (!refs.getId().equals(NodeReferencesId.valueOf(walker.getAttribute(TARGETID_ATTRIBUTE)))) {
+        if (!refs.getTargetId().equals(NodeId.valueOf(walker.getAttribute(TARGETID_ATTRIBUTE)))) {
             String msg = "invalid serialized state: targetId  mismatch";
             log.debug(msg);
             throw new ItemStateException(msg);
@@ -563,30 +561,27 @@
                     writer = new BufferedWriter(osw);
                 }
 
-                String parentId = (state.getParentId() == null) ? "" : state.getParentId().getUUID().toString();
+                String parentId = (state.getParentId() == null) ? "" : state.getParentId().toString();
                 String encodedNodeType = Text.encodeIllegalXMLCharacters(state.getNodeTypeName().toString());
                 writer.write("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>\n");
                 writer.write("<" + NODE_ELEMENT + " "
-                        + UUID_ATTRIBUTE + "=\"" + id.getUUID() + "\" "
+                        + UUID_ATTRIBUTE + "=\"" + id + "\" "
                         + PARENTUUID_ATTRIBUTE + "=\"" + parentId + "\" "
-                        + DEFINITIONID_ATTRIBUTE + "=\"" + state.getDefinitionId().toString() + "\" "
+                        + DEFINITIONID_ATTRIBUTE + "=\"" + state.getDefinitionId() + "\" "
                         + MODCOUNT_ATTRIBUTE + "=\"" + state.getModCount() + "\" "
                         + NODETYPE_ATTRIBUTE + "=\"" + encodedNodeType + "\">\n");
 
                 // mixin types
                 writer.write("\t<" + MIXINTYPES_ELEMENT + ">\n");
-                Iterator iter = state.getMixinTypeNames().iterator();
-                while (iter.hasNext()) {
+                for (Name mixin : state.getMixinTypeNames()) {
                     writer.write("\t\t<" + MIXINTYPE_ELEMENT + " "
-                            + NAME_ATTRIBUTE + "=\"" + Text.encodeIllegalXMLCharacters(iter.next().toString()) + "\"/>\n");
+                            + NAME_ATTRIBUTE + "=\"" + Text.encodeIllegalXMLCharacters(mixin.toString()) + "\"/>\n");
                 }
                 writer.write("\t</" + MIXINTYPES_ELEMENT + ">\n");
 
                 // properties
                 writer.write("\t<" + PROPERTIES_ELEMENT + ">\n");
-                iter = state.getPropertyNames().iterator();
-                while (iter.hasNext()) {
-                    Name propName = (Name) iter.next();
+                for (Name propName : state.getPropertyNames()) {
                     writer.write("\t\t<" + PROPERTY_ELEMENT + " "
                             + NAME_ATTRIBUTE + "=\"" + Text.encodeIllegalXMLCharacters(propName.toString()) + "\">\n");
                     // @todo serialize type, definition id and values
@@ -596,12 +591,10 @@
 
                 // child nodes
                 writer.write("\t<" + NODES_ELEMENT + ">\n");
-                iter = state.getChildNodeEntries().iterator();
-                while (iter.hasNext()) {
-                    ChildNodeEntry entry = (ChildNodeEntry) iter.next();
+                for (ChildNodeEntry entry : state.getChildNodeEntries()) {
                     writer.write("\t\t<" + NODE_ELEMENT + " "
                             + NAME_ATTRIBUTE + "=\"" + Text.encodeIllegalXMLCharacters(entry.getName().toString()) + "\" "
-                            + UUID_ATTRIBUTE + "=\"" + entry.getId().getUUID().toString() + "\">\n");
+                            + UUID_ATTRIBUTE + "=\"" + entry.getId() + "\">\n");
                     writer.write("\t\t</" + NODE_ELEMENT + ">\n");
                 }
                 writer.write("\t</" + NODES_ELEMENT + ">\n");
@@ -655,7 +648,7 @@
                 writer.write("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>\n");
                 writer.write("<" + PROPERTY_ELEMENT + " "
                         + NAME_ATTRIBUTE + "=\"" + Text.encodeIllegalXMLCharacters(state.getName().toString()) + "\" "
-                        + PARENTUUID_ATTRIBUTE + "=\"" + state.getParentId().getUUID() + "\" "
+                        + PARENTUUID_ATTRIBUTE + "=\"" + state.getParentId() + "\" "
                         + MULTIVALUED_ATTRIBUTE + "=\"" + Boolean.toString(state.isMultiValued()) + "\" "
                         + DEFINITIONID_ATTRIBUTE + "=\"" + state.getDefinitionId().toString() + "\" "
                         + MODCOUNT_ATTRIBUTE + "=\"" + state.getModCount() + "\" "
@@ -780,7 +773,7 @@
     /**
      * {@inheritDoc}
      */
-    public synchronized NodeReferences load(NodeReferencesId id)
+    public synchronized NodeReferences loadReferencesTo(NodeId id)
             throws NoSuchItemStateException, ItemStateException {
 
         if (!initialized) {
@@ -824,8 +817,7 @@
             throw new IllegalStateException("not initialized");
         }
 
-        NodeReferencesId id = refs.getId();
-        String refsFilePath = buildNodeReferencesFilePath(id);
+        String refsFilePath = buildNodeReferencesFilePath(refs.getTargetId());
         FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath);
         try {
             refsFile.makeParentDirs();
@@ -843,11 +835,9 @@
                 }
                 writer.write("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>\n");
                 writer.write("<" + NODEREFERENCES_ELEMENT + " "
-                        + TARGETID_ATTRIBUTE + "=\"" + refs.getId() + "\">\n");
+                        + TARGETID_ATTRIBUTE + "=\"" + refs.getTargetId() + "\">\n");
                 // write references (i.e. the id's of the REFERENCE properties)
-                Iterator iter = refs.getReferences().iterator();
-                while (iter.hasNext()) {
-                    PropertyId propId = (PropertyId) iter.next();
+                for (PropertyId propId : refs.getReferences()) {
                     writer.write("\t<" + NODEREFERENCE_ELEMENT + " "
                             + PROPERTYID_ATTRIBUTE + "=\"" + propId + "\"/>\n");
                 }
@@ -856,7 +846,7 @@
                 writer.close();
             }
         } catch (Exception e) {
-            String msg = "failed to store references: " + id;
+            String msg = "failed to store " + refs;
             log.debug(msg);
             throw new ItemStateException(msg, e);
         }
@@ -870,8 +860,7 @@
             throw new IllegalStateException("not initialized");
         }
 
-        NodeReferencesId id = refs.getId();
-        String refsFilePath = buildNodeReferencesFilePath(id);
+        String refsFilePath = buildNodeReferencesFilePath(refs.getTargetId());
         FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath);
         try {
             if (refsFile.exists()) {
@@ -879,7 +868,7 @@
                 refsFile.delete(true);
             }
         } catch (FileSystemException fse) {
-            String msg = "failed to delete references: " + id;
+            String msg = "failed to delete " + refs;
             log.debug(msg);
             throw new ItemStateException(msg, fse);
         }
@@ -926,7 +915,7 @@
     /**
      * {@inheritDoc}
      */
-    public synchronized boolean exists(NodeReferencesId id)
+    public synchronized boolean existsReferencesTo(NodeId id)
             throws ItemStateException {
 
         if (!initialized) {



Mime
View raw message