You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2009/09/17 20:48:42 UTC

svn commit: r816333 - in /jackrabbit/sandbox/JCR-2170: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journa...

Author: mreutegg
Date: Thu Sep 17 18:48:41 2009
New Revision: 816333

URL: http://svn.apache.org/viewvc?rev=816333&view=rev
Log:
JCR-2170: Remove PropDefId and NodeDefId
- merge with recent changes from trunk

Added:
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/JournalFactory.java
      - copied unchanged from r816328, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/JournalFactory.java
Removed:
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/JournalConfig.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterTest.java
Modified:
    jackrabbit/sandbox/JCR-2170/   (props changed)
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ClusterConfig.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/UserTransactionImpl.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestAll.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/journal/FileJournalTest.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository.xml
    jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractOperation.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddNode.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Operation.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPropertyValue.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/ReferenceChangeTracker.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/Importer.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
    jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java

Propchange: jackrabbit/sandbox/JCR-2170/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep 17 18:48:41 2009
@@ -1,3 +1,3 @@
 /jackrabbit/branches/1.5:794012,794100,794102
 /jackrabbit/sandbox/tripod-JCR-2209:795441-795863
-/jackrabbit/trunk:812417-816122
+/jackrabbit/trunk:812417-816328

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java Thu Sep 17 18:48:41 2009
@@ -16,23 +16,16 @@
  */
 package org.apache.jackrabbit.core.cluster;
 
-import java.io.File;
-import java.io.IOException;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.UUID;
 
 import javax.jcr.RepositoryException;
 
-import org.apache.commons.io.FileUtils;
-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;
-import org.apache.jackrabbit.core.config.JournalConfig;
-import org.apache.jackrabbit.core.journal.AbstractJournal;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.journal.InstanceRevision;
 import org.apache.jackrabbit.core.journal.Journal;
 import org.apache.jackrabbit.core.journal.JournalException;
@@ -63,11 +56,6 @@
     public static final String SYSTEM_PROPERTY_NODE_ID = "org.apache.jackrabbit.core.cluster.node_id";
 
     /**
-     * Cluster node id file.
-     */
-    private static final String CLUSTER_NODE_ID_FILE = "cluster_node.id";
-
-    /**
      * Producer identifier.
      */
     private static final String PRODUCER_ID = "JR";
@@ -209,35 +197,20 @@
      */
     protected void init() throws ClusterException {
         ClusterConfig cc = clusterContext.getClusterConfig();
-        clusterNodeId = getClusterNodeId(cc.getId());
+        clusterNodeId = cc.getId();
         syncDelay = cc.getSyncDelay();
 
         try {
-            JournalConfig jc = cc.getJournalConfig();
-            journal = (Journal) jc.newInstance();
-            setRepositoryHome(journal, clusterContext.getRepositoryHome());
-            journal.init(clusterNodeId, clusterContext.getNamespaceResolver());
+            journal = cc.getJournal(clusterContext.getNamespaceResolver());
             instanceRevision = journal.getInstanceRevision();
             journal.register(this);
             producer = journal.getProducer(PRODUCER_ID);
-        } catch (ConfigurationException e) {
-            throw new ClusterException(e.getMessage(), e.getCause());
+        } catch (RepositoryException e) {
+            throw new ClusterException(
+                    "Cluster initialization failed: " + this, e);
         } catch (JournalException e) {
-            throw new ClusterException(e.getMessage(), e.getCause());
-        }
-    }
-
-    /**
-     * Set a journal's repository home, if possible, i.e. if it is an
-     * <code>AbstractJournal</code>
-     *
-     * @param journal journal instance
-     * @param repHome repository home
-     */
-    private void setRepositoryHome(Journal journal, File repHome) {
-        if (journal instanceof AbstractJournal) {
-            AbstractJournal aj = (AbstractJournal) journal;
-            aj.setRepositoryHome(repHome);
+            throw new ClusterException(
+                    "Journal initialization failed: " + this, e);
         }
     }
 
@@ -394,44 +367,6 @@
         return journal;
     }
 
-    /**
-     * Return the instance id to be used for this node in the cluster.
-     * @param id configured id, <code>null</code> to generate a unique id
-     */
-    private String getClusterNodeId(String id) throws ClusterException {
-        if (id == null) {
-            id = System.getProperty(SYSTEM_PROPERTY_NODE_ID);
-            if (id == null) {
-                try {
-                    id = getClusterNodeIdFromFile();
-                } catch (IOException e) {
-                    throw new ClusterException(e.getMessage(), e.getCause());
-                }
-            }
-        }
-        return id;
-    }
-
-    /**
-     * Return a cluster node from a file, creating it if necessary.
-     *
-     * @return stored or generated cluster id
-     * @throws IOException if an I/O error occurs
-     */
-    protected String getClusterNodeIdFromFile() throws IOException {
-        String filename = clusterContext.getRepositoryHome() + File.separator + CLUSTER_NODE_ID_FILE;
-        File f = new File(filename);
-
-        if (f.exists() && f.canRead()) {
-            return FileUtils.readFileToString(f);
-        }
-
-        String id = UUID.randomUUID().toString();
-        FileUtils.writeStringToFile(f, id);
-        return id;
-
-    }
-
     //-----------------------------------------------< NamespaceEventListener >
 
     /**

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java Thu Sep 17 18:48:41 2009
@@ -20,7 +20,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Iterator;
 import java.util.Properties;
 import java.util.Map;
 import java.util.HashMap;
@@ -33,7 +32,7 @@
  * and property information required to instantiate a class that conforms
  * with the JavaBean conventions.
  */
