jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r701130 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ItemImpl.java ItemValidator.java
Date Thu, 02 Oct 2008 14:00:30 GMT
Author: jukka
Date: Thu Oct  2 07:00:30 2008
New Revision: 701130

URL: http://svn.apache.org/viewvc?rev=701130&view=rev
Log:
JCR-1775: Transaction-safe versioning

Remove the ItemImpl -> ItemValidator dependency.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?rev=701130&r1=701129&r2=701130&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
Thu Oct  2 07:00:30 2008
@@ -19,8 +19,10 @@
 import org.apache.commons.collections.iterators.IteratorChain;
 import org.apache.jackrabbit.core.nodetype.EffectiveNodeType;
 import org.apache.jackrabbit.core.nodetype.NodeDef;
+import org.apache.jackrabbit.core.nodetype.NodeTypeConflictException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
+import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.core.nodetype.PropertyDefinitionImpl;
 import org.apache.jackrabbit.core.security.AccessManager;
@@ -265,7 +267,6 @@
         }
         // fail-fast test: check status of this item's state
         if (isTransient()) {
-            String msg;
             final ItemState state = getItemState();
             switch (state.getStatus()) {
                 case ItemState.STATUS_EXISTING_MODIFIED:
@@ -367,8 +368,6 @@
 
         AccessManager accessMgr = session.getAccessManager();
         NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
-        ItemValidator validator = new ItemValidator(ntMgr.getNodeTypeRegistry(),
-                session.getHierarchyManager(), session);
         // walk through list of dirty transient items and validate each
         while (dirtyIter.hasNext()) {
             ItemState itemState = (ItemState) dirtyIter.next();
@@ -415,7 +414,7 @@
                 // primary type
                 NodeTypeImpl pnt = ntMgr.getNodeType(nodeState.getNodeTypeName());
                 // effective node type (primary type incl. mixins)
-                EffectiveNodeType ent = validator.getEffectiveNodeType(nodeState);
+                EffectiveNodeType ent = getEffectiveNodeType(nodeState);
                 /**
                  * if the transient node was added (i.e. if it is 'new') or if
                  * its primary type has changed, check its node type against the
@@ -670,9 +669,6 @@
      * </ul>
      */
     private void processShareableNodes(Iterator iter) throws RepositoryException {
-        NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
-        ItemValidator validator = new ItemValidator(ntMgr.getNodeTypeRegistry(),
-                session.getHierarchyManager(), session);
         while (iter.hasNext()) {
             ItemState is = (ItemState) iter.next();
             if (is.isNode()) {
@@ -680,10 +676,10 @@
                 boolean wasShareable = false;
                 if (ns.hasOverlayedState()) {
                     NodeState old = (NodeState) ns.getOverlayedState();
-                    EffectiveNodeType ntOld = validator.getEffectiveNodeType(old);
+                    EffectiveNodeType ntOld = getEffectiveNodeType(old);
                     wasShareable = ntOld.includesNodeType(NameConstants.MIX_SHAREABLE);
                 }
-                EffectiveNodeType ntNew = validator.getEffectiveNodeType(ns);
+                EffectiveNodeType ntNew = getEffectiveNodeType(ns);
                 boolean isShareable = ntNew.includesNodeType(NameConstants.MIX_SHAREABLE);
 
                 if (!wasShareable && isShareable) {
@@ -713,14 +709,11 @@
     private boolean initVersionHistories(Iterator iter) throws RepositoryException {
         // walk through list of transient items and search for new versionable nodes
         boolean createdTransientState = false;
-        NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
-        ItemValidator validator = new ItemValidator(ntMgr.getNodeTypeRegistry(),
-                session.getHierarchyManager(), session);
         while (iter.hasNext()) {
             ItemState itemState = (ItemState) iter.next();
             if (itemState.isNode()) {
                 NodeState nodeState = (NodeState) itemState;
-                EffectiveNodeType nt = validator.getEffectiveNodeType(nodeState);
+                EffectiveNodeType nt = getEffectiveNodeType(nodeState);
                 if (nt.includesNodeType(NameConstants.MIX_VERSIONABLE)) {
                     if (!nodeState.hasPropertyName(NameConstants.JCR_VERSIONHISTORY)) {
                         NodeImpl node = (NodeImpl) itemMgr.getItem(itemState.getId());
@@ -751,6 +744,29 @@
     }
 
     /**
+     * Helper method that builds the effective (i.e. merged and resolved)
+     * node type representation of the specified node's primary and mixin
+     * node types.
+     *
+     * @param state
+     * @return the effective node type
+     * @throws RepositoryException
+     */
+    private EffectiveNodeType getEffectiveNodeType(NodeState state)
+            throws RepositoryException {
+        try {
+            NodeTypeRegistry registry =
+                session.getNodeTypeManager().getNodeTypeRegistry();
+            return registry.getEffectiveNodeType(
+                    state.getNodeTypeName(), state.getMixinTypeNames());
+        } catch (NodeTypeConflictException e) {
+            throw new RepositoryException(
+                    "Failed to build effective node type of node state "
+                    + state.getId(), e);
+        }
+    }
+
+    /**
      * Failsafe mapping of internal <code>id</code> to JCR path for use in
      * diagnostic output, error messages etc.
      *

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java?rev=701130&r1=701129&r2=701130&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemValidator.java
Thu Oct  2 07:00:30 2008
@@ -35,7 +35,6 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.nodetype.ConstraintViolationException;
-import java.util.Set;
 
 /**
  * Utility class for validating an item against constraints



Mime
View raw message