jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1583562 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/NodeObserver.java
Date Tue, 01 Apr 2014 08:01:23 GMT
Author: mduerig
Date: Tue Apr  1 08:01:23 2014
New Revision: 1583562

URL: http://svn.apache.org/r1583562
Log:
OAK-1652: Incorrect name mapping in NodeObserver

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/NodeObserver.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/NodeObserver.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/NodeObserver.java?rev=1583562&r1=1583561&r2=1583562&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/NodeObserver.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/NodeObserver.java
Tue Apr  1 08:01:23 2014
@@ -26,7 +26,6 @@ import java.util.Set;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
-import javax.jcr.RepositoryException;
 
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
@@ -119,37 +118,45 @@ public abstract class NodeObserver imple
 
     @Override
     public void contentChanged(@Nonnull NodeState root, @Nullable CommitInfo info) {
-        try {
-            if (previousRoot != null) {
-                NamePathMapper namePathMapper = new NamePathMapperImpl(
-                        new GlobalNameMapper(new ImmutableRoot(root)));
-
-                Set<String> oakPropertyNames = Sets.newHashSet();
-                for (String name : propertyNames) {
-                    oakPropertyNames.add(namePathMapper.getJcrName(name));
-                }
-                NodeState before = previousRoot;
-                NodeState after = root;
-                EventHandler handler = new FilteredHandler(
-                        new VisibleFilter(),
-                        new NodeEventHandler("/", info, namePathMapper, oakPropertyNames));
-                for (String name : PathUtils.elements(path)) {
-                    String oakName = namePathMapper.getOakName(name);
-                    before = before.getChildNode(oakName);
-                    after = after.getChildNode(oakName);
-                    handler = handler.getChildHandler(oakName, before, after);
-                }
+        if (previousRoot != null) {
+            NamePathMapper namePathMapper = new NamePathMapperImpl(
+                    new GlobalNameMapper(new ImmutableRoot(root)));
 
-                EventGenerator generator = new EventGenerator(before, after, handler);
-                while (!generator.isDone()) {
-                    generator.generate();
+            Set<String> oakPropertyNames = Sets.newHashSet();
+            for (String name : propertyNames) {
+                String oakName = namePathMapper.getOakNameOrNull(name);
+                if (oakName == null) {
+                    LOG.warn("Ignoring invalid property name: {}", name);
+                } else {
+                    oakPropertyNames.add(oakName);
                 }
             }
 
-            previousRoot = root;
-        } catch (RepositoryException e) {
-            LOG.warn("Error while handling content change", e);
+            NodeState before = previousRoot;
+            NodeState after = root;
+            EventHandler handler = new FilteredHandler(
+                    new VisibleFilter(),
+                    new NodeEventHandler("/", info, namePathMapper, oakPropertyNames));
+
+            String oakPath = namePathMapper.getOakPath(path);
+            if (oakPath == null) {
+                LOG.warn("Cannot listen for changes on invalid path: {}", path);
+                return;
+            }
+
+            for (String oakName : PathUtils.elements(oakPath)) {
+                before = before.getChildNode(oakName);
+                after = after.getChildNode(oakName);
+                handler = handler.getChildHandler(oakName, before, after);
+            }
+
+            EventGenerator generator = new EventGenerator(before, after, handler);
+            while (!generator.isDone()) {
+                generator.generate();
+            }
         }
+
+        previousRoot = root;
     }
 
     private enum EventType {ADDED, DELETED, CHANGED}



Mime
View raw message