jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r793613 [2/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/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java Mon Jul 13 15:55:55 2009
@@ -22,12 +22,12 @@
 import java.util.Arrays;
 import java.util.BitSet;
 import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
-import java.util.Collection;
-import java.util.Collections;
 
 import javax.jcr.AccessDeniedException;
 import javax.jcr.Binary;
@@ -49,8 +49,6 @@
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryResult;
 import javax.jcr.lock.Lock;
 import javax.jcr.lock.LockException;
 import javax.jcr.lock.LockManager;
@@ -59,6 +57,8 @@
 import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
 import javax.jcr.version.OnParentVersionAction;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionException;
@@ -68,6 +68,9 @@
 
 import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
 import org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter;
+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.EffectiveNodeType;
 import org.apache.jackrabbit.core.nodetype.ItemDef;
 import org.apache.jackrabbit.core.nodetype.NodeDef;
@@ -79,12 +82,12 @@
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.core.nodetype.PropertyDefinitionImpl;
+import org.apache.jackrabbit.core.query.QueryManagerImpl;
 import org.apache.jackrabbit.core.security.authorization.Permission;
 import org.apache.jackrabbit.core.state.ChildNodeEntry;
 import org.apache.jackrabbit.core.state.ItemState;
 import org.apache.jackrabbit.core.state.ItemStateException;
 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;
@@ -97,7 +100,6 @@
 import org.apache.jackrabbit.core.version.LabelVersionSelector;
 import org.apache.jackrabbit.core.version.VersionImpl;
 import org.apache.jackrabbit.core.version.VersionSelector;
-import org.apache.jackrabbit.core.query.QueryManagerImpl;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
@@ -336,7 +338,7 @@
             if (name.equals(NameConstants.JCR_UUID)) {
                 // jcr:uuid property
                 genValues = new InternalValue[]{
-                        InternalValue.create(thisState.getNodeId().getUUID().toString())
+                        InternalValue.create(thisState.getNodeId().toString())
                 };
             }
 /*
@@ -540,7 +542,7 @@
         NodeState nodeState;
         try {
             if (id == null) {
-                id = new NodeId(UUID.randomUUID());
+                id = new NodeId();
             }
             nodeState =
                     stateMgr.createTransientNodeState(id, nodeType.getQName(),
@@ -1365,15 +1367,6 @@
     }
 
     /**
-     * Returns the (internal) uuid of this node.
-     *
-     * @return the uuid of this node
-     */
-    public UUID internalGetUUID() {
-        return ((NodeId) id).getUUID();
-    }
-
-    /**
      * Checks various pre-conditions that are common to all
      * <code>setProperty()</code> methods. The checks performed are:
      * <ul>
@@ -1632,8 +1625,8 @@
      * @param nodeName     name of the new node
      * @param nodeTypeName name of the new node's node type or <code>null</code>
      *                     if it should be determined automatically
-     * @param uuid         uuid of the new node or <code>null</code> if a new
-     *                     uuid should be assigned
+     * @param id           id of the new node or <code>null</code> if a new
+     *                     id should be assigned
      * @return the newly added node
      * @throws ItemExistsException
      * @throws NoSuchNodeTypeException
@@ -1643,7 +1636,7 @@
      * @throws RepositoryException
      */
     public synchronized NodeImpl addNode(Name nodeName, Name nodeTypeName,
-                                         UUID uuid)
+                                         NodeId id)
             throws ItemExistsException, NoSuchNodeTypeException, VersionException,
             ConstraintViolationException, LockException, RepositoryException {
         // check state of this instance
@@ -1657,7 +1650,7 @@
         if (nodeTypeName != null) {
             nt = session.getNodeTypeManager().getNodeType(nodeTypeName);
         }
-        return internalAddChildNode(nodeName, nt, uuid == null ? null : new NodeId(uuid));
+        return internalAddChildNode(nodeName, nt, id);
     }
 
     /**
@@ -1987,7 +1980,7 @@
         existing.remove();
 
         // create new child node
-        NodeImpl node = addNode(nodeName, nodeTypeName, id.getUUID());
+        NodeImpl node = addNode(nodeName, nodeTypeName, id);
         if (mixinNames != null) {
             for (int i = 0; i < mixinNames.length; i++) {
                 node.addMixin(mixinNames[i]);
@@ -3031,7 +3024,7 @@
             throw new UnsupportedRepositoryOperationException();
         }
 
-        return internalGetUUID().toString();
+        return getNodeId().toString();
     }
 
     /**
@@ -3356,7 +3349,9 @@
         try {
             internalSetProperty(NameConstants.JCR_ISCHECKEDOUT, InternalValue.create(false));
             if (isFull) {
-                internalSetProperty(NameConstants.JCR_BASEVERSION, InternalValue.create(new UUID(v.getUUID())));
+                internalSetProperty(
+                        NameConstants.JCR_BASEVERSION,
+                        InternalValue.create(new NodeId(v.getUUID())));
                 internalSetProperty(NameConstants.JCR_PREDECESSORS, InternalValue.EMPTY_ARRAY, PropertyType.REFERENCE);
                 if (hasProperty(NameConstants.JCR_ACTIVITY)) {
                     removeChildProperty(NameConstants.JCR_ACTIVITY);
@@ -3410,11 +3405,11 @@
                 Version baseVersion = session.getVersionManager().checkout(this);
                 props[1] = internalSetProperty(NameConstants.JCR_PREDECESSORS,
                         new InternalValue[]{
-                                InternalValue.create(new UUID(baseVersion.getUUID()))
+                                InternalValue.create(new NodeId(baseVersion.getUUID()))
                         });
                 if (activity != null) {
                     props[2] = internalSetProperty(NameConstants.JCR_ACTIVITY,
-                            InternalValue.create(activity.getNodeId().getUUID()));
+                            InternalValue.create(activity.getNodeId()));
                 }
             }
             if (hasPendingChanges) {
@@ -3566,7 +3561,7 @@
             try {
                 // check if versionable node exists
                 InternalFrozenNode fn = ((VersionImpl) version).getInternalFrozenNode();
-                node = (NodeImpl) session.getNodeByUUID(fn.getFrozenUUID());
+                node = (NodeImpl) session.getNodeById(fn.getFrozenId());
                 if (removeExisting) {
                     try {
                         Path relative = session.getQPath(relPath);
@@ -3576,7 +3571,7 @@
                         // move to respective location
                         session.move(node.getPath(), session.getJCRPath(dstPath));
                         // need to refetch ?
-                        node = (NodeImpl) session.getNodeByUUID(fn.getFrozenUUID());
+                        node = (NodeImpl) session.getNodeById(fn.getFrozenId());
                     } catch (NameException e) {
                         throw new RepositoryException(e);
                     }
@@ -3882,9 +3877,9 @@
                 Value[] vals = getProperty(NameConstants.JCR_PREDECESSORS).getValues();
                 InternalValue[] v = new InternalValue[vals.length + 1];
                 for (int i = 0; i < vals.length; i++) {
-                    v[i] = InternalValue.create(UUID.fromString(vals[i].getString()));
+                    v[i] = InternalValue.create(new NodeId(vals[i].getString()));
                 }
-                v[vals.length] = InternalValue.create(UUID.fromString(version.getUUID()));
+                v[vals.length] = InternalValue.create(new NodeId(version.getUUID()));
                 internalSetProperty(NameConstants.JCR_PREDECESSORS, v);
             }
 
@@ -3929,7 +3924,7 @@
             int i = 0;
             while (iter.hasNext()) {
                 String uuid = iter.next();
-                vals[i++] = InternalValue.create(UUID.fromString(uuid));
+                vals[i++] = InternalValue.create(new NodeId(uuid));
             }
             internalSetProperty(NameConstants.JCR_MERGEFAILED, vals);
         }
@@ -4010,10 +4005,10 @@
         NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
         NodeTypeImpl nt = ntMgr.getNodeType(frozen.getFrozenPrimaryType());
 
-        // get frozen uuid
-        UUID uuid = frozen.getFrozenUUID();
+        // get frozen id
+        NodeId id = frozen.getFrozenId();
 
-        NodeImpl node = internalAddChildNode(name, nt, new NodeId(uuid));
+        NodeImpl node = internalAddChildNode(name, nt, id);
 
         // get frozen mixin
         // todo: also respect mixing types on creation?
@@ -4054,10 +4049,10 @@
         NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
         NodeTypeImpl nt = ntMgr.getNodeType(frozen.getFrozenPrimaryType());
 
-        // get frozen uuid
-        UUID uuid = frozen.getFrozenUUID();
+        // get frozen id
+        NodeId id = frozen.getFrozenId();
 
-        NodeImpl node = internalAddNode(relPath, nt, new NodeId(uuid));
+        NodeImpl node = internalAddNode(relPath, nt, id);
 
         // get frozen mixin
         // todo: also respect mixing types on creation?
@@ -4324,8 +4319,9 @@
 
         if (isFull) {
             // 2. N's jcr:baseVersion property will be changed to point to V.
-            UUID uuid = ((NodeId) version.getId()).getUUID();
-            internalSetProperty(NameConstants.JCR_BASEVERSION, InternalValue.create(uuid));
+            internalSetProperty(
+                    NameConstants.JCR_BASEVERSION,
+                    InternalValue.create((NodeId) version.getId()));
 
             // 4. N's jcr:predecessor property is set to null
             internalSetProperty(NameConstants.JCR_PREDECESSORS, InternalValue.EMPTY_ARRAY, PropertyType.REFERENCE);
@@ -4359,8 +4355,7 @@
 
         // check uuid
         if (isNodeType(NameConstants.MIX_REFERENCEABLE)) {
-            UUID uuid = freeze.getFrozenUUID();
-            if (!internalGetUUID().equals(uuid)) {
+            if (!getNodeId().equals(freeze.getFrozenId())) {
                 throw new ItemExistsException("Unable to restore version of " + this + ". UUID changed.");
             }
         }
@@ -4432,10 +4427,10 @@
             } else if (n.getDefinition().getOnParentVersion() == OnParentVersionAction.VERSION) {
                 // only remove, if node to be restored does not contain child,
                 // or if restored child is not versionable
-                UUID vhUUID = n.hasProperty(NameConstants.JCR_VERSIONHISTORY)
-                        ? new UUID(n.getProperty(NameConstants.JCR_VERSIONHISTORY).getString())
+                NodeId vhId = n.hasProperty(NameConstants.JCR_VERSIONHISTORY)
+                        ? new NodeId(n.getProperty(NameConstants.JCR_VERSIONHISTORY).getString())
                         : null;
-                if (vhUUID == null || !freeze.hasFrozenHistory(vhUUID)) {
+                if (vhId == null || !freeze.hasFrozenHistory(vhId)) {
                     n.internalRemove(true);
                 }
             }
@@ -4448,9 +4443,9 @@
             if (child instanceof InternalFrozenNode) {
                 InternalFrozenNode f = (InternalFrozenNode) child;
                 // check for existing
-                if (f.getFrozenUUID() != null) {
+                if (f.getFrozenId() != null) {
                     try {
-                        NodeImpl existing = (NodeImpl) session.getNodeByUUID(f.getFrozenUUID());
+                        NodeImpl existing = (NodeImpl) session.getNodeById(f.getFrozenId());
                         // check if one of this restore trees node
                         if (removeExisting) {
                             existing.remove();
@@ -4665,9 +4660,8 @@
         sanityCheck();
 
         try {
-            NodeReferencesId targetId = new NodeReferencesId((NodeId) id);
-            if (stateMgr.hasNodeReferences(targetId)) {
-                NodeReferences refs = stateMgr.getNodeReferences(targetId);
+            if (stateMgr.hasNodeReferences(getNodeId())) {
+                NodeReferences refs = stateMgr.getNodeReferences(getNodeId());
                 // refs.getReferences() returns a list of PropertyId's
                 List<PropertyId> idList = refs.getReferences();
                 if (name != null) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java Mon Jul 13 15:55:55 2009
@@ -36,6 +36,7 @@
 import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.version.VersionException;
 
+import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.core.nodetype.PropertyDefinitionImpl;
 import org.apache.jackrabbit.core.security.authorization.Permission;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ProtectedItemModifier.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ProtectedItemModifier.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ProtectedItemModifier.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ProtectedItemModifier.java Mon Jul 13 15:55:55 2009
@@ -16,8 +16,16 @@
  */
 package org.apache.jackrabbit.core;
 
