You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by st...@apache.org on 2005/02/12 14:40:23 UTC

svn commit: r153503 [3/3] - in incubator/jackrabbit/trunk/src: java/org/apache/jackrabbit/core/ java/org/apache/jackrabbit/core/config/ java/org/apache/jackrabbit/core/nodetype/ java/org/apache/jackrabbit/core/search/ java/org/apache/jackrabbit/core/search/lucene/ java/org/apache/jackrabbit/core/search/sql/ java/org/apache/jackrabbit/core/search/xpath/ java/org/apache/jackrabbit/core/state/ java/org/apache/jackrabbit/core/util/uuid/ java/org/apache/jackrabbit/core/version/ java/org/apache/jackrabbit/core/version/persistence/ java/org/apache/jackrabbit/core/virtual/ java/org/apache/jackrabbit/core/xml/ test/org/apache/jackrabbit/core/ test/org/apache/jackrabbit/test/api/

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java?view=diff&r1=153502&r2=153503
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java Sat Feb 12 05:40:13 2005
@@ -16,24 +16,27 @@
  */
 package org.apache.jackrabbit.core.version.persistence;
 
-import org.apache.log4j.Logger;
-import org.apache.jackrabbit.core.version.*;
+import org.apache.commons.collections.ReferenceMap;
 import org.apache.jackrabbit.core.*;
-import org.apache.jackrabbit.core.util.uuid.UUID;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.state.*;
-import org.apache.commons.collections.ReferenceMap;
+import org.apache.jackrabbit.core.util.uuid.UUID;
+import org.apache.jackrabbit.core.version.InternalVersion;
+import org.apache.jackrabbit.core.version.InternalVersionHistory;
+import org.apache.jackrabbit.core.version.InternalVersionItem;
+import org.apache.jackrabbit.core.version.PersistentVersionManager;
+import org.apache.log4j.Logger;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import java.util.HashMap;
-import java.util.Map;
 import java.util.Iterator;
+import java.util.Map;
 
 /**
  * This Class implements the persistent part of the versioning. the
  * current implementation uses the 'normal' repository content as storage.
- * <p>
+ * <p/>
  * although the nodes need to be mapped again virtually in the real content,
  * the persistent nodes use a different structure as exposed later.
  * each versioning element (version history, version, freezes) is stored in a
@@ -41,51 +44,51 @@
  * a persistentnodestate that represents a version, is the UUID of that version.
  * the hierarchy is somewhat similar, thus histories contain versions, contain
  * frozen nodes, etc.
- * <p>
+ * <p/>
  * on startup, the entire structure is traversed, in order to get a mapping
  * from real to persistent uuids.
- * <p>
+ * <p/>
  * todo: the persistence is not synchronized yet and could lead to multi-threading issues
  */
