Index: /home/ntoper/workspace/jackrabbit/java/org/apache/jackrabbit/core/xml/SysViewImporter.java
===================================================================
--- /home/ntoper/workspace/jackrabbit/java/org/apache/jackrabbit/core/xml/SysViewImporter.java	(revision 0)
+++ /home/ntoper/workspace/jackrabbit/java/org/apache/jackrabbit/core/xml/SysViewImporter.java	(revision 0)
@@ -0,0 +1,290 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core.xml;
+
+import org.apache.jackrabbit.core.BatchedItemOperations;
+import org.apache.jackrabbit.core.HierarchyManager;
+import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
+import org.apache.jackrabbit.core.state.NodeState;
+import org.apache.jackrabbit.core.util.ReferenceChangeTracker;
+import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.name.QName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
+import java.util.List;
+import java.util.Stack;
+
+/**
+ * <code>WorkspaceImporter</code> ...
+ */
+public class SysViewImporter implements Importer {
+    
+    private static Logger log = LoggerFactory.getLogger(SysViewImporter.class);
+    
+    private final NodeState importTarget;
+    private final NodeTypeRegistry ntReg;
+    private final HierarchyManager hierMgr;
+    private final BatchedItemOperations itemOps;
+    
+    private final int uuidBehavior;
+    
+    private boolean aborted = false;
+    private Stack parents;
+    
+    /**
+     * helper object that keeps track of remapped uuid's and imported reference
+     * properties that might need correcting depending on the uuid mappings
+     */
+    private final ReferenceChangeTracker refTracker;
+    
+    private boolean raw;
+    
+    private boolean skip = false;
+    
+    //Used to find when stopping skipping
+    private NodeInfo skipNode;
+    
+    /**
+     * Creates a new <code>sysViewImporter</code> instance.
+     *
+     * @param parentPath   target path where to add the imported subtree
+     * @param hierMgr the HierarchyManager of the Repository
+     * @param ntReg the NodeTypeRegistry of the repository
+     * @param itemOps BatchedItemOperations to use
+     * @param uuidBehavior flag that governs how incoming UUIDs are handled
+     * @param raw boolean: if true we will not initialize anything (ie versioning) 
+     * and will not check anything before importing the data
+     * @throws PathNotFoundException        if no node exists at
+     *                                      <code>parentPath</code> or if the
+     *                                      current session is not granted read
+     *                                      access.
+     * @throws ConstraintViolationException if the node at
+     *                                      <code>parentPath</code> is protected
+     * @throws VersionException             if the node at
+     *                                      <code>parentPath</code> is not
+     *                                      checked-out
+     * @throws LockException                if a lock prevents the addition of
+     *                                      the subtree
+     * @throws RepositoryException          if another error occurs
+     */
+    public SysViewImporter(Path parentPath,
+            HierarchyManager hierMgr,
+            NodeTypeRegistry ntReg,
+            BatchedItemOperations itemOps,
+            int uuidBehavior,
+            boolean raw)
+    throws PathNotFoundException, ConstraintViolationException,
+    VersionException, LockException, RepositoryException {
+        
+        this.hierMgr = hierMgr;
+        this.itemOps = itemOps;
+        this.raw = raw;
+
+        //Perform preliminary checks
+        itemOps.verifyCanWrite(parentPath);
+        importTarget = itemOps.getNodeState(parentPath);
+        this.ntReg = ntReg;
+        this.uuidBehavior = uuidBehavior;
+        aborted = false;
+        refTracker = new ReferenceChangeTracker();
+        parents = new Stack();
+        parents.push(importTarget);
+    }
+
+    /**
+     * Can we add this node
+     *
+     * @param parent
+     * @param nodeInfo
+     * @return
+     * @throws RepositoryException 
+     * @throws ItemExistsException 
+     * @throws ItemNotFoundException 
+     * @throws LockException 
+     * @throws VersionException 
+     * @throws AccessDeniedException 
+     * @throws ConstraintViolationException 
+     */
+    private boolean isAddabble(NodeState parent, NodeInfo nodeInfo) throws ConstraintViolationException, AccessDeniedException, VersionException, LockException, ItemNotFoundException, ItemExistsException, RepositoryException {
+
+            itemOps.checkAddNode(parent, nodeInfo.getName(), nodeInfo.getNodeTypeName(),
+                    BatchedItemOperations.CHECK_ACCESS
+                    | BatchedItemOperations.CHECK_CONSTRAINTS
+                    | BatchedItemOperations.CHECK_LOCK
+                    | BatchedItemOperations.CHECK_VERSIONING);
+
+            QName nodeName = nodeInfo.getName();
+
+            if (parent.hasChildNodeEntry(nodeName)) {
+                 //TODO
+            }
+
+            return true;
+    }
+
+    private boolean checkNode(NodeInfo nodeInfo) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    private void createProperties(NodeState myNode, List propInfos) {
+        // TODO Auto-generated method stub
+    }
+
+    private NodeState createNode(NodeState parent, NodeInfo nodeInfo) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    private boolean isSkipped(NodeInfo nodeInfo) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    private boolean isCorrect(NodeState parent, NodeInfo nodeInfo, List propInfos) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+    
+
+    /*
+     *  switch (uuidBehavior) {
+     
+     case ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING: 
+     break;
+     
+     case ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING: 
+     break;
+     
+     case ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW:
+     break;
+     
+     case ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW: 
+     break;
+     
+     }*/    
+    //-------------------------------------------------------------< Importer >
+    /**
+     * {@inheritDoc}
+     */
+    public void start() throws RepositoryException {
+        try {
+            // start update operation
+            itemOps.edit();
+        } catch (IllegalStateException ise) {
+            aborted = true;
+            String msg = "internal error: failed to start update operation";
+            log.debug(msg);
+            throw new RepositoryException(msg, ise);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void startNode(NodeInfo nodeInfo, List propInfos)
+    throws RepositoryException {
+        if (aborted) {
+            return;
+        }
+
+        NodeState parent = (NodeState) parents.peek();
+
+        if (!isCorrect(parent, nodeInfo, propInfos)) {
+            throw new RepositoryException();
+        }
+
+        if (raw && !isAddabble(parent, nodeInfo)) {
+            skip = true;
+        }
+
+        if (skip) {
+            return;
+        }
+        //Should this node and children be skipped?
+        else if (isSkipped(nodeInfo)) {
+            skip  = true;
+            skipNode = nodeInfo;
+            return;
+        }
+
+        NodeState myNode = createNode(parent, nodeInfo);
+        createProperties(myNode, propInfos);
+        parents.push(myNode);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void endNode(NodeInfo nodeInfo) throws RepositoryException {
+        //End of skip mode
+        if (skipNode.equals(nodeInfo)) {
+            skip = false;
+            skipNode = null;
+            return;
+        }
+
+        if (aborted || skip) {
+            return;
+        }
+
+        try {
+            NodeState node = (NodeState) parents.pop();
+
+            if (!raw) {
+                postProcess(node);
+            }
+            itemOps.store(node);
+        } catch (IllegalStateException e) {
+            itemOps.cancel();
+            aborted = true;
+        }
+    }
+
+    private void postProcess(NodeState node) {
+        // TODO Auto-generated method stub
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void end() throws RepositoryException {
+        if (aborted) {
+            itemOps.cancel();
+            return;
+        }
+
+        // make sure import target is valid according to its definition
+        itemOps.validate(importTarget);
+
+        // finally store the state of the import target
+        // (the parent of the imported subtree)
+        itemOps.store(importTarget);
+
+        // finish update
+        itemOps.update();
+    }
+}