+import javax.jcr.AccessDeniedException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.nodetype.NodeDefinitionImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
+import org.apache.jackrabbit.core.retention.RetentionManagerImpl;
 import org.apache.jackrabbit.core.security.AccessManager;
 import org.apache.jackrabbit.core.security.authorization.Permission;
 import org.apache.jackrabbit.core.security.authorization.acl.ACLEditor;
@@ -25,16 +33,9 @@
 import org.apache.jackrabbit.core.state.ChildNodeEntry;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.value.InternalValue;
-import org.apache.jackrabbit.core.retention.RetentionManagerImpl;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
 
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.ItemExistsException;
-import javax.jcr.AccessDeniedException;
-
 /**
  * <code>SecurityItemModifier</code>: An abstract helper class to allow classes
  * of the security API residing outside of the core package to modify and remove
@@ -54,10 +55,10 @@
 
     protected ProtectedItemModifier(int permission) {
         Class cl = getClass();
-        if (!(cl.equals(UserManagerImpl.class) ||
-              cl.equals(RetentionManagerImpl.class) ||
-              cl.equals(ACLEditor.class) ||
-              cl.equals(org.apache.jackrabbit.core.security.authorization.principalbased.ACLEditor.class))) {
+        if (!(UserManagerImpl.class.isAssignableFrom(cl) ||
+              RetentionManagerImpl.class.isAssignableFrom(cl) ||
+              ACLEditor.class.isAssignableFrom(cl) ||
+              org.apache.jackrabbit.core.security.authorization.principalbased.ACLEditor.class.isAssignableFrom(cl))) {
             throw new IllegalArgumentException("Only UserManagerImpl, RetentionManagerImpl and ACLEditor may extend from the ProtectedItemModifier");
         }
         this.permission = permission;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryFactoryImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryFactoryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryFactoryImpl.java Mon Jul 13 15:55:55 2009
@@ -82,12 +82,16 @@
             throws RepositoryException {
         JackrabbitRepository repo = REPOSITORY_INSTANCES.get(home);
         if (repo == null) {
+            TransientRepository tr;
             if (home == null) {
-                repo = new TransientRepository();
+                tr = new TransientRepository();
+                // also remember this instance as the default repository
+                REPOSITORY_INSTANCES.put(null, tr);
             } else {
-                repo = new TransientRepository(conf, home);
+                tr = new TransientRepository(conf, home);
             }
-            REPOSITORY_INSTANCES.put(home, repo);
+            REPOSITORY_INSTANCES.put(tr.getHomeDir(), tr);
+            repo = tr;
         }
         return repo;
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java Mon Jul 13 15:55:55 2009
@@ -16,10 +16,38 @@
  */
 package org.apache.jackrabbit.core;
 
