jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1807346 - in /jackrabbit/branches/2.14: ./ jackrabbit-jcr-server/ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/ jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/jcr/observation/
Date Tue, 05 Sep 2017 13:09:33 GMT
Author: reschke
Date: Tue Sep  5 13:09:33 2017
New Revision: 1807346

URL: http://svn.apache.org/viewvc?rev=1807346&view=rev
Log:
JCR-4173: Unable to receive observation events when connecting via DavEx (ported to 2.14)

make sure we do not produce broken XML, add a minimal test case

Added:
    jackrabbit/branches/2.14/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/jcr/observation/
      - copied from r1807244, jackrabbit/trunk/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/jcr/observation/
Modified:
    jackrabbit/branches/2.14/   (props changed)
    jackrabbit/branches/2.14/jackrabbit-jcr-server/pom.xml
    jackrabbit/branches/2.14/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java

Propchange: jackrabbit/branches/2.14/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep  5 13:09:33 2017
@@ -1,3 +1,3 @@
 /jackrabbit/branches/JCR-2272:1173165-1176545
 /jackrabbit/sandbox/JCR-2415-lucene-3.0:1060860-1064038
-/jackrabbit/trunk:1776907,1776911-1776912,1776914,1776918,1779166,1779460,1779614,1779632,1780208,1780220,1780406,1785225,1786325,1786330,1787043,1787381,1792100,1792105,1792113,1792193,1793315,1793323,1793327,1793332,1796980,1797209,1797917,1798586,1799429,1799538,1799549,1799575,1800359,1800378,1800752,1802925,1802977,1807234
+/jackrabbit/trunk:1776907,1776911-1776912,1776914,1776918,1779166,1779460,1779614,1779632,1780208,1780220,1780406,1785225,1786325,1786330,1787043,1787381,1792100,1792105,1792113,1792193,1793315,1793323,1793327,1793332,1796980,1797209,1797917,1798586,1799429,1799538,1799549,1799575,1800359,1800378,1800752,1802925,1802977,1807234,1807244

Modified: jackrabbit/branches/2.14/jackrabbit-jcr-server/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-jcr-server/pom.xml?rev=1807346&r1=1807345&r2=1807346&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-jcr-server/pom.xml (original)
+++ jackrabbit/branches/2.14/jackrabbit-jcr-server/pom.xml Tue Sep  5 13:09:33 2017
@@ -261,6 +261,11 @@
       <artifactId>logback-classic</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
 </project>

Modified: jackrabbit/branches/2.14/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java?rev=1807346&r1=1807345&r2=1807346&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
(original)
+++ jackrabbit/branches/2.14/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
Tue Sep  5 13:09:33 2017
@@ -535,18 +535,8 @@ public class SubscriptionImpl implements
                     log.error("Internal error while retrieving event identifier. {}", e.getMessage());
                 }
                 // info
-                Element info = DomUtil.addChildElement(eventElem, XML_EVENTINFO, NAMESPACE);
                 try {
-                    Map<?, ?> m = event.getInfo();
-                    for (Map.Entry<?, ?> entry : m.entrySet()) {
-                        String key = entry.getKey().toString();
-                        Object value = entry.getValue();
-                        if (value != null) {
-                            DomUtil.addChildElement(info, key, Namespace.EMPTY_NAMESPACE,
value.toString());
-                        } else {
-                            DomUtil.addChildElement(info, key, Namespace.EMPTY_NAMESPACE);
-                        }
-                    }
+                    serializeInfoMap(eventElem, session, event.getInfo());
                 } catch (RepositoryException e) {
                     log.error("Internal error while retrieving event info. {}", e.getMessage());
                 }
@@ -555,6 +545,33 @@ public class SubscriptionImpl implements
         }
     }
 
+    protected static void serializeInfoMap(Element eventElem, Session session, Map<?,
?> map) {
+        // info
+        Element info = DomUtil.addChildElement(eventElem, XML_EVENTINFO, NAMESPACE);
+        Map<?, ?> m = map;
+        for (Map.Entry<?, ?> entry : m.entrySet()) {
+            try {
+                String key = entry.getKey().toString();
+                Namespace ns = Namespace.EMPTY_NAMESPACE;
+                int colon = key.indexOf(':');
+                if (colon >= 0) {
+                    String prefix = key.substring(0, colon);
+                    String localname = key.substring(colon + 1);
+                    ns = Namespace.getNamespace(prefix, session.getNamespaceURI(prefix));
+                    key = localname;
+                }
+                Object value = entry.getValue();
+                if (value != null) {
+                    DomUtil.addChildElement(info, key, ns, value.toString());
+                } else {
+                    DomUtil.addChildElement(info, key, ns);
+                }
+            } catch (RepositoryException nse) {
+                log.error("Internal error while getting namespaceUri, info map field skipped
for {}", entry.getKey());
+            }
+        }
+    }    
+    
     //----------------------------< TransactionEvent >------------------------
 
     /**



Mime
View raw message