jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1057220 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/ main/java/org/apache/jackrabbit/core/id/ main/java/org/apache/jackrabbit/core/persistence/bundle/ main/java/org/apache/jackrabbit/core/query/lucene/ ...
Date Mon, 10 Jan 2011 14:49:43 GMT
Author: thomasm
Date: Mon Jan 10 14:49:42 2011
New Revision: 1057220

URL: http://svn.apache.org/viewvc?rev=1057220&view=rev
Log:
JCR-2857 Support sequential (non-random) node ids

Added:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeIdFactory.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdFactoryTest.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeId.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/UpdatableItemStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionItemStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplConfig.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/PersistenceManagerTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cache/ConcurrentCacheTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/TestAll.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/util/BundleBindingTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IDFieldTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/SlowQueryHandler.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/AccessManagerTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/acl/EntryTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/AbstractISMLockingTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/ChangeLogTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueFactoryTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/xml/WorkspaceImporterTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java Mon Jan 10 14:49:42 2011
@@ -1099,8 +1099,7 @@ public class BatchedItemOperations exten
             throw new ItemExistsException(safeGetJCRPath(errorId));
         }
         if (id == null) {
-            // create new id
-            id = new NodeId();
+            id = context.getNodeIdFactory().newNodeId();
         }
         if (nodeTypeName == null) {
             // no primary node type specified,
@@ -1617,8 +1616,8 @@ public class BatchedItemOperations exten
                         sharedState.addShare(destParentId);
                         return sharedState;
                     }
-                    // always create new uuid
-                    id = new NodeId();
+                    // always create new node id
+                    id = context.getNodeIdFactory().newNodeId();
                     if (referenceable) {
                         // remember uuid mapping
                         refTracker.mappedId(srcState.getNodeId(), id);
@@ -1626,8 +1625,8 @@ public class BatchedItemOperations exten
                     break;
                 case CLONE:
                     if (!referenceable) {
-                        // non-referenceable node: always create new uuid
-                        id = new NodeId();
+                        // non-referenceable node: always create new node id
+                        id = context.getNodeIdFactory().newNodeId();
                         break;
                     }
                     // use same uuid as source node
@@ -1645,8 +1644,8 @@ public class BatchedItemOperations exten
                     break;
                 case CLONE_REMOVE_EXISTING:
                     if (!referenceable) {
-                        // non-referenceable node: always create new uuid
-                        id = new NodeId();
+                        // non-referenceable node: always create new node id
+                        id = context.getNodeIdFactory().newNodeId();
                         break;
                     }
                     // use same uuid as source node
@@ -1756,7 +1755,7 @@ public class BatchedItemOperations exten
             }
             // copy properties
             for (Name propName : srcState.getPropertyNames()) {
-                Path propPath = PathFactoryImpl.getInstance().create(srcPath, propName, true);                
+                Path propPath = PathFactoryImpl.getInstance().create(srcPath, propName, true);
                 PropertyId propId = new PropertyId(srcState.getNodeId(), propName);
                 if (!srcAccessMgr.canRead(propPath, propId)) {
                     continue;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java Mon Jan 10 14:49:42 2011
@@ -503,7 +503,7 @@ public class NodeImpl extends ItemImpl i
         NodeState nodeState;
         try {
             if (id == null) {
-                id = new NodeId();
+                id = sessionContext.getNodeIdFactory().newNodeId();
             }
             nodeState =
                     stateMgr.createTransientNodeState(id, nodeType.getQName(),

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java Mon Jan 10 14:49:42 2011
@@ -20,6 +20,7 @@ import org.apache.jackrabbit.core.cluste
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.NodeIdFactory;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.security.JackrabbitSecurityManager;
 import org.apache.jackrabbit.core.state.ItemStateCacheFactory;
@@ -90,6 +91,8 @@ public class RepositoryContext {
      */
     private ItemStateCacheFactory itemStateCacheFactory;
 
+    private NodeIdFactory nodeIdFactory;
+
     /**
      * Repository-wide timer instance.
      */
@@ -323,4 +326,12 @@ public class RepositoryContext {
         this.itemStateCacheFactory = itemStateCacheFactory;
     }
 
+    public void setNodeIdFactory(NodeIdFactory nodeIdFactory) {
+        this.nodeIdFactory = nodeIdFactory;
+    }
+
+    public NodeIdFactory getNodeIdFactory() {
+        return nodeIdFactory;
+    }
+
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java Mon Jan 10 14:49:42 2011
@@ -80,6 +80,7 @@ import org.apache.jackrabbit.core.fs.Fil
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
 import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.NodeIdFactory;
 import org.apache.jackrabbit.core.lock.LockManager;
 import org.apache.jackrabbit.core.lock.LockManagerImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
@@ -184,6 +185,8 @@ public class RepositoryImpl extends Abst
     // configuration of the repository
     protected final RepositoryConfig repConfig;
 
+    protected NodeIdFactory nodeIdFactory;
+
     /**
      * the delegating observation dispatcher for all workspaces
      */
@@ -303,6 +306,10 @@ public class RepositoryImpl extends Abst
                 context.setDataStore(dataStore);
             }
 
+            nodeIdFactory = new NodeIdFactory(repConfig.getHomeDir());
+            nodeIdFactory.open();
+            context.setNodeIdFactory(nodeIdFactory);
+
             context.setWorkspaceManager(new WorkspaceManager(this));
 
             // init workspace configs
@@ -391,7 +398,7 @@ public class RepositoryImpl extends Abst
                     // ensure this exception does not overlay the original
                     // startup exception and only log it
                     log.error("In addition to startup fail, another unexpected problem " +
-                    		"occurred while shutting down the repository again.", t);
+                            "occurred while shutting down the repository again.", t);
                 }
             }
         }
@@ -510,7 +517,8 @@ public class RepositoryImpl extends Abst
                 VERSION_STORAGE_NODE_ID,
                 ACTIVITIES_NODE_ID,
                 context.getItemStateCacheFactory(),
-                ismLocking);
+                ismLocking,
+                context.getNodeIdFactory());
     }
 
     /**
@@ -1138,6 +1146,12 @@ public class RepositoryImpl extends Abst
             log.error("error while closing repository file system", e);
         }
 
+        try {
+            nodeIdFactory.close();
+        } catch (RepositoryException e) {
+            log.error("error while closing repository file system", e);
+        }
+
         // make sure this instance is not used anymore
         disposed = true;
 
@@ -1377,7 +1391,8 @@ public class RepositoryImpl extends Abst
                 context.getNodeTypeRegistry(),
                 true,
                 context.getItemStateCacheFactory(),
-                locking);
+                locking,
+                context.getNodeIdFactory());
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeId.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeId.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeId.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeId.java Mon Jan 10 14:49:42 2011
@@ -160,22 +160,16 @@ public class NodeId implements ItemId, C
     }
 
     /**
-     * Creates a node identifier using the given random number generator.
-     *
-     * @param random random number generator
+     * Creates a random node identifier using a secure random number generator.
      */