-import EDU.oswego.cs.dl.util.concurrent.Mutex;
-import EDU.oswego.cs.dl.util.concurrent.ReadWriteLock;
-import EDU.oswego.cs.dl.util.concurrent.ReentrantWriterPreferenceReadWriteLock;
-import EDU.oswego.cs.dl.util.concurrent.WriterPreferenceReadWriteLock;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.StringReader;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Credentials;
+import javax.jcr.LoginException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.Value;
+import javax.jcr.observation.Event;
+import javax.jcr.observation.EventIterator;
+import javax.jcr.observation.EventListener;
+import javax.jcr.observation.ObservationManager;
+import javax.security.auth.Subject;
+
 import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.api.JackrabbitRepository;
@@ -27,11 +55,11 @@
 import org.apache.jackrabbit.core.cluster.ClusterContext;
 import org.apache.jackrabbit.core.cluster.ClusterException;
 import org.apache.jackrabbit.core.cluster.ClusterNode;
-import org.apache.jackrabbit.core.cluster.WorkspaceEventChannel;
-import org.apache.jackrabbit.core.cluster.WorkspaceListener;
 import org.apache.jackrabbit.core.cluster.LockEventChannel;
 import org.apache.jackrabbit.core.cluster.UpdateEventChannel;
 import org.apache.jackrabbit.core.cluster.UpdateEventListener;
+import org.apache.jackrabbit.core.cluster.WorkspaceEventChannel;
+import org.apache.jackrabbit.core.cluster.WorkspaceListener;
 import org.apache.jackrabbit.core.config.ClusterConfig;
 import org.apache.jackrabbit.core.config.PersistenceManagerConfig;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
@@ -44,6 +72,7 @@
 import org.apache.jackrabbit.core.fs.FileSystem;
 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.lock.LockManager;
 import org.apache.jackrabbit.core.lock.LockManagerImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
@@ -54,6 +83,8 @@
 import org.apache.jackrabbit.core.observation.ObservationDispatcher;
 import org.apache.jackrabbit.core.persistence.PMContext;
 import org.apache.jackrabbit.core.persistence.PersistenceManager;
+import org.apache.jackrabbit.core.retention.RetentionRegistry;
+import org.apache.jackrabbit.core.retention.RetentionRegistryImpl;
 import org.apache.jackrabbit.core.security.JackrabbitSecurityManager;
 import org.apache.jackrabbit.core.security.authentication.AuthContext;
 import org.apache.jackrabbit.core.security.simple.SimpleSecurityManager;
@@ -68,8 +99,6 @@
 import org.apache.jackrabbit.core.version.VersionManager;
 import org.apache.jackrabbit.core.version.VersionManagerImpl;
 import org.apache.jackrabbit.core.xml.ClonedInputSource;
-import org.apache.jackrabbit.core.retention.RetentionRegistry;
-import org.apache.jackrabbit.core.retention.RetentionRegistryImpl;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.spi.commons.namespace.RegistryNamespaceResolver;
@@ -77,36 +106,10 @@
 import org.slf4j.LoggerFactory;
 import org.xml.sax.InputSource;
 