-public class NativePVM implements PersistentVersionManager {
+public class NativePVM implements PersistentVersionManager, Constants {
 
     /**
      * the logger
      */
-    private static Logger log = Logger.getLogger(PersistentVersionManager.class);
+    private static Logger log = Logger.getLogger(NativePVM.class);
 
     /**
      * root path for version storage
      */
-    public static final QName VERSION_HISTORY_ROOT_NAME = new QName(NamespaceRegistryImpl.NS_JCR_URI, "persistentVersionStorage");
+    public static final QName VERSION_HISTORY_ROOT_NAME = new QName(NS_JCR_URI, "persistentVersionStorage");
     /**
      * name of the 'jcr:historyId' property
      */
-    public static final QName PROPNAME_HISTORY_ID = new QName(NamespaceRegistryImpl.NS_JCR_URI, "historyId");
+    public static final QName PROPNAME_HISTORY_ID = new QName(NS_JCR_URI, "historyId");
     /**
      * name of the 'jcr:versionableId' property
      */
-    public static final QName PROPNAME_VERSIONABLE_ID = new QName(NamespaceRegistryImpl.NS_JCR_URI, "versionableId");
+    public static final QName PROPNAME_VERSIONABLE_ID = new QName(NS_JCR_URI, "versionableId");
     /**
      * name of the 'jcr:versionId' property
      */
-    public static final QName PROPNAME_VERSION_ID = new QName(NamespaceRegistryImpl.NS_JCR_URI, "versionId");
+    public static final QName PROPNAME_VERSION_ID = new QName(NS_JCR_URI, "versionId");
     /**
      * name of the 'jcr:versionName' property
      */
-    public static final QName PROPNAME_VERSION_NAME = new QName(NamespaceRegistryImpl.NS_JCR_URI, "versionName");
+    public static final QName PROPNAME_VERSION_NAME = new QName(NS_JCR_URI, "versionName");
     /**
      * name of the 'jcr:versionLabels' node
      */
-    public static final QName NODENAME_VERSION_LABELS = new QName(NamespaceRegistryImpl.NS_JCR_URI, "versionLabels");
+    public static final QName NODENAME_VERSION_LABELS = new QName(NS_JCR_URI, "versionLabels");
     /**
      * name of the 'jcr:name' property
      */
-    public static final QName PROPNAME_NAME = new QName(NamespaceRegistryImpl.NS_JCR_URI, "name");
+    public static final QName PROPNAME_NAME = new QName(NS_JCR_URI, "name");
     /**
      * name of the 'jcr:version' property
      */
-    public static final QName PROPNAME_VERSION = new QName(NamespaceRegistryImpl.NS_JCR_URI, "version");
+    public static final QName PROPNAME_VERSION = new QName(NS_JCR_URI, "version");
 
     /**
      * the id of the persisten root node
@@ -95,22 +98,22 @@
     /**
      * The nodetype name of a persistent version
      */
-    protected static final QName NT_REP_VERSION = new QName(NamespaceRegistryImpl.NS_REP_URI, "version");
+    protected static final QName NT_REP_VERSION = new QName(NS_REP_URI, "version");
 
     /**
      * The nodetype name of a presistent version history
      */
-    protected static final QName NT_REP_VERSION_HISTORY = new QName(NamespaceRegistryImpl.NS_REP_URI, "versionHistory");
+    protected static final QName NT_REP_VERSION_HISTORY = new QName(NS_REP_URI, "versionHistory");
 
     /**
      * the nodetype name of a persistent frozen node
      */
-    protected static final QName NT_REP_FROZEN = new QName(NamespaceRegistryImpl.NS_REP_URI, "frozen");
+    protected static final QName NT_REP_FROZEN = new QName(NS_REP_URI, "frozen");
 
     /**
      * the nodetype name of a persistent frozen history
      */
-    protected static final QName NT_REP_FROZEN_HISTORY = new QName(NamespaceRegistryImpl.NS_REP_URI, "frozenVersionHistory");
+    protected static final QName NT_REP_FROZEN_HISTORY = new QName(NS_REP_URI, "frozenVersionHistory");
 
     /**
      * the persistent root node of the version histories
@@ -137,7 +140,7 @@
      * mapping from virtual uuids to persistent ids of the persistent nodes
      * key=internalId, value=PersistentId
      */
-    private HashMap idsByInternal= new HashMap();
+    private HashMap idsByInternal = new HashMap();
 
     /**
      * map of versioned uuids. key=versionedUUID, value=externalId
@@ -150,7 +153,7 @@
     private Map items = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT);
 
     /**
-     * Creates a new PersistentVersionManager.
+     * Creates a new NativePVM.
      *
      * @param pMgr
      * @param ntReg
@@ -167,7 +170,7 @@
             historyRoot = new PersistentNode(stateMgr, nodeState);
             initVirtualIds(historyRoot.getState());
             long t2 = System.currentTimeMillis();
-            log.info("loaded " + idsByExternal.size() + " virtual ids in " + (t2-t1) + "ms.");
+            log.info("loaded " + idsByExternal.size() + " virtual ids in " + (t2 - t1) + "ms.");
         } catch (ItemStateException e) {
             throw new RepositoryException("Unable to initialize PersistentVersionManager: " + e.toString(), e);
         }
@@ -177,6 +180,7 @@
      * Close this persistence version manager. After having closed a persistence
      * manager, further operations on this object are treated as illegal
      * and throw
+     *
      * @throws Exception if an error occurs
      */
     public void close() throws Exception {
@@ -187,6 +191,7 @@
 
     /**
      * initializes the internal item ids
+     *
      * @param parent
      * @throws RepositoryException
      * @throws ItemStateException
@@ -204,6 +209,7 @@
 
     /**
      * initializes the internal item ids
+     *
      * @param realUUID
      * @param state
      * @throws ItemStateException
@@ -213,7 +219,7 @@
             throws ItemStateException, RepositoryException {
         PersistentId id = new PersistentId(realUUID, state);
         if (id.type != PersistentId.TYPE_UNDEFINED) {
-            synchronized(idsByExternal) {
+            synchronized (idsByExternal) {
                 idsByExternal.put(id.externalId, id);
                 idsByInternal.put(id.internalId, id);
             }
@@ -229,17 +235,19 @@
 
     /**
      * returns the persistentid for a given external uuid
+     *
      * @param uuid
      * @return
      */
     private PersistentId getIdByExternal(String uuid) {
-        synchronized(idsByExternal) {
+        synchronized (idsByExternal) {
             return (PersistentId) idsByExternal.get(uuid);
         }
     }
 
     /**
      * returns the persustentid for a given internal uuid
+     *
      * @param uuid
      * @return
      */
@@ -249,12 +257,13 @@
 
     /**
      * returns the persustentid for a give internal uuid and item type
+     *
      * @param uuid
      * @param type
      * @return
      */
     private PersistentId getIdByExternal(String uuid, int type) {
-        synchronized(idsByExternal) {
+        synchronized (idsByExternal) {
             PersistentId id = (PersistentId) idsByExternal.get(uuid);
             return id != null && id.type == type ? id : null;
         }
@@ -263,6 +272,7 @@
     /**
      * Retrusn the version history that corresponds to the versionable node of
      * the given uuid.
+     *
      * @param uuid
      * @return
      */
@@ -284,7 +294,7 @@
 
         // check if version history for that node already exists
         InternalVersionHistoryImpl hist = getHistoryByVersionableUUID(node.internalGetUUID());
-        if (hist!=null) {
+        if (hist != null) {
             return hist;
         }
 
@@ -294,15 +304,15 @@
             // create deep path
             String uuid = UUID.randomUUID().toString();
             PersistentNode root = historyRoot;
-            for (int i=0; i<3; i++) {
-                QName name = new QName(NamespaceRegistryImpl.NS_DEFAULT_URI, uuid.substring(i*2, i*2+2));
+            for (int i = 0; i < 3; i++) {
+                QName name = new QName(NS_DEFAULT_URI, uuid.substring(i * 2, i * 2 + 2));
                 if (!root.hasNode(name)) {
-                    root.addNode(name, NodeTypeRegistry.NT_UNSTRUCTURED);
+                    root.addNode(name, NT_UNSTRUCTURED);
                     root.store();
                 }
                 root = root.getNode(name, 1);
             }
-            QName historyNodeName = new QName(NamespaceRegistryImpl.NS_DEFAULT_URI, uuid);
+            QName historyNodeName = new QName(NS_DEFAULT_URI, uuid);
 
             // create new history node in the persistent state
             hist = InternalVersionHistoryImpl.create(this, root, uuid, historyNodeName, node);
@@ -315,7 +325,7 @@
             throw new RepositoryException(e);
         }
 
-        log.info("Created new version history " + hist.getId()+ " for " + node.safeGetJCRPath() + ". NumHistories=" + versionedUUIDs.size());
+        log.info("Created new version history " + hist.getId() + " for " + node.safeGetJCRPath() + ". NumHistories=" + versionedUUIDs.size());
         return hist;
     }
 
@@ -330,7 +340,7 @@
             throws RepositoryException {
 
         PersistentId pid = getIdByExternal(histId, PersistentId.TYPE_HISTORY);
-        return pid==null ? null : (InternalVersionHistory) getItem(pid);
+        return pid == null ? null : (InternalVersionHistory) getItem(pid);
     }
 
     /**
@@ -387,7 +397,7 @@
             throws RepositoryException {
 
         PersistentId pid = getIdByExternal(versionId, PersistentId.TYPE_VERSION);
-        return pid==null ? null : (InternalVersion) getItem(pid);
+        return pid == null ? null : (InternalVersion) getItem(pid);
     }
 
     /**
@@ -402,6 +412,7 @@
 
     /**
      * checks, if the item with the given external id exists
+     *
      * @param externalId
      * @return
      */
@@ -411,6 +422,7 @@
 
     /**
      * returns the item referred by the external id
+     *
      * @param externalId
      * @return
      * @throws RepositoryException
@@ -418,11 +430,12 @@
     public InternalVersionItem getItemByExternal(String externalId)
             throws RepositoryException {
         PersistentId pid = getIdByExternal(externalId);
-        return pid==null ? null : getItem(pid);
+        return pid == null ? null : getItem(pid);
     }
 
     /**
      * returns the item referred by the internal id
+     *
      * @param internalId
      * @return
      * @throws RepositoryException
@@ -430,11 +443,12 @@
     public InternalVersionItem getItemByInternal(String internalId)
             throws RepositoryException {
         PersistentId pid = getIdByInternal(internalId);
-        return pid==null ? null : getItem(pid);
+        return pid == null ? null : getItem(pid);
     }
 
     /**
      * returns the item with the given persistent id
+     *
      * @param pid
      * @return
      * @throws RepositoryException
@@ -442,10 +456,10 @@
     private InternalVersionItem getItem(PersistentId pid)
             throws RepositoryException {
 
-        InternalVersionItem item =(InternalVersionItem) items.get(pid);
-        if (item==null) {
+        InternalVersionItem item = (InternalVersionItem) items.get(pid);
+        if (item == null) {
             PersistentNode pNode = historyRoot.getNodeByUUID(pid.internalId);
-            if (pNode!=null) {
+            if (pNode != null) {
                 InternalVersionItem parent = getItemByInternal(pNode.getParentUUID());
                 if (pid.type == PersistentId.TYPE_FROZEN) {
                     item = new InternalFrozenNodeImpl(this, pNode, pid.externalId, parent);
@@ -459,7 +473,7 @@
                     //return null;
                 }
             }
-            if (item!=null) {
+            if (item != null) {
                 items.put(pid, item);
             }
         }
@@ -478,11 +492,11 @@
         // assuming node is versionable and checkout (check in nodeimpl)
         // To create a new version of a versionable node N, the client calls N.checkin.
         // This causes the following series of events:
-        String histUUID = node.getProperty(VersionManager.PROPNAME_VERSION_HISTORY).getString();
+        String histUUID = node.getProperty(Constants.JCR_VERSIONHISTORY).getString();
         InternalVersionHistoryImpl history = (InternalVersionHistoryImpl) getVersionHistory(histUUID);
 
         // 0. resolve the predecessors
-        Value[] values = node.getProperty(VersionManager.PROPNAME_PREDECESSORS).getValues();
+        Value[] values = node.getProperty(Constants.JCR_PREDECESSORS).getValues();
         InternalVersion[] preds = new InternalVersion[values.length];
         for (int i = 0; i < values.length; i++) {
             preds[i] = history.getVersion(values[i].getString());
@@ -548,13 +562,19 @@
         private static final int TYPE_FROZEN = 3;
         private static final int TYPE_FROZEN_HISTORY = 4;
 
-        /** the type of the persistent node */
+        /**
+         * the type of the persistent node
+         */
         private final int type;
 
-        /** the persistent uuid of the node */
+        /**
+         * the persistent uuid of the node
+         */
         private final String externalId;
 
-        /** the persistent uuid of the node */
+        /**
+         * the persistent uuid of the node
+         */
         private final String internalId;
 
         public PersistentId(int type, String external, String internal) {

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualNodeState.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualNodeState.java?view=diff&r1=153502&r2=153503
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualNodeState.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualNodeState.java Sat Feb 12 05:40:13 2005
@@ -16,8 +16,8 @@
  */
 package org.apache.jackrabbit.core.virtual;
 
+import org.apache.jackrabbit.core.Constants;
 import org.apache.jackrabbit.core.InternalValue;
-import org.apache.jackrabbit.core.ItemImpl;
 import org.apache.jackrabbit.core.QName;
 import org.apache.jackrabbit.core.state.ItemState;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
@@ -31,7 +31,7 @@
 /**
  * This Class implements a virtual node state
  */
-public class VirtualNodeState extends NodeState {
+public class VirtualNodeState extends NodeState implements Constants {
 
     /**
      * The virtual item state provide that created this node state
@@ -46,6 +46,7 @@
 
     /**
      * creates a new virtual node state
+     *
      * @param stateMgr
      * @param parentUUID
      * @param uuid
@@ -54,16 +55,16 @@
      * @throws RepositoryException
      */
     public VirtualNodeState(VirtualItemStateProvider stateMgr,
-                                   String parentUUID,
-                                   String uuid,
-                                   QName nodeTypeName,
-                                   QName[] mixins)
+                            String parentUUID,
+                            String uuid,
+                            QName nodeTypeName,
+                            QName[] mixins)
             throws RepositoryException {
         super(uuid, nodeTypeName, parentUUID, ItemState.STATUS_EXISTING, false);
         this.stateMgr = stateMgr;
 
         // add default properties
-        setPropertyValue(ItemImpl.PROPNAME_PRIMARYTYPE, InternalValue.create(nodeTypeName));
+        setPropertyValue(JCR_PRIMARYTYPE, InternalValue.create(nodeTypeName));
         setMixinNodeTypes(mixins);
     }
 
@@ -85,7 +86,7 @@
      */
     public InternalValue[] getPropertyValues(QName name) throws NoSuchItemStateException {
         VirtualPropertyState ps = getProperty(name);
-        return ps==null ? null : ps.getValues();
+        return ps == null ? null : ps.getValues();
     }
 
     /**
@@ -96,11 +97,12 @@
      */
     public InternalValue getPropertyValue(QName name) throws NoSuchItemStateException {
         VirtualPropertyState ps = getProperty(name);
-        return ps==null || ps.getValues().length==0 ? null : ps.getValues()[0];
+        return ps == null || ps.getValues().length == 0 ? null : ps.getValues()[0];
     }
 
     /**
      * returns the property state of the given name
+     *
      * @param name
      * @return
      * @throws NoSuchItemStateException
@@ -161,7 +163,7 @@
             throws RepositoryException {
 
         VirtualPropertyState prop = (VirtualPropertyState) properties.get(name);
-        if (prop==null) {
+        if (prop == null) {
             prop = stateMgr.createPropertyState(this, name, type, multiValued);
             properties.put(name, prop);
             addPropertyEntry(name);
@@ -183,11 +185,12 @@
             values[i] = InternalValue.create(mixins[i]);
         }
         setMixinTypeNames(set);
-        setPropertyValues(ItemImpl.PROPNAME_MIXINTYPES, PropertyType.NAME, values);
+        setPropertyValues(JCR_MIXINTYPES, PropertyType.NAME, values);
     }
 
     /**
      * Creates a new VirtualChildNodeEntry
+     *
      * @param nodeName
      * @param uuid
      * @param index
@@ -199,6 +202,7 @@
 
     /**
      * Creates a new VirtualPropertyEntry
+     *
      * @param name
      * @return
      */

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/AbstractSAXEventGenerator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/AbstractSAXEventGenerator.java?view=diff&r1=153502&r2=153503
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/AbstractSAXEventGenerator.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/AbstractSAXEventGenerator.java Sat Feb 12 05:40:13 2005
@@ -41,7 +41,7 @@
  * </ul>
  * for every item it encounters.
  */
-abstract class AbstractSAXEventGenerator {
+abstract class AbstractSAXEventGenerator implements Constants {
 
     private static Logger log = Logger.getLogger(AbstractSAXEventGenerator.class);
 
@@ -51,16 +51,6 @@
     protected final boolean skipBinary;
     protected final boolean noRecurse;
 
-    // dummy name for root node (jcr:root)
-    public static final QName NODENAME_ROOT =
-            new QName(NamespaceRegistryImpl.NS_JCR_URI, "root");
-    // jcr:uuid
-    protected static final QName PROPNAME_UUID = ItemImpl.PROPNAME_UUID;
-    // jcr:primaryType
-    protected static final QName PROPNAME_PRIMARYTYPE = ItemImpl.PROPNAME_PRIMARYTYPE;
-    // jcr:mixinTypes
-    protected static final QName PROPNAME_MIXINTYPES = ItemImpl.PROPNAME_MIXINTYPES;
-
     /**
      * Constructor
      *
@@ -130,20 +120,20 @@
 
         // serialize jcr:primaryType, jcr:mixinTypes & jcr:uuid first:
         // jcr:primaryType
-        if (node.hasProperty(PROPNAME_PRIMARYTYPE)) {
-            process(node.getProperty(PROPNAME_PRIMARYTYPE), level + 1);
+        if (node.hasProperty(JCR_PRIMARYTYPE)) {
+            process(node.getProperty(JCR_PRIMARYTYPE), level + 1);
         } else {
             String msg = "internal error: missing jcr:primaryType property on node " + node.safeGetJCRPath();
             log.debug(msg);
             throw new RepositoryException(msg);
         }
         // jcr:mixinTypes
-        if (node.hasProperty(PROPNAME_MIXINTYPES)) {
-            process(node.getProperty(PROPNAME_MIXINTYPES), level + 1);
+        if (node.hasProperty(JCR_MIXINTYPES)) {
+            process(node.getProperty(JCR_MIXINTYPES), level + 1);
         }
         // jcr:uuid
-        if (node.hasProperty(PROPNAME_UUID)) {
-            process(node.getProperty(PROPNAME_UUID), level + 1);
+        if (node.hasProperty(JCR_UUID)) {
+            process(node.getProperty(JCR_UUID), level + 1);
         }
 
         // serialize remaining properties
@@ -151,9 +141,9 @@
         while (propIter.hasNext()) {
             PropertyImpl prop = (PropertyImpl) propIter.nextProperty();
             QName name = prop.getQName();
-            if (PROPNAME_PRIMARYTYPE.equals(name)
-                    || PROPNAME_MIXINTYPES.equals(name)
-                    || PROPNAME_UUID.equals(name)) {
+            if (JCR_PRIMARYTYPE.equals(name)
+                    || JCR_MIXINTYPES.equals(name)
+                    || JCR_UUID.equals(name)) {
                 continue;
             }
             // serialize property

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java?view=diff&r1=153502&r2=153503
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java Sat Feb 12 05:40:13 2005
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.core.xml;
 
 import org.apache.jackrabbit.core.*;
-import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.log4j.Logger;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
@@ -61,9 +60,9 @@
     protected void addTextNode(NodeImpl parent, String text) throws SAXException {
         if (text.length() > 0) {
             try {
-                NodeImpl txtNode = (NodeImpl) parent.addNode(DocViewSAXEventGenerator.NODENAME_XMLTEXT);
+                NodeImpl txtNode = (NodeImpl) parent.addNode(Constants.JCR_XMLTEXT);
                 StringValue val = new StringValue(text.toString());
-                txtNode.setProperty(DocViewSAXEventGenerator.PROPNAME_XMLCHARACTERS, val);
+                txtNode.setProperty(Constants.JCR_XMLCHARACTERS, val);
             } catch (RepositoryException re) {
                 throw new SAXException(re);
             }
@@ -98,7 +97,7 @@
 
             // @todo how should 'system' properties be handled in document view (e.g. jcr:primaryType,jcr:mixinTypes, jcr:uuid)?
             NodeImpl currentParent = (NodeImpl) parents.peek();
-            currentParent = (NodeImpl) currentParent.addNode(nodeName, NodeTypeRegistry.NT_UNSTRUCTURED);
+            currentParent = (NodeImpl) currentParent.addNode(nodeName, Constants.NT_UNSTRUCTURED);
             parents.push(currentParent);
 
             // properties

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/DocViewSAXEventGenerator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/DocViewSAXEventGenerator.java?view=diff&r1=153502&r2=153503
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/DocViewSAXEventGenerator.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/DocViewSAXEventGenerator.java Sat Feb 12 05:40:13 2005
@@ -45,13 +45,6 @@
 
     public static final String CDATA_TYPE = "CDATA";
 
-    // jcr:xmltext
-    public static final QName NODENAME_XMLTEXT =
-            new QName(NamespaceRegistryImpl.NS_JCR_URI, "xmltext");
-    // jcr:xmlcharacters
-    public static final QName PROPNAME_XMLCHARACTERS =
-            new QName(NamespaceRegistryImpl.NS_JCR_URI, "xmlcharacters");
-
     // used to temporarily store properties of a node
     private final List props;
 
@@ -98,13 +91,13 @@
     protected void leavingProperties(NodeImpl node, int level)
             throws RepositoryException, SAXException {
         QName name = node.getQName();
-        if (name.equals(NODENAME_XMLTEXT)) {
+        if (name.equals(JCR_XMLTEXT)) {
             // the node represents xml character data
             Iterator iter = props.iterator();
             while (iter.hasNext()) {
                 PropertyImpl prop = (PropertyImpl) iter.next();
                 QName propName = prop.getQName();
-                if (propName.equals(PROPNAME_XMLCHARACTERS)) {
+                if (propName.equals(JCR_XMLCHARACTERS)) {
                     // assume jcr:xmlcharacters is single-valued
                     char[] chars = prop.getValue().getString().toCharArray();
                     contentHandler.characters(chars, 0, chars.length);
@@ -120,7 +113,7 @@
             try {
                 if (node.isRepositoryRoot()) {
                     // root node needs a name
-                    elemName = NODENAME_ROOT.toJCRName(session.getNamespaceResolver());
+                    elemName = JCR_ROOT.toJCRName(session.getNamespaceResolver());
                 } else {
                     elemName = name.toJCRName(session.getNamespaceResolver());
                 }
@@ -196,7 +189,7 @@
                     } else {
                         textVal = val.getString();
                     }
-                    // enocde spaces in value
+                    // enocde blanks in value
                     textVal = Text.replace(textVal, " ", "_x0020_");
                     attrValue.append(textVal);
                 }
@@ -213,7 +206,7 @@
     protected void leaving(NodeImpl node, int level)
             throws RepositoryException, SAXException {
         QName name = node.getQName();
-        if (name.equals(NODENAME_XMLTEXT)) {
+        if (name.equals(JCR_XMLTEXT)) {
             // the node represents xml character data
             // (already processed in leavingProperties(NodeImpl, int)
             return;
@@ -223,7 +216,7 @@
         try {
             if (node.isRepositoryRoot()) {
                 // root node needs a name
-                elemName = NODENAME_ROOT.toJCRName(session.getNamespaceResolver());
+                elemName = JCR_ROOT.toJCRName(session.getNamespaceResolver());
             } else {
                 elemName = name.toJCRName(session.getNamespaceResolver());
             }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/ImportHandler.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/ImportHandler.java?view=diff&r1=153502&r2=153503
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/ImportHandler.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/ImportHandler.java Sat Feb 12 05:40:13 2005
@@ -43,7 +43,9 @@
     protected boolean systemViewXML;
     protected boolean initialized;
 
-    public ImportHandler(NodeImpl importTargetNode, NamespaceRegistryImpl nsReg, SessionImpl session) {
+    public ImportHandler(NodeImpl importTargetNode,
+                         NamespaceRegistryImpl nsReg,
+                         SessionImpl session) {
         this.importTargetNode = importTargetNode;
         this.session = session;
         this.nsReg = nsReg;
@@ -55,7 +57,9 @@
      */
     public void warning(SAXParseException e) throws SAXException {
         // log exception and carry on...
-        log.warn("warning encountered at line: " + e.getLineNumber() + ", column: " + e.getColumnNumber() + " while parsing XML stream", e);
+        log.warn("warning encountered at line: " + e.getLineNumber()
+                + ", column: " + e.getColumnNumber()
+                + " while parsing XML stream", e);
     }
 
     /**
@@ -63,7 +67,9 @@
      */
     public void error(SAXParseException e) throws SAXException {
         // log exception and carry on...
-        log.error("error encountered at line: " + e.getLineNumber() + ", column: " + e.getColumnNumber() + " while parsing XML stream", e);
+        log.error("error encountered at line: " + e.getLineNumber()
+                + ", column: " + e.getColumnNumber()
+                + " while parsing XML stream", e);
     }
 
     /**
@@ -71,7 +77,9 @@
      */
     public void fatalError(SAXParseException e) throws SAXException {
         // log and re-throw exception
-        log.error("fatal error encountered at line: " + e.getLineNumber() + ", column: " + e.getColumnNumber() + " while parsing XML stream", e);
+        log.error("fatal error encountered at line: " + e.getLineNumber()
+                + ", column: " + e.getColumnNumber()
+                + " while parsing XML stream", e);
         throw e;
     }
 
@@ -96,7 +104,8 @@
     /**
      * @see ContentHandler#startPrefixMapping(String, String)
      */
-    public void startPrefixMapping(String prefix, String uri) throws SAXException {
+    public void startPrefixMapping(String prefix, String uri)
+            throws SAXException {
         try {
             String oldPrefix = session.getNamespacePrefix(uri);
             // namespace is already registered; check prefix
@@ -108,7 +117,8 @@
                 try {
                     session.setNamespacePrefix(prefix, uri);
                 } catch (RepositoryException re) {
-                    throw new SAXException("failed to remap namespace " + uri + " to prefix " + prefix, re);
+                    throw new SAXException("failed to remap namespace " + uri
+                            + " to prefix " + prefix, re);
                 }
             }
         } catch (NamespaceException nse) {
@@ -134,7 +144,8 @@
     /**
      * @see ContentHandler#startElement(String, String, String, Attributes)
      */
-    public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
+    public void startElement(String namespaceURI, String localName, String qName,
+                             Attributes atts) throws SAXException {
         if (!initialized) {
             // the namespace of the first element determines the type of XML
             // (system view/document view)
@@ -151,7 +162,7 @@
                     throw new SAXException(msg, e);
                 }
             }
-            systemViewXML = NamespaceRegistryImpl.NS_SV_URI.equals(nsURI);
+            systemViewXML = Constants.NS_SV_URI.equals(nsURI);
 
             if (systemViewXML) {
                 targetHandler = new SysViewImportHandler(importTargetNode, session);
@@ -177,7 +188,8 @@
     /**
      * @see ContentHandler#endElement(String, String, String)
      */
-    public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
+    public void endElement(String namespaceURI, String localName, String qName)
+            throws SAXException {
         // delegate to target handler
         targetHandler.endElement(namespaceURI, localName, qName);
     }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/SysViewImportHandler.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/SysViewImportHandler.java?view=diff&r1=153502&r2=153503
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/SysViewImportHandler.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/SysViewImportHandler.java Sat Feb 12 05:40:13 2005
@@ -18,10 +18,8 @@
 
 import org.apache.jackrabbit.core.*;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
-import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.util.Base64;
 import org.apache.jackrabbit.core.util.ValueHelper;
-import org.apache.jackrabbit.core.version.VersionManager;
 import org.apache.log4j.Logger;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
@@ -39,7 +37,7 @@
 /**
  * <code>SysViewImportHandler</code>  ...
  */
-class SysViewImportHandler extends DefaultHandler {
+class SysViewImportHandler extends DefaultHandler implements Constants {
     private static Logger log = Logger.getLogger(SysViewImportHandler.class);
 
     private SessionImpl session;
@@ -58,7 +56,7 @@
     private LinkedList references = new LinkedList();
 
     /**
-     * list of all mix:referenceable
+     * mapping <original uuid> to <new uuid> of mix:referenceable nodes
      */
     private HashMap referees = new HashMap();
 
@@ -81,7 +79,9 @@
     /**
      * @see ContentHandler#startElement(String, String, String, Attributes)
      */
-    public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
+    public void startElement(String namespaceURI, String localName,
+                             String qName, Attributes atts)
+            throws SAXException {
         try {
             String elemName;
             String nsURI;
@@ -100,7 +100,7 @@
                 }
             }
             // check namespace
-            if (!NamespaceRegistryImpl.NS_SV_URI.equals(nsURI)) {
+            if (!NS_SV_URI.equals(nsURI)) {
                 throw new SAXException(new InvalidSerializedDataException("invalid namespace for element in system view xml document: " + nsURI));
             }
             // check element name
@@ -222,7 +222,7 @@
 
                 // check if all system properties (jcr:primaryType, jcr:uuid etc.)
                 // have been collected and create node as necessary
-                if (currentPropName.equals(ItemImpl.PROPNAME_PRIMARYTYPE)) {
+                if (currentPropName.equals(JCR_PRIMARYTYPE)) {
                     try {
                         current.primaryType = QName.fromJCRName((String) currentPropValues.get(0), session.getNamespaceResolver());
                     } catch (IllegalNameException ine) {
@@ -230,7 +230,7 @@
                     } catch (UnknownPrefixException upe) {
                         throw new SAXException(new InvalidSerializedDataException("illegal node type name: " + currentPropValues.get(0), upe));
                     }
-                } else if (currentPropName.equals(ItemImpl.PROPNAME_MIXINTYPES)) {
+                } else if (currentPropName.equals(JCR_MIXINTYPES)) {
                     if (current.mixinTypes == null) {
                         current.mixinTypes = new ArrayList(currentPropValues.size());
                     }
@@ -244,7 +244,7 @@
                             throw new SAXException(new InvalidSerializedDataException("illegal mixin type name: " + currentPropValues.get(i), upe));
                         }
                     }
-                } else if (currentPropName.equals(ItemImpl.PROPNAME_UUID)) {
+                } else if (currentPropName.equals(JCR_UUID)) {
                     current.uuid = (String) currentPropValues.get(0);
                     // jcr:uuid is the last system property; we can assume that all
                     // required system properties have been collected by now
@@ -253,13 +253,13 @@
                         // we're ready to create the node
                         createNode(current);
                     }
-                } else if (currentPropName.equals(VersionManager.PROPNAME_BASE_VERSION)) {
+                } else if (currentPropName.equals(JCR_BASEVERSION)) {
                     // ignore so far
-                } else if (currentPropName.equals(VersionManager.PROPNAME_VERSION_HISTORY)) {
+                } else if (currentPropName.equals(JCR_VERSIONHISTORY)) {
                     // ignore so far
-                } else if (currentPropName.equals(VersionManager.PROPNAME_PREDECESSORS)) {
+                } else if (currentPropName.equals(JCR_PREDECESSORS)) {
                     // ignore so far
-                } else if (currentPropName.equals(VersionManager.PROPNAME_IS_CHECKED_OUT)) {
+                } else if (currentPropName.equals(JCR_ISCHECKEDOUT)) {
                     // ignore so far
                 } else {
                     // non-system property encountered; we can assume that all
@@ -314,8 +314,8 @@
                         // can only be multi-valued (n == 0 || n > 1)
                         current.node.setProperty(currentPropName, vals);
                     }
-                    // check if reference for later resolution
                     if (currentPropType == PropertyType.REFERENCE) {
+                        // store reference for later resolution
                         references.add(current.node.getProperty(currentPropName));
                     }
                 }
@@ -335,42 +335,9 @@
         }
     }
 
-    private void createNode(ImportState state) throws RepositoryException {
-        if (state.primaryType == null) {
-            throw new InvalidSerializedDataException("missing mandatory jcr:primaryType property");
-        }
-        if (state.uuid != null) {
-            // @todo what are the semantics of the uuid with respect to import?
-            // move existing node with given uuid to current position?
-            // create with new uuid? what about reference values refering to given uuid?
-        }
-        if (state.parent.hasNode(state.nodeName)) {
-            state.node = state.parent.getNode(state.nodeName);
-            NodeDef def = state.node.getDefinition();
-            if (def.isProtected() || def.isAutoCreate()) {
-                // @todo how to handle protected/auto-created child node?
-                state.node = (NodeImpl) state.parent.getNode(state.nodeName);
-            } else if (!def.allowSameNameSibs()) {
-                throw new ItemExistsException(state.parent.safeGetJCRPath() + "/" + state.nodeName);
-            }
-        }
-        if (state.node == null) {
-            state.node = (NodeImpl) state.parent.addNode(state.nodeName, state.primaryType);
-            if (state.mixinTypes != null) {
-                for (int i = 0; i < state.mixinTypes.size(); i++) {
-                    NodeTypeImpl mixin = session.getNodeTypeManager().getNodeType((QName) state.mixinTypes.get(i));
-                    state.node.addMixin(mixin.getName());
-                }
-            }
-        }
-
-        // check for mix:referenceable
-        if (state.node.isNodeType(NodeTypeRegistry.MIX_REFERENCEABLE)) {
-            log.info("adding refereee: ori=" + state.uuid + " new=" + state.node.getUUID());
-            referees.put(state.uuid, state.node.getUUID());
-        }
-    }
-
+    /**
+     * @see ContentHandler#endDocument()
+     */
     public void endDocument() throws SAXException {
         try {
             // adjust all reference properties
@@ -386,7 +353,7 @@
                             String original = val.getString();
                             String adjusted = (String) referees.get(original);
                             if (adjusted == null) {
-                                log.error("Reference " + original + " of property can not be adjusted! " + prop.getPath());
+                                log.warn("Reference " + original + " of property can not be adjusted! " + prop.getPath());
                                 newVals[i] = val;
                             } else {
                                 newVals[i] = new ReferenceValue(session.getNodeByUUID(adjusted));
@@ -402,18 +369,53 @@
                         String original = val.getString();
                         String adjusted = (String) referees.get(original);
                         if (adjusted == null) {
-                            log.error("Reference " + original + " of property can not be adjusted! " + prop.getPath());
+                            log.warn("Reference " + original + " of property can not be adjusted! " + prop.getPath());
                         } else {
                             prop.setValue(session.getNodeByUUID(adjusted));
                         }
                     }
                 }
             }
-        } catch (RepositoryException e) {
-            log.error("Error while adjusting reference proerties: " + e.toString());
+        } catch (RepositoryException re) {
+            throw new SAXException("failed to adjust REFERENCE properties", re);
         }
     }
 
+    private void createNode(ImportState state) throws RepositoryException {
+        if (state.primaryType == null) {
+            throw new InvalidSerializedDataException("missing mandatory jcr:primaryType property");
+        }
+        if (state.uuid != null) {
+            // @todo what are the semantics of the uuid with respect to import?
+            // move existing node with given uuid to current position?
+            // create with new uuid? what about reference values refering to given uuid?
+        }
+        if (state.parent.hasNode(state.nodeName)) {
+            state.node = state.parent.getNode(state.nodeName);
+            NodeDef def = state.node.getDefinition();
+            if (def.isProtected() || def.isAutoCreate()) {
+                // @todo how to handle protected/auto-created child node?
+                state.node = (NodeImpl) state.parent.getNode(state.nodeName);
+            } else if (!def.allowSameNameSibs()) {
+                throw new ItemExistsException(state.parent.safeGetJCRPath() + "/" + state.nodeName);
+            }
+        }
+        if (state.node == null) {
+            state.node = (NodeImpl) state.parent.addNode(state.nodeName, state.primaryType);
+            if (state.mixinTypes != null) {
+                for (int i = 0; i < state.mixinTypes.size(); i++) {
+                    NodeTypeImpl mixin = session.getNodeTypeManager().getNodeType((QName) state.mixinTypes.get(i));
+                    state.node.addMixin(mixin.getName());
+                }
+            }
+        }
+
+        // check for mix:referenceable
+        if (state.node.isNodeType(MIX_REFERENCEABLE)) {
+            log.info("adding refereee: ori=" + state.uuid + " new=" + state.node.getUUID());
+            referees.put(state.uuid, state.node.getUUID());
+        }
+    }
 
     //--------------------------------------------------------< inner classes >
     class ImportState {

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/SysViewSAXEventGenerator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/SysViewSAXEventGenerator.java?view=diff&r1=153502&r2=153503
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/SysViewSAXEventGenerator.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/SysViewSAXEventGenerator.java Sat Feb 12 05:40:13 2005
@@ -50,9 +50,6 @@
     public static final String CDATA_TYPE = "CDATA";
     public static final String ENUMERATION_TYPE = "ENUMERATION";
 
-    public static final String NS_SV_PREFIX = NamespaceRegistryImpl.NS_SV_PREFIX;
-    public static final String NS_SV_URI = NamespaceRegistryImpl.NS_SV_URI;
-
     /**
      * Constructor
      *
@@ -84,7 +81,7 @@
         try {
             if (node.isRepositoryRoot()) {
                 // root node needs a name
-                nodeName = NODENAME_ROOT.toJCRName(session.getNamespaceResolver());
+                nodeName = JCR_ROOT.toJCRName(session.getNamespaceResolver());
             } else {
                 nodeName = name.toJCRName(session.getNamespaceResolver());
             }

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/core/TestAll.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/core/TestAll.java?view=diff&r1=153502&r2=153503
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/core/TestAll.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/core/TestAll.java Sat Feb 12 05:40:13 2005
@@ -21,7 +21,7 @@
 import junit.framework.TestSuite;
 
 /**
- * Test suite that includes all testcases for the Search module.
+ * Test suite that includes all testcases for the Core module.
  */
 public class TestAll extends TestCase {
 

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java?view=diff&r1=153502&r2=153503
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java Sat Feb 12 05:40:13 2005
@@ -41,10 +41,7 @@
         suite.addTestSuite(GetAncestorTest.class);
         suite.addTestSuite(RootNodeTest.class);
         suite.addTestSuite(NamespaceRegistryTest.class);
-
-	// references test currently corrupts repository
-	// enable again, when bug JCR-44 is fixed
-        // suite.addTestSuite(ReferencesTest.class);
+        suite.addTestSuite(ReferencesTest.class);
 
         return suite;
     }