jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r430791 [2/3] - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ lock/ name/ nodetype/ operation/ query/ state/ util/ version/ xml/
Date Fri, 11 Aug 2006 14:00:03 GMT
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/PropertyDefinitionImpl.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/PropertyDefinitionImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/PropertyDefinitionImpl.java Fri Aug 11 07:00:00 2006
@@ -26,7 +26,9 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
+import javax.jcr.PropertyType;
 import javax.jcr.nodetype.PropertyDefinition;
+import java.io.IOException;
 
 /**
  * This class implements the <code>PropertyDefinition</code> interface.
@@ -42,7 +44,7 @@
     private static Logger log = LoggerFactory.getLogger(PropertyDefinitionImpl.class);
 
     private final ValueFactory valueFactory;
-    
+
     /**
      * Package private constructor
      *
@@ -61,20 +63,28 @@
      * {@inheritDoc}
      */
     public Value[] getDefaultValues() {
-        QValue[] defVals = QValue.create(((QPropertyDefinition) itemDef).getDefaultValues());
-        if (defVals == null) {
-            return null;
+        QPropertyDefinition pDef = ((QPropertyDefinition) itemDef);
+        QValue[] defVals;
+        if (pDef.getRequiredType() == PropertyType.BINARY) {
+            try {
+                defVals = QValue.create(pDef.getDefaultValuesAsStream(), pDef.getRequiredType());
+            } catch (IOException e) {
+                String propName = (getName() == null) ? "[null]" : getName();
+                log.error("Illegal default value specified for property " + propName + " in node type " + getDeclaringNodeType(), e);
+                return null;
+            }
+        } else {
+            defVals = QValue.create(pDef.getDefaultValues(), pDef.getRequiredType());
         }
+
         Value[] values = new Value[defVals.length];
         for (int i = 0; i < defVals.length; i++) {
             try {
                 values[i] = ValueFormat.getJCRValue(defVals[i], nsResolver, valueFactory);
-            } catch (RepositoryException re) {
+            } catch (RepositoryException e) {
                 // should never get here
                 String propName = (getName() == null) ? "[null]" : getName();
-                log.error("illegal default value specified for property "
-                        + propName + " in node type " + getDeclaringNodeType(),
-                        re);
+                log.error("illegal default value specified for property " + propName + " in node type " + getDeclaringNodeType(), e);
                 return null;
             }
         }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java Fri Aug 11 07:00:00 2006
@@ -64,4 +64,8 @@
         Remove rm = new Remove(state.getId(), state.getParent().getNodeId());
         return rm;
     }
+
+    public static Operation create(ItemId removeId, NodeId parentId) {
+        return new Remove(removeId, parentId);
+    }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/NodeIteratorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/NodeIteratorImpl.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/NodeIteratorImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/NodeIteratorImpl.java Fri Aug 11 07:00:00 2006
@@ -17,49 +17,52 @@
 package org.apache.jackrabbit.jcr2spi.query;
 
 import org.apache.jackrabbit.jcr2spi.ItemManager;
-import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateManager;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.spi.IdIterator;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.QueryInfo;
+import org.apache.jackrabbit.spi.ItemId;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
+import javax.jcr.Item;
 
 import java.util.NoSuchElementException;
+import java.util.Iterator;
 
 // DIFF JR: this class uses a different package than the jackrabbit original
 /**
  * Implements a {@link javax.jcr.NodeIterator} returned by
  * {@link javax.jcr.query.QueryResult#getNodes()}.
  */
-class NodeIteratorImpl implements ScoreNodeIterator {
+public class NodeIteratorImpl implements ScoreNodeIterator {
 
     /** Logger instance for this class */
     private static final Logger log = LoggerFactory.getLogger(NodeIteratorImpl.class);
 
     /** ItemManager to turn Ids into Node instances */
-    protected final ItemManager itemMgr;
+    private final ItemManager itemMgr;
 
-    /** The namespace resolver */
-    protected final NamespaceResolver resolver;
+    /** ItemManager to turn Ids into Node instances */
+    private final ItemStateManager itemStateMgr;
 
     /** The query result info */
-    protected final QueryInfo queryInfo;
+    private final QueryInfo queryInfo;
 
     /** The ItemId's of the result nodes */
-    protected final IdIterator ids;
+    private final IdIterator ids;
 
     /** Index of the jcr:score column. */
-    protected final int scoreIndex;
+    private final int scoreIndex;
 
     /** Current position of this node iterator */
-    protected int pos = -1;
+    private int pos = -1;
 
     /** Number of invalid nodes */
-    protected int invalid = 0;
+    private int invalid = 0;
 
     /** Id of the next Node */
     private NodeId nextId;
@@ -70,26 +73,25 @@
     /**
      * Creates a new <code>NodeIteratorImpl</code> instance.
      *
-     * @param itemMgr   the <code>ItemManager</code> to turn Id's into
-     *                  <code>Node</code> instances.
-     * @param resolver  the namespace resolver.
+     * @param itemMgr The <code>ItemManager</code> to build <code>Node</code> instances.
+     * @param itemStateMgr The <code>ItemStateManager</code> used to build
+     * <code>ItemState</code>s from the ids returned by the query.
      * @param queryInfo the query result.
-     * @throws RepositoryException if an error occurs while creating a node
-     *                             iterator.
+     * @throws RepositoryException if an error occurs while creating a node iterator.
      */
     // DIFF JR: use QueryInfo instead of UUID String[]
-    NodeIteratorImpl(ItemManager itemMgr,
-                     NamespaceResolver resolver,
-                     QueryInfo queryInfo) throws RepositoryException {
+    public NodeIteratorImpl(ItemManager itemMgr, ItemStateManager itemStateMgr,
+                            QueryInfo queryInfo) throws RepositoryException {
         this.itemMgr = itemMgr;
-        this.resolver = resolver;
+        this.itemStateMgr = itemStateMgr;
         this.queryInfo = queryInfo;
         this.ids = queryInfo.getNodeIds();
+        
         QName[] columnNames = queryInfo.getColumnNames();
         int idx = -1;
         for (int i = 0; i < columnNames.length; i++) {
             if (columnNames[i].getNamespaceURI().equals(QName.NS_JCR_URI)
-                    && columnNames[i].getLocalName().startsWith(QName.JCR_SCORE.getLocalName())) {
+                && columnNames[i].getLocalName().startsWith(QName.JCR_SCORE.getLocalName())) {
                 idx = i;
                 break;
             }
@@ -101,39 +103,52 @@
         fetchNext();
     }
 
+    //------------------------------------------------------< ScoreIterator >---
     /**
-     * Returns the next <code>Node</code> in the result set.
+     * Returns the score of the node returned by {@link #nextNode()}. In other
+     * words, this method returns the score value of the next <code>Node</code>.
      *
-     * @return the next <code>Node</code> in the result set.
-     * @throws NoSuchElementException if iteration has no more
-     *   <code>Node</code>s.
+     * @return the score of the node returned by {@link #nextNode()}.
+     * @throws NoSuchElementException if there is no next node.
+     * @see ScoreNodeIterator#getScore()
      */
-    public Node nextNode() throws NoSuchElementException {
-        if (next == null) {
+    public float getScore() throws NoSuchElementException {
+        if (!hasNext()) {
+            throw new NoSuchElementException();
+        }
+        String scoreString = queryInfo.getValues(nextId)[scoreIndex];
+        try {
+            return Float.parseFloat(scoreString);
+        } catch (NumberFormatException e) {
             throw new NoSuchElementException();
         }
-        Node n = next;
-        fetchNext();
-        return n;
     }
 
+    //-------------------------------------------------------< NodeIterator >---
     /**
      * Returns the next <code>Node</code> in the result set.
      *
      * @return the next <code>Node</code> in the result set.
-     * @throws NoSuchElementException if iteration has no more
-     *   <code>Node</code>s.
+     * @throws NoSuchElementException if iteration has no more <code>Node</code>s.
+     * @see javax.jcr.NodeIterator#nextNode()
      */
-    public Object next() throws NoSuchElementException {
-        return nextNode();
+    public Node nextNode() throws NoSuchElementException {
+        if (next == null) {
+            throw new NoSuchElementException();
+        }
+        Node n = next;
+        fetchNext();
+        return n;
     }
 
+    //------------------------------------------------------< RangeIterator >---
     /**
      * Skip a number of <code>Node</code>s in this iterator.
      *
      * @param skipNum the non-negative number of <code>Node</code>s to skip
-     * @throws NoSuchElementException
-     *          if skipped past the last <code>Node</code> in this iterator.
+     * @throws NoSuchElementException if skipped past the last <code>Node</code>
+     * in this iterator.
+     * @see javax.jcr.NodeIterator#skip(long)
      */
     public void skip(long skipNum) throws NoSuchElementException {
         if (skipNum < 0) {
@@ -159,6 +174,7 @@
      * invalid node is detected, the size of this iterator is adjusted.
      *
      * @return the number of node in this iterator.
+     * @see javax.jcr.RangeIterator#getSize()
      */
     public long getSize() {
         if (ids.getSize() != -1) {
@@ -172,17 +188,30 @@
      * Returns the current position in this <code>NodeIterator</code>.
      *
      * @return the current position in this <code>NodeIterator</code>.
+     * @see javax.jcr.RangeIterator#getPosition()
      */
     public long getPosition() {
         return pos - invalid;
     }
 
     /**
+     * Returns the next <code>Node</code> in the result set.
+     *
+     * @return the next <code>Node</code> in the result set.
+     * @throws NoSuchElementException if iteration has no more <code>Node</code>s.
+     * @see java.util.Iterator#next()
+     */
+    public Object next() throws NoSuchElementException {
+        return nextNode();
+    }
+
+    /**
      * Returns <code>true</code> if there is another <code>Node</code>
      * available; <code>false</code> otherwise.
      *
      * @return <code>true</code> if there is another <code>Node</code>
      *  available; <code>false</code> otherwise.
+     * @see java.util.Iterator#hasNext()
      */
     public boolean hasNext() {
         return next != null;
@@ -190,30 +219,13 @@
 
     /**
      * @throws UnsupportedOperationException always.
+     * @see Iterator#remove()
      */
     public void remove() {
         throw new UnsupportedOperationException("remove");
     }
 
-    /**
-     * Returns the score of the node returned by {@link #nextNode()}. In other
-     * words, this method returns the score value of the next <code>Node</code>.
-     * 
-     * @return the score of the node returned by {@link #nextNode()}.
-     * @throws NoSuchElementException if there is no next node.
-     */
-    public float getScore() throws NoSuchElementException {
-        if (!hasNext()) {
-            throw new NoSuchElementException();
-        }
-        String scoreString = queryInfo.getValues(nextId)[scoreIndex];
-        try {
-            return Float.parseFloat(scoreString);
-        } catch (NumberFormatException e) {
-            throw new NoSuchElementException();
-        }
-    }
-
+    //------------------------------------------------------------< private >---
     /**
      * Clears {@link #next} and tries to fetch the next Node instance.
      * When this method returns {@link #next} refers to the next available
@@ -221,8 +233,6 @@
      * method returns, then there are no more valid element in this iterator.
      */
     private void fetchNext() {
-        // TODO
-        /*
         // reset
         next = null;
         while (next == null && ids.hasNext()) {
@@ -233,7 +243,7 @@
                     continue;
                 }
                 nextId = (NodeId)id;
-                Item tmp = itemMgr.getItem(nextId);
+                Item tmp = itemMgr.getItem(itemStateMgr.getItemState(nextId));
 
                 if (tmp.isNode()) {
                     next = (Node) tmp;
@@ -251,6 +261,5 @@
             }
         }
         pos++;
-        */
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryImpl.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryImpl.java Fri Aug 11 07:00:00 2006
@@ -17,8 +17,8 @@
 package org.apache.jackrabbit.jcr2spi.query;
 
 import org.apache.jackrabbit.jcr2spi.ItemManager;
-import org.apache.jackrabbit.jcr2spi.SessionImpl;
 import org.apache.jackrabbit.jcr2spi.WorkspaceManager;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateManager;
 import org.apache.jackrabbit.name.MalformedPathException;
 import org.apache.jackrabbit.name.NamespaceResolver;
 import org.apache.jackrabbit.name.NoPrefixDeclaredException;
@@ -26,6 +26,7 @@
 import org.apache.jackrabbit.name.PathFormat;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.NameFormat;
+import org.apache.jackrabbit.spi.QueryInfo;
 
 import javax.jcr.ItemExistsException;
 import javax.jcr.ItemNotFoundException;
@@ -33,6 +34,7 @@
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Session;
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.query.InvalidQueryException;
@@ -48,80 +50,80 @@
     /**
      * The session of the user executing this query
      */
-    protected SessionImpl session;
+    private final Session session;
 
     /**
-     * The namespace resolver of the session that executes this query.
+     * The namespace nsResolver of the session that executes this query.
      */
     // DIFF JR: added
-    protected NamespaceResolver resolver;
+    private final NamespaceResolver nsResolver;
 
     /**
      * The item manager of the session that executes this query.
      */
-    protected ItemManager itemManager;
+    private final ItemManager itemManager;
+
+    /**
+     * The item state manager of the session that executes this query.
+     */
+    private final ItemStateManager itemStateManager;
 
     /**
      * The query statement
      */
-    protected String statement;
+    private String statement;
 
     /**
      * The syntax of the query statement
      */
-    protected String language;
+    private String language;
 
     /**
      * The node where this query is persisted. Only set when this is a persisted
      * query.
      */
-    protected Node node;
+    private Node node;
 
     /**
      * The query handler for this query.
      */
     // DIFF JR: use WorkspaceManager (-> RepositoryService) instead
     //protected QueryHandler handler;
-    protected WorkspaceManager wspManager;
-
-    /**
-     * Flag indicating whether this query is initialized.
-     */
-    private boolean initialized = false;
+    private WorkspaceManager wspManager;
 
     /**
-     * Initializes this query.
+     * Creates a new query.
      *
      * @param session    the session that created this query.
+     * @param nsResolver the namespace resolver to be used.
      * @param itemMgr    the item manager of that session.
+     * @param itemStateManager the item state manager of that session.
      * @param wspManager the workspace manager that belongs to the session.
      * @param statement  the query statement.
      * @param language   the language of the query statement.
      * @throws InvalidQueryException if the query is invalid.
      */
     // DIFF JR: uses WorkspaceManager instead of QueryHandler
-    public void init(SessionImpl session,
-                     NamespaceResolver resolver,
-                     ItemManager itemMgr,
+    public QueryImpl(Session session, NamespaceResolver nsResolver,
+                     ItemManager itemMgr, ItemStateManager itemStateManager,
                      WorkspaceManager wspManager,
-                     String statement,
-                     String language) throws InvalidQueryException {
-        checkNotInitialized();
+                     String statement, String language) throws InvalidQueryException {
         this.session = session;
-        this.resolver = resolver;
+        this.nsResolver = nsResolver;
         this.itemManager = itemMgr;
+        this.itemStateManager = itemStateManager;
         this.statement = statement;
         this.language = language;
         this.wspManager = wspManager;
         // DIFF JR: todo validate statement
         //this.query = handler.createExecutableQuery(session, itemMgr, statement, language);
-        initialized = true;
     }
 
     /**
-     * Initializes this query from a node.
+     * Creates a query from a node.
      *
      * @param session    the session that created this query.
+     * @param nsResolver the namespace resolver to be used.
      * @param itemMgr    the item manager of that session.
      * @param wspManager the workspace manager that belongs to the session.
      * @param node       the node from where to read the query.
@@ -130,129 +132,94 @@
      *                               the node.
      */
     // DIFF JR: uses WorkspaceManager instead of QueryHandler
-    public void init(SessionImpl session,
-                     NamespaceResolver resolver,
-                     ItemManager itemMgr,
-                     WorkspaceManager wspManager,
-                     Node node)
-            throws InvalidQueryException, RepositoryException {
-        checkNotInitialized();
+    public QueryImpl(Session session, NamespaceResolver nsResolver,
+                     ItemManager itemMgr, ItemStateManager itemStateManager,
+                     WorkspaceManager wspManager, Node node)
+        throws InvalidQueryException, RepositoryException {
+
         this.session = session;
-        this.resolver = resolver;
+        this.nsResolver = nsResolver;
         this.itemManager = itemMgr;
+        this.itemStateManager = itemStateManager;
         this.node = node;
         this.wspManager = wspManager;
 
         try {
-            if (!node.isNodeType(NameFormat.format(QName.NT_QUERY, resolver))) {
-                throw new InvalidQueryException("node is not of type nt:query");
+            if (!node.isNodeType(NameFormat.format(QName.NT_QUERY, nsResolver))) {
+                throw new InvalidQueryException("Node is not of type nt:query");
             }
-            statement = node.getProperty(NameFormat.format(QName.JCR_STATEMENT, resolver)).getString();
-            language = node.getProperty(NameFormat.format(QName.JCR_LANGUAGE, resolver)).getString();
+            statement = node.getProperty(NameFormat.format(QName.JCR_STATEMENT, nsResolver)).getString();
+            language = node.getProperty(NameFormat.format(QName.JCR_LANGUAGE, nsResolver)).getString();
             // DIFF JR: todo validate statement
             //query = handler.createExecutableQuery(session, itemMgr, statement, language);
         } catch (NoPrefixDeclaredException e) {
             throw new RepositoryException(e.getMessage(), e);
         }
-        initialized = true;
     }
 
     /**
-     * {@inheritDoc}
+     * @see Query#execute() 
      */
     public QueryResult execute() throws RepositoryException {
-        checkInitialized();
-        return new QueryResultImpl(itemManager,
-                wspManager.executeQuery(statement, language), resolver);
+        QueryInfo qI = wspManager.executeQuery(statement, language);
+        return new QueryResultImpl(itemManager, itemStateManager, qI, nsResolver);
     }
 
     /**
-     * {@inheritDoc}
+     * @see Query#getStatement()
      */
     public String getStatement() {
-        checkInitialized();
         return statement;
     }
 
     /**
-     * {@inheritDoc}
+     * @see Query#getLanguage()
      */
     public String getLanguage() {
-        checkInitialized();
         return language;
     }
 
     /**
-     * {@inheritDoc}
+     * @see Query#getStoredQueryPath()
      */
-    public String getStoredQueryPath()
-            throws ItemNotFoundException, RepositoryException {
-        checkInitialized();
+    public String getStoredQueryPath() throws ItemNotFoundException, RepositoryException {
         if (node == null) {
-            throw new ItemNotFoundException("not a persistent query");
+            throw new ItemNotFoundException("Not a persistent query.");
         }
         return node.getPath();
     }
 
     /**
-     * {@inheritDoc}
+     * @see Query#storeAsNode(String)
      */
-    public Node storeAsNode(String absPath)
-            throws ItemExistsException,
-            PathNotFoundException,
-            VersionException,
-            ConstraintViolationException,
-            LockException,
-            UnsupportedRepositoryOperationException,
-            RepositoryException {
+    public Node storeAsNode(String absPath) throws ItemExistsException,
+        PathNotFoundException, VersionException, ConstraintViolationException,
+        LockException, UnsupportedRepositoryOperationException, RepositoryException {
 
-        checkInitialized();
         try {
-            Path p = PathFormat.parse(absPath, resolver).getNormalizedPath();
+            Path p = PathFormat.parse(absPath, nsResolver).getNormalizedPath();
             if (!p.isAbsolute()) {
                 throw new RepositoryException(absPath + " is not an absolute path");
             }
             if (session.itemExists(absPath)) {
                 throw new ItemExistsException(absPath);
             }
-            String jcrParent = PathFormat.format(p.getAncestor(1), resolver);
+            String jcrParent = PathFormat.format(p.getAncestor(1), nsResolver);
             if (!session.itemExists(jcrParent)) {
                 throw new PathNotFoundException(jcrParent);
             }
-            String relPath = PathFormat.format(p, resolver).substring(1);
-            String ntName = NameFormat.format(QName.NT_QUERY, resolver);
+            String relPath = PathFormat.format(p, nsResolver).substring(1);
+            String ntName = NameFormat.format(QName.NT_QUERY, nsResolver);
             Node queryNode = session.getRootNode().addNode(relPath, ntName);
             // set properties
-            queryNode.setProperty(NameFormat.format(QName.JCR_LANGUAGE, resolver), language);
-            queryNode.setProperty(NameFormat.format(QName.JCR_STATEMENT, resolver), statement);
+            queryNode.setProperty(NameFormat.format(QName.JCR_LANGUAGE, nsResolver), language);
+            queryNode.setProperty(NameFormat.format(QName.JCR_STATEMENT, nsResolver), statement);
             node = queryNode;
             return node;
         } catch (MalformedPathException e) {
             throw new RepositoryException(e.getMessage(), e);
         } catch (NoPrefixDeclaredException e) {
             throw new RepositoryException(e.getMessage(), e);
-        }
-    }
-
-    //-----------------------------< internal >---------------------------------
-
-    /**
-     * Checks if this query is not yet initialized and throws an
-     * <code>IllegalStateException</code> if it is already initialized.
-     */
-    protected void checkNotInitialized() {
-        if (initialized) {
-            throw new IllegalStateException("already initialized");
-        }
-    }
-
-    /**
-     * Checks if this query is initialized and throws an
-     * <code>IllegalStateException</code> if it is not yet initialized.
-     */
-    protected void checkInitialized() {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
         }
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java Fri Aug 11 07:00:00 2006
@@ -17,12 +17,13 @@
 package org.apache.jackrabbit.jcr2spi.query;
 
 import org.apache.jackrabbit.jcr2spi.ItemManager;
-import org.apache.jackrabbit.jcr2spi.SessionImpl;
 import org.apache.jackrabbit.jcr2spi.WorkspaceManager;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateManager;
 import org.apache.jackrabbit.name.NamespaceResolver;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryManager;
@@ -35,13 +36,13 @@
     /**
      * The <code>Session</code> for this QueryManager.
      */
-    private final SessionImpl session;
+    private final Session session;
 
     /**
-     * The namespace resolver for this query manager.
+     * The namespace nsResolver for this query manager.
      */
     // DIFF JR: added
-    private final NamespaceResolver resolver;
+    private final NamespaceResolver nsResolver;
 
     /**
      * The <code>ItemManager</code> of for item retrieval in search results
@@ -49,58 +50,65 @@
     private final ItemManager itemMgr;
 
     /**
+     * The <code>ItemStateManager</code> of for item retrieval in search results
+     */
+    private final ItemStateManager itemStateManager;
+
+    /**
      * The <code>WorkspaceManager</code> where queries are executed.
      */
     private final WorkspaceManager wspManager;
 
     /**
      * Creates a new <code>QueryManagerImpl</code> for the passed
-     * <code>session</code>
+     * <code>Session</code>.
      *
      * @param session
-     * @param resolver
+     * @param nsResolver
      * @param itemMgr
+     * @param itemStateManager
      * @param wspManager
      */
-    public QueryManagerImpl(SessionImpl session,
-                            NamespaceResolver resolver,
+    public QueryManagerImpl(Session session,
+                            NamespaceResolver nsResolver,
                             ItemManager itemMgr,
+                            ItemStateManager itemStateManager,
                             WorkspaceManager wspManager) {
         this.session = session;
-        this.resolver = resolver;
+        this.nsResolver = nsResolver;
         this.itemMgr = itemMgr;
+        this.itemStateManager = itemStateManager;
         this.wspManager = wspManager;
     }
 
     /**
-     * {@inheritDoc}
+     * @see QueryManager#createQuery(String, String)
      */
     public Query createQuery(String statement, String language)
             throws InvalidQueryException, RepositoryException {
-        sanityCheck();
-        QueryImpl query = new QueryImpl();
-        query.init(session, resolver, itemMgr, wspManager, statement, language);
+        checkIsAlive();
+        QueryImpl query = new QueryImpl(session, nsResolver, itemMgr, itemStateManager, wspManager, statement, language);
         return query;
     }
 
     /**
-     * {@inheritDoc}
+     * @see QueryManager#getQuery(Node)
      */
     public Query getQuery(Node node)
             throws InvalidQueryException, RepositoryException {
-        sanityCheck();
-        QueryImpl query = new QueryImpl();
-        query.init(session, resolver, itemMgr, wspManager, node);
+        checkIsAlive();
+        QueryImpl query = new QueryImpl(session, nsResolver, itemMgr, itemStateManager, wspManager, node);
         return query;
     }
 
     /**
-     * {@inheritDoc}
+     * @see QueryManager#getSupportedQueryLanguages()
      */
     public String[] getSupportedQueryLanguages() throws RepositoryException {
         return wspManager.getSupportedQueryLanguages();
     }
 
+    //------------------------------------------------------------< private >---
     /**
      * Checks if this <code>QueryManagerImpl</code> instance is still usable,
      * otherwise throws a {@link javax.jcr.RepositoryException}.
@@ -108,7 +116,7 @@
      * @throws RepositoryException if this query manager is not usable anymore,
      *                             e.g. the corresponding session is closed.
      */
-    private void sanityCheck() throws RepositoryException {
+    private void checkIsAlive() throws RepositoryException {
         if (!session.isLive()) {
             throw new RepositoryException("corresponding session has been closed");
         }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryResultImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryResultImpl.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryResultImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryResultImpl.java Fri Aug 11 07:00:00 2006
@@ -18,6 +18,7 @@
 // DIFF JR: this class uses a different package than the jackrabbit original
 
 import org.apache.jackrabbit.jcr2spi.ItemManager;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateManager;
 import org.apache.jackrabbit.name.NamespaceResolver;
 import org.apache.jackrabbit.name.NoPrefixDeclaredException;
 import org.apache.jackrabbit.name.QName;
@@ -34,7 +35,7 @@
 /**
  * Implements the <code>javax.jcr.query.QueryResult</code> interface.
  */
-public class QueryResultImpl implements QueryResult {
+class QueryResultImpl implements QueryResult {
 
     /**
      * The logger instance for this class
@@ -47,12 +48,17 @@
     private final ItemManager itemMgr;
 
     /**
+     * The item state manager of the session executing the query
+     */
+    private final ItemStateManager itemStateMgr;
+
+    /**
      * The spi query result.
      */
     private final QueryInfo queryInfo;
 
     /**
-     * The namespace resolver of the session executing the query
+     * The namespace nsResolver of the session executing the query
      */
     private final NamespaceResolver nsResolver;
 
@@ -60,15 +66,16 @@
      * Creates a new query result.
      *
      * @param itemMgr     the item manager of the session executing the query.
+     * @param itemStateMgr the item state manager of the session executing the query.
      * @param queryInfo   the spi query result.
-     * @param resolver    the namespace nsResolver of the session executing the query.
+     * @param nsResolver    the namespace nsResolver of the session executing the query.
      */
-    public QueryResultImpl(ItemManager itemMgr,
-                           QueryInfo queryInfo,
-                           NamespaceResolver resolver) {
+    QueryResultImpl(ItemManager itemMgr, ItemStateManager itemStateMgr,
+                    QueryInfo queryInfo, NamespaceResolver nsResolver) {
         this.itemMgr = itemMgr;
+        this.itemStateMgr = itemStateMgr;
         this.queryInfo = queryInfo;
-        this.nsResolver = resolver;
+        this.nsResolver = nsResolver;
     }
 
     /**
@@ -110,6 +117,6 @@
      * @return a node iterator over the result nodes.
      */
     private ScoreNodeIterator getNodeIterator() throws RepositoryException {
-        return new NodeIteratorImpl(itemMgr, nsResolver, queryInfo);
+        return new NodeIteratorImpl(itemMgr, itemStateMgr, queryInfo);
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/RowIteratorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/RowIteratorImpl.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/RowIteratorImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/RowIteratorImpl.java Fri Aug 11 07:00:00 2006
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 package org.apache.jackrabbit.jcr2spi.query;
-// DIFF JR: this class uses a different package than the jackrabbit original
 
 import org.apache.jackrabbit.name.IllegalNameException;
 import org.apache.jackrabbit.name.NamespaceResolver;
@@ -33,12 +32,14 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.Node;
+import javax.jcr.RangeIterator;
 import javax.jcr.query.Row;
 import javax.jcr.query.RowIterator;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.NoSuchElementException;
 import java.util.Set;
+import java.util.Iterator;
 
 /**
  * Implements the {@link javax.jcr.query.RowIterator} interface returned by
@@ -77,23 +78,26 @@
         this.nsResolver = resolver;
     }
 
+    //--------------------------------------------------------< RowIterator >---
     /**
      * Returns the next <code>Row</code> in the iteration.
      *
      * @return the next <code>Row</code> in the iteration.
-     * @throws NoSuchElementException if iteration has no more
-     *                                <code>Row</code>s.
+     * @throws NoSuchElementException if iteration has no more <code>Row</code>s.
+     * @see RowIterator#nextRow()
      */
     public Row nextRow() throws NoSuchElementException {
         return new RowImpl(nodes.getScore(), nodes.nextNode());
     }
 
+    //------------------------------------------------------< RangeIterator >---
     /**
      * Skip a number of <code>Row</code>s in this iterator.
      *
      * @param skipNum the non-negative number of <code>Row</code>s to skip
-     * @throws NoSuchElementException if skipped past the last
-     *                                <code>Row</code> in this iterator.
+     * @throws NoSuchElementException if skipped past the last <code>Row</code>
+     * in this iterator.
+     * @see javax.jcr.RangeIterator#skip(long)
      */
     public void skip(long skipNum) throws NoSuchElementException {
         nodes.skip(skipNum);
@@ -103,6 +107,7 @@
      * Returns the number of <code>Row</code>s in this iterator.
      *
      * @return the number of <code>Row</code>s in this iterator.
+     * @see RangeIterator#getSize()
      */
     public long getSize() {
         return nodes.getSize();
@@ -117,6 +122,7 @@
      * i.e. an empty iterator will always return 0.
      *
      * @return the current position withing this iterator.
+     * @see RangeIterator#getPosition()
      */
     public long getPosition() {
         return nodes.getPosition();
@@ -124,6 +130,7 @@
 
     /**
      * @throws UnsupportedOperationException always.
+     * @see Iterator#remove()
      */
     public void remove() {
         throw new UnsupportedOperationException("remove");
@@ -135,6 +142,7 @@
      * return an <code>Row</code> rather than throwing an exception.)
      *
      * @return <code>true</code> if the iterator has more elements.
+     * @see Iterator#hasNext()
      */
     public boolean hasNext() {
         return nodes.hasNext();
@@ -145,13 +153,13 @@
      *
      * @return the next <code>Row</code> in the iteration.
      * @throws NoSuchElementException if iteration has no more <code>Row</code>s.
+     * @see Iterator#next()
      */
     public Object next() throws NoSuchElementException {
         return nextRow();
     }
 
-    //---------------------< class RowImpl >------------------------------------
-
+    //---------------------< inner class RowImpl >------------------------------
     /**
      * Implements the {@link javax.jcr.query.Row} interface, which represents
      * a row in the query result.
@@ -186,11 +194,12 @@
          * @param node  the underlying <code>Node</code> for this <code>Row</code>.
          */
         // DIFF JR: use Node instead of NodeImpl
-        RowImpl(float score, Node node) {
+        private RowImpl(float score, Node node) {
             this.score = score;
             this.node = node;
         }
 
+        //------------------------------------------------------------< Row >---
         /**
          * Returns an array of all the values in the same order as the property
          * names (column names) returned by
@@ -198,7 +207,8 @@
          *
          * @return a <code>Value</code> array.
          * @throws RepositoryException if an error occurs while retrieving the
-         *                             values from the <code>Node</code>.
+         * values from the <code>Node</code>.
+         * @see Row#getValues()
          */
         public Value[] getValues() throws RepositoryException {
             if (values == null) {
@@ -252,6 +262,7 @@
          *                               among the column names of the query result table.
          * @throws RepositoryException   if <code>propertyName</code> is not a
          *                               valid property name.
+         * @see Row#getValue(String)
          */
         public Value getValue(String propertyName) throws ItemNotFoundException, RepositoryException {
             if (propertySet == null) {

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java Fri Aug 11 07:00:00 2006
@@ -348,6 +348,17 @@
     }
 
     //------------------------------------------------------< check methods >---
+    /**
+     *
+     * @param parentState
+     * @param options
+     * @throws VersionException
+     * @throws LockException
+     * @throws ItemNotFoundException
+     * @throws ItemExistsException
+     * @throws PathNotFoundException
+     * @throws RepositoryException
+     */
     public void checkIsWritable(NodeState parentState, int options) throws VersionException,
         LockException, ItemNotFoundException,
         ItemExistsException, PathNotFoundException, RepositoryException {
@@ -450,6 +461,21 @@
         checkWriteProperty(parentState, propertyName, definition, options);
     }
 
+    /**
+     * 
+     * @param parentState
+     * @param propertyName
+     * @param definition
+     * @param options
+     * @throws ConstraintViolationException
+     * @throws AccessDeniedException
+     * @throws VersionException
+     * @throws LockException
+     * @throws ItemNotFoundException
+     * @throws ItemExistsException
+     * @throws PathNotFoundException
+     * @throws RepositoryException
+     */
     public void checkWriteProperty(NodeState parentState, QName propertyName, QPropertyDefinition definition, int options)
         throws ConstraintViolationException, AccessDeniedException,
         VersionException, LockException, ItemNotFoundException,
@@ -640,7 +666,7 @@
             return;
         }
         NodeState nodeState = (itemState.isNode()) ? (NodeState)itemState : itemState.getParent();
-        if (!mgrProvider.getVersionManager().isCheckedOut(nodeState.getNodeId())) {
+        if (!mgrProvider.getVersionManager().isCheckedOut(nodeState)) {
             throw new VersionException(safeGetJCRPath(nodeState) + " is checked-in");
         }
     }
@@ -661,7 +687,7 @@
         NodeState nodeState = (itemState.isNode())
             ? ((NodeState)itemState)
             : itemState.getParent();
-        mgrProvider.getLockManager().checkLock(nodeState.getNodeId());
+        mgrProvider.getLockManager().checkLock(nodeState);
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeReferences.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeReferences.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeReferences.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeReferences.java Fri Aug 11 07:00:00 2006
@@ -25,6 +25,7 @@
  */
 public interface NodeReferences {
 
+    // TODO: probably not needed with spi -> remove
     // DIFF JR: return NodeId instead of NodeReferenceId
     /**
      * Returns the identifier of this node references object.

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java Fri Aug 11 07:00:00 2006
@@ -58,8 +58,6 @@
 import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.IdFactory;
 import org.apache.jackrabbit.value.QValue;
-import org.apache.jackrabbit.value.ValueHelper;
-import org.apache.jackrabbit.value.ValueFormat;
 
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.ItemNotFoundException;
@@ -74,8 +72,6 @@
 import javax.jcr.PathNotFoundException;
 import javax.jcr.Session;
 import javax.jcr.MergeException;
-import javax.jcr.Value;
-import javax.jcr.ValueFactory;
 import javax.jcr.version.VersionException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
@@ -89,6 +85,7 @@
 import java.util.Arrays;
 import java.util.Calendar;
 import java.io.InputStream;
+import java.io.IOException;
 
 /**
  * <code>SessionItemStateManager</code> ...
@@ -115,7 +112,6 @@
     private final NamespaceResolver nsResolver;
 
     private final IdFactory idFactory;
-    private final ValueFactory valueFactory;
     private final ItemStateValidator validator;
 
     // DIFF JR: store root id. since 'CachingItemStateManager' not used any more
@@ -132,7 +128,6 @@
     public SessionItemStateManager(NodeId rootId,
                                    UpdatableItemStateManager workspaceItemStateMgr,
                                    IdFactory idFactory,
-                                   ValueFactory valueFactory,
                                    ItemStateValidator validator,
                                    NamespaceResolver nsResolver) {
         this.workspaceItemStateMgr = workspaceItemStateMgr;
@@ -142,8 +137,6 @@
         this.validator = validator;
         // DIFF JR: idFactory added
         this.idFactory = idFactory;
-        // DIFF JR: valueFactory added
-        this.valueFactory = valueFactory;
 
         this.nsResolver = nsResolver;
         this.rootId = rootId;
@@ -348,9 +341,9 @@
         }
 
         if (state.isNode()) {
-            NodeId nodeId = ((NodeState)state).getNodeId();
+            NodeState nodeState = (NodeState)state;
             // build list of 'new', 'modified' or 'stale' descendants
-            Iterator iter = getDescendantTransientItemStates(nodeId);
+            Iterator iter = getDescendantTransientItemStates(nodeState);
             while (iter.hasNext()) {
                 ItemState childState = (ItemState) iter.next();
                 switch (childState.getStatus()) {
@@ -370,7 +363,7 @@
             }
 
             // build list of deleted states
-            Iterator atticIter = getDescendantTransientItemStatesInAttic(nodeId);
+            Iterator atticIter = getDescendantTransientItemStatesInAttic(nodeState);
             while (atticIter.hasNext()) {
                 ItemState transientState = (ItemState) atticIter.next();
                 changeLog.deleted(transientState);
@@ -455,11 +448,11 @@
      * <p/>
      * The instances are returned in depth-first tree traversal order.
      *
-     * @param parentId the id of the common parent of the transient item state
-     *                 instances to be returned.
+     * @param parent the common parent state of the transient item state
+     * instances to be returned.
      * @return an iterator over descendant transient item state instances
      */
-    private Iterator getDescendantTransientItemStates(NodeId parentId) {
+    private Iterator getDescendantTransientItemStates(NodeState parent) {
         // DIFF JACKRABBIT: if (!transientStateMgr.hasAnyItemStates()) {
         if (transientStateMgr.getEntriesCount() == 0) {
             return Collections.EMPTY_LIST.iterator();
@@ -478,7 +471,7 @@
                 // determine relative depth: > 0 means it's a descendant
                 int depth;
                 try {
-                    depth = getHierarchyManager().getRelativeDepth(parentId, state.getId());
+                    depth = getHierarchyManager().getRelativeDepth(parent, state);
                 } catch (ItemNotFoundException infe) {
                     /**
                      * one of the parents of the specified item has been
@@ -542,14 +535,14 @@
     }
 
     /**
-     * Same as <code>{@link #getDescendantTransientItemStates(NodeId)}</code>
+     * Same as <code>{@link #getDescendantTransientItemStates(NodeState)}</code>
      * except that item state instances in the attic are returned.
      *
-     * @param parentId the id of the common parent of the transient item state
-     *                 instances to be returned.
+     * @param parent the common parent of the transient item state
+     * instances to be returned.
      * @return an iterator over descendant transient item state instances in the attic
      */
-    private Iterator getDescendantTransientItemStatesInAttic(NodeId parentId) {
+    private Iterator getDescendantTransientItemStatesInAttic(NodeState parent) {
         // DIFF JACKRABBIT: if (!transientStateMgr.hasAnyItemStatesInAttic()) {
         if (!transientStateMgr.hasEntriesInAttic()) {
             return Collections.EMPTY_LIST.iterator();
@@ -573,7 +566,7 @@
             while (iter.hasNext()) {
                 ItemState state = (ItemState) iter.next();
                 // determine relative depth: > 0 means it's a descendant
-                int depth = zombieHierMgr.getRelativeDepth(parentId, state.getId());
+                int depth = zombieHierMgr.getRelativeDepth(parent, state);
                 if (depth < 1) {
                     // not a descendant
                     continue;
@@ -675,7 +668,7 @@
         throws StaleItemStateException {
         ItemState transientState;
         if (root.isNode()) {
-            Iterator iter = getDescendantTransientItemStatesInAttic((NodeId) root.getId());
+            Iterator iter = getDescendantTransientItemStatesInAttic((NodeState)root);
             while (iter.hasNext()) {
                 transientState = (ItemState) iter.next();
                 // check if stale
@@ -755,7 +748,7 @@
 
         if (state.isNode()) {
             // build list of 'new' or 'modified' descendants
-            Iterator iter = getDescendantTransientItemStates((NodeId) state.getId());
+            Iterator iter = getDescendantTransientItemStates((NodeState) state);
             while (iter.hasNext()) {
                 transientState = (ItemState) iter.next();
                 // fail-fast test: check status of transient state
@@ -1321,9 +1314,11 @@
         for (int i = 0; i < pda.length; i++) {
             QPropertyDefinition pd = pda[i];
             QValue[] autoValue = computeSystemGeneratedPropertyValues(nodeState, pd);
-            int propOptions = 0; // nothing to check
-            // execute 'addProperty' without adding operation.
-            addPropertyState(nodeState, pd.getQName(), pd.getRequiredType(), autoValue, pd, propOptions);
+            if (autoValue != null) {
+                int propOptions = 0; // nothing to check
+                // execute 'addProperty' without adding operation.
+                addPropertyState(nodeState, pd.getQName(), pd.getRequiredType(), autoValue, pd, propOptions);
+            }
         }
 
         // recursively add 'auto-create' child nodes defined in node type
@@ -1509,17 +1504,24 @@
      * @return the computed values
      */
     private QValue[] computeSystemGeneratedPropertyValues(NodeState parent,
-                                                          QPropertyDefinition def)
-        throws RepositoryException {
+                                                          QPropertyDefinition def) {
         QValue[] genValues = null;
         /**
          * todo: need to come up with some callback mechanism for applying system generated values
          * (e.g. using a NodeTypeInstanceHandler interface)
          */
-        String[] defaultValues = def.getDefaultValues();
-        if (defaultValues != null && defaultValues.length > 0) {
-            Value[] vs = ValueHelper.convert(defaultValues, def.getRequiredType(), valueFactory);
-            genValues = ValueFormat.getQValues(vs, nsResolver);
+        String[] qDefaultValues = def.getDefaultValues();
+        if (qDefaultValues != null && qDefaultValues.length > 0) {
+            if (def.getRequiredType() == PropertyType.BINARY) {
+                try {
+                    genValues = QValue.create(def.getDefaultValuesAsStream(), def.getRequiredType());
+                } catch (IOException e) {
+                    log.error("Internal error while build QValue from property definition: ", e.getMessage());
+                    return null;
+                }
+            } else {
+               genValues = QValue.create(qDefaultValues, def.getRequiredType());
+            }
         } else {
             // some predefined nodetypes declare auto-created properties without
             // default values

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/LogUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/LogUtil.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/LogUtil.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/LogUtil.java Fri Aug 11 07:00:00 2006
@@ -22,6 +22,8 @@
 import org.apache.jackrabbit.name.PathFormat;
 import org.apache.jackrabbit.name.NoPrefixDeclaredException;
 import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.NameFormat;
 import org.apache.jackrabbit.jcr2spi.HierarchyManager;
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.apache.jackrabbit.spi.ItemId;
@@ -70,6 +72,24 @@
             ItemId id = itemState.getId();
             log.error("failed to convert " + id + " to JCR path.");
             return id.toString();
+        }
+    }
+
+    /**
+     * Failsafe conversion of a <code>QName</code> to a JCR name for use in
+     * error messages etc.
+     *
+     * @param qName
+     * @param nsResolver
+     * @return JCR name or String representation of the given <code>QName</code>
+     * in case the resolution fails.
+     */
+    public static String saveGetJCRName(QName qName, NamespaceResolver nsResolver) {
+        try {
+            return NameFormat.format(qName, nsResolver);
+        } catch (NoPrefixDeclaredException e) {
+            log.error("failed to convert " + qName + " to JCR name.");
+            return qName.toString();
         }
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/ReferenceChangeTracker.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/ReferenceChangeTracker.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/ReferenceChangeTracker.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/ReferenceChangeTracker.java Fri Aug 11 07:00:00 2006
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.jcr2spi.util;
 
 import org.apache.jackrabbit.jcr2spi.state.PropertyState;
-import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.value.QValue;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -65,15 +64,15 @@
      * Store the given uuid mapping for later lookup using
      * <code>#adjustReferences(UpdatableItemStateManager, ItemStateValidator)</code>.
      *
-     * @param oldNodeId old nodeId
-     * @param newNodeId new nodeId
+     * @param oldUUID
+     * @param newUUID
      */
-    public void mappedNodeIds(NodeId oldNodeId, NodeId newNodeId) {
-        if (oldNodeId.equals(newNodeId) || oldNodeId.getUUID() == null) {
+    public void mappedUUIDs(String oldUUID, String newUUID) {
+        if (oldUUID.equals(newUUID) || oldUUID == null) {
             // only remember if uuid exists and has changed
             return;
         }
-        uuidMap.put(oldNodeId.getUUID(), newNodeId.getUUID());
+        uuidMap.put(oldUUID, newUUID);
     }
 
     /**
@@ -82,7 +81,7 @@
      *
      * @param oldReference old uuid represented by the given <code>QValue</code>
      * @return mapped new QValue of the reference value or <code>null</code> if no such mapping exists
-     * @see #mappedNodeIds(NodeId,NodeId)
+     * @see #mappedUUIDs(String,String)
      */
     public QValue getMappedReference(QValue oldReference) {
         QValue remapped = null;

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java Fri Aug 11 07:00:00 2006
@@ -21,7 +21,10 @@
 
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.spi.NodeId;
+
 import java.util.Collection;
 
 /**
@@ -31,17 +34,29 @@
 
     private static Logger log = LoggerFactory.getLogger(DefaultVersionManager.class);
 
-    public void checkin(NodeId nodeId) throws RepositoryException {
+    public void checkin(NodeState nodeState) throws RepositoryException {
         throw new UnsupportedRepositoryOperationException("Versioning ist not supported by this repository.");
     }
 
-    public void checkout(NodeId nodeId) throws RepositoryException {
+    public void checkout(NodeState nodeState) throws RepositoryException {
         throw new UnsupportedRepositoryOperationException("Versioning ist not supported by this repository.");
     }
 
-    public boolean isCheckedOut(NodeId nodeId) throws RepositoryException {
+    public boolean isCheckedOut(NodeState nodeState) throws RepositoryException {
         log.debug("Versioning is not supported by this repository.");
         return true;
+    }
+
+    public void removeVersion(NodeId versionHistoryId, NodeId versionId) throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException("Versioning ist not supported by this repository.");
+    }
+
+    public void addVersionLabel(NodeId versionHistoryId, NodeId versionId, QName qLabel, boolean moveLabel) throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException("Versioning ist not supported by this repository.");
+    }
+
+    public void removeVersionLabel(NodeId versionHistoryId, NodeId versionId, QName qLabel) throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException("Versioning ist not supported by this repository.");
     }
 
     public void restore(NodeId nodeId, NodeId versionId, boolean removeExisting) throws RepositoryException {

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java Fri Aug 11 07:00:00 2006
@@ -23,10 +23,6 @@
 import org.apache.jackrabbit.jcr2spi.SessionImpl;
 import org.apache.jackrabbit.jcr2spi.ItemLifeCycleListener;
 import org.apache.jackrabbit.jcr2spi.LazyItemIterator;
-import org.apache.jackrabbit.jcr2spi.operation.AddLabel;
-import org.apache.jackrabbit.jcr2spi.operation.Operation;
-import org.apache.jackrabbit.jcr2spi.operation.RemoveLabel;
-import org.apache.jackrabbit.jcr2spi.operation.Remove;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
 import org.apache.jackrabbit.jcr2spi.state.ChildNodeEntry;
@@ -72,10 +68,11 @@
                               ItemLifeCycleListener[] listeners) throws VersionException {
         super(itemMgr, session, state, definition, listeners);
 
+        this.vhState = state;
+
         // retrieve nodestate of the jcr:versionLabels node
-        vhState = state;
-        if (vhState.hasChildNodeEntry(QName.JCR_VERSIONLABELS)) {
-            ChildNodeEntry lnEntry = vhState.getChildNodeEntry(QName.JCR_VERSIONLABELS, Path.INDEX_DEFAULT);
+        if (state.hasChildNodeEntry(QName.JCR_VERSIONLABELS)) {
+            ChildNodeEntry lnEntry = state.getChildNodeEntry(QName.JCR_VERSIONLABELS, Path.INDEX_DEFAULT);
             try {
                 labelNodeState = lnEntry.getNodeState();
             } catch (ItemStateException e) {
@@ -151,8 +148,13 @@
      * @see VersionHistory#getVersion(String)
      */
     public Version getVersion(String versionName) throws VersionException, RepositoryException {
-        NodeState vState = getVersionState(versionName);
-        return (Version) itemMgr.getItem(vState);
+        try {
+            NodeState vState = getVersionEntry(versionName).getNodeState();
+            return (Version) itemMgr.getItem(vState);
+        } catch (ItemStateException e) {
+            // should not occur
+            throw new RepositoryException(e);
+        }
     }
 
     /**
@@ -167,6 +169,7 @@
         try {
             return (Version) itemMgr.getItem(vEntry.getNodeState());
         } catch (ItemStateException e) {
+            // should not occur
             throw new RepositoryException(e);
         }
     }
@@ -182,10 +185,9 @@
      */
     public void addVersionLabel(String versionName, String label, boolean moveLabel) throws VersionException, RepositoryException {
         QName qLabel = getQLabel(label);
-        // TODO: ev. delegate to versionmanager
         ChildNodeEntry vEntry = getVersionEntry(versionName);
-        Operation op = AddLabel.create(vhState.getNodeId(), vEntry.getId(), qLabel, moveLabel);
-        itemStateMgr.execute(op);
+        // delegate to version manager that operates on workspace directely
+        session.getVersionManager().addVersionLabel(vhState.getNodeId(), vEntry.getId(), qLabel, moveLabel);
     }
 
     /**
@@ -197,10 +199,10 @@
      */
     public void removeVersionLabel(String label) throws VersionException, RepositoryException {
         QName qLabel = getQLabel(label);
-        // TODO: ev. delegate to versionmanager
         ChildNodeEntry vEntry = getVersionEntryByLabel(getQLabel(label));
-        Operation op = RemoveLabel.create(vhState.getNodeId(), vEntry.getId(), qLabel);
-        itemStateMgr.execute(op);
+
+        // delegate to version manager that operates on workspace directely
+        session.getVersionManager().removeVersionLabel(vhState.getNodeId(), vEntry.getId(), qLabel);
     }
 
     /**
@@ -304,11 +306,9 @@
      * @throws RepositoryException
      * @see VersionHistory#removeVersion(String)
      */
-    public void removeVersion(String versionName) throws ReferentialIntegrityException, AccessDeniedException, UnsupportedRepositoryOperationException, VersionException, RepositoryException {
-        NodeState vState = getVersionState(versionName);
-        // TODO: ev. delegate to versionmanager
-        Operation rm = Remove.create(vState);
-        itemStateMgr.execute(rm);
+    public void removeVersion(String versionName) throws RepositoryException {
+        ChildNodeEntry vEntry = getVersionEntry(versionName);
+        session.getVersionManager().removeVersion(vEntry.getId(), vhState.getNodeId());
     }
 
     //---------------------------------------------------------------< Item >---
@@ -355,21 +355,6 @@
                 return vEntry;
             }
         } catch (NameException e) {
-            throw new RepositoryException(e);
-        }
-    }
-
-    /**
-     *
-     * @param versionName
-     * @return
-     * @throws VersionException
-     * @throws RepositoryException
-     */
-    private NodeState getVersionState(String versionName) throws VersionException, RepositoryException {
-        try {
-            return getVersionEntry(versionName).getNodeState();
-        } catch (ItemStateException e) {
             throw new RepositoryException(e);
         }
     }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java Fri Aug 11 07:00:00 2006
@@ -41,7 +41,8 @@
 
     private static Logger log = LoggerFactory.getLogger(VersionImpl.class);
 
-    public VersionImpl(ItemManager itemMgr, SessionImpl session, NodeState state, NodeDefinition definition, ItemLifeCycleListener[] listeners) {
+    public VersionImpl(ItemManager itemMgr, SessionImpl session, NodeState state,
+                       NodeDefinition definition, ItemLifeCycleListener[] listeners) {
         super(itemMgr, session, state, definition, listeners);
     }
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java Fri Aug 11 07:00:00 2006
@@ -17,6 +17,8 @@
 package org.apache.jackrabbit.jcr2spi.version;
 
 import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
 
 import javax.jcr.RepositoryException;
 import java.util.Collection;
@@ -26,11 +28,20 @@
  */
 public interface VersionManager {
 
-    public void checkin(NodeId nodeId) throws RepositoryException;
+    // TODO fix method definitions (throw clauses)
+    // TODO review usage of NodeId. for Restore it is requried, since the target must not point to an existing node.
 
-    public void checkout(NodeId nodeId) throws RepositoryException;
+    public void checkin(NodeState nodeState) throws RepositoryException;
 
-    public boolean isCheckedOut(NodeId nodeId) throws RepositoryException;
+    public void checkout(NodeState nodeState) throws RepositoryException;
+
+    public boolean isCheckedOut(NodeState nodeState) throws RepositoryException;
+
+    public void removeVersion(NodeId versionHistoryId, NodeId versionId) throws RepositoryException;
+
+    public void addVersionLabel(NodeId versionHistoryId, NodeId versionId, QName qLabel, boolean moveLabel) throws RepositoryException;
+
+    public void removeVersionLabel(NodeId versionHistoryId, NodeId versionId, QName qLabel) throws RepositoryException;
 
     public void restore(NodeId nodeId, NodeId versionId, boolean removeExisting) throws RepositoryException;
 
@@ -44,7 +55,7 @@
      * @return A Collection of <code>ItemId</code> containing the ids of those
      * <code>Node</code>s that failed to be merged and need manual resolution
      * by the user of the API.
-     * @see #resolveMergeConflict(NodeId, NodeId, boolean)
+     * @see #resolveMergeConflict(NodeId,NodeId,boolean)
      */
     public Collection merge(NodeId nodeId, String workspaceName, boolean bestEffort) throws RepositoryException;
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java Fri Aug 11 07:00:00 2006
@@ -27,6 +27,9 @@
 import org.apache.jackrabbit.jcr2spi.operation.Restore;
 import org.apache.jackrabbit.jcr2spi.operation.ResolveMergeConflict;
 import org.apache.jackrabbit.jcr2spi.operation.Merge;
+import org.apache.jackrabbit.jcr2spi.operation.Remove;
+import org.apache.jackrabbit.jcr2spi.operation.AddLabel;
+import org.apache.jackrabbit.jcr2spi.operation.RemoveLabel;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 
@@ -35,7 +38,6 @@
 import org.apache.jackrabbit.spi.EventIterator;
 import org.apache.jackrabbit.spi.Event;
 import org.apache.jackrabbit.spi.NodeId;
-import org.apache.jackrabbit.spi.PropertyId;
 
 import java.util.Collection;
 import java.util.List;
@@ -54,20 +56,26 @@
         this.stateManager = stateManager;
     }
 
-    public void checkin(NodeId nodeId) throws RepositoryException {
-        Operation ci = Checkin.create(nodeId);
+    public void checkin(NodeState nodeState) throws RepositoryException {
+        Operation ci = Checkin.create(nodeState.getNodeId());
         stateManager.execute(ci);
     }
 
-    public void checkout(NodeId nodeId) throws RepositoryException {
-        Operation co = Checkout.create(nodeId);
+    public void checkout(NodeState nodeState) throws RepositoryException {
+        Operation co = Checkout.create(nodeState.getNodeId());
         stateManager.execute(co);
     }
 
-    public boolean isCheckedOut(NodeId nodeId) throws RepositoryException {
+    /**
+     * Search nearest ancestor that is versionable. If no versionable ancestor
+     * can be found, <code>true</code> is returned.
+     *
+     * @param nodeState
+     * @return
+     * @throws RepositoryException
+     */
+    public boolean isCheckedOut(NodeState nodeState) throws RepositoryException {
         try {
-            NodeState nodeState = (NodeState) stateManager.getItemState(nodeId);
-            // search nearest ancestor that is versionable
             /**
              * FIXME should not only rely on existence of jcr:isCheckedOut property
              * but also verify that node.isNodeType("mix:versionable")==true;
@@ -81,15 +89,28 @@
                 }
                 nodeState = parentState;
             }
-            PropertyId propId = nodeState.getPropertyState(QName.JCR_ISCHECKEDOUT).getPropertyId();
-            PropertyState propState = (PropertyState) stateManager.getItemState(propId);
-
+            PropertyState propState = nodeState.getPropertyState(QName.JCR_ISCHECKEDOUT);
             Boolean b = Boolean.valueOf(propState.getValue().getString());
             return b.booleanValue();
         } catch (ItemStateException e) {
             // should not occur
             throw new RepositoryException(e);
         }
+    }
+
+    public void removeVersion(NodeId versionHistoryId, NodeId versionId) throws RepositoryException {
+        Operation op = Remove.create(versionId, versionHistoryId);
+        stateManager.execute(op);
+    }
+
+    public void addVersionLabel(NodeId versionHistoryId, NodeId versionId, QName qLabel, boolean moveLabel) throws RepositoryException {
+        Operation op = AddLabel.create(versionHistoryId, versionId, qLabel, moveLabel);
+        stateManager.execute(op);
+    }
+
+    public void removeVersionLabel(NodeId versionHistoryId, NodeId versionId, QName qLabel) throws RepositoryException {
+        Operation op = RemoveLabel.create(versionHistoryId, versionId, qLabel);
+        stateManager.execute(op);
     }
 
     public void restore(NodeId nodeId, NodeId versionId, boolean removeExisting) throws RepositoryException {

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java Fri Aug 11 07:00:00 2006
@@ -28,8 +28,6 @@
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
-import org.apache.jackrabbit.spi.NodeId;
-import org.apache.jackrabbit.spi.IdFactory;
 
 import java.io.IOException;
 import java.io.Reader;
@@ -59,8 +57,8 @@
      * @param importer
      * @param nsContext
      */
-    DocViewImportHandler(Importer importer, NamespaceResolver nsContext, IdFactory idFactory) {
-        super(importer, nsContext, idFactory);
+    DocViewImportHandler(Importer importer, NamespaceResolver nsContext) {
+        super(importer, nsContext);
     }
 
     /**
@@ -171,7 +169,7 @@
             nodeName = ISO9075.decode(nodeName);
 
             // properties
-            NodeId id = null;
+            String uuid = null;
             QName nodeTypeName = null;
             QName[] mixinTypes = null;
 
@@ -220,14 +218,14 @@
                 } else if (propName.equals(QName.JCR_UUID)) {
                     // jcr:uuid
                     if (attrValue.length() > 0) {
-                        id = idFactory.createNodeId(attrValue);
+                        uuid = attrValue;
                     }
                 } else {
                     props.add(new Importer.PropInfo(propName, PropertyType.UNDEFINED, propValues));
                 }
             }
 
-            Importer.NodeInfo node = new Importer.NodeInfo(nodeName, nodeTypeName, mixinTypes, id);
+            Importer.NodeInfo node = new Importer.NodeInfo(nodeName, nodeTypeName, mixinTypes, uuid);
             // all information has been collected, now delegate to importer
             importer.startNode(node, props, nsContext);
             // push current node data onto stack

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/ImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/ImportHandler.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/ImportHandler.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/ImportHandler.java Fri Aug 11 07:00:00 2006
@@ -32,7 +32,6 @@
 import javax.jcr.NamespaceException;
 import javax.jcr.RepositoryException;
 import javax.jcr.NamespaceRegistry;
-import org.apache.jackrabbit.spi.IdFactory;
 
 /**
  * An <code>ImportHandler</code> instance can be used to import serialized
@@ -57,7 +56,6 @@
     private final Importer importer;
     private final NamespaceRegistry nsReg;
     private final NamespaceResolver nsResolver;
-    private final IdFactory idFactory;
 
     private Locator locator;
     private ContentHandler targetHandler;
@@ -77,11 +75,10 @@
 
     // DIFF JACKRABBIT: pass NamespaceRegistry instead of impl.
     public ImportHandler(Importer importer, NamespaceResolver nsResolver,
-                         NamespaceRegistry nsReg, IdFactory idFactory) {
+                         NamespaceRegistry nsReg) {
         this.importer = importer;
         this.nsResolver = nsResolver;
         this.nsReg = nsReg;
-        this.idFactory = idFactory;
 
         nsContext = new NamespaceContext();
     }
@@ -227,9 +224,9 @@
             systemViewXML = QName.NS_SV_URI.equals(namespaceURI);
 
             if (systemViewXML) {
-                targetHandler = new SysViewImportHandler(importer, nsContext, idFactory);
+                targetHandler = new SysViewImportHandler(importer, nsContext);
             } else {
-                targetHandler = new DocViewImportHandler(importer, nsContext, idFactory);
+                targetHandler = new DocViewImportHandler(importer, nsContext);
             }
             targetHandler.startDocument();
             initialized = true;

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/Importer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/Importer.java?rev=430791&r1=430790&r2=430791&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/Importer.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/Importer.java Fri Aug 11 07:00:00 2006
@@ -18,7 +18,6 @@
 
 import org.apache.jackrabbit.name.NamespaceResolver;
 import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.spi.NodeId;
 
 import javax.jcr.RepositoryException;
 
@@ -61,16 +60,16 @@
         private QName name;
         private QName nodeTypeName;
         private QName[] mixinNames;
-        private NodeId id;
+        private String uuid;
 
         public NodeInfo() {
         }
 
-        public NodeInfo(QName name, QName nodeTypeName, QName[] mixinNames, NodeId id) {
+        public NodeInfo(QName name, QName nodeTypeName, QName[] mixinNames, String uuid) {
             this.name = name;
             this.nodeTypeName = nodeTypeName;
             this.mixinNames = mixinNames;
-            this.id = id;
+            this.uuid = uuid;
         }
 
         public void setName(QName name) {
@@ -97,12 +96,12 @@
             return mixinNames;
         }
 
-        public void setId(NodeId id) {
-            this.id = id;
+        public void setUUID(String uuid) {
+            this.uuid = uuid;
         }
 
-        public NodeId getId() {
-            return id;
+        public String getUUID() {
+            return uuid;
         }
     }
 



Mime
View raw message