-import javax.jcr.AccessDeniedException;
-import javax.jcr.Credentials;
-import javax.jcr.LoginException;
-import javax.jcr.NamespaceRegistry;
-import javax.jcr.NoSuchWorkspaceException;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
-import javax.jcr.Value;
-import javax.jcr.observation.Event;
-import javax.jcr.observation.EventIterator;
-import javax.jcr.observation.EventListener;
-import javax.jcr.observation.ObservationManager;
-import javax.security.auth.Subject;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.StringReader;
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
+import EDU.oswego.cs.dl.util.concurrent.Mutex;
+import EDU.oswego.cs.dl.util.concurrent.ReadWriteLock;
+import EDU.oswego.cs.dl.util.concurrent.ReentrantWriterPreferenceReadWriteLock;
+import EDU.oswego.cs.dl.util.concurrent.WriterPreferenceReadWriteLock;
 
 /**
  * A <code>RepositoryImpl</code> ...

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java Mon Jul 13 15:55:55 2009
@@ -23,7 +23,6 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.NoSuchElementException;
 import java.util.Set;
 
 import javax.jcr.NamespaceException;
@@ -38,6 +37,7 @@
 import org.apache.jackrabbit.core.config.SearchConfig;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.observation.EventImpl;
 import org.apache.jackrabbit.core.observation.SynchronousEventListener;
@@ -48,7 +48,6 @@
 import org.apache.jackrabbit.core.query.QueryObjectModelImpl;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.NodeState;
-import org.apache.jackrabbit.core.state.NodeStateIterator;
 import org.apache.jackrabbit.core.state.SharedItemStateManager;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
@@ -424,8 +423,8 @@
             }
         }
 
-        NodeStateIterator addedStates = new NodeStateIterator() {
-            private final Iterator iter = addedNodes.keySet().iterator();
+        Iterator<NodeState> addedStates = new Iterator<NodeState>() {
+            private final Iterator<NodeId> iter = addedNodes.keySet().iterator();
 
             public void remove() {
                 throw new UnsupportedOperationException();
@@ -436,10 +435,6 @@
             }
 
             public NodeState next() {
-                return nextNodeState();
-            }
-
-            public NodeState nextNodeState() {
                 NodeState item = null;
                 NodeId id = (NodeId) iter.next();
                 try {
@@ -457,25 +452,7 @@
                 return item;
             }
         };
-        NodeIdIterator removedIds = new NodeIdIterator() {
-            private final Iterator iter = removedNodes.iterator();
-
-            public NodeId nextNodeId() throws NoSuchElementException {
-                return (NodeId) iter.next();
-            }
-
-            public void remove() {
-                throw new UnsupportedOperationException();
-            }
-
-            public boolean hasNext() {
-                return iter.hasNext();
-            }
-
-            public Object next() {
-                return nextNodeId();
-            }
-        };
+        Iterator<NodeId> removedIds = removedNodes.iterator();
 
         if (removedNodes.size() > 0 || addedNodes.size() > 0) {
             try {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java Mon Jul 13 15:55:55 2009
@@ -65,8 +65,11 @@
 import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.commons.AbstractSession;
 import org.apache.jackrabbit.core.RepositoryImpl.WorkspaceInfo;
+import org.apache.jackrabbit.core.cluster.ClusterException;
+import org.apache.jackrabbit.core.cluster.ClusterNode;
 import org.apache.jackrabbit.core.config.WorkspaceConfig;
 import org.apache.jackrabbit.core.data.GarbageCollector;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.lock.LockManager;
 import org.apache.jackrabbit.core.nodetype.NodeDefinitionImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
@@ -99,7 +102,6 @@
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
-import org.apache.jackrabbit.uuid.UUID;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.ContentHandler;
@@ -111,6 +113,19 @@
 public class SessionImpl extends AbstractSession
         implements JackrabbitSession, NamespaceResolver, NamePathResolver, IdentifierResolver, Dumpable {
 
+    /**
+     * Name of the session attribute that controls whether the
+     * {@link #refresh(boolean)} method will cause the repository to
+     * synchronize itself to changes in other cluster nodes. This cluster
+     * synchronization is enabled by default, unless an attribute with this
+     * name is set (any non-null value) for this session.
+     *
+     * @since Apache Jackrabbit 1.6
+     * @see <a href="https://issues.apache.org/jira/browse/JCR-1753">JCR-1753</a>
+     */
+    public static final String DISABLE_CLUSTER_SYNC_ON_REFRESH =
+        "org.apache.jackrabbit.disableClusterSyncOnRefresh";
+
     private static Logger log = LoggerFactory.getLogger(SessionImpl.class);
 
     /**
@@ -499,35 +514,6 @@
     }
 
     /**
-     * Retrieves the referenceable node with the given <code>UUID</code>.
-     *
-     * @param uuid uuid of the node to be retrieved
-     * @return referenceable node with the given uuid
-     * @throws ItemNotFoundException if no node exists with the given uuid or
-     * if the existing node is not referenceable.
-     * @throws RepositoryException if another error occurs.
-     * @see #getNodeByUUID(String)
-     * @see #getNodeById(NodeId)
-     */
-    public Node getNodeByUUID(UUID uuid) throws ItemNotFoundException, RepositoryException {
-        NodeImpl node = getNodeById(new NodeId(uuid));
-        // since the uuid of a node is only exposed through jcr:uuid declared
-        // by mix:referenceable it's rather unlikely that a client can possibly
-        // know the internal uuid of a non-referenceable node; omitting the
-        // check for mix:referenceable seems therefore to be a reasonable
-        // compromise in order to improve performance.
-/*
-        if (node.isNodeType(Name.MIX_REFERENCEABLE)) {
-            return node;
-        } else {
-            // there is a node with that uuid but the node does not expose it
-            throw new ItemNotFoundException(uuid.toString());
-        }
-*/
-        return node;
-    }
-
-    /**
      * Retrieves the <code>Node</code> with the given id.
      *
      * @param id id of node to be retrieved
@@ -845,7 +831,21 @@
      */
     public Node getNodeByUUID(String uuid) throws ItemNotFoundException, RepositoryException {
         try {
-            return getNodeByUUID(UUID.fromString(uuid));
+            NodeImpl node = getNodeById(new NodeId(uuid));
+            // since the uuid of a node is only exposed through jcr:uuid declared
+            // by mix:referenceable it's rather unlikely that a client can possibly
+            // know the internal uuid of a non-referenceable node; omitting the
+            // check for mix:referenceable seems therefore to be a reasonable
+            // compromise in order to improve performance.
+            /*
+            if (node.isNodeType(Name.MIX_REFERENCEABLE)) {
+                return node;
+            } else {
+                // there is a node with that uuid but the node does not expose it
+                throw new ItemNotFoundException(uuid.toString());
+            }
+             */
+            return node;
         } catch (IllegalArgumentException e) {
             // Assuming the exception is from UUID.fromString()
             throw new RepositoryException("Invalid UUID: " + uuid, e);
@@ -915,6 +915,17 @@
         // check sanity of this session
         sanityCheck();
 
+        // JCR-1753: Ensure that we are up to date with cluster changes
+        ClusterNode cluster = rep.getClusterNode();
+        if (cluster != null && clusterSyncOnRefresh()) {
+            try {
+                cluster.sync();
+            } catch (ClusterException e) {
+                throw new RepositoryException(
+                        "Unable to synchronize with the cluster", e);
+            }
+        }
+
         if (!keepChanges) {
             // optimization
             itemStateMgr.disposeAllTransientItemStates();
@@ -924,6 +935,22 @@
     }
 
     /**
+     * Checks whether the {@link #refresh(boolean)} method should cause
+     * cluster synchronization.
+     * <p>
+     * Subclasses can override this method to implement alternative
+     * rules on when cluster synchronization should be done.
+     *
+     * @return <code>true</code> if the {@link #DISABLE_CLUSTER_SYNC_ON_REFRESH}
+     *         attribute is <em>not</em> set, <code>false</code> otherwise
+     * @since Apache Jackrabbit 1.6
+     * @see <a href="https://issues.apache.org/jira/browse/JCR-1753">JCR-1753</a>
+     */
+    protected boolean clusterSyncOnRefresh() {
+        return getAttribute(DISABLE_CLUSTER_SYNC_ON_REFRESH) == null;
+    }
+
+    /**
      * {@inheritDoc}
      */
     public boolean hasPendingChanges() throws RepositoryException {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SystemSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SystemSession.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SystemSession.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SystemSession.java Mon Jul 13 15:55:55 2009
@@ -16,26 +16,28 @@
  */
 package org.apache.jackrabbit.core;
 
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.security.AccessControlPolicy;
+import javax.jcr.security.Privilege;
+import javax.security.auth.Subject;
+
 import org.apache.jackrabbit.core.config.WorkspaceConfig;
+import org.apache.jackrabbit.core.id.ItemId;
 import org.apache.jackrabbit.core.security.AMContext;
+import org.apache.jackrabbit.core.security.AbstractAccessControlManager;
 import org.apache.jackrabbit.core.security.AccessManager;
 import org.apache.jackrabbit.core.security.SystemPrincipal;
-import org.apache.jackrabbit.core.security.AbstractAccessControlManager;
 import org.apache.jackrabbit.core.security.authorization.AccessControlProvider;
-import org.apache.jackrabbit.core.security.authorization.WorkspaceAccessManager;
 import org.apache.jackrabbit.core.security.authorization.PrivilegeRegistry;
-import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.core.security.authorization.WorkspaceAccessManager;
 import org.apache.jackrabbit.spi.Name;
-import javax.jcr.security.Privilege;
-import javax.jcr.security.AccessControlPolicy;
-
-import javax.jcr.AccessDeniedException;
-import javax.jcr.RepositoryException;
-import javax.jcr.PathNotFoundException;
-import javax.security.auth.Subject;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
+import org.apache.jackrabbit.spi.Path;
 
 /**
  * A <code>SystemSession</code> ...

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java Mon Jul 13 15:55:55 2009
@@ -121,13 +121,20 @@
     private final Properties descriptors;
 
     /**
+     * The path to the repository home directory.
+     */
+    private final String home;
+
+    /**
      * Creates a transient repository proxy that will use the given repository
      * factory to initialize the underlying repository instances.
      *
      * @param factory repository factory
+     * @param home    the path to the repository home directory.
      */
-    public TransientRepository(RepositoryFactory factory) {
+    public TransientRepository(RepositoryFactory factory, String home) {
         this.factory = factory;
+        this.home = home;
         this.repository = null;
         this.descriptors = new Properties();
 
@@ -171,7 +178,7 @@
             public RepositoryImpl getRepository() throws RepositoryException {
                 return RepositoryImpl.create(config);
             }
-        });
+        }, config.getHomeDir());
     }
 
     /**
@@ -231,7 +238,14 @@
                             "Invalid repository configuration file: " + xml, e);
                 }
             }
-        });
+        }, dir.getAbsolutePath());
+    }
+
+    /**
+     * @return the path to the repository home directory.
+     */
+    public String getHomeDir() {
+        return home;
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java Mon Jul 13 15:55:55 2009
@@ -41,6 +41,8 @@
 import org.apache.jackrabbit.api.JackrabbitWorkspace;
 import org.apache.jackrabbit.commons.AbstractWorkspace;
 import org.apache.jackrabbit.core.config.WorkspaceConfig;
+import org.apache.jackrabbit.core.id.ItemId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.lock.LockManager;
 import org.apache.jackrabbit.core.lock.SessionLockManager;
 import org.apache.jackrabbit.core.observation.EventStateCollection;
@@ -831,7 +833,7 @@
                 Version[] restored = null;
                 for (VersionImpl v : toRestore.values()) {
                     try {
-                        NodeImpl node = (NodeImpl) session.getNodeByUUID(v.getInternalFrozenNode().getFrozenUUID());
+                        NodeImpl node = (NodeImpl) session.getNodeById(v.getInternalFrozenNode().getFrozenId());
                         restored = node.internalRestore(v, vsel, removeExisting);
                         // remove restored versions from set
                         for (Version r : restored) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ZombieHierarchyManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ZombieHierarchyManager.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ZombieHierarchyManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ZombieHierarchyManager.java Mon Jul 13 15:55:55 2009
@@ -16,16 +16,18 @@
  */
 package org.apache.jackrabbit.core;
 
+import java.util.Iterator;
+
+import org.apache.jackrabbit.core.id.ItemId;
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.state.ChildNodeEntry;
 import org.apache.jackrabbit.core.state.ItemState;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.ItemStateManager;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.NodeState;
-import org.apache.jackrabbit.core.state.ChildNodeEntry;
 import org.apache.jackrabbit.spi.Name;
 
-import java.util.Iterator;
-
 /**
  * <code>HierarchyManager</code> implementation that is also able to
  * build/resolve paths of those items that have been moved or removed

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ChangeLogRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ChangeLogRecord.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ChangeLogRecord.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ChangeLogRecord.java Mon Jul 13 15:55:55 2009
@@ -28,7 +28,7 @@
 import javax.jcr.Session;
 import javax.jcr.PropertyType;
 
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.journal.JournalException;
 import org.apache.jackrabbit.core.journal.Record;
@@ -370,27 +370,21 @@
     protected void doWrite() throws JournalException {
         writeTimestampRecord();
         writeUserDataRecord();
-        Iterator deletedStates = changes.deletedStates();
-        while (deletedStates.hasNext()) {
-            ItemState state = (ItemState) deletedStates.next();
+        for (ItemState state : changes.deletedStates()) {
             if (state.isNode()) {
                 writeNodeRecord(DELETED, (NodeState) state);
             } else {
                 writePropertyRecord(DELETED, (PropertyState) state);
             }
         }
-        Iterator modifiedStates = changes.modifiedStates();
-        while (modifiedStates.hasNext()) {
-            ItemState state = (ItemState) modifiedStates.next();
+        for (ItemState state : changes.modifiedStates()) {
             if (state.isNode()) {
                 writeNodeRecord(MODIFIED, (NodeState) state);
             } else {
                 writePropertyRecord(MODIFIED, (PropertyState) state);
             }
         }
-        Iterator addedStates = changes.addedStates();
-        while (addedStates.hasNext()) {
-            ItemState state = (ItemState) addedStates.next();
+        for (ItemState state : changes.addedStates()) {
             if (state.isNode()) {
                 writeNodeRecord(ADDED, (NodeState) state);
             } else {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java Mon Jul 13 15:55:55 2009
@@ -26,7 +26,7 @@
 import javax.jcr.RepositoryException;
 
 import org.apache.commons.io.FileUtils;
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.cluster.WorkspaceRecord.CreateWorkspaceAction;
 import org.apache.jackrabbit.core.config.ClusterConfig;
 import org.apache.jackrabbit.core.config.ConfigurationException;
@@ -132,6 +132,15 @@
     private final Latch stopLatch = new Latch();
 
     /**
+     * Sync counter, used to avoid repeated sync() calls from piling up.
+     * Only updated within the critical section guarded by {@link #syncLock}.
+     *
+     * @since Apache Jackrabbit 1.6
+     * @see <a href="https://issues.apache.org/jira/browse/JCR-1753">JCR-1753</a>
+     */
+    private volatile int syncCount = 0;
+
+    /**
      * Status flag, one of {@link #NONE}, {@link #STARTED} or {@link #STOPPED}.
      */
     private int status;
@@ -304,6 +313,8 @@
      * @throws ClusterException if an error occurs
      */
     public void sync() throws ClusterException {
+        int count = syncCount;
+
         try {
             syncLock.acquire();
         } catch (InterruptedException e) {
@@ -312,7 +323,12 @@
         }
 
         try {
-            journal.sync();
+            // JCR-1753: Only synchronize if no other thread already did so
+            // while we were waiting to acquire the syncLock.
+            if (count == syncCount) {
+                journal.sync();
+                syncCount++;
+            }
         } catch (JournalException e) {
             throw new ClusterException(e.getMessage(), e.getCause());
         } finally {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/LockEventChannel.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/LockEventChannel.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/LockEventChannel.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/LockEventChannel.java Mon Jul 13 15:55:55 2009
@@ -16,7 +16,7 @@
  */
 package org.apache.jackrabbit.core.cluster;
 
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.NodeId;
 
 /**
  * Event channel used to transmit lock events.

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

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

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java Mon Jul 13 15:55:55 2009
@@ -16,9 +16,8 @@
  */
 package org.apache.jackrabbit.core.data;
 
-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.RepositoryImpl;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.SessionListener;
@@ -217,9 +216,7 @@
 
     private void scanPersistenceManagers() throws ItemStateException, RepositoryException {
         for (IterablePersistenceManager pm : pmList) {
-            NodeIdIterator it = pm.getAllNodeIds(null, 0);
-            while (it.hasNext()) {
-                NodeId id = it.nextNodeId();
+            for (NodeId id : pm.getAllNodeIds(null, 0)) {
                 if (callback != null) {
                     callback.beforeScanning(null);
                 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java Mon Jul 13 15:55:55 2009
@@ -1178,8 +1178,7 @@
                     // Skip comments and empty lines
                     if (!sql.startsWith("#") && sql.length() > 0) {
                         // replace prefix variable
-                        sql = Text.replace(sql, SCHEMA_OBJECT_PREFIX_VARIABLE, schemaObjectPrefix);
-                        // execute sql stmt
+                        sql = createSchemaSql(sql);
                         stmt.executeUpdate(sql);
                     }
                     // read next sql stmt
@@ -1193,6 +1192,14 @@
     }
 
     /**
+     * Replace wildcards.
+     */
+    protected String createSchemaSql(String sql) {
+        sql = Text.replace(sql, SCHEMA_OBJECT_PREFIX_VARIABLE, schemaObjectPrefix);
+        return sql;
+    }
+
+    /**
      * Builds the SQL statements
      */
     protected void buildSQLStatements() {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DbFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DbFileSystem.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DbFileSystem.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DbFileSystem.java Mon Jul 13 15:55:55 2009
@@ -77,6 +77,17 @@
  *       &lt;param name="schemaObjectPrefix" value="rep_"/&gt;
  *   &lt;/FileSystem&gt;
  * </pre>
+ * The following is a fragment from a sample configuration using Ingres:
+ * <pre>
+ *   &lt;FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem"&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="rep_"/&gt;
+ *   &lt;/FileSystem&gt;
+ * </pre>
  * The following is a fragment from a sample configuration using PostgreSQL:
  * <pre>
  *   &lt;FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem"&gt;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java Mon Jul 13 15:55:55 2009
@@ -25,8 +25,8 @@
 
 import org.apache.commons.collections.BidiMap;
 import org.apache.commons.collections.bidimap.DualHashBidiMap;
-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.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
@@ -129,7 +129,7 @@
                 writeInt(index);
             } else {
                 writeByte(UUID_LITERAL);
-                write(nodeId.getUUID().getRawBytes());
+                write(nodeId.getRawBytes());
             }
         }
     }
@@ -228,7 +228,7 @@
         } else if (uuidType == UUID_LITERAL) {
             byte[] b = new byte[Constants.UUID_BYTE_LENGTH];
             readFully(b);
-            NodeId nodeId = new NodeId(new UUID(b));
+            NodeId nodeId = new NodeId(b);
             nodeIdIndex.put(nodeId, nodeIdIndex.size());
             return nodeId;
         } else {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java Mon Jul 13 15:55:55 2009
@@ -16,8 +16,8 @@
  */
 package org.apache.jackrabbit.core.journal;
 
-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.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java Mon Jul 13 15:55:55 2009
@@ -17,7 +17,7 @@
 package org.apache.jackrabbit.core.lock;
 
 import org.apache.jackrabbit.core.SessionImpl;
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.NodeId;
 
 import javax.jcr.Session;
 

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

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java Mon Jul 13 15:55:55 2009
@@ -19,11 +19,11 @@
 import EDU.oswego.cs.dl.util.concurrent.ReentrantLock;
 import org.apache.commons.collections.map.LinkedMap;
 import org.apache.commons.io.IOUtils;
-import org.apache.jackrabbit.core.ItemId;
+import org.apache.jackrabbit.core.id.ItemId;
 import org.apache.jackrabbit.core.ItemValidator;
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.NodeImpl;
-import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.SessionListener;
 import org.apache.jackrabbit.core.TransactionContext;

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

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java Mon Jul 13 15:55:55 2009
@@ -19,7 +19,7 @@
 import org.apache.jackrabbit.core.TransactionException;
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.SessionImpl;
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java Mon Jul 13 15:55:55 2009
@@ -16,7 +16,7 @@
  */
 package org.apache.jackrabbit.core.nodetype.virtual;
 
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.PropertyImpl;
 import org.apache.jackrabbit.core.SessionImpl;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java Mon Jul 13 15:55:55 2009
@@ -24,7 +24,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.version.OnParentVersionAction;
 
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.nodetype.NodeDef;
 import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
@@ -39,7 +39,6 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
-import org.apache.jackrabbit.uuid.UUID;
 
 /**
  * This Class implements a virtual item state provider that exposes the
@@ -156,7 +155,7 @@
     private VirtualNodeState createNodeTypeState(VirtualNodeState parent,
                                                  NodeTypeDef ntDef)
             throws RepositoryException {
-        NodeId id = new NodeId(calculateStableUUID(ntDef.getName().toString()));
+        NodeId id = calculateStableId(ntDef.getName().toString());
         VirtualNodeState ntState = createNodeState(parent, ntDef.getName(), id, NameConstants.NT_NODETYPE);
 
         // add properties
@@ -201,8 +200,8 @@
                                                     PropDef propDef,
                                                     NodeTypeDef ntDef, int n)
             throws RepositoryException {
-        NodeId id = new NodeId(calculateStableUUID(
-                ntDef.getName().toString() + "/" + NameConstants.JCR_PROPERTYDEFINITION.toString() + "/" + n));
+        NodeId id = calculateStableId(
+                ntDef.getName().toString() + "/" + NameConstants.JCR_PROPERTYDEFINITION.toString() + "/" + n);
         VirtualNodeState pState = createNodeState(
                 parent, NameConstants.JCR_PROPERTYDEFINITION, id,
                 NameConstants.NT_PROPERTYDEFINITION);
@@ -250,8 +249,8 @@
                                                      NodeDef cnDef,
                                                      NodeTypeDef ntDef, int n)
             throws RepositoryException {
-        NodeId id = new NodeId(calculateStableUUID(
-                ntDef.getName().toString() + "/" + NameConstants.JCR_CHILDNODEDEFINITION.toString() + "/" + n));
+        NodeId id = calculateStableId(
+                ntDef.getName().toString() + "/" + NameConstants.JCR_CHILDNODEDEFINITION.toString() + "/" + n);
         VirtualNodeState pState = createNodeState(
                 parent, NameConstants.JCR_CHILDNODEDEFINITION, id, NameConstants.NT_CHILDNODEDEFINITION);
         // add properties
@@ -273,18 +272,18 @@
     }
 
     /**
-     * Calclulates a stable uuid out of the given string. The alogrith does a
-     * MD5 digest from the string an converts it into the uuid format.
+     * Calculates a stable identifier out of the given string. The algorithm
+     * does a MD5 digest from the string an converts it into the UUID format.
      *
      * @param name
      * @return
      * @throws RepositoryException
      */
-    private static UUID calculateStableUUID(String name) throws RepositoryException {
+    private static NodeId calculateStableId(String name) throws RepositoryException {
         try {
             MessageDigest md = MessageDigest.getInstance("MD5");
             byte[] digest = md.digest(name.getBytes("utf-8"));
-            return new UUID(digest);
+            return new NodeId(digest);
         } catch (NoSuchAlgorithmException e) {
             throw new RepositoryException(e);
         } catch (UnsupportedEncodingException e) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ChangeLogBasedHierarchyMgr.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ChangeLogBasedHierarchyMgr.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ChangeLogBasedHierarchyMgr.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ChangeLogBasedHierarchyMgr.java Mon Jul 13 15:55:55 2009
@@ -17,9 +17,9 @@
 package org.apache.jackrabbit.core.observation;
 
 import org.apache.jackrabbit.core.HierarchyManager;
-import org.apache.jackrabbit.core.ItemId;
+import org.apache.jackrabbit.core.id.ItemId;
 import org.apache.jackrabbit.core.ZombieHierarchyManager;
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.CachingHierarchyManager;
 import org.apache.jackrabbit.core.state.ChangeLog;
 import org.apache.jackrabbit.core.state.ItemState;
@@ -27,14 +27,12 @@
 import org.apache.jackrabbit.core.state.ItemStateManager;
 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.spi.Path;
 import org.apache.jackrabbit.spi.Name;
 
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.RepositoryException;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 /**
@@ -169,7 +167,7 @@
         /**
          * Always throws a {@link UnsupportedOperationException}.
          */
-        public NodeReferences getNodeReferences(NodeReferencesId id)
+        public NodeReferences getNodeReferences(NodeId id)
                 throws NoSuchItemStateException, ItemStateException {
             throw new UnsupportedOperationException();
         }
@@ -177,7 +175,7 @@
         /**
          * {@inheritDoc}
          */
-        public boolean hasNodeReferences(NodeReferencesId id) {
+        public boolean hasNodeReferences(NodeId id) {
             return false;
         }
     }
@@ -190,7 +188,8 @@
         /**
          * Map of deleted {@link ItemState}s indexed by {@link ItemId}.
          */
-        private final Map deleted = new HashMap();
+        private final Map<ItemId, ItemState> deleted =
+            new HashMap<ItemId, ItemState>();
 
         /**
          * Creates a new <code>AtticItemStateManager</code> based on
@@ -199,8 +198,7 @@
          *  <code>ChangeLog</code>.
          */
         private AtticItemStateManager(ChangeLog changes) {
-            for (Iterator it = changes.deletedStates(); it.hasNext();) {
-                ItemState state = (ItemState) it.next();
+            for (ItemState state : changes.deletedStates()) {
                 deleted.put(state.getId(), state);
             }
         }
@@ -239,7 +237,7 @@
         /**
          * Always throws a {@link UnsupportedOperationException}.
          */
-        public NodeReferences getNodeReferences(NodeReferencesId id)
+        public NodeReferences getNodeReferences(NodeId id)
                 throws NoSuchItemStateException, ItemStateException {
             throw new UnsupportedOperationException();
         }
@@ -247,7 +245,7 @@
         /**
          * {@inheritDoc}
          */
-        public boolean hasNodeReferences(NodeReferencesId id) {
+        public boolean hasNodeReferences(NodeId id) {
             return false;
         }
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java Mon Jul 13 15:55:55 2009
@@ -16,7 +16,7 @@
  */
 package org.apache.jackrabbit.core.observation;
 
-import org.apache.jackrabbit.core.ItemId;
+import org.apache.jackrabbit.core.id.ItemId;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.state.ItemState;
 import org.apache.jackrabbit.spi.Path;
@@ -178,11 +178,11 @@
      * @param events       the collection of {@link EventState}s.
      * @param deletedItems Iterator of deleted <code>ItemState</code>s.
      */
-    void prepareDeleted(EventStateCollection events, Iterator<ItemState> deletedItems) {
+    void prepareDeleted(EventStateCollection events, Iterable<ItemState> deletedItems) {
         Set<ItemId> denied = null;
         Set<ItemId> deletedIds = new HashSet<ItemId>();
-        while (deletedItems.hasNext()) {
-            deletedIds.add((deletedItems.next()).getId());
+        for (ItemState state : deletedItems) {
+            deletedIds.add(state.getId());
         }
 
         for (Iterator<EventState> it = events.iterator(); it.hasNext();) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventFilter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventFilter.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventFilter.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventFilter.java Mon Jul 13 15:55:55 2009
@@ -21,7 +21,7 @@
 
 import org.apache.jackrabbit.core.ItemManager;
 import org.apache.jackrabbit.core.SessionImpl;
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
 import org.apache.jackrabbit.spi.Path;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java Mon Jul 13 15:55:55 2009
@@ -22,7 +22,7 @@
 
 import org.apache.jackrabbit.api.observation.JackrabbitEvent;
 import javax.jcr.observation.Event;
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventState.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventState.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventState.java Mon Jul 13 15:55:55 2009
@@ -17,9 +17,9 @@
 package org.apache.jackrabbit.core.observation;
 
 import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
-import org.apache.jackrabbit.core.ItemId;
-import org.apache.jackrabbit.core.PropertyId;
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.ItemId;
+import org.apache.jackrabbit.core.id.PropertyId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.spi.Path;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java Mon Jul 13 15:55:55 2009
@@ -17,8 +17,8 @@
 package org.apache.jackrabbit.core.observation;
 
 import org.apache.jackrabbit.core.HierarchyManager;
-import org.apache.jackrabbit.core.ItemId;
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.ItemId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
 import org.apache.jackrabbit.core.state.ChangeLog;
@@ -160,9 +160,7 @@
          */
 
         // 1. modified items
-
-        for (Iterator<ItemState> it = changes.modifiedStates(); it.hasNext();) {
-            ItemState state = it.next();
+        for (ItemState state : changes.modifiedStates()) {
             if (state.isNode()) {
                 // node changed
                 // covers the following cases:
@@ -349,9 +347,7 @@
         }
 
         // 2. removed items
-
-        for (Iterator<ItemState> it = changes.deletedStates(); it.hasNext();) {
-            ItemState state = it.next();
+        for (ItemState state : changes.deletedStates()) {
             if (state.isNode()) {
                 // node deleted
                 NodeState n = (NodeState) state;
@@ -391,9 +387,7 @@
         }
 
         // 3. added items
-
-        for (Iterator<ItemState> it = changes.addedStates(); it.hasNext();) {
-            ItemState state = it.next();
+        for (ItemState state : changes.addedStates()) {
             if (state.isNode()) {
                 // node created
                 NodeState n = (NodeState) state;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java Mon Jul 13 15:55:55 2009
@@ -18,7 +18,7 @@
 
 import org.apache.jackrabbit.core.ItemManager;
 import org.apache.jackrabbit.core.SessionImpl;
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.cluster.ClusterNode;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/AbstractPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/AbstractPersistenceManager.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/AbstractPersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/AbstractPersistenceManager.java Mon Jul 13 15:55:55 2009
@@ -16,8 +16,8 @@
  */
 package org.apache.jackrabbit.core.persistence;
 
-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.state.ChangeLog;
 import org.apache.jackrabbit.core.state.ItemState;
 import org.apache.jackrabbit.core.state.ItemStateException;
@@ -25,8 +25,6 @@
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
 
-import java.util.Iterator;
-
 /**
  * Implementation <code>PersistenceManager</code> that handles some
  * concepts.
@@ -57,40 +55,32 @@
      * {@inheritDoc}
      */
     public synchronized void store(ChangeLog changeLog) throws ItemStateException {
-        Iterator<ItemState> iter = changeLog.deletedStates();
-        while (iter.hasNext()) {
-            ItemState state = iter.next();
+        for (ItemState state : changeLog.deletedStates()) {
             if (state.isNode()) {
                 destroy((NodeState) state);
             } else {
                 destroy((PropertyState) state);
             }
         }
-        iter = changeLog.addedStates();
-        while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+        for (ItemState state : changeLog.addedStates()) {
             if (state.isNode()) {
                 store((NodeState) state);
             } else {
                 store((PropertyState) state);
             }
         }
-        iter = changeLog.modifiedStates();
-        while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+        for (ItemState state : changeLog.modifiedStates()) {
             if (state.isNode()) {
                 store((NodeState) state);
             } else {
                 store((PropertyState) state);
             }
         }
-        Iterator<NodeReferences> refIter = changeLog.modifiedRefs();
-        while (iter.hasNext()) {
-            NodeReferences refs = refIter.next();
+        for (NodeReferences refs : changeLog.modifiedRefs()) {
             if (refs.hasReferences()) {
                 store(refs);
             } else {
-                if (exists(refs.getId())) {
+                if (existsReferencesTo(refs.getTargetId())) {
                     destroy(refs);
                 }
             }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/IterablePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/IterablePersistenceManager.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/IterablePersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/IterablePersistenceManager.java Mon Jul 13 15:55:55 2009
@@ -16,8 +16,7 @@
  */
 package org.apache.jackrabbit.core.persistence;
 
-import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.NodeIdIterator;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.state.ItemStateException;
 
 import javax.jcr.RepositoryException;
@@ -42,7 +41,7 @@
      * @throws ItemStateException if an error while loading occurs.
      * @throws RepositoryException if a repository exception occurs
      */
-    NodeIdIterator getAllNodeIds(NodeId after, int maxCount)
+    Iterable<NodeId> getAllNodeIds(NodeId after, int maxCount)
             throws ItemStateException, RepositoryException;
 
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PMContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PMContext.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PMContext.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PMContext.java Mon Jul 13 15:55:55 2009
@@ -19,7 +19,7 @@
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.NodeId;
 
 import javax.jcr.NamespaceRegistry;
 import java.io.File;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceCopier.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceCopier.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceCopier.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceCopier.java Mon Jul 13 15:55:55 2009
@@ -19,13 +19,12 @@
 import java.util.HashSet;
 import java.util.Set;
 
-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.state.ChangeLog;
 import org.apache.jackrabbit.core.state.ChildNodeEntry;
 import org.apache.jackrabbit.core.state.ItemStateException;
 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.spi.Name;
@@ -142,11 +141,11 @@
         }
 
         // Copy all node references
-        NodeReferencesId refsId = new NodeReferencesId(sourceNode.getNodeId());
-        if (source.exists(refsId)) {
-            changes.modified(source.load(refsId));
-        } else if (target.exists(refsId)) {
-            NodeReferences references = target.load(refsId);
+        if (source.existsReferencesTo(sourceNode.getNodeId())) {
+            changes.modified(source.loadReferencesTo(sourceNode.getNodeId()));
+        } else if (target.existsReferencesTo(sourceNode.getNodeId())) {
+            NodeReferences references =
+                target.loadReferencesTo(sourceNode.getNodeId());
             references.clearAllReferences();
             changes.modified(references);
         }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceManager.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PersistenceManager.java Mon Jul 13 15:55:55 2009
@@ -16,14 +16,13 @@
  */
 package org.apache.jackrabbit.core.persistence;
 
-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.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.NodeReferences;
-import org.apache.jackrabbit.core.state.NodeReferencesId;
 import org.apache.jackrabbit.core.state.ChangeLog;
 
 /**
@@ -132,13 +131,13 @@
             throws NoSuchItemStateException, ItemStateException;
 
     /**
-     * Load the persistent members of a node references object.
+     * Load the persisted references to the node with the given identifier.
      *
      * @param id reference target node id
      * @throws NoSuchItemStateException if the target node does not exist
      * @throws ItemStateException if another error occurs
      */
-    NodeReferences load(NodeReferencesId id)
+    NodeReferences loadReferencesTo(NodeId id)
             throws NoSuchItemStateException, ItemStateException;
 
     /**
@@ -169,7 +168,7 @@
      *         <code>false</code> otherwise
      * @throws ItemStateException on persistence manager errors
      */
-    boolean exists(NodeReferencesId targetId) throws ItemStateException;
+    boolean existsReferencesTo(NodeId targetId) throws ItemStateException;
 
     /**
      * Atomically saves the given set of changes.



Mime
View raw message