jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1138520 - in /jackrabbit/sandbox/spi2microkernel/src: main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Date Wed, 22 Jun 2011 15:59:16 GMT
Author: mduerig
Date: Wed Jun 22 15:59:15 2011
New Revision: 1138520

URL: http://svn.apache.org/viewvc?rev=1138520&view=rev
Log:
spi2microkernel prototype (WIP)
observation (WIP): user data support

Modified:
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
    jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java?rev=1138520&r1=1138519&r2=1138520&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
Wed Jun 22 15:59:15 2011
@@ -158,15 +158,15 @@ public class SubscriptionImpl implements
         //------------------------------------------< private >---
         
         private EventBundle createEventBundle(JSONObject jsonObject) {
-            String revisionId = getString(jsonObject, "id");
-            String userData = ""; // getString(jsonObject, "msg");  // todo see http://markmail.org/message/fzf7clnyvs6uzaus
+            String revisionId = getString(jsonObject, "id", false);
+            String userData = getString(jsonObject, "msg", true);  // todo see http://markmail.org/message/fzf7clnyvs6uzaus
 
             EventTemplate eventTemplate = new EventTemplate()
                     .setTimestamp(getLong(jsonObject, "ts"))
                     .setUserId(sessionState.getSessionInfo().getUserID())
                     .setUserData(userData);
 
-            String changes = getString(jsonObject, "changes");
+            String changes = getString(jsonObject, "changes", false);
             Collection<Event> events = getEvents(changes, eventTemplate);
 
             boolean isLocal = commitLog.contains(revisionId);  // todo performance: this
does a linear search on the list
@@ -244,10 +244,10 @@ public class SubscriptionImpl implements
         private void moveNode(JsopTokenizer jsopTokenizer, EventTemplate eventTemplate, Collection<Event>
events) {
             // todo implement moveNode
         }
-
-        private String getString(JSONObject jsonObject, String key) {
+        
+        private String getString(JSONObject jsonObject, String key, boolean allowNull) {
             Object o = jsonObject.get(key);
-            if (o instanceof String) {
+            if (o instanceof String || allowNull && o == null) {
                 return (String) o;
             }
             else {

Modified: jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java?rev=1138520&r1=1138519&r2=1138520&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Wed Jun 22 15:59:15 2011
@@ -910,6 +910,7 @@ public class RepositoryTest {
     @Test
     public void observation() throws RepositoryException, InterruptedException {
         ObservationManager obsMgr = getSession().getWorkspace().getObservationManager();
+        obsMgr.setUserData("my user data");
         obsMgr.addEventListener(new EventListener(){
                 public void onEvent(EventIterator events) {
                     while (events.hasNext()) {



Mime
View raw message