jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r123983 - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: . jndi/provider nodetype version version/persistence
Date Mon, 03 Jan 2005 15:01:30 GMT
Author: stefan
Date: Mon Jan  3 07:01:28 2005
New Revision: 123983

URL: http://svn.apache.org/viewcvs?view=rev&rev=123983
Log:
fixed issue JCR-36: NodeTypeRegistry.reregister unregisters dependent types
http://issues.apache.org/jira/browse/JCR-36



Modified:
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/jndi/provider/DummyInitialContextFactory.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java

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&rev=123983&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java&r1=123982&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java&r2=123983
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java	(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java	Mon Jan 
3 07:01:28 2005
@@ -586,7 +586,7 @@
         // primary type
         set.add(nodeType.getQName());
         try {
-            return ntReg.buildEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
+            return ntReg.getEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
         } catch (NodeTypeConflictException ntce) {
             String msg = "internal error: failed to build effective node type for node "
+ safeGetJCRPath();
             log.error(msg, ntce);
@@ -1704,7 +1704,7 @@
         }
         NodeTypeRegistry ntReg = session.getNodeTypeManager().getNodeTypeRegistry();
         try {
-            EffectiveNodeType ent = ntReg.buildEffectiveNodeType((QName[]) mixinNames.toArray(new
QName[mixinNames.size()]));
+            EffectiveNodeType ent = ntReg.getEffectiveNodeType((QName[]) mixinNames.toArray(new
QName[mixinNames.size()]));
             return ent.includesNodeType(ntName);
         } catch (NodeTypeConflictException ntce) {
             String msg = "internal error: invalid mixin node type(s)";
@@ -1788,14 +1788,14 @@
             // primary type
             set.add(nodeType.getQName());
             // build effective node type representing primary type including existing mixin's
-            entExisting = ntReg.buildEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
+            entExisting = ntReg.getEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
             if (entExisting.includesNodeType(ntName)) {
                 throw new RepositoryException(mixinName + ": already contained in mixin types");
             }
             // add new mixin
             set.add(ntName);
             // try to build new effective node type (will throw in case of conflicts)
-            ntReg.buildEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
+            ntReg.getEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
         } catch (NodeTypeConflictException ntce) {
             throw new ConstraintViolationException(ntce.getMessage());
         }
@@ -1916,7 +1916,7 @@
             // primary type
             set.add(nodeType.getQName());
             // build effective node type representing primary type including remaining mixin's
-            entRemaining = ntReg.buildEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
+            entRemaining = ntReg.getEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
         } catch (NodeTypeConflictException ntce) {
             throw new ConstraintViolationException(ntce.getMessage());
         }
@@ -2010,14 +2010,14 @@
             // primary type
             set.add(nodeType.getQName());
             // build effective node type representing primary type including existing mixin's
-            entExisting = ntReg.buildEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
+            entExisting = ntReg.getEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
             if (entExisting.includesNodeType(ntName)) {
                 return false;
             }
             // add new mixin
             set.add(ntName);
             // try to build new effective node type (will throw in case of conflicts)
