jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1138510 - in /jackrabbit/sandbox/microkernel/src: main/java/org/apache/jackrabbit/mk/ main/java/org/apache/jackrabbit/mk/api/ main/java/org/apache/jackrabbit/mk/mem/ main/java/org/apache/jackrabbit/mk/store/ test/java/org/apache/jackrabbit...
Date Wed, 22 Jun 2011 15:41:57 GMT
Author: stefan
Date: Wed Jun 22 15:41:57 2011
New Revision: 1138510

URL: http://svn.apache.org/viewvc?rev=1138510&view=rev
Log:
MicroKernel prototype (WIP)

added commit-msg support

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/Revision.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Commit.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/MutableCommit.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConcurrentWriteTest.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java?rev=1138510&r1=1138509&r2=1138510&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java
Wed Jun 22 15:41:57 2011
@@ -143,7 +143,8 @@ public class MicroKernelImpl implements 
             }
             commitBuff.object().
                 key("id").value(commit.getId()).
-                key("ts").value(commit.getCommitTS());
+                key("ts").value(commit.getCommitTS()).
+                key("msg").value(commit.getMsg());
             final JsopBuilder buff = new JsopBuilder();
             try {
                 String path = "/";
@@ -244,13 +245,13 @@ public class MicroKernelImpl implements 
         }
     }
 