-public class BeanConfig {
+public class BeanConfig<T> {
 
     private static Logger log = LoggerFactory.getLogger(BeanConfig.class);
 
@@ -155,27 +154,24 @@
     public Object newInstance() throws ConfigurationException {
         try {
             // Instantiate the object using the default constructor
-            Class objectClass =
+            Class<?> objectClass =
                 Class.forName(getClassName(), true, getClassLoader());
             Object object = objectClass.newInstance();
 
             // Set all configured bean properties
             BeanMap map = new BeanMap(object);
-            Iterator iterator = map.keyIterator();
-            while (iterator.hasNext()) {
-                String name = (String) iterator.next();
-                String value = properties.getProperty(name);
+            for (Object key : map.keySet()) {
+                String value = properties.getProperty(key.toString());
                 if (value != null) {
-                    map.put(name, properties.getProperty(name));
+                    map.put(key, value);
                 }
             }
 
             if (validate) {
                 // Check that no invalid property names were configured
-                Iterator it = properties.keySet().iterator();
-                while (it.hasNext()) {
-                    String key = (String) it.next();
-                    if (!map.containsKey(key) && properties.getProperty(key) != null) {
+                for (Object key : properties.keySet()) {
+                    if (!map.containsKey(key)
+                            && properties.getProperty(key.toString()) != null) {
                         String msg =
                             "Configured class " + object.getClass().getName()
                             + " does not contain the property " + key
@@ -186,7 +182,7 @@
                 }
             }
 
-            return object;
+            return (T) object;
         } catch (ClassNotFoundException e) {
             throw new ConfigurationException(
                     "Configured bean implementation class " + getClassName()

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ClusterConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ClusterConfig.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ClusterConfig.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ClusterConfig.java Thu Sep 17 18:48:41 2009
@@ -16,11 +16,16 @@
  */
 package org.apache.jackrabbit.core.config;
 
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.core.journal.Journal;
+import org.apache.jackrabbit.core.journal.JournalFactory;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+
 /**
- * Cluster configuration. This includes the journal configuration
- * {@link JournalConfig}.
+ * Cluster configuration.
  */
-public class ClusterConfig {
+public class ClusterConfig implements JournalFactory {
 
     /**
      * Identifier.
@@ -33,9 +38,9 @@
     private final long syncDelay;
 
     /**
-     * Journal configuration.
+     * Journal factory.
      */
-    private final JournalConfig jc;
+    private final JournalFactory jf;
 
     /**
      * Creates a new cluster configuration.
@@ -44,10 +49,10 @@
      * @param syncDelay syncDelay, in milliseconds
      * @param jc journal configuration
      */
-    public ClusterConfig(String id, long syncDelay, JournalConfig jc) {
+    public ClusterConfig(String id, long syncDelay, JournalFactory jf) {
         this.id = id;
         this.syncDelay = syncDelay;
-        this.jc = jc;
+        this.jf = jf;
     }
 
     /**
@@ -69,11 +74,16 @@
     }
 
     /**
-     * Returns the journal configuration.
+     * Returns an initialized journal instance.
      *
-     * @return journal configuration
-     */
-    public JournalConfig getJournalConfig() {
-        return jc;
+     * @param resolver namespace resolver
+     * @return initialized journal
+     * @throws RepositoryException 
+     * @throws RepositoryException if the journal can not be created
+     */
+    public Journal getJournal(NamespaceResolver resolver)
+            throws RepositoryException {
+        return jf.getJournal(resolver);
     }
+
 }

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java Thu Sep 17 18:48:41 2009
@@ -16,24 +16,33 @@
  */
 package org.apache.jackrabbit.core.config;
 
+import org.apache.commons.io.FileUtils;
+import org.apache.jackrabbit.core.cluster.ClusterNode;
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.data.DataStoreFactory;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.FileSystemFactory;
+import org.apache.jackrabbit.core.journal.AbstractJournal;
+import org.apache.jackrabbit.core.journal.Journal;
+import org.apache.jackrabbit.core.journal.JournalException;
+import org.apache.jackrabbit.core.journal.JournalFactory;
 import org.apache.jackrabbit.core.state.DefaultISMLocking;
 import org.apache.jackrabbit.core.state.ISMLocking;
 import org.apache.jackrabbit.core.state.ISMLockingFactory;
 import org.apache.jackrabbit.core.util.RepositoryLock;
 import org.apache.jackrabbit.core.util.RepositoryLockMechanism;
 import org.apache.jackrabbit.core.util.RepositoryLockMechanismFactory;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.xml.sax.InputSource;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.Properties;
+import java.util.UUID;
 
 import javax.jcr.RepositoryException;
 
@@ -169,6 +178,11 @@
     private static final String AC_PROVIDER_ELEMENT = "AccessControlProvider";
 
     /**
+     * Name of the cluster node id file.
+     */
+    private static final String CLUSTER_NODE_ID_FILE = "cluster_node.id";
+
+    /**
      * Creates a new configuration parser with the given parser variables.
      *
      * @param variables parser variables
@@ -265,7 +279,7 @@
         SearchConfig sc = parseSearchConfig(root);
 
         // Optional journal configuration
-        ClusterConfig cc = parseClusterConfig(root);
+        ClusterConfig cc = parseClusterConfig(root, new File(home));
 
         // Optional data store factory
         DataStoreFactory dsf = getDataStoreFactory(root, home);
@@ -666,10 +680,11 @@
      * method returns <code>null</code>.
      *
      * @param parent parent of the <code>Journal</code> element
+     * @param home repository home directory
      * @return cluster configuration, or <code>null</code>
      * @throws ConfigurationException if the configuration is broken
      */
-    protected ClusterConfig parseClusterConfig(Element parent)
+    protected ClusterConfig parseClusterConfig(Element parent, File home)
             throws ConfigurationException {
 
         NodeList children = parent.getChildNodes();
@@ -679,17 +694,32 @@
                     && CLUSTER_ELEMENT.equals(child.getNodeName())) {
                 Element element = (Element) child;
 
-                String id = null;
-
+                // Find the cluster node id
+                String id =
+                    System.getProperty(ClusterNode.SYSTEM_PROPERTY_NODE_ID);
                 String value = getAttribute(element, ID_ATTRIBUTE, null);
                 if (value != null) {
                     id = replaceVariables(value);
+                } else if (id == null) {
+                    File file = new File(home, CLUSTER_NODE_ID_FILE);
+                    try {
+                        if (file.exists() && file.canRead()) {
+                            id = FileUtils.readFileToString(file);
+                        } else {
+                            id = UUID.randomUUID().toString();
+                            FileUtils.writeStringToFile(file, id);
+                        }
+                    } catch (IOException e) {
+                        throw new ConfigurationException(
+                                "Failed to access cluster node id: " + file, e);
+                    }
                 }
-                value = getAttribute(element, SYNC_DELAY_ATTRIBUTE, DEFAULT_SYNC_DELAY);
-                long syncDelay = Long.parseLong(replaceVariables(value));
 
-                JournalConfig jc = parseJournalConfig(element);
-                return new ClusterConfig(id, syncDelay, jc);
+                long syncDelay = Long.parseLong(replaceVariables(getAttribute(
+                        element, SYNC_DELAY_ATTRIBUTE, DEFAULT_SYNC_DELAY)));
+
+                JournalFactory jf = getJournalFactory(element, home, id);
+                return new ClusterConfig(id, syncDelay, jf);
             }
         }
         return null;
@@ -708,14 +738,39 @@
      * element.
      *
      * @param cluster parent cluster element
-     * @return journal configuration, or <code>null</code>
-     * @throws ConfigurationException if the configuration is broken
-     */
-    protected JournalConfig parseJournalConfig(Element cluster)
-            throws ConfigurationException {
-
-        return new JournalConfig(
-                parseBeanConfig(cluster, JOURNAL_ELEMENT));
+     * @param home repository home directory
+     * @param id cluster node id
+     * @return journal factory
+     * @throws ConfigurationException if the configuration is broken
+     */
+    protected JournalFactory getJournalFactory(
+            final Element cluster, final File home, final String id)
+            throws ConfigurationException {
+        return new JournalFactory() {
+            public Journal getJournal(NamespaceResolver resolver)
+                    throws RepositoryException {
+                BeanConfig config = parseBeanConfig(cluster, JOURNAL_ELEMENT);
+                Object object = config.newInstance();
+                if (object instanceof Journal) {
+                    Journal journal = (Journal) object;
+                    if (journal instanceof AbstractJournal) {
+                        ((AbstractJournal) journal).setRepositoryHome(home);
+                    }
+                    try {
+                        journal.init(id, resolver);
+                    } catch (JournalException e) {
+                        // TODO: Should JournalException extend RepositoryException?
+                        throw new RepositoryException(
+                                "Journal initialization failed: " + journal, e);
+                    }
+                    return journal;
+                } else {
+                    throw new RepositoryException(
+                            "Invalid Journal implementation class: "
+                            + config.getClassName());
+                }
+            }
+        };
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/UserTransactionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/UserTransactionImpl.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/UserTransactionImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/UserTransactionImpl.java Thu Sep 17 18:48:41 2009
@@ -122,19 +122,18 @@
 
             status = Status.STATUS_COMMITTING;
             if (distributedThreadAccess) {
-                try {
-                    Thread distributedThread = new Thread() {
-                        public void run() {
-                            try {
-                                xares.commit(xid, false);
-                            } catch (Exception e) {
-                                throw new RuntimeException(e.getMessage());
-                            }
+                Thread distributedThread = new Thread() {
+                    public void run() {
+                        try {
+                            xares.commit(xid, false);
+                        } catch (Exception e) {
+                            throw new RuntimeException(e.getMessage());
                         }
-                    };
-                    distributedThread.start();
-                    distributedThread.join(1000);
-                } catch (InterruptedException e) {
+                    }
+                };
+                distributedThread.start();
+                distributedThread.join(1000);
+                if (distributedThread.isAlive()) {
                     throw new SystemException(
                             "Commit from different thread but same XID must not block");
                 }
@@ -158,6 +157,8 @@
                 se.initCause(e.getCause());
                 throw se;
             }
+        } catch (InterruptedException e) {
+            throw new SystemException("Thread.join() interrupted");
         }
     }
 

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java Thu Sep 17 18:48:41 2009
@@ -17,22 +17,25 @@
 package org.apache.jackrabbit.core.cluster;
 
 import java.util.ArrayList;
-import java.util.Properties;
 
-import org.apache.jackrabbit.core.id.NodeId;
+import javax.jcr.RepositoryException;
+
 import org.apache.jackrabbit.core.cluster.SimpleEventListener.LockEvent;
 import org.apache.jackrabbit.core.cluster.SimpleEventListener.NamespaceEvent;
 import org.apache.jackrabbit.core.cluster.SimpleEventListener.NodeTypeEvent;
 import org.apache.jackrabbit.core.cluster.SimpleEventListener.UnlockEvent;
 import org.apache.jackrabbit.core.cluster.SimpleEventListener.UpdateEvent;
-import org.apache.jackrabbit.core.config.BeanConfig;
 import org.apache.jackrabbit.core.config.ClusterConfig;
-import org.apache.jackrabbit.core.config.JournalConfig;
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.journal.Journal;
+import org.apache.jackrabbit.core.journal.JournalFactory;
 import org.apache.jackrabbit.core.journal.MemoryJournal;
+import org.apache.jackrabbit.core.journal.MemoryJournal.MemoryRecord;
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.test.JUnitTest;
 
 /**
@@ -59,7 +62,7 @@
     /**
      * Records shared among multiple memory journals.
      */
-    private ArrayList records = new ArrayList();
+    private ArrayList<MemoryRecord> records = new ArrayList<MemoryRecord>();
 
     /**
      * Master.
@@ -179,7 +182,7 @@
         ntd.setName(NameFactoryImpl.getInstance().create("", "test"));
         ntd.setSupertypes(new Name[]{NameConstants.NT_BASE});
 
-        ArrayList list = new ArrayList();
+        ArrayList<NodeTypeDef> list = new ArrayList<NodeTypeDef>();
         list.add(ntd);
 
         NodeTypeEvent event = new NodeTypeEvent(NodeTypeEvent.REGISTER, list);
@@ -202,7 +205,7 @@
         ntd.setName(NameFactoryImpl.getInstance().create("", "test"));
         ntd.setSupertypes(new Name[]{NameConstants.NT_BASE});
 
-        ArrayList list = new ArrayList();
+        ArrayList<NodeTypeDef> list = new ArrayList<NodeTypeDef>();
         list.add(ntd);
 
         NodeTypeEvent event = new NodeTypeEvent(NodeTypeEvent.REREGISTER, list);
@@ -223,7 +226,7 @@
     public void testNodeTypeUnregistration() throws Exception {
         Name name = NameFactoryImpl.getInstance().create("", "test");
 
-        ArrayList list = new ArrayList();
+        ArrayList<Name> list = new ArrayList<Name>();
         list.add(name);
 
         NodeTypeEvent event = new NodeTypeEvent(NodeTypeEvent.UNREGISTER, list);
@@ -277,19 +280,26 @@
      * @param id cluster node id
      * @param records memory journal's list of records
      */
-    private ClusterNode createClusterNode(String id, ArrayList records)
-            throws ClusterException {
-
-        BeanConfig bc = new BeanConfig(MemoryJournal.class.getName(), new Properties());
-        JournalConfig jc = new JournalConfig(bc);
-        ClusterConfig cc = new ClusterConfig(id, SYNC_DELAY, jc);
+    private ClusterNode createClusterNode(
+            String id, ArrayList<MemoryRecord> records) throws Exception {
+        final MemoryJournal journal = new MemoryJournal();
+        JournalFactory jf = new JournalFactory() {
+            public Journal getJournal(NamespaceResolver resolver)
+                    throws RepositoryException {
+                return journal;
+            }
+        };
+        ClusterConfig cc = new ClusterConfig(id, SYNC_DELAY, jf);
         SimpleClusterContext context = new SimpleClusterContext(cc);
 
-        ClusterNode clusterNode = new ClusterNode();
-        clusterNode.init(context);
+        journal.setRepositoryHome(context.getRepositoryHome());
+        journal.init(id, context.getNamespaceResolver());
         if (records != null) {
-            ((MemoryJournal) clusterNode.getJournal()).setRecords(records);
+            journal.setRecords(records);
         }
+
+        ClusterNode clusterNode = new ClusterNode();
+        clusterNode.init(context);
         return clusterNode;
     }
 }

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestAll.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestAll.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestAll.java Thu Sep 17 18:48:41 2009
@@ -38,7 +38,6 @@
         TestSuite suite = new TestSuite();
 
         suite.addTestSuite(ClusterRecordTest.class);
-        suite.addTestSuite(ClusterTest.class);
 
         return suite;
     }

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java Thu Sep 17 18:48:41 2009
@@ -20,6 +20,7 @@
 import org.xml.sax.InputSource;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.input.ClosedInputStream;
+import org.apache.jackrabbit.core.cluster.ClusterNode;
 import org.apache.jackrabbit.core.security.authorization.WorkspaceAccessManager;
 
 import java.io.File;
@@ -259,16 +260,56 @@
         final String id = "testvalue";
         final long syncDelay = 11;
 
-        System.setProperty("cluster.id", id);
+        System.setProperty(ClusterNode.SYSTEM_PROPERTY_NODE_ID, id);
         System.setProperty("cluster.syncDelay", Long.toString(syncDelay));
+        try {
+            InputStream in = getClass().getResourceAsStream(
+                    "/org/apache/jackrabbit/core/cluster/repository.xml");
+            RepositoryConfig config = RepositoryConfig.create(in, DIR.getPath());
+
+            ClusterConfig clusterConfig = config.getClusterConfig();
+            assertEquals(id, clusterConfig.getId());
+            assertEquals(syncDelay, clusterConfig.getSyncDelay());
+        } finally {
+            System.clearProperty(ClusterNode.SYSTEM_PROPERTY_NODE_ID);
+            System.clearProperty("cluster.syncDelay");
+        }
+    }
+
+    public void testAutomaticClusterNodeIdCreation() throws Exception {
+        final long syncDelay = 12;
 
-        InputStream in = getClass().getResourceAsStream(
-                "/org/apache/jackrabbit/core/cluster/repository.xml");
-        RepositoryConfig config = RepositoryConfig.create(in, DIR.getPath());
-
-        ClusterConfig clusterConfig = config.getClusterConfig();
-        assertEquals(id, clusterConfig.getId());
-        assertEquals(syncDelay, clusterConfig.getSyncDelay());
+        System.setProperty("cluster.syncDelay", Long.toString(syncDelay));
+        try {
+            File file = new File(DIR, "cluster_node.id");
+            assertFalse(file.exists());
+
+            // Check that a new cluster node id is automatically persisted
+            InputStream in = getClass().getResourceAsStream(
+                    "/org/apache/jackrabbit/core/cluster/repository.xml");
+            RepositoryConfig config = RepositoryConfig.create(in, DIR.getPath());
+
+            assertTrue(file.exists());
+            String id = FileUtils.readFileToString(file);
+
+            ClusterConfig clusterConfig = config.getClusterConfig();
+            assertEquals(id, clusterConfig.getId());
+            assertEquals(syncDelay, clusterConfig.getSyncDelay());
+
+            // Check that the persisted cluster node id is used when it exists
+            in = getClass().getResourceAsStream(
+                    "/org/apache/jackrabbit/core/cluster/repository.xml");
+            config = RepositoryConfig.create(in, DIR.getPath());
+
+            assertTrue(file.exists());
+            assertEquals(id, FileUtils.readFileToString(file));
+
+            clusterConfig = config.getClusterConfig();
+            assertEquals(id, clusterConfig.getId());
+            assertEquals(syncDelay, clusterConfig.getSyncDelay());
+        } finally {
+            System.clearProperty("cluster.syncDelay");
+        }
     }
 
 }

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/journal/FileJournalTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/journal/FileJournalTest.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/journal/FileJournalTest.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/journal/FileJournalTest.java Thu Sep 17 18:48:41 2009
@@ -17,14 +17,14 @@
 package org.apache.jackrabbit.core.journal;
 
 import java.io.File;
-import java.util.Properties;
+
+import javax.jcr.RepositoryException;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.core.cluster.ClusterNode;
 import org.apache.jackrabbit.core.cluster.SimpleClusterContext;
-import org.apache.jackrabbit.core.config.BeanConfig;
 import org.apache.jackrabbit.core.config.ClusterConfig;
-import org.apache.jackrabbit.core.config.JournalConfig;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.test.JUnitTest;
 
 /**
@@ -87,20 +87,25 @@
      * @see <a href="http://issues.apache.org/jira/browse/JCR-904">JCR-904</a>
      */
     public void testRevisionIsOptional() throws Exception {
-        Properties params = new Properties();
-        params.setProperty("directory", journalDirectory.getPath());
-
-        BeanConfig bc = new BeanConfig(FileJournal.class.getName(), params);
-        JournalConfig jc = new JournalConfig(bc);
-
-        ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jc);
+        final FileJournal journal = new FileJournal();
+        journal.setDirectory(journalDirectory.getPath());
+        JournalFactory jf = new JournalFactory() {
+            public Journal getJournal(NamespaceResolver resolver) {
+                return journal;
+            }
+        };
+        ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jf);
         SimpleClusterContext context = new SimpleClusterContext(cc, repositoryHome);
 
+        journal.setRepositoryHome(repositoryHome);
+        journal.init(CLUSTER_NODE_ID, context.getNamespaceResolver());
+
         ClusterNode clusterNode = new ClusterNode();
         clusterNode.init(context);
 
         try {
-            File revisionFile = new File(repositoryHome, FileJournal.DEFAULT_INSTANCE_FILE_NAME);
+            File revisionFile =
+                new File(repositoryHome, FileJournal.DEFAULT_INSTANCE_FILE_NAME);
             assertTrue(revisionFile.exists());
         } finally {
             clusterNode.stop();
@@ -114,12 +119,13 @@
      * @throws Exception
      */
     public void testClusterInitIncompleteBadJournalClass() throws Exception {
-        Properties params = new Properties();
-
-        BeanConfig bc = new BeanConfig(Object.class.getName(), params);
-        JournalConfig jc = new JournalConfig(bc);
-
-        ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jc);
+        JournalFactory jf = new JournalFactory() {
+            public Journal getJournal(NamespaceResolver resolver)
+                    throws RepositoryException {
+                throw new RepositoryException("Journal not available");
+            }
+        };
+        ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jf);
         SimpleClusterContext context = new SimpleClusterContext(cc);
 
         ClusterNode clusterNode = new ClusterNode();
@@ -142,16 +148,23 @@
      * @throws Exception
      */
     public void testClusterInitIncompleteMissingParam() throws Exception {
-        Properties params = new Properties();
-
-        BeanConfig bc = new BeanConfig(FileJournal.class.getName(), params);
-        JournalConfig jc = new JournalConfig(bc);
-
-        ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jc);
+        JournalFactory jf = new JournalFactory() {
+            public Journal getJournal(NamespaceResolver resolver)
+                    throws RepositoryException {
+                try {
+                    FileJournal journal = new FileJournal();
+                    // no setDirectory() call here
+                    journal.init(CLUSTER_NODE_ID, resolver);
+                    return journal;
+                } catch (JournalException e) {
+                    throw new RepositoryException("Expected failure", e);
+                }
+            }
+        };
+        ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jf);
         SimpleClusterContext context = new SimpleClusterContext(cc);
 
         ClusterNode clusterNode = new ClusterNode();
-
         try {
             clusterNode.init(context);
             fail("Bad cluster configuration.");

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository.xml?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository.xml (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository.xml Thu Sep 17 18:48:41 2009
@@ -142,7 +142,7 @@
     <!--
         Cluster configuration with system variables.
     -->
-    <Cluster id="${cluster.id}" syncDelay="${cluster.syncDelay}">
+    <Cluster syncDelay="${cluster.syncDelay}">
         <Journal class="org.apache.jackrabbit.core.journal.JNDIDatabaseJournal">
             <param name="schema" value="oracle" />
         </Journal>

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java Thu Sep 17 18:48:41 2009
@@ -80,7 +80,7 @@
         });
 
         Map<String, QValue[]> descr = config.getRepositoryService().getRepositoryDescriptors();       
-        descriptors = new HashMap(descr.size());
+        descriptors = new HashMap<String, Value[]>(descr.size());
         for (String key : descr.keySet()) {
             QValue[] qvs = descr.get(key);
             Value[] vs = new Value[qvs.length];
@@ -172,8 +172,8 @@
             if (reference == null) {
                 reference = new Reference(RepositoryImpl.class.getName(), RepositoryImpl.Factory.class.getName(), null);
                 // carry over all addresses from referenceable config
-                for (Enumeration en = confref.getReference().getAll(); en.hasMoreElements(); ) {
-                    reference.add((RefAddr)(en.nextElement()));
+                for (Enumeration<RefAddr> en = confref.getReference().getAll(); en.hasMoreElements(); ) {
+                    reference.add(en.nextElement());
                 }
 
                 // also add the information required by factory class
@@ -223,7 +223,7 @@
         public static final String RCF = RepositoryImpl.class.getName() + ".factory";
         public static final String RCC = RepositoryImpl.class.getName() + ".class";
 
-        public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception {
+        public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment) throws Exception {
 
             Object res = null;
             if (obj instanceof Reference) {
@@ -255,8 +255,8 @@
                         configFactoryClassName, null);
 
                     // carry over all arguments except our own
-                    for (Enumeration en = ref.getAll(); en.hasMoreElements(); ){
-                        RefAddr ra = (RefAddr)en.nextElement();
+                    for (Enumeration<RefAddr> en = ref.getAll(); en.hasMoreElements(); ){
+                        RefAddr ra = en.nextElement();
                         String type = ra.getType();
                         if (! RCF.equals(type) && ! RCC.equals(type)) {
                             newref.add(ra);

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java Thu Sep 17 18:48:41 2009
@@ -76,16 +76,16 @@
      * only if a lock ends his life by {@link Node#unlock()} or by implicit
      * unlock upon {@link Session#logout()}.
      */
-    private final Map lockMap;
+    private final Map<NodeState, LockImpl> lockMap;
 
     public LockManagerImpl(WorkspaceManager wspManager, ItemManager itemManager,
                            CacheBehaviour cacheBehaviour) {
         this.wspManager = wspManager;
         this.itemManager = itemManager;
         this.cacheBehaviour = cacheBehaviour;
-        // use hard references in order to make sure, that entries refering
+        // use hard references in order to make sure, that entries referring
         // to locks created by the current session are not removed.
-        lockMap = new HashMap();
+        lockMap = new HashMap<NodeState, LockImpl>();
     }
 
     //----------------< org.apache.jackrabbit.jcr2spi.lock.LockStateManager >---
@@ -129,11 +129,11 @@
         Operation op = LockRelease.create(nodeState);
         wspManager.execute(op);
 
-        // if unlock was successfull: clean up lock map and lock life cycle
+        // if unlock was successful: clean up lock map and lock life cycle
         // in case the corresponding Lock object exists (and thus has been
         // added to the map.
         if (lockMap.containsKey(nodeState)) {
-            LockImpl l = (LockImpl) lockMap.remove(nodeState);
+            LockImpl l = lockMap.remove(nodeState);
             l.lockState.unlocked();
         }
     }
@@ -220,14 +220,14 @@
      */
     public void removeLockToken(String lt) throws LockException, RepositoryException {
         // JSR170 v. 1.0.1 defines that the token of a session-scoped lock may
-        // not be moved over to another session. thus removal ist not possible
+        // not be moved over to another session. Thus removal is not possible
         // and the lock is always present in the lock map.
-        Iterator it = lockMap.values().iterator();
+        Iterator<LockImpl> it = lockMap.values().iterator();
         boolean found = false;
         // loop over cached locks to determine if the token belongs to a session
         // scoped lock, in which case the removal must fail immediately.
         while (it.hasNext() && !found) {
-            LockImpl l = (LockImpl) it.next();
+            LockImpl l = it.next();
             if (lt.equals(l.getLockToken())) {
                 // break as soon as the lock associated with the given token was found.
                 found = true;
@@ -250,10 +250,10 @@
      */
     public void loggingOut(Session session) {
         // remove any session scoped locks:
-        NodeState[] lhStates = (NodeState[]) lockMap.keySet().toArray(new NodeState[lockMap.size()]);
+        NodeState[] lhStates = lockMap.keySet().toArray(new NodeState[lockMap.size()]);
         for (int i = 0; i < lhStates.length; i++) {
             NodeState nState = lhStates[i];
-            LockImpl l = (LockImpl) lockMap.get(nState);
+            LockImpl l = lockMap.get(nState);
             if (l.isSessionScoped() && l.isLockOwningSession()) {
                 try {
                     unlock(nState);
@@ -271,7 +271,7 @@
      */
     public void loggedOut(Session session) {
         // release all remaining locks without modifying their lock status
-        LockImpl[] locks = (LockImpl[]) lockMap.values().toArray(new LockImpl[lockMap.size()]);
+        LockImpl[] locks = lockMap.values().toArray(new LockImpl[lockMap.size()]);
         for (int i = 0; i < locks.length; i++) {
             locks[i].lockState.release();
         }
@@ -285,7 +285,7 @@
      * Note, that this methods does NOT check if the given node state would
      * be affected by the lock present on an ancestor state.
      * Note, that in certain cases it might not be possible to detect a lock
-     * being present due to the fact that the hierarchy might be imcomplete or
+     * being present due to the fact that the hierarchy might be incomplete or
      * not even readable completely. For this reason it seem equally reasonable
      * to search for jcr:lockIsDeep property only and omitting all kind of
      * verification regarding nodetypes present.
@@ -419,7 +419,7 @@
 
     private LockImpl getLockFromMap(NodeState nodeState) {
         try {
-            LockImpl l = (LockImpl) lockMap.get(nodeState);
+            LockImpl l = lockMap.get(nodeState);
             if (l != null && l.isLive()) {
                 return l;
             }
@@ -439,7 +439,7 @@
      * @throws RepositoryException
      */
     private void notifyTokenAdded(String lt) throws RepositoryException {
-        LockTokenListener[] listeners = (LockTokenListener[]) lockMap.values().toArray(new LockTokenListener[lockMap.size()]);
+        LockTokenListener[] listeners = lockMap.values().toArray(new LockTokenListener[lockMap.size()]);
         for (int i = 0; i < listeners.length; i++) {
             listeners[i].lockTokenAdded(lt);
         }
@@ -453,7 +453,7 @@
      * @throws RepositoryException
      */
     private void notifyTokenRemoved(String lt) throws RepositoryException {
-        LockTokenListener[] listeners = (LockTokenListener[]) lockMap.values().toArray(new LockTokenListener[lockMap.size()]);
+        LockTokenListener[] listeners = lockMap.values().toArray(new LockTokenListener[lockMap.size()]);
         for (int i = 0; i < listeners.length; i++) {
             listeners[i].lockTokenRemoved(lt);
         }
@@ -798,7 +798,7 @@
                 // unless this lock is session-scoped (token is never transfered)
                 // and the session isn't the owner yet (token already present),
                 // it could be that this affects this lock and session became
-                // lock holder -> releoad info to assert.
+                // lock holder -> reload info to assert.
                 lockState.reloadLockInfo();
             }
         }

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractOperation.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractOperation.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractOperation.java Thu Sep 17 18:48:41 2009
@@ -33,9 +33,9 @@
 public abstract class AbstractOperation implements Operation {
 
     /**
-     * The collection of affected ItemIds.
+     * The collection of affected ItemStates.
      */
-    private final Collection affectedStates = new ArrayList();
+    private final Collection<ItemState> affectedStates = new ArrayList<ItemState>();
     protected int status;
 
     /**
@@ -51,8 +51,13 @@
     /**
      * @inheritDoc
      */
-    public Collection getAffectedItemStates() {
-        return (affectedStates.isEmpty()) ? Collections.EMPTY_LIST : Collections.unmodifiableCollection(affectedStates);
+    public Collection<ItemState> getAffectedItemStates() {
+    	if (affectedStates.isEmpty()) {
+    		return Collections.emptySet();
+    	}
+    	else {
+    		return Collections.unmodifiableCollection(affectedStates);
+    	}
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddNode.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddNode.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddNode.java Thu Sep 17 18:48:41 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.jcr2spi.operation;
 
+import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NodeId;
@@ -46,7 +47,7 @@
     private final Name nodeTypeName;
     private final String uuid;
 
-    private List addedStates = new ArrayList();
+    private List<ItemState> addedStates = new ArrayList<ItemState>();
 
     private AddNode(NodeState parentState, Name nodeName, Name nodeTypeName, String uuid)
             throws RepositoryException {
@@ -110,11 +111,11 @@
         return uuid;
     }
 
-    public void addedState(List newStates) {
+    public void addedState(List<ItemState> newStates) {
         addedStates.addAll(newStates);
     }
 
-    public List getAddedStates() {
+    public List<ItemState> getAddedStates() {
         return addedStates;
     }
 

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java Thu Sep 17 18:48:41 2009
@@ -20,6 +20,7 @@
 import org.apache.jackrabbit.jcr2spi.version.VersionManager;
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
+import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.NodeId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -46,7 +47,7 @@
     private final boolean isShallow;
     private final VersionManager mgr;
 
-    private Iterator failedIds = null;
+    private Iterator<ItemId> failedIds = null;
 
     private Merge(NodeState nodeState, String srcWorkspaceName, boolean bestEffort, boolean isShallow, VersionManager mgr) {
         this.nodeState = nodeState;
@@ -117,7 +118,7 @@
         return srcWorkspaceName == null;
     }
 
-    public void setFailedIds(Iterator failedIds) {
+    public void setFailedIds(Iterator<ItemId> failedIds) {
         if (failedIds == null) {
             throw new IllegalArgumentException("IdIterator must not be null.");
         }
@@ -127,7 +128,7 @@
         this.failedIds = failedIds;
     }
 
-    public Iterator getFailedIds() {
+    public Iterator<ItemId> getFailedIds() {
         if (failedIds == null) {
             throw new IllegalStateException("Merge operation has not been executed yet.");
         }

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Operation.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Operation.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Operation.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Operation.java Thu Sep 17 18:48:41 2009
@@ -56,7 +56,7 @@
      *
      * @return collection of affected <code>ItemState</code>s.
      */
-    public Collection getAffectedItemStates();
+    public Collection<ItemState> getAffectedItemStates();
 
     /**
      * Informs this Operation that it has been successfully executed.

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPropertyValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPropertyValue.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPropertyValue.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPropertyValue.java Thu Sep 17 18:48:41 2009
@@ -106,13 +106,13 @@
     public static Operation create(PropertyState propState, QValue[] qValues,
                                    int valueType) throws RepositoryException {
         // compact array (purge null entries)
-        List list = new ArrayList();
+        List<QValue> list = new ArrayList<QValue>();
         for (int i = 0; i < qValues.length; i++) {
             if (qValues[i] != null) {
                 list.add(qValues[i]);
             }
         }
-        QValue[] cleanValues = (QValue[]) list.toArray(new QValue[list.size()]);
+        QValue[] cleanValues = list.toArray(new QValue[list.size()]);
         SetPropertyValue sv = new SetPropertyValue(propState, valueType, cleanValues);
         return sv;
     }

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/ReferenceChangeTracker.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/ReferenceChangeTracker.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/ReferenceChangeTracker.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/ReferenceChangeTracker.java Thu Sep 17 18:48:41 2009
@@ -27,6 +27,8 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 /**
  * Simple helper class that can be used to keep track of uuid mappings
@@ -41,11 +43,11 @@
     /**
      * mapping <original uuid> to <new uuid> of mix:referenceable nodes
      */
-    private final HashMap uuidMap = new HashMap();
+    private final Map<String, String> uuidMap = new HashMap<String, String>();
     /**
      * list of processed reference properties that might need correction
      */
-    private final ArrayList references = new ArrayList();
+    private final List<PropertyState> references = new ArrayList<PropertyState>();
 
     /**
      * Creates a new instance.
@@ -91,7 +93,7 @@
             try {
                 String oldValue = oldReference.getString();
                 if (uuidMap.containsKey(oldValue)) {
-                    String newValue = uuidMap.get(oldValue).toString();
+                    String newValue = uuidMap.get(oldValue);
                     remapped = factory.create(newValue, PropertyType.REFERENCE);
                 }
             } catch (RepositoryException e) {
@@ -113,7 +115,7 @@
         }
     }
 
-    public Iterator getReferences() {
+    public Iterator<PropertyState> getReferences() {
         return references.iterator();
     }
 }

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java Thu Sep 17 18:48:41 2009
@@ -104,7 +104,7 @@
         checkStatus();
         refreshEntry(vhEntry);
         Iterator childIter = vhEntry.getNodeEntries();
-        List versionEntries = new ArrayList();
+        List<NodeEntry> versionEntries = new ArrayList<NodeEntry>();
         // all child-nodes except from jcr:versionLabels point to Versions.
         while (childIter.hasNext()) {
             NodeEntry entry = (NodeEntry) childIter.next();
@@ -124,7 +124,7 @@
         // TODO: improve and use lazy loading of versions as needed.
         // TODO: change session.getNodeByUUID to Session.getNodeByIdentifier as soon as implemented
 
-        List versions = new ArrayList();
+        List<Version> versions = new ArrayList<Version>();
         Version rootV = getRootVersion();
         Node vn = session.getNodeByUUID(getVersionableUUID());
         Version v = vn.getBaseVersion();
@@ -247,7 +247,7 @@
         checkValidVersion(version);
         String vUUID = version.getUUID();
 
-        List vlabels = new ArrayList();
+        List<String> vlabels = new ArrayList<String>();
         Name[] qLabels = getQLabels();
         for (int i = 0; i < qLabels.length; i++) {
             String uuid = getVersionByLabel(qLabels[i]).getUUID();
@@ -255,7 +255,7 @@
                 vlabels.add(session.getNameResolver().getJCRName(qLabels[i]));
             }
         }
-        return (String[]) vlabels.toArray(new String[vlabels.size()]);
+        return vlabels.toArray(new String[vlabels.size()]);
     }
 
     /**
@@ -324,7 +324,7 @@
      */
     private Name[] getQLabels() throws RepositoryException {
         refreshEntry(labelNodeEntry);
-        List labelNames = new ArrayList();
+        List<Name> labelNames = new ArrayList<Name>();
         for (Iterator it = labelNodeEntry.getPropertyEntries(); it.hasNext(); ) {
             PropertyEntry pe = (PropertyEntry) it.next();
             if (! NameConstants.JCR_PRIMARYTYPE.equals(pe.getName()) &&
@@ -332,7 +332,7 @@
                 labelNames.add(pe.getName());
             }
         }
-        return (Name[]) labelNames.toArray(new Name[labelNames.size()]);
+        return labelNames.toArray(new Name[labelNames.size()]);
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java Thu Sep 17 18:48:41 2009
@@ -172,7 +172,7 @@
      * @see #resolveMergeConflict(NodeState,NodeState,boolean)
      * @see javax.jcr.Node#merge(String, boolean)
      */
-    public Iterator merge(NodeState nodeState, String workspaceName, boolean bestEffort) throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException;
+    public Iterator<NodeId> merge(NodeState nodeState, String workspaceName, boolean bestEffort) throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException;
 
     /**
      * @param nodeState
@@ -190,7 +190,7 @@
      * @see #resolveMergeConflict(NodeState,NodeState,boolean)
      * @see javax.jcr.Node#merge(String, boolean)
      */
-    public Iterator merge(NodeState nodeState, String workspaceName, boolean bestEffort, boolean isShallow) throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException;
+    public Iterator<NodeId> merge(NodeState nodeState, String workspaceName, boolean bestEffort, boolean isShallow) throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException;
 
 
     /**
@@ -239,7 +239,7 @@
      * @throws UnsupportedRepositoryOperationException
      * @throws RepositoryException
      */
-    public Iterator mergeActivity(NodeState activityState) throws UnsupportedRepositoryOperationException, RepositoryException;
+    public Iterator<NodeId> mergeActivity(NodeState activityState) throws UnsupportedRepositoryOperationException, RepositoryException;
 
     /**
      *

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java Thu Sep 17 18:48:41 2009
@@ -33,6 +33,7 @@
 import java.io.IOException;
 import java.io.Reader;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Stack;
 
 /**
@@ -49,7 +50,7 @@
      * in the startElement method and is popped from the stack in the
      * endElement method.
      */
-    private final Stack stack = new Stack();
+    private final Stack<Importer.NodeInfo> stack = new Stack<Importer.NodeInfo>();
     // buffer used to merge adjacent character data
     private BufferedStringValue textHandler = new BufferedStringValue();
 
@@ -133,7 +134,7 @@
                         new Importer.NodeInfo(NameConstants.JCR_XMLTEXT, null, null, null);
                 Importer.TextValue[] values =
                         new Importer.TextValue[]{textHandler};
-                ArrayList props = new ArrayList();
+                List<Importer.PropInfo> props = new ArrayList<Importer.PropInfo>();
                 Importer.PropInfo prop =
                         new Importer.PropInfo(NameConstants.JCR_XMLCHARACTERS, PropertyType.STRING, values);
                 props.add(prop);
@@ -177,7 +178,7 @@
             Name nodeTypeName = null;
             Name[] mixinTypes = null;
 
-            ArrayList props = new ArrayList(atts.getLength());
+            List<Importer.PropInfo> props = new ArrayList<Importer.PropInfo>(atts.getLength());
             for (int i = 0; i < atts.getLength(); i++) {
                 if (atts.getURI(i).equals(Name.NS_XMLNS_URI)) {
                     // skip namespace declarations reported as attributes
@@ -287,7 +288,7 @@
         // process buffered character data
         processCharacters();
 
-        Importer.NodeInfo node = (Importer.NodeInfo) stack.peek();
+        Importer.NodeInfo node = stack.peek();
         try {
             // call Importer
             importer.endNode(node);

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/Importer.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/Importer.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/Importer.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/Importer.java Thu Sep 17 18:48:41 2009
@@ -41,7 +41,7 @@
      * context.
      * @throws RepositoryException
      */
-    void startNode(NodeInfo nodeInfo, List propInfos, NamePathResolver resolver)
+    void startNode(NodeInfo nodeInfo, List<PropInfo> propInfos, NamePathResolver resolver)
             throws RepositoryException;
 
     /**

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java Thu Sep 17 18:48:41 2009
@@ -68,7 +68,6 @@
 import java.io.Reader;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Stack;
 import java.util.UUID;
@@ -86,7 +85,7 @@
     private final SessionImpl session;
     private final SessionItemStateManager stateMgr;
 
-    private final Stack parents;
+    private final Stack<NodeState> parents;
 
     private boolean importerClosed;
     private boolean sessionClosed;
@@ -131,7 +130,7 @@
             session.getValidator().checkIsWritable(importTarget, options);
 
             refTracker = new ReferenceChangeTracker();
-            parents = new Stack();
+            parents = new Stack<NodeState>();
             parents.push(importTarget);
         } catch (ItemNotFoundException e) {
             throw new PathNotFoundException(LogUtil.safeGetJCRPath(parentPath, session.getPathResolver()));
@@ -143,21 +142,21 @@
      * {@inheritDoc}
      */
     public void start() throws RepositoryException {
-        // explicitely set status of importer and start listening on session
+        // explicitly set status of importer and start listening on session
         setClosed(false);
     }
 
    /**
      * {@inheritDoc}
      */
-    public void startNode(NodeInfo nodeInfo, List propInfos, NamePathResolver resolver)
+    public void startNode(NodeInfo nodeInfo, List<PropInfo> propInfos, NamePathResolver resolver)
             throws RepositoryException {
        if (isClosed()) {
            // workspace-importer only: ignore if import has been aborted before.
            return;
        }
        checkSession();
-       NodeState parent = (NodeState) parents.peek();
+       NodeState parent = parents.peek();
        if (parent == null) {
            // parent node was skipped, skip this child node also
            parents.push(null); // push null onto stack for skipped node
@@ -226,9 +225,7 @@
        // node state may be 'null' if applicable def is protected
        if (nodeState != null) {
            // process properties
-           Iterator iter = propInfos.iterator();
-           while (iter.hasNext()) {
-               PropInfo pi = (PropInfo) iter.next();
+    	   for (PropInfo pi : propInfos) {
                importProperty(pi, nodeState, resolver);
            }
        }
@@ -632,7 +629,7 @@
      * @throws RepositoryException
      */
     private void checkIncludesMixReferenceable(Importer.NodeInfo nodeInfo) throws RepositoryException {
-        List l = new ArrayList();
+        List<Name> l = new ArrayList<Name>();
         l.add(nodeInfo.getNodeTypeName());
         Name[] mixinNames = nodeInfo.getMixinNames();
         if (mixinNames != null && mixinNames.length > 0) {
@@ -642,7 +639,7 @@
             // shortcut
             return;
         }
-        Name[] ntNames = (Name[]) l.toArray(new Name[l.size()]);
+        Name[] ntNames = l.toArray(new Name[l.size()]);
         EffectiveNodeType ent = session.getEffectiveNodeTypeProvider().getEffectiveNodeType(ntNames);
         if (!ent.includesNodeType(NameConstants.MIX_REFERENCEABLE)) {
             throw new ConstraintViolationException("XML defines jcr:uuid without defining import node to be referenceable.");

Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java?rev=816333&r1=816332&r2=816333&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java Thu Sep 17 18:48:41 2009
@@ -29,7 +29,7 @@
 import javax.jcr.RepositoryException;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.List;
 import java.util.Stack;
 
 /**
@@ -58,7 +58,7 @@
      * the same instance is popped from the stack in the endElement method
      * when the corresponding sv:node element is encountered.
      */
-    private final Stack stack = new Stack();
+    private final Stack<ImportState> stack = new Stack<ImportState>();
 
     /**
      * fields used temporarily while processing sv:property and sv:value elements
@@ -66,7 +66,7 @@
     private Name currentPropName;
     private int currentPropType = PropertyType.UNDEFINED;
     // list of AppendableValue objects
-    private ArrayList currentPropValues = new ArrayList();
+    private List<Importer.TextValue> currentPropValues = new ArrayList<Importer.TextValue>();
     private AppendableValue currentPropValue;
 
     /**
@@ -86,7 +86,7 @@
         }
         Name[] mixins = null;
         if (state.mixinNames != null) {
-            mixins = (Name[]) state.mixinNames.toArray(new Name[state.mixinNames.size()]);
+            mixins = state.mixinNames.toArray(new Name[state.mixinNames.size()]);
         }
         Importer.NodeInfo nodeInfo = new Importer.NodeInfo(state.nodeName, state.nodeTypeName, mixins, state.uuid);
 
@@ -98,8 +98,7 @@
             if (start) {
                 importer.startNode(nodeInfo, state.props, resolver);
                 // dispose temporary property values
-                for (Iterator iter = state.props.iterator(); iter.hasNext();) {
-                    Importer.PropInfo pi = (Importer.PropInfo) iter.next();
+                for (Importer.PropInfo pi : state.props) {
                     disposePropertyValues(pi);
                 }
             }
@@ -136,7 +135,7 @@
 
             if (!stack.isEmpty()) {
                 // process current node first
-                ImportState current = (ImportState) stack.peek();
+                ImportState current = stack.peek();
                 // need to start current node
                 if (!current.started) {
                     processNode(current, true, false);
@@ -232,7 +231,7 @@
     public void endElement(String namespaceURI, String localName, String qName)
             throws SAXException {
         // check element name
-        ImportState state = (ImportState) stack.peek();
+        ImportState state = stack.peek();
         if (NODE.equals(localName)) {
             // sv:node element
             if (!state.started) {
@@ -265,7 +264,7 @@
                 }
             } else if (currentPropName.equals(NameConstants.JCR_MIXINTYPES)) {
                 if (state.mixinNames == null) {
-                    state.mixinNames = new ArrayList(currentPropValues.size());
+                    state.mixinNames = new ArrayList<Name>(currentPropValues.size());
                 }
                 for (int i = 0; i < currentPropValues.size(); i++) {
                     AppendableValue val =
@@ -291,7 +290,7 @@
                     throw new SAXException("error while retrieving value", ioe);
                 }
             } else {
-                Importer.TextValue[] values = (Importer.TextValue[]) currentPropValues.toArray(new Importer.TextValue[currentPropValues.size()]);
+                Importer.TextValue[] values = currentPropValues.toArray(new Importer.TextValue[currentPropValues.size()]);
                 Importer.PropInfo prop = new Importer.PropInfo(currentPropName, currentPropType, values);
                 state.props.add(prop);
             }
@@ -320,7 +319,7 @@
         /**
          * list of mixin types of current node
          */
-        ArrayList mixinNames;
+        List<Name> mixinNames;
         /**
          * uuid of current node
          */
@@ -329,7 +328,7 @@
         /**
          * list of PropInfo instances representing properties of current node
          */
-        ArrayList props = new ArrayList();
+        List<Importer.PropInfo> props = new ArrayList<Importer.PropInfo>();
 
         /**
          * flag indicating whether startNode() has been called for current node