jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1163330 - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src: main/java/org/apache/jackrabbit/spi2microkernel/ test/java/org/apache/jackrabbit/spi2microkernel/
Date Tue, 30 Aug 2011 18:53:00 GMT
Author: mduerig
Date: Tue Aug 30 18:53:00 2011
New Revision: 1163330

URL: http://svn.apache.org/viewvc?rev=1163330&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP)
set correct userId for observation events

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

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java?rev=1163330&r1=1163329&r2=1163330&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
Tue Aug 30 18:53:00 2011
@@ -819,7 +819,9 @@ public class RepositoryServiceImpl exten
                 @Override
                 public String call() {
                     String rev = microKernel.getHeadRevision();
-                    return microKernel.commit("/", jsop.toString(), rev, ((SessionInfoImpl)
sessionInfo).getUserData());
+                    String userId = sessionInfo.getUserID();
+                    String userData = ((SessionInfoImpl) sessionInfo).getUserData();
+                    return microKernel.commit("/", jsop.toString(), rev, userId + ":" + userData);
// fixme encode properly
                 }
             });
         }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java?rev=1163330&r1=1163329&r2=1163330&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
Tue Aug 30 18:53:00 2011
@@ -292,7 +292,9 @@ public class SubscriptionImpl implements
 
         private EventBundle createEventBundle(JSONObject jsonObject) throws RepositoryException
{
             String revisionId = getString(jsonObject, "id", false);
-            String userData = getString(jsonObject, "msg", true);
+            String msg = getString(jsonObject, "msg", true);
+            String userId = msg.substring(0, msg.indexOf(":"));   // fixme decode properly
+            String userData = msg.substring(msg.indexOf(":") + 1);  // fixme decode properly
             long timeStamp = getLong(jsonObject, "ts");
             String changes = getString(jsonObject, "changes", false);
             log.debug("Creating event bundle from changes in revision " + revisionId + "
at " + timeStamp);
@@ -300,7 +302,7 @@ public class SubscriptionImpl implements
 
             EventTemplate eventTemplate = new EventTemplate()
                     .setTimestamp(timeStamp)
-                    .setUserId(sessionState.getSessionInfo().getUserID())  // fixme: need
userId of session who caused the event: put into msg, and parser from there
+                    .setUserId(userId)
                     .setUserData(userData);
 
             Collection<Event> events = getEvents(changes, eventTemplate);

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java?rev=1163330&r1=1163329&r2=1163330&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Tue Aug 30 18:53:00 2011
@@ -46,6 +46,7 @@ import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.RepositoryFactory;
 import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
 import javax.jcr.Value;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeManager;
@@ -1179,8 +1180,9 @@ public class RepositoryTest {
         final List<Event> failedEvents = new ArrayList<Event>();
 
         final String userData = "my user data";
+        final String userId = "someone";
+
         ObservationManager obsMgr = getSession().getWorkspace().getObservationManager();
-        obsMgr.setUserData(userData);
         obsMgr.addEventListener(new EventListener() {
                 @Override
                 public void onEvent(EventIterator events) {
@@ -1188,6 +1190,7 @@ public class RepositoryTest {
                         Event event = events.nextEvent();
                         try {
                             assertEquals(userData, event.getUserData());
+                            assertEquals(userId, event.getUserID());
                             switch (event.getType()) {
                                 case Event.NODE_ADDED:
                                     if (!addNodes.remove(event.getPath())) {
@@ -1227,20 +1230,27 @@ public class RepositoryTest {
             Event.NODE_ADDED | Event.NODE_REMOVED | Event.NODE_MOVED | Event.PROPERTY_ADDED
|
             Event.PROPERTY_REMOVED | Event.PROPERTY_CHANGED | Event.PERSIST, "/", true, null,
null, false);
 
-        Node n = getNode(testPath);
-        n.setProperty("prop0", "val0");
-        Node n1 = n.addNode("1");
-        n1.setProperty("prop1", "val1");
-        n1.setProperty("prop2", "val2");
-        n.addNode("2");
-        getSession().save();
-
-        n.setProperty("property", 42);
-        n.addNode("3").setProperty("prop3", "val3");
-        n1.setProperty("prop1", "val1 new");
-        n1.getProperty("prop2").remove();
-        n.getNode("2").remove();
-        getSession().save();
+        Session session = getRepository().login(new SimpleCredentials(userId, "".toCharArray()));
+        try {
+            session.getWorkspace().getObservationManager().setUserData(userData);
+            Node n = session.getNode(testPath);
+            n.setProperty("prop0", "val0");
+            Node n1 = n.addNode("1");
+            n1.setProperty("prop1", "val1");
+            n1.setProperty("prop2", "val2");
+            n.addNode("2");
+            n.getSession().save();
+
+            n.setProperty("property", 42);
+            n.addNode("3").setProperty("prop3", "val3");
+            n1.setProperty("prop1", "val1 new");
+            n1.getProperty("prop2").remove();
+            n.getNode("2").remove();
+            n.getSession().save();
+        }
+        finally {
+            session.logout();
+        }
 
         new Loop() { @Override public void test() {
             assertTrue(failedEvents.isEmpty());



Mime
View raw message