-    public String commit(String path, String jsonDiff, String revisionId) throws MicroKernelException
{
+    public String commit(String path, String jsonDiff, String revisionId, String message)
throws MicroKernelException {
         if (rep == null) {
             throw new IllegalStateException("this instance has already been disposed");
         }
         try {
             JsopTokenizer t = new JsopTokenizer(jsonDiff);
-            CommitBuilder cb = rep.getCommitBuilder(revisionId);
+            CommitBuilder cb = rep.getCommitBuilder(revisionId, message);
             while (true) {
                 int r = t.read();
                 if (r == JsopTokenizer.END) {

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java?rev=1138510&r1=1138509&r2=1138510&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java
Wed Jun 22 15:41:57 2011
@@ -98,8 +98,8 @@ public class Repository {
         return store.getNode(ids[ids.length - 1]);
     }
 
-    public CommitBuilder getCommitBuilder(String revId) throws Exception {
-        return new CommitBuilder(revId, this);
+    public CommitBuilder getCommitBuilder(String revId, String msg) throws Exception {
+        return new CommitBuilder(revId, msg, this);
 
     }
 

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java?rev=1138510&r1=1138509&r2=1138510&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
Wed Jun 22 15:41:57 2011
@@ -128,7 +128,7 @@ public interface MicroKernel {
      * <p/>
      * Format:
      * <pre>
-     * [ { "id" : "<revisionId>", "ts" : <revisionTimestamp>, "changes" : "<JSON
diff>" }, ... ]
+     * [ { "id" : "<revisionId>", "ts" : <revisionTimestamp>, "msg" : <commitMessage>,
"changes" : "<JSON diff>" }, ... ]
      * </pre>
      *
      * @param fromRevisionId first revision to be returned in journal
@@ -235,10 +235,11 @@ public interface MicroKernel {
      * @param path path denoting target node
      * @param jsonDiff changes to be applied in JSON diff format.
      * @param revisionId revision the changes are based on
+     * @param message commit message
      * @return id of newly created revision
      * @throws MicroKernelException if an error occurs
      */
-    String /* revisionId */ commit(String path, String jsonDiff, String revisionId)
+    String /* revisionId */ commit(String path, String jsonDiff, String revisionId, String
message)
             throws MicroKernelException;
 
 

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java?rev=1138510&r1=1138509&r2=1138510&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java
Wed Jun 22 15:41:57 2011
@@ -62,16 +62,16 @@ public class MemoryKernelImpl implements
         revisions = new TreeMap<Long, Revision>();
         revisionList = new ArrayList<Revision>();
         headRoot = new NodeImpl(headRevId);
-        commit("+\"/\" {}");
+        commit("+\"/\" {}", "create root node");
     }
 
-    private void commit(String jsonDiff) {
-        Revision r = new Revision(headRevId, clock.time(), headRoot, jsonDiff);
+    private void commit(String jsonDiff, String msg) {
+        Revision r = new Revision(headRevId, clock.time(), headRoot, jsonDiff, msg);
         revisions.put(headRevId, r);
         revisionList.add(r);
     }
 
-    public synchronized String commit(String path, String jsonDiff, String revisionId) {
+    public synchronized String commit(String path, String jsonDiff, String revisionId, String
message) {
         // TODO do we really need 'path'? store the path is in the diff instead
         // TODO what is the exact meaning of 'revisionId'? is it allowed to commit
         // using an old revision, if yes when is it allowed, or how is it different from
using head?
@@ -83,7 +83,7 @@ public class MemoryKernelImpl implements
 
         headRevId++;
         apply(path, jsonDiff);
-        commit(jsonDiff);
+        commit(jsonDiff, message);
         return getHeadRevision();
     }
 
@@ -135,7 +135,7 @@ public class MemoryKernelImpl implements
     }
 
     public String getRevisions(long since, int maxEntries) {
-        Revision find = new Revision(0, since, null, null);
+        Revision find = new Revision(0, since, null, null, null);
         int index = Collections.binarySearch(revisionList, find, new Comparator<Revision>()
{
             public int compare(Revision o1, Revision o2) {
                 long t1 = o1.getTime(), t2 = o2.getTime();
@@ -165,6 +165,7 @@ public class MemoryKernelImpl implements
             buff.object().
                 key("id").value(Long.toString(rev.getId())).
                 key("ts").value(rev.getTime()).
+                key("msg").value(rev.getMsg()).
                 key("changes").value(rev.getDiff()).
             endObject();
         }

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/Revision.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/Revision.java?rev=1138510&r1=1138509&r2=1138510&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/Revision.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/Revision.java
Wed Jun 22 15:41:57 2011
@@ -22,12 +22,14 @@ public class Revision {
     private final long time;
     private final NodeImpl root;
     private final String diff;
+    private final String msg;
 
-    public Revision(long id, long time, NodeImpl root, String diff) {
+    public Revision(long id, long time, NodeImpl root, String diff, String msg) {
         this.id = id;
         this.time = time;
         this.root = root;
         this.diff = diff;
+        this.msg = msg;
     }
 
     public NodeImpl getRootNode() {
@@ -46,4 +48,8 @@ public class Revision {
         return diff;
     }
 
+    public String getMsg() {
+        return msg;
+    }
+
 }

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Commit.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Commit.java?rev=1138510&r1=1138509&r2=1138510&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Commit.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Commit.java
Wed Jun 22 15:41:57 2011
@@ -33,12 +33,16 @@ public class Commit extends StoredObject
     // commit timestamp
     final long commitTS;
 
-    protected Commit(String id, String rootNodeId, long commitTS, String parentId) {
+    // commit msg
+    final String msg;
+
+    protected Commit(String id, String rootNodeId, long commitTS, String msg, String parentId)
{
         super(id);
 
         this.rootNodeId = rootNodeId;
         this.parentId = parentId;
         this.commitTS = commitTS;
+        this.msg = msg;
     }
 
     public String getRootNodeId() {
@@ -53,6 +57,10 @@ public class Commit extends StoredObject
         return commitTS;
     }
 
+    public String getMsg() {
+        return msg;
+    }
+
     //--------------------------------------------------------< serialization >
 
     public static Commit fromBytes(String id, InputStream is) throws Exception {
@@ -63,8 +71,9 @@ public class Commit extends StoredObject
             }
             String rootNodeId = in.readUTF();
             long commitTS = in.readLong();
+            String msg = in.readUTF();
             String parentId = in.readUTF();
-            return new Commit(id, rootNodeId, commitTS, "".equals(parentId) ? null : parentId);
+            return new Commit(id, rootNodeId, commitTS, "".equals(msg) ? null : msg, "".equals(parentId)
? null : parentId);
         } finally {
             in.close();
         }

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java?rev=1138510&r1=1138509&r2=1138510&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java
Wed Jun 22 15:41:57 2011
@@ -33,6 +33,8 @@ public class CommitBuilder {
 
     String baseRevId;
 
+    final String msg;
+
     final Repository rep;
     final ObjectStore store;
 
@@ -40,8 +42,9 @@ public class CommitBuilder {
     // change log
     final List<Change> changeLog;
 
-    public CommitBuilder(String baseRevId, Repository rep) throws Exception {
+    public CommitBuilder(String baseRevId, String msg, Repository rep) throws Exception {
         this.baseRevId = baseRevId;
+        this.msg = msg;
         this.rep = rep;
         store = rep.getStore();
         staged = new HashMap<String, MutableNode>();
@@ -197,6 +200,7 @@ public class CommitBuilder {
             MutableCommit newCommit = new MutableCommit();
             newCommit.setParentId(baseRevId);
             newCommit.setCommitTS(System.currentTimeMillis());
+            newCommit.setMsg(msg);
             newCommit.setRootNodeId(rootNodeId);
             newRevId = store.putCommit(newCommit);
 

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/MutableCommit.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/MutableCommit.java?rev=1138510&r1=1138509&r2=1138510&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/MutableCommit.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/MutableCommit.java
Wed Jun 22 15:41:57 2011
@@ -33,6 +33,9 @@ public class MutableCommit {
     // commit timestamp
     long commitTS;
 
+    // commit message
+    String msg;
+
     // id of parent commit
     String parentId;
 
@@ -63,6 +66,14 @@ public class MutableCommit {
         this.commitTS = commitTS;
     }
 
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
     //--------------------------------------------------------< serialization >
 
     public InputStream toBytes() {
@@ -72,6 +83,7 @@ public class MutableCommit {
             out.write(Constants.COMMIT);
             out.writeUTF(rootNodeId);
             out.writeLong(commitTS);
+            out.writeUTF(msg == null ? "" : msg);
             out.writeUTF(parentId == null ? "" : parentId);
             out.close();
         } catch (IOException e) {

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConcurrentWriteTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConcurrentWriteTest.java?rev=1138510&r1=1138509&r2=1138510&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConcurrentWriteTest.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConcurrentWriteTest.java
Wed Jun 22 15:41:57 2011
@@ -50,9 +50,9 @@ public class ConcurrentWriteTest extends
 
         String head = mk.getHeadRevision();
         if (mk.nodeExists("/test", head)) {
-            head = mk.commit("/", "-\"test\"", head);
+            head = mk.commit("/", "-\"test\"", head, null);
         }
-        head = mk.commit("/", "+\"test\" : {\"jcr:primaryType\":\"nt:unstructured\"}", head);
+        head = mk.commit("/", "+\"test\" : {\"jcr:primaryType\":\"nt:unstructured\"}", head,
null);
 
         String oldHead = head;
         System.out.println("new HEAD: " + oldHead);
@@ -120,7 +120,7 @@ public class ConcurrentWriteTest extends
                 }
             }
             sb.append('}');
-            revId = mk.commit("/test", sb.toString(), revId);
+            revId = mk.commit("/test", sb.toString(), revId, null);
         }
     }
 }

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java?rev=1138510&r1=1138509&r2=1138510&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java
Wed Jun 22 15:41:57 2011
@@ -39,19 +39,19 @@ public class HelloWorld {
 
         if (mk.nodeExists("/test", head)) {
             // head = mk.commit(null, "- \"/test\"", head);
-            head = mk.commit("/", "-\"test\"", head);
+            head = mk.commit("/", "-\"test\"", head, null);
         }
 
-        head = mk.commit("/", "+\"foo\" : {\"bar\":{\"x\":\"100\"}}", head);
+        head = mk.commit("/", "+\"foo\" : {\"bar\":{\"x\":\"100\"}}", head, null);
         String s = mk.getNodes("/foo/bar", head);
         System.out.println(s);
 
         // head = mk.commit(null, "+\"/test\" : {\"name\":\"hello\"}", head);
-        head = mk.commit("/", "+\"test\" : {\"y\":\"true\", \"text\":[\"hello\", \"world\",
true]}", head);
+        head = mk.commit("/", "+\"test\" : {\"y\":\"true\", \"text\":[\"hello\", \"world\",
true]}", head, null);
 
         // head = mk.commit(null, "+\"/test\" : {\"name\":\"hello\"}", head);
-        head = mk.commit("/", "^\"test/x\" : false", head);
-        head = mk.commit("/", "^\"test/x\" : null", head);
+        head = mk.commit("/", "^\"test/x\" : false", head, null);
+        head = mk.commit("/", "^\"test/x\" : null", head, null);
 
         // head = mk.getHeadRevision();
         s = mk.getNodes("/test", head);
@@ -59,7 +59,7 @@ public class HelloWorld {
 
         System.out.println(s);
 
-        head = mk.commit("/", "-\"test\"", head);
+        head = mk.commit("/", "-\"test\"", head, null);
         s = mk.getNodes("/", head);
         System.out.println(s);
 



Mime
View raw message