-    public NodeId(Random random) {
-        this(   // Most significant 64 bits, with version field set to 4
+    public static NodeId randomId() {
+        Random random = SeededSecureRandom.getInstance();
+        return new NodeId(
+                // Most significant 64 bits, with version field set to 4
                 random.nextLong() & 0xFfffFfffFfff0fffL | 0x0000000000004000L,
                 // Least significant 64 bits, with variant field set to IETF
-                random.nextLong() & 0x3fffFfffFfffFfffL | 0x8000000000000000L);
-    }
-
-    /**
-     * Creates a random node identifier using a secure random number generator.
-     */
-    public NodeId() {
-        this(SeededSecureRandom.getInstance());
+                random.nextLong() & 0x3fffFfffFfffFfffL | 0x8000000000000000L
+            );
     }
 
     /**

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeIdFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeIdFactory.java?rev=1057220&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeIdFactory.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeIdFactory.java Mon Jan 10 14:49:42 2011
@@ -0,0 +1,128 @@
+/*
+ * 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.core.id;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Properties;
+import java.util.UUID;
+import javax.jcr.RepositoryException;
+
+/**
+ * A factory for creating new node ids.
+ */
+public class NodeIdFactory {
+
+    public final static String SEQUENTIAL_NODE_ID = "jackrabbit.sequentialNodeId";
+
+    private final static String NODE_ID_FILE = "nodeId.properties";
+    private final static String NODE_ID_FILE_TEMP = "nodeId.properties.temp";
+    private final static String MSB = "msb";
+    private final static String NEXT_LSB = "nextLsb";
+    private final static int DEFAULT_CACHE_SIZE = 128;
+
+    private final String repositoryHome;
+
+    private boolean createRandom;
+    private long msb;
+    private long nextLsb;
+    private long storedLsb;
+    private int cacheSize = DEFAULT_CACHE_SIZE;
+
+    public NodeIdFactory(String repositoryHome) {
+        this.repositoryHome = repositoryHome;
+    }
+
+    public void setCacheSize(int cacheSize) {
+        this.cacheSize = cacheSize;
+    }
+
+    public void open() throws RepositoryException {
+        String seq = System.getProperty(SEQUENTIAL_NODE_ID);
+        if (seq == null) {
+            createRandom = true;
+            return;
+        }
+        try {
+            File n = new File(repositoryHome, NODE_ID_FILE);
+            if (!n.exists()) {
+                File temp = new File(repositoryHome, NODE_ID_FILE_TEMP);
+                if (temp.exists()) {
+                    temp.renameTo(n);
+                } else {
+                    n.getParentFile().mkdirs();
+                    n.createNewFile();
+                }
+            }
+            Properties p = new Properties();
+            p.load(new FileReader(n));
+            String defaultMsb = "", defaultLsb = "0";
+            int index = seq.indexOf("/");
+            if (index >= 0) {
+                defaultMsb = seq.substring(0, index);
+                defaultLsb = seq.substring(index + 1);
+            }
+            String m = p.getProperty(MSB, defaultMsb);
+            if (m.length() == 0) {
+                msb = UUID.randomUUID().getLeastSignificantBits();
+                // ensure it doesn't conflict with version 1-5 UUIDs
+                msb &= ~0xf000;
+            } else {
+                msb = Long.parseLong(m, 16);
+            }
+            storedLsb = nextLsb = Long.parseLong(p.getProperty(NEXT_LSB, defaultLsb), 16);
+        } catch (Exception e) {
+            throw new RepositoryException("Could not open node id factory", e);
+        }
+    }
+
+    public void close() throws RepositoryException {
+        if (!createRandom) {
+            store(nextLsb);
+        }
+    }
+
+    private void store(long lsb) throws RepositoryException {
+        this.storedLsb = lsb;
+        Properties p = new Properties();
+        p.setProperty(MSB, Long.toHexString(msb));
+        p.setProperty(NEXT_LSB, Long.toHexString(lsb));
+        try {
+            File temp = new File(repositoryHome, NODE_ID_FILE_TEMP);
+            p.store(new FileWriter(temp), null);
+            File n = new File(repositoryHome, NODE_ID_FILE);
+            n.delete();
+            temp.renameTo(n);
+        } catch (IOException e) {
+            throw new RepositoryException("Could not store next node id", e);
+        }
+    }
+
+    public NodeId newNodeId() throws RepositoryException {
+        if (createRandom) {
+            return NodeId.randomId();
+        }
+        long lsb = nextLsb++;
+        if (lsb >= storedLsb) {
+            store(lsb + cacheSize);
+        }
+        return new NodeId(msb, lsb);
+    }
+
+}

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java Mon Jan 10 14:49:42 2011
@@ -101,7 +101,7 @@ public abstract class AbstractBundlePers
 
     /** Sentinel instance used to mark a non-existent bundle in the cache */
     private static final NodePropBundle MISSING =
-        new NodePropBundle(new NodeId());
+        new NodePropBundle(NodeId.randomId());
 
     /** the index for namespaces */
     private StringIndex nsIndex;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java Mon Jan 10 14:49:42 2011
@@ -1645,7 +1645,7 @@ public class MultiIndex {
          */
         private static final int ENTRY_LENGTH =
             Long.toString(Long.MAX_VALUE).length() + Action.ADD_NODE.length()
-            + new NodeId().toString().length() + 2;
+            + new NodeId(0, 0).toString().length() + 2;
 
         /**
          * The id of the node to add.
@@ -1928,7 +1928,7 @@ public class MultiIndex {
          */
         private static final int ENTRY_LENGTH =
             Long.toString(Long.MAX_VALUE).length() + Action.DELETE_NODE.length()
-            + new NodeId().toString().length() + 2;
+            + new NodeId(0, 0).toString().length() + 2;
 
         /**
          * The id of the node to remove.

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java Mon Jan 10 14:49:42 2011
@@ -30,6 +30,7 @@ import org.apache.jackrabbit.core.Worksp
 import org.apache.jackrabbit.core.config.WorkspaceConfig;
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.NodeIdFactory;
 import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.observation.ObservationManagerImpl;
@@ -286,6 +287,10 @@ public class SessionContext implements N
         this.observationManager = observationManager;
     }
 
+    public NodeIdFactory getNodeIdFactory() {
+        return repositoryContext.getNodeIdFactory();
+    }
+
     //--------------------------------------------------------< NameResolver >
 
     public Name getQName(String name)

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java Mon Jan 10 14:49:42 2011
@@ -20,6 +20,7 @@ import javax.jcr.ReferentialIntegrityExc
 
 import org.apache.jackrabbit.core.id.ItemId;
 import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.NodeIdFactory;
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.observation.EventStateCollectionFactory;
 import org.apache.jackrabbit.spi.Name;
@@ -76,8 +77,8 @@ public class LocalItemStateManager
 
     /**
      * Creates a new {@code LocalItemStateManager} instance and registers it as an {@link ItemStateListener}
-     * with the given {@link SharedItemStateManager}. 
-     * 
+     * with the given {@link SharedItemStateManager}.
+     *
      * @param sharedStateMgr the {@link SharedItemStateManager}
      * @param factory the {@link EventStateCollectionFactory}
      * @param cacheFactory the {@link ItemStateCacheFactory}
@@ -548,4 +549,9 @@ public class LocalItemStateManager
     public void nodeRemoved(NodeState state, Name name, int index, NodeId id) {
         dispatcher.notifyNodeRemoved(state, name, index, id);
     }
+
+    public NodeIdFactory getNodeIdFactory() {
+        return sharedStateMgr.getNodeIdFactory();
+    }
+
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java Mon Jan 10 14:49:42 2011
@@ -37,6 +37,7 @@ import org.apache.jackrabbit.core.Hierar
 import org.apache.jackrabbit.core.ZombieHierarchyManager;
 import org.apache.jackrabbit.core.id.ItemId;
 import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.NodeIdFactory;
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.spi.Name;
 import org.slf4j.Logger;
@@ -479,7 +480,7 @@ public class SessionItemStateManager
                     // remove any descendant candidates
                     boolean skip = false;
                     for (Iterator<NodeId> it = candidateIds.iterator(); it.hasNext();) {
-                        NodeId id = it.next();    
+                        NodeId id = it.next();
                         if (nodeId.equals(id) || hierMgr.isAncestor(id, nodeId)) {
                             // already a candidate or a descendant thereof
                             // => skip
@@ -968,4 +969,9 @@ public class SessionItemStateManager
             return false;
         }
     }
+
+    public NodeIdFactory getNodeIdFactory() {
+        return stateMgr.getNodeIdFactory();
+    }
+
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java Mon Jan 10 14:49:42 2011
@@ -30,6 +30,7 @@ import org.apache.jackrabbit.core.Reposi
 import org.apache.jackrabbit.core.cluster.UpdateEventChannel;
 import org.apache.jackrabbit.core.id.ItemId;
 import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.NodeIdFactory;
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.nodetype.EffectiveNodeType;
 import org.apache.jackrabbit.core.nodetype.NodeTypeConflictException;
@@ -181,6 +182,8 @@ public class SharedItemStateManager
      */
     private UpdateEventChannel eventChannel;
 
+    private final NodeIdFactory nodeIdFactory;
+
     /**
      * Creates a new <code>SharedItemStateManager</code> instance.
      *
@@ -193,7 +196,8 @@ public class SharedItemStateManager
                                   NodeTypeRegistry ntReg,
                                   boolean usesReferences,
                                   ItemStateCacheFactory cacheFactory,
-                                  ISMLocking locking)
+                                  ISMLocking locking,
+                                  NodeIdFactory nodeIdFactory)
             throws ItemStateException {
         cache = new ItemStateReferenceCache(cacheFactory);
         this.persistMgr = persistMgr;
@@ -201,6 +205,7 @@ public class SharedItemStateManager
         this.usesReferences = usesReferences;
         this.rootNodeId = rootNodeId;
         this.ismLocking = locking;
+        this.nodeIdFactory = nodeIdFactory;
         // create root node state if it doesn't yet exist
         if (!hasNonVirtualItemState(rootNodeId)) {
             createRootNodeState(rootNodeId, ntReg);
@@ -1114,17 +1119,17 @@ public class SharedItemStateManager
         }
 
     }
-    
+
     /**
      * Validates the hierarchy consistency of the changes in the changelog.
-     * 
+     *
      * @param changeLog
      *            The local changelog the should be validated
      * @throws ItemStateException
      *             If the hierarchy changes are inconsistent.
      * @throws RepositoryException
      *             If the consistency could not be validated
-     * 
+     *
      */
     private void validateHierarchy(ChangeLog changeLog) throws ItemStateException, RepositoryException {
 
@@ -1140,7 +1145,7 @@ public class SharedItemStateManager
 
     /**
      * Checks the parents and children of all deleted node states in the changelog.
-     * 
+     *
      * @param changeLog
      *            The local changelog the should be validated
      * @throws ItemStateException
@@ -1210,7 +1215,7 @@ public class SharedItemStateManager
 
     /**
      * Checks the parents and children of all added node states in the changelog.
-     * 
+     *
      * @param changeLog
      *            The local changelog the should be validated
      * @throws ItemStateException
@@ -1262,7 +1267,7 @@ public class SharedItemStateManager
 
     /**
      * Checks the parents and children of all modified node states in the changelog.
-     * 
+     *
      * @param changeLog
      *            The local changelog the should be validated
      * @throws ItemStateException
@@ -1371,7 +1376,7 @@ public class SharedItemStateManager
 
     /**
      * Check the consistency of a parent/child relationship.
-     * 
+     *
      * @param changeLog
      *            The changelog to check
      * @param childState
@@ -1417,7 +1422,7 @@ public class SharedItemStateManager
     /**
      * Determines whether the specified node is <i>shareable</i>, i.e. whether the mixin type <code>mix:shareable</code>
      * is either directly assigned or indirectly inherited.
-     * 
+     *
      * @param state
      *            node state to check
      * @return true if the specified node is <i>shareable</i>, false otherwise.
@@ -1441,7 +1446,7 @@ public class SharedItemStateManager
             throw new RepositoryException(msg, ntce);
         }
     }
-    
+
     /**
      * Begin update operation. This will return an object that can itself be
      * ended/canceled.
@@ -1848,4 +1853,9 @@ public class SharedItemStateManager
             throw new ItemStateException("Interrupted while acquiring write lock");
         }
     }
+
+    public NodeIdFactory getNodeIdFactory() {
+        return this.nodeIdFactory;
+    }
+
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/UpdatableItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/UpdatableItemStateManager.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/UpdatableItemStateManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/UpdatableItemStateManager.java Mon Jan 10 14:49:42 2011
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.core.state
 
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.NodeIdFactory;
 
 import javax.jcr.ReferentialIntegrityException;
 
@@ -120,4 +121,7 @@ public interface UpdatableItemStateManag
      * Disposes this <code>UpdatableItemStateManager</code> and frees resources.
      */
     void dispose();
+
+    NodeIdFactory getNodeIdFactory();
+
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java Mon Jan 10 14:49:42 2011
@@ -354,7 +354,7 @@ class InternalVersionHistoryImpl extends
     public synchronized Name[] getVersionNames() {
         return nameCache.keySet().toArray(new Name[nameCache.size()]);
     }
-    
+
     /**
      * {@inheritDoc}
      */
@@ -563,7 +563,7 @@ class InternalVersionHistoryImpl extends
             predecessors = new InternalValue[]{InternalValue.create(last)};
         }
 
-        NodeId versionId = new NodeId();
+        NodeId versionId = vMgr.getNodeIdFactory().newNodeId();
         NodeStateEx vNode = node.addNode(name, NameConstants.NT_VERSION, versionId, true);
 
         // check for jcr:activity
@@ -619,7 +619,7 @@ class InternalVersionHistoryImpl extends
             NodeState nodeState, NodeId copiedFrom) throws RepositoryException {
 
         // create history node
-        NodeId historyId = new NodeId();
+        NodeId historyId = vMgr.getNodeIdFactory().newNodeId();
         NodeStateEx pNode = parent.addNode(name, NameConstants.NT_VERSIONHISTORY, historyId, true);
 
         // set the versionable uuid
@@ -635,7 +635,7 @@ class InternalVersionHistoryImpl extends
         }
 
         // create root version
-        NodeId versionId = new NodeId();
+        NodeId versionId = vMgr.getNodeIdFactory().newNodeId();
         NodeStateEx vNode = pNode.addNode(NameConstants.JCR_ROOTVERSION, NameConstants.NT_VERSION, versionId, true);
 
         // initialize 'created' and 'predecessors'

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java Mon Jan 10 14:49:42 2011
@@ -29,6 +29,7 @@ import javax.jcr.Session;
 import javax.jcr.version.VersionException;
 
 import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.NodeIdFactory;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.state.DefaultISMLocking;
 import org.apache.jackrabbit.core.state.ISMLocking.ReadLock;
@@ -76,12 +77,16 @@ abstract class InternalVersionManagerBas
      */
     private final DefaultISMLocking rwLock = new DefaultISMLocking();
 
+    private final NodeIdFactory nodeIdFactory;
+
     protected InternalVersionManagerBase(NodeTypeRegistry ntReg,
                                          NodeId historiesId,
-                                         NodeId activitiesId) {
+                                         NodeId activitiesId,
+                                         NodeIdFactory nodeIdFactory) {
         this.ntReg = ntReg;
         this.historiesId = historiesId;
         this.activitiesId = activitiesId;
+        this.nodeIdFactory = nodeIdFactory;
     }
 
 //-------------------------------------------------------< InternalVersionManager >
@@ -449,7 +454,7 @@ abstract class InternalVersionManagerBas
         WriteOperation operation = startWriteOperation();
         try {
             // create deep path
-            NodeId activityId = new NodeId();
+            NodeId activityId = nodeIdFactory.newNodeId();
             NodeStateEx parent = getParentNode(getActivitiesRoot(), activityId.toString(), NameConstants.REP_ACTIVITIES);
             Name name = getName(activityId.toString());
 
@@ -728,7 +733,7 @@ abstract class InternalVersionManagerBas
 
     /**
      * Set version label on the specified version.
-     * 
+     *
      * @param history version history
      * @param version version name
      * @param label version label
@@ -816,4 +821,9 @@ abstract class InternalVersionManagerBas
             throw new RepositoryException(e);
         }
     }
+
+    public NodeIdFactory getNodeIdFactory() {
+        return nodeIdFactory;
+    }
+
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java Mon Jan 10 14:49:42 2011
@@ -35,6 +35,7 @@ import org.apache.jackrabbit.core.cluste
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.id.ItemId;
 import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.NodeIdFactory;
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.observation.DelegatingObservationDispatcher;
@@ -120,7 +121,7 @@ public class InternalVersionManagerImpl 
      * Persistent root node of the activities.
      */
     private final NodeStateEx activitiesRoot;
-    
+
     /**
      * Map of returned items. this is kept for invalidating
      */
@@ -149,8 +150,9 @@ public class InternalVersionManagerImpl 
                               NodeId historiesId,
                               NodeId activitiesId,
                               ItemStateCacheFactory cacheFactory,
-                              ISMLocking ismLocking) throws RepositoryException {
-        super(ntReg, historiesId, activitiesId);
+                              ISMLocking ismLocking,
+                              NodeIdFactory nodeIdFactory) throws RepositoryException {
+        super(ntReg, historiesId, activitiesId, nodeIdFactory);
         try {
             this.pMgr = pMgr;
             this.fs = fs;
@@ -188,7 +190,7 @@ public class InternalVersionManagerImpl 
                 pMgr.store(cl);
             }
 
-            sharedStateMgr = createItemStateManager(pMgr, systemId, ntReg, cacheFactory, ismLocking);
+            sharedStateMgr = createItemStateManager(pMgr, systemId, ntReg, cacheFactory, ismLocking, nodeIdFactory);
 
             stateMgr = LocalItemStateManager.createInstance(sharedStateMgr, escFactory, cacheFactory);
             stateMgr.addListener(this);
@@ -572,9 +574,10 @@ public class InternalVersionManagerImpl 
                                                              NodeId rootId,
                                                              NodeTypeRegistry ntReg,
                                                              ItemStateCacheFactory cacheFactory,
-                                                             ISMLocking ismLocking)
+                                                             ISMLocking ismLocking,
+                                                             NodeIdFactory nodeIdFactory)
             throws ItemStateException {
-        return new VersionItemStateManager(pMgr, rootId, ntReg, cacheFactory, ismLocking);
+        return new VersionItemStateManager(pMgr, rootId, ntReg, cacheFactory, ismLocking, nodeIdFactory);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java Mon Jan 10 14:49:42 2011
@@ -115,7 +115,7 @@ public class InternalXAVersionManager ex
     public InternalXAVersionManager(InternalVersionManagerImpl vMgr, NodeTypeRegistry ntReg,
                             SessionImpl session, ItemStateCacheFactory cacheFactory)
             throws RepositoryException {
-        super(ntReg, vMgr.historiesId, vMgr.activitiesId);
+        super(ntReg, vMgr.historiesId, vMgr.activitiesId, vMgr.getNodeIdFactory());
         this.vMgr = vMgr;
         this.session = session;
         this.stateMgr = XAItemStateManager.createInstance(vMgr.getSharedStateMgr(),

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java Mon Jan 10 14:49:42 2011
@@ -557,7 +557,7 @@ public class NodeStateEx {
         NodeId parentId = nodeState.getNodeId();
         // create a new node state
         if (id == null) {
-            id = new NodeId();
+            id = stateMgr.getNodeIdFactory().newNodeId();
         }
         NodeState state = stateMgr.createNew(id, nodeTypeName, parentId);
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionItemStateManager.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionItemStateManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionItemStateManager.java Mon Jan 10 14:49:42 2011
@@ -22,6 +22,7 @@ import java.util.Set;
 import javax.jcr.ReferentialIntegrityException;
 
 import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.NodeIdFactory;
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.persistence.PersistenceManager;
@@ -55,9 +56,10 @@ public class VersionItemStateManager ext
                                    NodeId rootNodeId,
                                    NodeTypeRegistry ntReg,
                                    ItemStateCacheFactory cacheFactory,
-                                   ISMLocking locking)
+                                   ISMLocking locking,
+                                   NodeIdFactory nodeIdFactory)
             throws ItemStateException {
-        super(persistMgr, rootNodeId, ntReg, false, cacheFactory, locking);
+        super(persistMgr, rootNodeId, ntReg, false, cacheFactory, locking, nodeIdFactory);
         this.pMgr = persistMgr;
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplConfig.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplConfig.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplConfig.java Mon Jan 10 14:49:42 2011
@@ -181,7 +181,7 @@ abstract public class VersionManagerImpl
         Name name = InternalVersionManagerBase.getName(rootId.toString());
 
         if (configId == null) {
-            configId = new NodeId();
+            configId = context.getNodeIdFactory().newNodeId();
         }
         NodeStateEx config = configParent.addNode(name, NameConstants.NT_CONFIGURATION, configId, true);
         Set<Name> mix = new HashSet<Name>();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java Mon Jan 10 14:49:42 2011
@@ -319,12 +319,10 @@ public abstract class AbstractVISProvide
                                             NodeId id, Name nodeTypeName)
             throws RepositoryException {
 
+        assert id != null;
+
         // create a new node state
-        VirtualNodeState state;
-        if (id == null) {
-            id = new NodeId();
-        }
-        state = new VirtualNodeState(this, parent.getNodeId(), id, nodeTypeName, Name.EMPTY_ARRAY);
+        VirtualNodeState state = new VirtualNodeState(this, parent.getNodeId(), id, nodeTypeName, Name.EMPTY_ARRAY);
 
         cache(state);
         return state;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java Mon Jan 10 14:49:42 2011
@@ -74,7 +74,7 @@ public interface VirtualItemStateProvide
      *
      * @param parent
      * @param name
-     * @param id
+     * @param id (must not be null)
      * @param nodeTypeName
      * @return
      * @throws RepositoryException

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/PersistenceManagerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/PersistenceManagerTest.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/PersistenceManagerTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/PersistenceManagerTest.java Mon Jan 10 14:49:42 2011
@@ -46,9 +46,9 @@ import org.apache.jackrabbit.spi.commons
 
 public class PersistenceManagerTest extends TestCase {
 
-    private static final NodeId NODE_ID = new NodeId();
+    private static final NodeId NODE_ID = NodeId.randomId();
 
-    private static final NodeId CHILD_ID = new NodeId();
+    private static final NodeId CHILD_ID = NodeId.randomId();
 
     private static final Name TEST =
         NameFactoryImpl.getInstance().create("", "test");

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cache/ConcurrentCacheTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cache/ConcurrentCacheTest.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cache/ConcurrentCacheTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cache/ConcurrentCacheTest.java Mon Jan 10 14:49:42 2011
@@ -33,7 +33,7 @@ public class ConcurrentCacheTest extends
     public void testConcurrentCache() {
         NodeId[] ids = new NodeId[1000];
         for (int i = 0; i < ids.length; i++) {
-            ids[i] = new NodeId();
+            ids[i] = NodeId.randomId();
         }
 
         ConcurrentCache<NodeId, NodeId> cache =

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java Mon Jan 10 14:49:42 2011
@@ -144,7 +144,7 @@ public class ClusterRecordTest extends J
      * @throws Exception
      */
     public void testLockOperation() throws Exception {
-        LockEvent event = new LockEvent(new NodeId(), true, "admin");
+        LockEvent event = new LockEvent(NodeId.randomId(), true, "admin");
 
         master.createLockChannel(DEFAULT_WORKSPACE).create(event.getNodeId(),
                 event.isDeep(), event.getUserId()).ended(true);
@@ -162,7 +162,7 @@ public class ClusterRecordTest extends J
      * @throws Exception
      */
     public void testUnlockOperation() throws Exception {
-        UnlockEvent event = new UnlockEvent(new NodeId());
+        UnlockEvent event = new UnlockEvent(NodeId.randomId());
 
         master.createLockChannel(DEFAULT_WORKSPACE).create(event.getNodeId()).ended(true);
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java Mon Jan 10 14:49:42 2011
@@ -156,7 +156,7 @@ public class UpdateEventFactory {
     protected NodeState createNodeState() {
         Name ntName = nameFactory.create("{}testnt");
         NodeState n = new NodeState(
-                new NodeId(), ntName,
+                NodeId.randomId(), ntName,
                 ROOT_NODE_ID, NodeState.STATUS_EXISTING, false);
         n.setMixinTypeNames(Collections.EMPTY_SET);
         return n;

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java Mon Jan 10 14:49:42 2011
@@ -117,7 +117,7 @@ public class PersistenceManagerIteratorT
 
                 log("Random access");
                 for (int j = 0; j < 50; j++) {
-                    after = new NodeId();
+                    after = NodeId.randomId();
                     log(" bigger than: " + after);
                     for (NodeId id : apm.getAllNodeIds(after, 2)) {
                         log("    " + id);

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdFactoryTest.java?rev=1057220&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdFactoryTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdFactoryTest.java Mon Jan 10 14:49:42 2011
@@ -0,0 +1,120 @@
+/*
+ * 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.core.id;
+
+import java.io.File;
+import java.io.IOException;
+import javax.jcr.RepositoryException;
+import org.apache.commons.io.FileUtils;
+import junit.framework.TestCase;
+
+public class NodeIdFactoryTest extends TestCase {
+
+    private static final String factoryDir = "target/temp/nodeIdFactory";
+
+    public void setUp() throws IOException {
+        FileUtils.deleteDirectory(new File(factoryDir));
+    }
+
+    public void tearDown() throws IOException {
+        setUp();
+    }
+
+    public void testRandomVersusSequential() throws RepositoryException {
+        System.clearProperty(NodeIdFactory.SEQUENTIAL_NODE_ID);
+        NodeIdFactory f = new NodeIdFactory(factoryDir);
+        f.open();
+        NodeId id = f.newNodeId();
+        assertTrue(id.getLeastSignificantBits() != 0);
+        f.close();
+
+        System.setProperty(NodeIdFactory.SEQUENTIAL_NODE_ID, "true");
+        f = new NodeIdFactory(factoryDir);
+        f.open();
+        id = f.newNodeId();
+        assertTrue(id.getLeastSignificantBits() == 0);
+        f.close();
+    }
+
+    public void testNormalUsage() throws RepositoryException {
+        System.setProperty(NodeIdFactory.SEQUENTIAL_NODE_ID, "true");
+        NodeIdFactory f = new NodeIdFactory(factoryDir);
+        f.open();
+        assertEquals("00000000-0000-0000-0000-000000000000", f.newNodeId().toString());
+        f.close();
+        f = new NodeIdFactory(factoryDir);
+        f.open();
+        assertEquals("00000000-0000-0000-0000-000000000001", f.newNodeId().toString());
+        f.close();
+    }
+
+    public void testOffset() throws RepositoryException {
+        System.setProperty(NodeIdFactory.SEQUENTIAL_NODE_ID, "ab/0");
+        NodeIdFactory f = new NodeIdFactory(factoryDir);
+        f.open();
+        assertEquals("00000000-0000-00ab-0000-000000000000", f.newNodeId().toString());
+        f.close();
+        f = new NodeIdFactory(factoryDir);
+        f.open();
+        assertEquals("00000000-0000-00ab-0000-000000000001", f.newNodeId().toString());
+        f.close();
+    }
+
+    public void testKillRepository() throws RepositoryException {
+        System.setProperty(NodeIdFactory.SEQUENTIAL_NODE_ID, "true");
+        int cacheSize = 8;
+        for (int i = 1; i < 40; i++) {
+            File id = new File(factoryDir, "nodeId.properties");
+            id.delete();
+            NodeIdFactory f = new NodeIdFactory(factoryDir);
+            f.setCacheSize(cacheSize);
+            f.open();
+            NodeId last = null;
+            for (int j = 0; j < i; j++) {
+                last = f.newNodeId();
+            }
+            // don't close the factory - this is the same as killing the process
+            // f.close();
+            f = new NodeIdFactory(factoryDir);
+            f.setCacheSize(cacheSize);
+            f.open();
+            NodeId n = f.newNodeId();
+            assertTrue("now: " + n + " last: " + last, n.compareTo(last) > 0);
+            long diff = n.getLeastSignificantBits() - last.getLeastSignificantBits();
+            assertTrue("diff: " + diff, diff > 0 && diff <= cacheSize);
+            f.close();
+        }
+    }
+
+    public void testKillWhileSaving() throws RepositoryException {
+        System.setProperty(NodeIdFactory.SEQUENTIAL_NODE_ID, "true");
+        NodeIdFactory f = new NodeIdFactory(factoryDir);
+        f.open();
+        assertEquals("00000000-0000-0000-0000-000000000000", f.newNodeId().toString());
+        f.close();
+        File id = new File(factoryDir, "nodeId.properties");
+        assertTrue(id.exists());
+        File idTemp = new File(factoryDir, "nodeId.properties.temp");
+        id.renameTo(idTemp);
+        f = new NodeIdFactory(factoryDir);
+        f.open();
+        assertEquals("00000000-0000-0000-0000-000000000001", f.newNodeId().toString());
+        assertFalse(idTemp.exists());
+        f.close();
+    }
+
+}

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdTest.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdTest.java Mon Jan 10 14:49:42 2011
@@ -21,7 +21,7 @@ import junit.framework.TestCase;
 public class NodeIdTest extends TestCase {
 
     private static final NodeId[] ids = {
-        new NodeId(), // random id
+        NodeId.randomId(), // random id
         new NodeId(0, 0),
         new NodeId(-1, -1),
         new NodeId("cafebabe-cafe-babe-cafe-babecafebabe")
@@ -81,7 +81,7 @@ public class NodeIdTest extends TestCase
     public void testUuidFormat() {
         long maxHigh = 0, maxLow = 0, minHigh = -1L, minLow = -1L;
         for (int i = 0; i < 100; i++) {
-            NodeId id = new NodeId();
+            NodeId id = NodeId.randomId();
             assertUuidFormat(id);
             maxHigh |= id.getMostSignificantBits();
             maxLow |= id.getLeastSignificantBits();

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/TestAll.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/TestAll.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/TestAll.java Mon Jan 10 14:49:42 2011
@@ -32,7 +32,10 @@ public class TestAll extends TestCase {
      */
     public static Test suite() {
         TestSuite suite = new TestSuite("Identifier tests");
+
+        suite.addTestSuite(NodeIdFactoryTest.class);
         suite.addTestSuite(NodeIdTest.class);
+
         return suite;
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/util/BundleBindingTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/util/BundleBindingTest.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/util/BundleBindingTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/util/BundleBindingTest.java Mon Jan 10 14:49:42 2011
@@ -50,11 +50,11 @@ public class BundleBindingTest extends T
 
     protected void setUp() throws Exception {
         final String[] strings = new String[] {
-                "http://www.jcp.org/jcr/1.0", 
-                "http://www.jcp.org/jcr/nt/1.0", 
-                "http://www.jcp.org/jcr/mix/1.0", 
+                "http://www.jcp.org/jcr/1.0",
+                "http://www.jcp.org/jcr/nt/1.0",
+                "http://www.jcp.org/jcr/mix/1.0",
                 "unstructured",
-                "created", 
+                "created",
                 "createdBy",
                 "",
                 "binary",
@@ -87,7 +87,7 @@ public class BundleBindingTest extends T
     }
 
     public void testEmptyBundle() throws Exception {
-        NodePropBundle bundle = new NodePropBundle(new NodeId());
+        NodePropBundle bundle = new NodePropBundle(NodeId.randomId());
         bundle.setParentId(new NodeId(1, 2));
         bundle.setNodeTypeName(NameConstants.NT_UNSTRUCTURED);
         bundle.setMixinTypeNames(Collections.<Name>emptySet());
@@ -286,27 +286,27 @@ public class BundleBindingTest extends T
      * Tests serialization of custom namespaces.
      */
     public void testCustomNamespaces() throws Exception {
-        NodePropBundle bundle = new NodePropBundle(new NodeId());
-        bundle.setParentId(new NodeId());
+        NodePropBundle bundle = new NodePropBundle(NodeId.randomId());
+        bundle.setParentId(NodeId.randomId());
         bundle.setNodeTypeName(NameConstants.NT_UNSTRUCTURED);
         bundle.setMixinTypeNames(Collections.<Name>emptySet());
         bundle.setSharedSet(Collections.<NodeId>emptySet());
 
-        bundle.addChildNodeEntry(factory.create("ns1", "test"), new NodeId());
-        bundle.addChildNodeEntry(factory.create("ns2", "test"), new NodeId());
-        bundle.addChildNodeEntry(factory.create("ns3", "test"), new NodeId());
-        bundle.addChildNodeEntry(factory.create("ns4", "test"), new NodeId());
-        bundle.addChildNodeEntry(factory.create("ns5", "test"), new NodeId());
-        bundle.addChildNodeEntry(factory.create("ns6", "test"), new NodeId());
-        bundle.addChildNodeEntry(factory.create("ns7", "test"), new NodeId());
-        bundle.addChildNodeEntry(factory.create("ns8", "test"), new NodeId());
-        bundle.addChildNodeEntry(factory.create("ns1", "test"), new NodeId());
-        bundle.addChildNodeEntry(factory.create("ns1", "test"), new NodeId());
-        bundle.addChildNodeEntry(factory.create("ns2", "test"), new NodeId());
-        bundle.addChildNodeEntry(factory.create("ns3", "test"), new NodeId());
-        bundle.addChildNodeEntry(factory.create("ns1", "test"), new NodeId());
-        bundle.addChildNodeEntry(factory.create("ns2", "test"), new NodeId());
-        bundle.addChildNodeEntry(factory.create("ns3", "test"), new NodeId());
+        bundle.addChildNodeEntry(factory.create("ns1", "test"), NodeId.randomId());
+        bundle.addChildNodeEntry(factory.create("ns2", "test"), NodeId.randomId());
+        bundle.addChildNodeEntry(factory.create("ns3", "test"), NodeId.randomId());
+        bundle.addChildNodeEntry(factory.create("ns4", "test"), NodeId.randomId());
+        bundle.addChildNodeEntry(factory.create("ns5", "test"), NodeId.randomId());
+        bundle.addChildNodeEntry(factory.create("ns6", "test"), NodeId.randomId());
+        bundle.addChildNodeEntry(factory.create("ns7", "test"), NodeId.randomId());
+        bundle.addChildNodeEntry(factory.create("ns8", "test"), NodeId.randomId());
+        bundle.addChildNodeEntry(factory.create("ns1", "test"), NodeId.randomId());
+        bundle.addChildNodeEntry(factory.create("ns1", "test"), NodeId.randomId());
+        bundle.addChildNodeEntry(factory.create("ns2", "test"), NodeId.randomId());
+        bundle.addChildNodeEntry(factory.create("ns3", "test"), NodeId.randomId());
+        bundle.addChildNodeEntry(factory.create("ns1", "test"), NodeId.randomId());
+        bundle.addChildNodeEntry(factory.create("ns2", "test"), NodeId.randomId());
+        bundle.addChildNodeEntry(factory.create("ns3", "test"), NodeId.randomId());
 
         assertBundleRoundtrip(bundle);
     }
@@ -344,8 +344,8 @@ public class BundleBindingTest extends T
 
     private void assertValueSerialization(InternalValue value)
             throws Exception {
-        NodePropBundle bundle = new NodePropBundle(new NodeId());
-        bundle.setParentId(new NodeId());
+        NodePropBundle bundle = new NodePropBundle(NodeId.randomId());
+        bundle.setParentId(NodeId.randomId());
         bundle.setNodeTypeName(NameConstants.NT_UNSTRUCTURED);
         bundle.setMixinTypeNames(Collections.<Name>emptySet());
         bundle.setSharedSet(Collections.<NodeId>emptySet());

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IDFieldTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IDFieldTest.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IDFieldTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IDFieldTest.java Mon Jan 10 14:49:42 2011
@@ -27,7 +27,7 @@ import junit.framework.TestCase;
 public class IDFieldTest extends TestCase {
 
     public void testPerformance() {
-        NodeId id = new NodeId();
+        NodeId id = NodeId.randomId();
         long time = System.currentTimeMillis();
         for (int i = 0; i < 1000 * 1000; i++) {
             new IDField(id);

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/SlowQueryHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/SlowQueryHandler.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/SlowQueryHandler.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/SlowQueryHandler.java Mon Jan 10 14:49:42 2011
@@ -36,7 +36,7 @@ public class SlowQueryHandler extends Se
         } catch (InterruptedException e) {
             // ignore
         }
-        getContext().getItemStateManager().hasItemState(new NodeId());
+        getContext().getItemStateManager().hasItemState(NodeId.randomId());
         super.doInit();
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/AccessManagerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/AccessManagerTest.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/AccessManagerTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/AccessManagerTest.java Mon Jan 10 14:49:42 2011
@@ -118,7 +118,7 @@ public class AccessManagerTest extends A
 
     public void testCheckPermissionWithUnknowId() throws RepositoryException, NotExecutableException {
         Session s = getHelper().getReadOnlySession();
-        NodeId id = new NodeId();
+        NodeId id = NodeId.randomId();
         try {
             AccessManager acMgr = getAccessManager(s);
             acMgr.checkPermission(id, AccessManager.READ);

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/acl/EntryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/acl/EntryTest.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/acl/EntryTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/acl/EntryTest.java Mon Jan 10 14:49:42 2011
@@ -62,7 +62,7 @@ public class EntryTest extends AbstractE
         // false since acl has been created from path only -> no id
         assertFalse(entry.isLocal(((NodeImpl) testRootNode).getNodeId()));
         // false since internal id is null -> will never match.
-        assertFalse(entry.isLocal(new NodeId()));
+        assertFalse(entry.isLocal(NodeId.randomId()));
     }
 
     public void testIsLocal2()  throws NotExecutableException, RepositoryException {
@@ -80,14 +80,14 @@ public class EntryTest extends AbstractE
         assertTrue(acls[0] instanceof ACLTemplate);
 
         ACLTemplate acl = (ACLTemplate) acls[0];
-        assertEquals(path, acl.getPath());       
+        assertEquals(path, acl.getPath());
 
         ACLTemplate.Entry entry = acl.createEntry(testPrincipal, new Privilege[] {acMgr.privilegeFromName(Privilege.JCR_READ)}, true, Collections.<String,Value>emptyMap());
 
         // node is must be present + must match to testrootnodes id.
         assertTrue(entry.isLocal(((NodeImpl) testRootNode).getNodeId()));
         // but not to a random id.
-        assertFalse(entry.isLocal(new NodeId()));
+        assertFalse(entry.isLocal(NodeId.randomId()));
     }
 
     public void testRestrictions() throws RepositoryException {

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/AbstractISMLockingTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/AbstractISMLockingTest.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/AbstractISMLockingTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/AbstractISMLockingTest.java Mon Jan 10 14:49:42 2011
@@ -55,7 +55,7 @@ public abstract class AbstractISMLocking
     protected void setUp() throws Exception {
         super.setUp();
         locking = createISMLocking();
-        NodeId id = new NodeId();
+        NodeId id = NodeId.randomId();
         state = new NodeState(id, NameConstants.NT_BASE, null, ItemState.STATUS_EXISTING, true);
         refs = new NodeReferences(state.getNodeId());
         logs = new ArrayList<ChangeLog>();
@@ -82,7 +82,7 @@ public abstract class AbstractISMLocking
      * Checks the following requirement: <p/> <i>While a read lock is held for a given item with id
      * <code>I</code> an implementation must ensure that no write lock is issued for a change log that
      * contains a reference to an item with id <code>I</code>. </i>
-     * 
+     *
      * @throws InterruptedException on interruption; this will err the test
      */
     public void testReadBlocksWrite() throws InterruptedException {
@@ -98,7 +98,7 @@ public abstract class AbstractISMLocking
      * <code>C</code> an implementation must ensure that no read lock is issued for an item that is contained
      * in <code>C</code>, unless the current thread is the owner of the write lock!</i> <p/> The "unless"
      * clause is tested by {@link #testWriteBlocksRead_notIfSameThread()} test.
-     * 
+     *
      * @throws InterruptedException on interruption; this will err the test
      */
     public void testWriteBlocksRead() throws InterruptedException {
@@ -132,7 +132,7 @@ public abstract class AbstractISMLocking
      * with <code>C</code>. That is both change logs contain a reference to the same item. Please note that an
      * implementation is free to block requests entirely for additional write lock while a write lock is
      * active. It is not a requirement to support concurrent write locks.
-     * 
+     *
      * @throws InterruptedException on interruption; this will err the test
      */
     public void testIntersectingWrites() throws InterruptedException {
@@ -147,7 +147,7 @@ public abstract class AbstractISMLocking
 
     /**
      * Checks if a downgraded write lock allows other threads to read again.
-     * 
+     *
      * @throws InterruptedException on interruption; this will err the test
      */
     public void testDowngrade() throws InterruptedException {
@@ -166,7 +166,7 @@ public abstract class AbstractISMLocking
      * Creates and starts a thread that acquires and releases the write lock of the given
      * <code>ISMLocking</code> for the given changelog. The thread's interrupted status is set if it was
      * interrupted during the acquire-release sequence and could therefore not finish it.
-     * 
+     *
      * @param lock the <code>ISMLocking</code> to use
      * @param changeLog the <code>ChangeLog</code> to use
      * @return a thread that has been started
@@ -190,7 +190,7 @@ public abstract class AbstractISMLocking
      * Creates and starts an thread that acquires and releases the read lock of the given
      * <code>ISMLocking</code> for the given id. The thread's interrupted status is set if it was interrupted
      * during the acquire-release sequence and could therefore not finish it.
-     * 
+     *
      * @param lock the <code>ISMLocking</code> to use
      * @param id the id to use
      * @return a thread that has been started
@@ -214,7 +214,7 @@ public abstract class AbstractISMLocking
      * Verifies that the given thread is blocked. Then it interrupts the thread and waits a certain amount of
      * time for it to complete. (If it doesn't complete within that time then the test that calls this method
      * fails).
-     * 
+     *
      * @param other a started thread
      * @throws InterruptedException on interruption
      */
@@ -230,7 +230,7 @@ public abstract class AbstractISMLocking
      * Verifies that the given thread is not blocked and runs to completion within a certain amount of time
      * and without interruption. (If it doesn't complete within that time without interruption then the test
      * that calls this method fails).
-     * 
+     *
      * @param other a started thread
      * @throws InterruptedException on interruption
      */

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/ChangeLogTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/ChangeLogTest.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/ChangeLogTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/ChangeLogTest.java Mon Jan 10 14:49:42 2011
@@ -40,7 +40,7 @@ public class ChangeLogTest extends Abstr
      * entry in either the added nor the removed states
      */
     public void testAddDelete() throws Exception {
-        PropertyId id = new PropertyId(new NodeId(), factory.create("", "a"));
+        PropertyId id = new PropertyId(NodeId.randomId(), factory.create("", "a"));
         ItemState state = new PropertyState(id, ItemState.STATUS_NEW, false);
 
         ChangeLog log = new ChangeLog();
@@ -59,7 +59,7 @@ public class ChangeLogTest extends Abstr
      * in the added states.
      */
     public void testAddModify() throws Exception {
-        PropertyId id = new PropertyId(new NodeId(), factory.create("", "a"));
+        PropertyId id = new PropertyId(NodeId.randomId(), factory.create("", "a"));
         ItemState state = new PropertyState(id, ItemState.STATUS_NEW, false);
 
         ChangeLog log = new ChangeLog();
@@ -80,7 +80,7 @@ public class ChangeLogTest extends Abstr
     public void testPreserveOrder() throws Exception {
         ItemState[] states = new ItemState[10];
         for (int i = 0; i < states.length; i++) {
-            PropertyId id = new PropertyId(new NodeId(), factory.create("", "a" + i));
+            PropertyId id = new PropertyId(NodeId.randomId(), factory.create("", "a" + i));
             states[i] = new PropertyState(id, ItemState.STATUS_NEW, false);
         }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueFactoryTest.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueFactoryTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueFactoryTest.java Mon Jan 10 14:49:42 2011
@@ -38,7 +38,7 @@ public class InternalValueFactoryTest ex
         factory = InternalValueFactory.getInstance();
         rootPath = PathFactoryImpl.getInstance().getRootPath();
         testName = NameFactoryImpl.getInstance().create(Name.NS_JCR_URI, "data");
-        reference = new NodeId().toString();
+        reference = NodeId.randomId().toString();
     }
 
     protected void tearDown() throws Exception {

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueTest.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueTest.java Mon Jan 10 14:49:42 2011
@@ -38,7 +38,7 @@ public class InternalValueTest extends Q
         factory = InternalValueFactory.getInstance();
         rootPath = PathFactoryImpl.getInstance().getRootPath();
         testName = NameFactoryImpl.getInstance().create(Name.NS_JCR_URI, "data");
-        reference = new NodeId().toString();
+        reference = NodeId.randomId().toString();
     }
 
     protected void tearDown() throws Exception {

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java Mon Jan 10 14:49:42 2011
@@ -64,9 +64,9 @@ public class VersionIteratorImplTest ext
 
     public void testVersionIterator() throws Exception {
 
-        InternalVersion version = new DummyInternalVersion(new InternalVersion[] {}, new NodeId());
+        InternalVersion version = new DummyInternalVersion(new InternalVersion[] {}, NodeId.randomId());
         for (int i = 1; i < VERSION_COUNT; i++) {
-            version = new DummyInternalVersion(new InternalVersion[] {version}, new NodeId());
+            version = new DummyInternalVersion(new InternalVersion[] {version}, NodeId.randomId());
         }
 
         try {

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/xml/WorkspaceImporterTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/xml/WorkspaceImporterTest.java?rev=1057220&r1=1057219&r2=1057220&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/xml/WorkspaceImporterTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/xml/WorkspaceImporterTest.java Mon Jan 10 14:49:42 2011
@@ -53,7 +53,7 @@ public class WorkspaceImporterTest exten
      */
     public void testReferenceImport() throws Exception {
         try {
-            NodeId id = new NodeId();
+            NodeId id = NodeId.randomId();
             String xml =
                 "<sv:node sv:name=\"a\""
                 + " xmlns:jcr=\"http://www.jcp.org/jcr/1.0\""



Mime
View raw message