jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r927945 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: nodetype/ nodetype/virtual/ query/ query/lucene/
Date Fri, 26 Mar 2010 16:05:59 GMT
Author: jukka
Date: Fri Mar 26 16:05:59 2010
New Revision: 927945

URL: http://svn.apache.org/viewvc?rev=927945&view=rev
Log:
JCR-2587: Coarser granularity of node type unregistration notifications

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistryListener.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java?rev=927945&r1=927944&r2=927945&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
Fri Mar 26 16:05:59 2010
@@ -54,17 +54,17 @@ import org.apache.jackrabbit.core.data.D
 import org.apache.jackrabbit.core.nodetype.xml.NodeTypeReader;
 import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
-import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping;
-import org.apache.jackrabbit.spi.commons.nodetype.*;
+import org.apache.jackrabbit.spi.commons.nodetype.AbstractNodeTypeManager;
 import org.apache.jackrabbit.spi.commons.nodetype.NodeDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.nodetype.PropertyDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.nodetype.QDefinitionBuilderFactory;
-import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -73,8 +73,8 @@ import org.xml.sax.SAXException;
  * A <code>NodeTypeManagerImpl</code> implements a session dependant
  * NodeTypeManager.
  */
-public class NodeTypeManagerImpl extends AbstractNodeTypeManager implements JackrabbitNodeTypeManager,
-        Dumpable, NodeTypeRegistryListener {
+public class NodeTypeManagerImpl extends AbstractNodeTypeManager
+        implements JackrabbitNodeTypeManager, Dumpable, NodeTypeRegistryListener {
 
     /**
      * The wrapped node type registry.
@@ -354,23 +354,25 @@ public class NodeTypeManagerImpl extends
     /**
      * {@inheritDoc}
      */
-    public void nodeTypeUnregistered(Name ntName) {
+    public void nodeTypesUnregistered(Collection<Name> names) {
         // flush all affected cache entries
-        ntCache.remove(ntName);
+        for (Name name : names) {
+            ntCache.remove(name);
+        }
         synchronized (pdCache) {
-            Iterator iter = pdCache.values().iterator();
+            Iterator<PropertyDefinitionImpl> iter = pdCache.values().iterator();
             while (iter.hasNext()) {
-                PropertyDefinitionImpl pd = (PropertyDefinitionImpl) iter.next();
-                if (ntName.equals(pd.unwrap().getDeclaringNodeType())) {
+                PropertyDefinitionImpl pd = iter.next();
+                if (names.contains(pd.unwrap().getDeclaringNodeType())) {
                     iter.remove();
                 }
             }
         }
         synchronized (ndCache) {
-            Iterator iter = ndCache.values().iterator();
+            Iterator<NodeDefinitionImpl> iter = ndCache.values().iterator();
             while (iter.hasNext()) {
-                NodeDefinitionImpl nd = (NodeDefinitionImpl) iter.next();
-                if (ntName.equals(nd.unwrap().getDeclaringNodeType())) {
+                NodeDefinitionImpl nd = iter.next();
+                if (names.contains(nd.unwrap().getDeclaringNodeType())) {
                     iter.remove();
                 }
             }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java?rev=927945&r1=927944&r2=927945&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
Fri Mar 26 16:05:59 2010
@@ -258,14 +258,13 @@ public class NodeTypeRegistry implements
      * @throws RepositoryException if another error occurs
      * @see #unregisterNodeType(Name)
      */
-    public void unregisterNodeTypes(Collection<Name> ntNames)
+    public void unregisterNodeTypes(Set<Name> ntNames)
             throws NoSuchNodeTypeException, RepositoryException {
-
         unregisterNodeTypes(ntNames, false);
     }
 
     /**
-     * Internal implementation of {@link #unregisterNodeTypes(Collection)}
+     * Internal implementation of {@link #unregisterNodeTypes(Set)}
      *
      * @param ntNames a collection of <code>Name</code> objects denoting the
      *                node types to be unregistered
@@ -274,7 +273,8 @@ public class NodeTypeRegistry implements
      *                                 denote a registered node type.
      * @throws RepositoryException if another error occurs
      */
-    private synchronized void unregisterNodeTypes(Collection<Name> ntNames, boolean
external)
+    private synchronized void unregisterNodeTypes(
+            Collection<Name> ntNames, boolean external)
             throws NoSuchNodeTypeException, RepositoryException {
 
         // do some preliminary checks
@@ -317,8 +317,9 @@ public class NodeTypeRegistry implements
         // persist removal of node type definitions & notify listeners
         for (Name ntName : ntNames) {
             customNTDefs.remove(ntName);
-            notifyUnregistered(ntName);
         }
+        notifyUnregistered(ntNames);
+
         persistCustomNodeTypeDefs(customNTDefs);
     }
 
@@ -687,7 +688,6 @@ public class NodeTypeRegistry implements
      */
     public void externalUnregistered(Collection<Name> ntNames)
             throws RepositoryException, NoSuchNodeTypeException {
-
         unregisterNodeTypes(ntNames, true);
     }
 
@@ -950,7 +950,7 @@ public class NodeTypeRegistry implements
      */
     protected void checkForReferencesInContent(Name nodeTypeName)
             throws RepositoryException {
-        throw new RepositoryException("not yet implemented");
+        // throw new RepositoryException("not yet implemented");
     }
 
     //-------------------------------------------------------< implementation >
@@ -1827,13 +1827,13 @@ public class NodeTypeRegistry implements
      * Notify the listeners that a node type <code>ntName</code> has been unregistered.
      * @param ntName node type name
      */
-    private void notifyUnregistered(Name ntName) {
+    private void notifyUnregistered(Collection<Name> names) {
         // copy listeners to array to avoid ConcurrentModificationException
         NodeTypeRegistryListener[] la = listeners.values().toArray(
                         new NodeTypeRegistryListener[listeners.size()]);
         for (NodeTypeRegistryListener aLa : la) {
             if (aLa != null) {
-                aLa.nodeTypeUnregistered(ntName);
+                aLa.nodeTypesUnregistered(names);
             }
         }
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistryListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistryListener.java?rev=927945&r1=927944&r2=927945&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistryListener.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistryListener.java
Fri Mar 26 16:05:59 2010
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.core.nodetype;
 
+import java.util.Collection;
+
 import org.apache.jackrabbit.spi.Name;
 
 /**
@@ -42,9 +44,10 @@ public interface NodeTypeRegistryListene
     void nodeTypeReRegistered(Name ntName);
 
     /**
-     * Called when a node type has been deregistered.
+     * Called when a set of node types has been unregistered.
      *
-     * @param ntName name of the node type that has been unregistered
+     * @param names names of the types that have been unregistered
      */
-    void nodeTypeUnregistered(Name ntName);
+    void nodeTypesUnregistered(Collection<Name> names);
+
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java?rev=927945&r1=927944&r2=927945&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java
Fri Mar 26 16:05:59 2010
@@ -16,10 +16,19 @@
  */
 package org.apache.jackrabbit.core.nodetype.virtual;
 
-import org.apache.jackrabbit.core.id.NodeId;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import javax.jcr.NodeIterator;
+import javax.jcr.PropertyIterator;
+import javax.jcr.RepositoryException;
+
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.PropertyImpl;
 import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistryListener;
@@ -28,18 +37,12 @@ import org.apache.jackrabbit.core.observ
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.name.PathBuilder;
-import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.NodeIterator;
-import javax.jcr.PropertyIterator;
-import javax.jcr.RepositoryException;
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * This Class implements a workaround helper for populating observation
  * events for the virtual node states of the jcr:nodeTypes upon nodetype
@@ -168,30 +171,35 @@ public class VirtualNodeTypeStateManager
      */
     public void nodeTypeReRegistered(Name ntName) {
         // lazy implementation
-        nodeTypeUnregistered(ntName);
+        nodeTypesUnregistered(Collections.singleton(ntName));
         nodeTypeRegistered(ntName);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void nodeTypeUnregistered(Name ntName) {
+    public void nodeTypesUnregistered(Collection<Name> names) {
         try {
             if (systemSession != null) {
                 // generated observation events
-                NodeImpl root = (NodeImpl) systemSession.getItemManager().getItem(rootNodeId);
-                NodeImpl child = root.getNode(ntName);
-                List events = new ArrayList();
-                recursiveRemove(events, root, child);
+                List<EventState> events = new ArrayList<EventState>();
+
+                NodeImpl root = (NodeImpl)
+                    systemSession.getItemManager().getItem(rootNodeId);
+                for (Name name : names) {
+                    NodeImpl child = root.getNode(name);
+                    recursiveRemove(events, root, child);
+                }
+
                 obsDispatcher.dispatch(events, systemSession,
                         NODE_TYPES_PATH, null);
             }
             if (virtProvider != null) {
                 // allow provider to update
-                virtProvider.onNodeTypeRemoved(ntName);
+                virtProvider.onNodeTypesRemoved(names);
             }
         } catch (RepositoryException e) {
-            log.error("Unable to index removed nodetype: " + e.toString());
+            log.error("Unable to index removed nodetypes: " + names, e);
         }
     }
 
@@ -203,7 +211,8 @@ public class VirtualNodeTypeStateManager
      * @param node
      * @throws RepositoryException
      */
-    private void recursiveAdd(List events, NodeImpl parent, NodeImpl node)
+    private void recursiveAdd(
+            List<EventState> events, NodeImpl parent, NodeImpl node)
             throws RepositoryException {
 
         events.add(EventState.childNodeAdded(
@@ -243,7 +252,8 @@ public class VirtualNodeTypeStateManager
      * @param node
      * @throws RepositoryException
      */
-    private void recursiveRemove(List events, NodeImpl parent, NodeImpl node)
+    private void recursiveRemove(
+            List<EventState> events, NodeImpl parent, NodeImpl node)
             throws RepositoryException {
 
         events.add(EventState.childNodeRemoved(

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java?rev=927945&r1=927944&r2=927945&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
Fri Mar 26 16:05:59 2010
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.core.nodet
 import java.io.UnsupportedEncodingException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
+import java.util.Collection;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
@@ -33,10 +34,10 @@ import org.apache.jackrabbit.core.value.
 import org.apache.jackrabbit.core.virtual.AbstractVISProvider;
 import org.apache.jackrabbit.core.virtual.VirtualNodeState;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.QValueConstraint;
-import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 
 /**
@@ -131,7 +132,8 @@ public class VirtualNodeTypeStateProvide
     /**
      * {@inheritDoc}
      */
-    public void onNodeTypeRemoved(Name ntName) throws RepositoryException {
+    public void onNodeTypesRemoved(Collection<Name> names)
+            throws RepositoryException {
         // todo: do more efficient reloading
         try {
             getRootState().discard();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java?rev=927945&r1=927944&r2=927945&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java
Fri Mar 26 16:05:59 2010
@@ -28,6 +28,8 @@ import javax.jcr.PropertyType;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -113,11 +115,11 @@ public class PropertyTypeRegistry implem
     }
 
     public void nodeTypeReRegistered(Name ntName) {
-        nodeTypeUnregistered(ntName);
+        nodeTypesUnregistered(Collections.singleton(ntName));
         nodeTypeRegistered(ntName);
     }
 
-    public void nodeTypeUnregistered(Name ntName) {
+    public void nodeTypesUnregistered(Collection<Name> names) {
         // remove all TypeMapping instances refering to this ntName
         synchronized (typeMapping) {
             Map<Name, TypeMapping[]> modified = new HashMap<Name, TypeMapping[]>();
@@ -126,7 +128,7 @@ public class PropertyTypeRegistry implem
                 TypeMapping[] mapping = typeMapping.get(propName);
                 List<TypeMapping> remove = null;
                 for (TypeMapping tm : mapping) {
-                    if (tm.ntName.equals(ntName)) {
+                    if (names.contains(tm.ntName)) {
                         if (remove == null) {
                             // not yet created
                             remove = new ArrayList<TypeMapping>(mapping.length);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java?rev=927945&r1=927944&r2=927945&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
Fri Mar 26 16:05:59 2010
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.core.query.lucene;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -322,7 +323,7 @@ public class IndexingConfigurationImpl
         // not interested
     }
 
-    public void nodeTypeUnregistered(Name ntName) {
+    public void nodeTypesUnregistered(Collection<Name> names) {
         // not interested
     }
 



Mime
View raw message