jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r157109 - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: ItemImpl.java NodeImpl.java lock/LockManagerImpl.java nodetype/EffectiveNodeType.java xml/WorkspaceImporter.java
Date Fri, 11 Mar 2005 16:44:13 GMT
Author: stefan
Date: Fri Mar 11 08:44:10 2005
New Revision: 157109

URL: http://svn.apache.org/viewcvs?view=rev&rev=157109
Log:
- fixed bug in EffectiveNodeType.getApplicableChildNodeDef()
- some minor cosmetical changes
- WorkspaceImporter: work in progress...

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java?view=diff&r1=157108&r2=157109
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java Fri Mar 11
08:44:10 2005
@@ -869,6 +869,80 @@
     }
 
     /**
+     * Same as <code>{@link Item#remove()}</code> except for the
+     * <code>noChecks</code> parameter.
+     *
+     * @param noChecks
+     * @throws VersionException
+     * @throws LockException
+     * @throws RepositoryException
+     */
+    protected void internalRemove(boolean noChecks)
+            throws VersionException, LockException, RepositoryException {
+
+        // check state of this instance
+        sanityCheck();
+
+        Path.PathElement thisName = getPrimaryPath().getNameElement();
+
+        // check if protected
+        if (isNode()) {
+            NodeImpl node = (NodeImpl) this;
+            // check if this is the root node
+            if (node.getDepth() == 0) {
+                String msg = safeGetJCRPath() + ": cannot remove root node";
+                log.debug(msg);
+                throw new RepositoryException(msg);
+            }
+
+            NodeDef def = node.getDefinition();
+            // check protected flag
+            if (!noChecks && def.isProtected()) {
+                String msg = safeGetJCRPath() + ": cannot remove a protected node";
+                log.debug(msg);
+                throw new ConstraintViolationException(msg);
+            }
+        } else {
+            PropertyImpl prop = (PropertyImpl) this;
+            PropertyDef def = prop.getDefinition();
+            // check protected flag
+            if (!noChecks && def.isProtected()) {
+                String msg = safeGetJCRPath() + ": cannot remove a protected property";
+                log.debug(msg);
+                throw new ConstraintViolationException(msg);
+            }
+        }
+
+        NodeImpl parentNode = (NodeImpl) getParent();
+
+        // verify that parent node is checked-out
+        if (!noChecks && !parentNode.internalIsCheckedOut()) {
+            String msg = parentNode.safeGetJCRPath() + ": cannot remove a child of a checked-in
node";
+            log.debug(msg);
+            throw new VersionException(msg);
+        }
+
+        // check protected flag of parent node
+        if (!noChecks && parentNode.getDefinition().isProtected()) {
+            String msg = parentNode.safeGetJCRPath() + ": cannot remove a child of a protected
node";
+            log.debug(msg);
+            throw new ConstraintViolationException(msg);
+        }
+
+        // check lock status
+        if (!noChecks) {
+            parentNode.checkLock();
+        }
+
+        // delegate the removal of the child item to the parent node
+        if (isNode()) {
+            parentNode.removeChildNode(thisName.getName(), thisName.getIndex());
+        } else {
+            parentNode.removeChildProperty(thisName.getName());
+        }
+    }
+
+    /**
      * Same as <code>{@link Item#getName()}</code> except that
      * this method returns a <code>QName</code> instead of a
      * <code>String</code>.
@@ -1037,74 +1111,6 @@
      */
     public void remove() throws VersionException, LockException, RepositoryException {
         internalRemove(false);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void internalRemove(boolean noChecks)
-            throws VersionException, LockException, RepositoryException {
-
-        // check state of this instance
-        sanityCheck();
-
-        Path.PathElement thisName = getPrimaryPath().getNameElement();
-
-        // check if protected
-        if (isNode()) {
-            NodeImpl node = (NodeImpl) this;
-            // check if this is the root node
-            if (node.getDepth() == 0) {
-                String msg = safeGetJCRPath() + ": cannot remove root node";
-                log.debug(msg);
-                throw new RepositoryException(msg);
-            }
-
-            NodeDef def = node.getDefinition();
-            // check protected flag
-            if (!noChecks && def.isProtected()) {
-                String msg = safeGetJCRPath() + ": cannot remove a protected node";
-                log.debug(msg);
-                throw new ConstraintViolationException(msg);
-            }
-        } else {
-            PropertyImpl prop = (PropertyImpl) this;
-            PropertyDef def = prop.getDefinition();
-            // check protected flag
-            if (!noChecks && def.isProtected()) {
-                String msg = safeGetJCRPath() + ": cannot remove a protected property";
-                log.debug(msg);
-                throw new ConstraintViolationException(msg);
-            }
-        }
-
-        NodeImpl parentNode = (NodeImpl) getParent();
-
-        // verify that parent node is checked-out
-        if (!noChecks && !parentNode.internalIsCheckedOut()) {
-            String msg = parentNode.safeGetJCRPath() + ": cannot remove a child of a checked-in
node";
-            log.debug(msg);
-            throw new VersionException(msg);
-        }
-
-        // check protected flag of parent node
-        if (!noChecks && parentNode.getDefinition().isProtected()) {
-            String msg = parentNode.safeGetJCRPath() + ": cannot remove a child of a protected
node";
-            log.debug(msg);
-            throw new ConstraintViolationException(msg);
-        }
-
-        // check lock status
-        if (!noChecks) {
-            parentNode.checkLock();
-        }
-
-        // delegate the removal of the child item to the parent node
-        if (isNode()) {
-            parentNode.removeChildNode(thisName.getName(), thisName.getIndex());
-        } else {
-            parentNode.removeChildProperty(thisName.getName());
-        }
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java?view=diff&r1=157108&r2=157109
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java Fri Mar 11
08:44:10 2005
@@ -523,7 +523,7 @@
         removeChildProperty(qName);
     }
 
-    public void removeChildProperty(QName propName) throws RepositoryException {
+    protected void removeChildProperty(QName propName) throws RepositoryException {
         // modify the state of 'this', i.e. the parent node
         NodeState thisState = (NodeState) getOrCreateTransientItemState();
 
@@ -1179,6 +1179,10 @@
      * Note that no type conversion is being performed, i.e. it's the caller's
      * responsibility to make sure that the type of the given value is compatible
      * with the specified property's definition.
+     * <p/>
+     * <b>Important:</b> This method is public in order to make it accessible
+     * from internal code located sub packages, i.e. it should never be called
+     * from an application directly.
      *
      * @param name
      * @param value
@@ -1220,6 +1224,9 @@
      * Note that no type conversion is being performed, i.e. it's the caller's
      * responsibility to make sure that the type of the given values is compatible
      * with the specified property's definition.
+     * <p/>
+     * <b>Important:</b> This method is for internal use only and should never
+     * be called from an application directly.
      *
      * @param name
      * @param values

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?view=diff&r1=157108&r2=157109
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
Fri Mar 11 08:44:10 2005
@@ -267,8 +267,8 @@
             info.setLive(false);
 
             // remove properties in content
-            node.removeChildProperty(Constants.JCR_LOCKOWNER);
-            node.removeChildProperty(Constants.JCR_LOCKISDEEP);
+            node.internalSetProperty(Constants.JCR_LOCKOWNER, null);
+            node.internalSetProperty(Constants.JCR_LOCKISDEEP, null);
             node.save();
             
         } catch (RepositoryException e) {
@@ -341,8 +341,8 @@
         info.setLive(false);
 
         // remove properties in content
-        node.removeChildProperty(Constants.JCR_LOCKOWNER);
-        node.removeChildProperty(Constants.JCR_LOCKISDEEP);
+        node.internalSetProperty(Constants.JCR_LOCKOWNER, null);
+        node.internalSetProperty(Constants.JCR_LOCKISDEEP, null);
         node.save();
     }
 

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java?view=diff&r1=157108&r2=157109
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
Fri Mar 11 08:44:10 2005
@@ -521,13 +521,22 @@
                     ChildNodeDef nd = (ChildNodeDef) def;
                     // node definition with that name exists
                     if (nodeTypeName != null) {
-                        // check node type constraints
-                        checkRequiredPrimaryType(nodeTypeName, nd.getRequiredPrimaryTypes());
+                        try {
+                            // check node type constraints
+                            checkRequiredPrimaryType(nodeTypeName, nd.getRequiredPrimaryTypes());
+                        } catch (ConstraintViolationException cve) {
+                            // ignore and try next
+                            continue;
+                        }
+                        // found node definition
                         return nd;
                     } else {
                         if (nd.getDefaultPrimaryType() == null) {
-                            // no default node type defined
-                            throw new ConstraintViolationException("node type for " + name
+ " can not be determined");
+                            // no default node type defined, try next
+                            continue;
+                        } else {
+                            // found node definition with default node type
+                            return nd;
                         }
                     }
                 }
@@ -547,6 +556,7 @@
                     // ignore and try next
                     continue;
                 }