-            ntReg.buildEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
+            ntReg.getEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
         } catch (NodeTypeConflictException ntce) {
             return false;
         }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java?view=diff&rev=123983&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java&r1=123982&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java&r2=123983
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java	(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java	Mon
Jan  3 07:01:28 2005
@@ -406,7 +406,7 @@
         // primary type
         set.add(state.getNodeTypeName());
         try {
-            return ntReg.buildEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
+            return ntReg.getEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
         } catch (NodeTypeConflictException ntce) {
             String msg = "internal error: failed to build effective node type for node "
+ state.getUUID();
             log.error(msg, ntce);

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/jndi/provider/DummyInitialContextFactory.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/jndi/provider/DummyInitialContextFactory.java?view=diff&rev=123983&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/jndi/provider/DummyInitialContextFactory.java&r1=123982&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/jndi/provider/DummyInitialContextFactory.java&r2=123983
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/jndi/provider/DummyInitialContextFactory.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/jndi/provider/DummyInitialContextFactory.java
Mon Jan  3 07:01:28 2005
@@ -19,8 +19,8 @@
 import javax.naming.Context;
 import javax.naming.NamingException;
 import javax.naming.spi.InitialContextFactory;
-import java.util.Hashtable;
 import java.util.HashMap;
+import java.util.Hashtable;
 
 /**
  * <code>DummyInitialContextFactory</code> ...
@@ -28,23 +28,24 @@
 public class DummyInitialContextFactory implements InitialContextFactory {
 
     private static HashMap contexts = new HashMap();
+
     /**
      * @see InitialContextFactory#getInitialContext(java.util.Hashtable)
      */
     public Context getInitialContext(Hashtable environment) throws NamingException {
 
-	String url = (String) environment.get(Context.PROVIDER_URL);
-	if (url==null) {
-	    throw new NamingException("Unable to create context. Environment is missing a " + Context.PROVIDER_URL);
-	}
+        String url = (String) environment.get(Context.PROVIDER_URL);
+        if (url == null) {
+            throw new NamingException("Unable to create context. Environment is missing a
" + Context.PROVIDER_URL);
+        }
 
-	synchronized (DummyInitialContextFactory.contexts) {
-	    DummyContext ctx = (DummyContext) contexts.get(url);
-	    if (ctx==null) {
-		ctx = new DummyContext(environment);
-		contexts.put(url, ctx);
-	    }
-	    return ctx;
-	}
+        synchronized (DummyInitialContextFactory.contexts) {
+            DummyContext ctx = (DummyContext) contexts.get(url);
+            if (ctx == null) {
+                ctx = new DummyContext(environment);
+                contexts.put(url, ctx);
+            }
+            return ctx;
+        }
     }
 }

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&rev=123983&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java&r1=123982&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java&r2=123983
==============================================================================
--- 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
Mon Jan  3 07:01:28 2005
@@ -167,7 +167,7 @@
         // resolve supertypes recursively
         QName[] supertypes = ntd.getSupertypes();
         if (supertypes != null && supertypes.length > 0) {
-            ent.internalMerge(ntReg.buildEffectiveNodeType(supertypes), true);
+            ent.internalMerge(ntReg.getEffectiveNodeType(supertypes), true);
         }
 
         // we're done

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java?view=diff&rev=123983&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java&r1=123982&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java&r2=123983
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
Mon Jan  3 07:01:28 2005
@@ -568,7 +568,7 @@
          */
         if (supertypes != null && supertypes.length > 0) {
             try {
-                EffectiveNodeType est = buildEffectiveNodeType(supertypes);
+                EffectiveNodeType est = getEffectiveNodeType(supertypes);
                 // make sure that all primary types except nt:base extend from nt:base
                 if (!ntd.isMixin() && !NT_BASE.equals(ntd.getName()) &&
                         !est.includesNodeType(NT_BASE)) {
@@ -913,24 +913,46 @@
     }
 
     /**
+     *
      * @param ntName
      * @return
+     * @throws NoSuchNodeTypeException
      */
     public synchronized EffectiveNodeType getEffectiveNodeType(QName ntName)
             throws NoSuchNodeTypeException {
+        // 1. make sure that the specified node type is registered
+        if (!registeredNTDefs.containsKey(ntName)) {
+            throw new NoSuchNodeTypeException(ntName.toString());
+        }
+
+        // 2. check if effective node type has already been built
         WeightedKey key = new WeightedKey(new QName[]{ntName});
         if (entCache.contains(key)) {
             return entCache.get(key);
-        } else {
-            throw new NoSuchNodeTypeException(ntName.toString());
+        }
+
+        // 3. build effective node type
+        try {
+            EffectiveNodeType ent = EffectiveNodeType.create(this, ntName);
+            // store new effective node type
+            entCache.put(ent);
+            return ent;
+        } catch (NodeTypeConflictException ntce) {
+            // should never get here as all registered node types have to be valid!
+            String msg = "internal error: encountered invalid registered node type " + ntName;
+            log.error(msg, ntce);
+            throw new NoSuchNodeTypeException(msg, ntce);
         }
     }
 
     /**
+     *
      * @param ntNames
      * @return
+     * @throws NodeTypeConflictException
+     * @throws NoSuchNodeTypeException
      */
-    public synchronized EffectiveNodeType buildEffectiveNodeType(QName[] ntNames)
+    public synchronized EffectiveNodeType getEffectiveNodeType(QName[] ntNames)
             throws NodeTypeConflictException, NoSuchNodeTypeException {
         // 1. make sure every single node type is registered
         for (int i = 0; i < ntNames.length; i++) {
@@ -941,7 +963,7 @@
 
         WeightedKey key = new WeightedKey(ntNames);
 
-        // 2. check if aggregate has already been build
+        // 2. check if aggregate has already been built
         if (entCache.contains(key)) {
             return entCache.get(key);
         }
@@ -960,14 +982,18 @@
                 key = key.subtract(key);
                 break;
             }
-            // walk list of existing aggregates sorted by 'weight' of
-            // aggregate (i.e. the cost of building it)
+            /**
+             * walk list of existing aggregates sorted by 'weight' of
+             * aggregate (i.e. the cost of building it)
+             */
             boolean foundSubResult = false;
             Iterator iter = entCache.keys();
             while (iter.hasNext()) {
                 WeightedKey k = (WeightedKey) iter.next();
-                // check if the existing aggregate is a 'subset' of the one
-                // we're looking for
+                /**
+                 * check if the existing aggregate is a 'subset' of the one
+                 * we're looking for
+                 */
                 if (key.contains(k)) {
                     tmpResults.add(entCache.get(k));
                     // subtract the result from the temporary key
@@ -977,8 +1003,10 @@
                 }
             }
             if (!foundSubResult) {
-                // no matching sub-aggregates found:
-                // build aggregate of remaining node types through iteration
+                /**
+                 * no matching sub-aggregates found:
+                 * build aggregate of remaining node types through iteration
+                 */
                 QName[] remainder = key.toArray();
                 for (int i = 0; i < remainder.length; i++) {
                     EffectiveNodeType ent = null;
@@ -1296,7 +1324,7 @@
         NodeTypeDef ntdOld = (NodeTypeDef) registeredNTDefs.get(name);
         NodeTypeDefDiff diff = NodeTypeDefDiff.create(ntdOld, ntd);
         if (!diff.isModified()) {
-            // the definition has been modified, there's nothing to do here...
+            // the definition has not been modified, there's nothing to do here...
             return getEffectiveNodeType(name);
         }
         if (diff.isTrivial()) {

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java?view=diff&rev=123983&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java&r1=123982&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java&r2=123983
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
Mon Jan  3 07:01:28 2005
@@ -292,15 +292,10 @@
             def = getApplicableChildNodeDef(parent, name, nodeType == null ? null : nodeType.getQName());
         } catch (RepositoryException re) {
             // hack, use nt:unstructured as parent
-            try {
-                NodeTypeRegistry ntReg = getNodeTypeManager().getNodeTypeRegistry();
-                EffectiveNodeType ent = ntReg.buildEffectiveNodeType(new QName[]{NodeTypeRegistry.NT_UNSTRUCTURED});
-                ChildNodeDef cnd = ent.getApplicableChildNodeDef(name, nodeTypeName);
-                def = getNodeTypeManager().getNodeDef(new NodeDefId(cnd));
-            } catch (NodeTypeConflictException e) {
-                String msg = "no definition found in parent node's node type for new node";
-                throw new ConstraintViolationException(msg, re);
-            }
+            NodeTypeRegistry ntReg = getNodeTypeManager().getNodeTypeRegistry();
+            EffectiveNodeType ent = ntReg.getEffectiveNodeType(NodeTypeRegistry.NT_UNSTRUCTURED);
+            ChildNodeDef cnd = ent.getApplicableChildNodeDef(name, nodeTypeName);
+            def = getNodeTypeManager().getNodeDef(new NodeDefId(cnd));
         }
         if (nodeType == null) {
             // use default node type
@@ -408,7 +403,7 @@
         // primary type
         set.add(parent.getNodeTypeName());
         try {
-            return ntReg.buildEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
+            return ntReg.getEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
         } catch (NodeTypeConflictException ntce) {
             String msg = "internal error: failed to build effective node type for node "
+ parent.getUUID();
             throw new RepositoryException(msg, ntce);

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java?view=diff&rev=123983&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java&r1=123982&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java&r2=123983
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java
Mon Jan  3 07:01:28 2005
@@ -295,7 +295,7 @@
         // primary type
         set.add(nodeState.getNodeTypeName());
         try {
-            return ntReg.buildEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
+            return ntReg.getEffectiveNodeType((QName[]) set.toArray(new QName[set.size()]));
         } catch (NodeTypeConflictException ntce) {
             String msg = "internal error: failed to build effective node type for node "
+ nodeState.getUUID();
             throw new RepositoryException(msg, ntce);
@@ -396,15 +396,10 @@
             def = getApplicableChildNodeDef(name, nodeType == null ? null : nodeType.getQName());
         } catch (RepositoryException re) {
             // hack, use nt:unstructured as parent
-            try {
-                NodeTypeRegistry ntReg = ntMgr.getNodeTypeRegistry();
-                EffectiveNodeType ent = ntReg.buildEffectiveNodeType(new QName[]{NodeTypeRegistry.NT_UNSTRUCTURED});
-                ChildNodeDef cnd = ent.getApplicableChildNodeDef(name, nodeTypeName);
-                def = ntMgr.getNodeDef(new NodeDefId(cnd));
-            } catch (NodeTypeConflictException e) {
-                String msg = "no definition found in parent node's node type for new node";
-                throw new ConstraintViolationException(msg, re);
-            }
+            NodeTypeRegistry ntReg = ntMgr.getNodeTypeRegistry();
+            EffectiveNodeType ent = ntReg.getEffectiveNodeType(NodeTypeRegistry.NT_UNSTRUCTURED);
+            ChildNodeDef cnd = ent.getApplicableChildNodeDef(name, nodeTypeName);
+            def = ntMgr.getNodeDef(new NodeDefId(cnd));
         }
 
         if (nodeType == null) {

Mime
View raw message