+                // found residual node definition
                 return nd;
             } else {
                 // since no node type has been specified for the new node,

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java?view=diff&r1=157108&r2=157109
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
Fri Mar 11 08:44:10 2005
@@ -42,6 +42,7 @@
 
     private static Logger log = Logger.getLogger(WorkspaceImporter.class);
 
+    private final NodeState importTarget;
     private final WorkspaceImpl wsp;
     private final HierarchyManager hierMgr;
     private final UpdatableItemStateManager stateMgr;
@@ -60,9 +61,10 @@
      */
     private final ArrayList references;
 
-    public WorkspaceImporter(NodeState importTargetState,
+    public WorkspaceImporter(NodeState importTarget,
                              WorkspaceImpl wsp,
                              int uuidBehavior) {
+        this.importTarget = importTarget;
         this.wsp = wsp;
 
         hierMgr = wsp.getHierarchyManager();
@@ -76,7 +78,7 @@
         references = new ArrayList();
 
         parents = new Stack();
-        parents.push(importTargetState);
+        parents.push(importTarget);
     }
 
     protected NodeState createNode(NodeState parent,
@@ -217,8 +219,8 @@
             throw new RepositoryException(msg, ise);
 */
         } finally {
-            // update operation failed, cancel all modifications
             if (!succeeded) {
+                // update operation failed, cancel all modifications
                 aborted = true;
                 stateMgr.cancel();
             }
@@ -314,8 +316,8 @@
             stateMgr.store(node);
             succeeded = true;
         } finally {
-            // update operation failed, cancel all modifications
             if (!succeeded) {
+                // update operation failed, cancel all modifications
                 aborted = true;
                 stateMgr.cancel();
             }
@@ -373,15 +375,13 @@
                 }
             }
 */
-
-            // finally pop the last item from the stack, the import target node
-            NodeState importTarget = (NodeState) parents.pop();
-            // we're done with it, store its state
+            // finally store the state of the import target
+            // (the parent of the imported subtree)
             stateMgr.store(importTarget);
             succeeded = true;
         } finally {
-            // update operation failed, cancel all modifications
             if (!succeeded) {
+                // update operation failed, cancel all modifications
                 aborted = true;
                 stateMgr.cancel();
             }



Mime
View raw message