jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1329867 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: core/KernelContentSession.java kernel/KernelNodeStore.java kernel/KernelRoot.java
Date Tue, 24 Apr 2012 17:15:47 GMT
Author: mduerig
Date: Tue Apr 24 17:15:46 2012
New Revision: 1329867

URL: http://svn.apache.org/viewvc?rev=1329867&view=rev
Log:
OAK-18: Define Oak API 
- tentative means for saving to node store

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentSession.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelRoot.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentSession.java?rev=1329867&r1=1329866&r2=1329867&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentSession.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentSession.java
Tue Apr 24 17:15:46 2012
@@ -18,12 +18,12 @@ package org.apache.jackrabbit.oak.core;
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.oak.api.AuthInfo;
-import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.api.QueryEngine;
+import org.apache.jackrabbit.oak.api.Root;
+import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
 import org.apache.jackrabbit.oak.kernel.KernelRoot;
-import org.apache.jackrabbit.oak.kernel.NodeStore;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,12 +41,12 @@ class KernelContentSession implements Co
 
     private final SimpleCredentials credentials;
     private final String workspaceName;
-    private final NodeStore store;
+    private final KernelNodeStore store;
     private final QueryEngine queryEngine;
     private final CoreValueFactory valueFactory;
 
     public KernelContentSession(SimpleCredentials credentials, String workspaceName,
-            NodeStore store, QueryEngine queryEngine, CoreValueFactory valueFactory) {
+            KernelNodeStore store, QueryEngine queryEngine, CoreValueFactory valueFactory)
{
 
         this.credentials = credentials;
         this.workspaceName = workspaceName;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java?rev=1329867&r1=1329866&r2=1329867&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
Tue Apr 24 17:15:46 2012
@@ -44,4 +44,16 @@ public class KernelNodeStore implements 
         throw new UnsupportedOperationException(); // TODO
     }
 
+    // TODO clarify write access to store. Expose through interface
+    void save(KernelRoot root, NodeState base) {
+        if (!(base instanceof KernelNodeState)) {
+            throw new IllegalArgumentException("Base state is not from this store");
+        }
+
+        KernelNodeState baseState = (KernelNodeState) base;
+        String targetPath = baseState.getPath();
+        String targetRevision = baseState.getRevision();
+        String jsop = root.getChanges();
+        kernel.commit(targetPath, jsop, targetRevision, null);
+    }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelRoot.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelRoot.java?rev=1329867&r1=1329866&r2=1329867&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelRoot.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelRoot.java
Tue Apr 24 17:15:46 2012
@@ -18,12 +18,11 @@
  */
 package org.apache.jackrabbit.oak.kernel;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.api.MicroKernelException;
 import org.apache.jackrabbit.mk.json.JsonBuilder;
+import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.Root;
-import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.kernel.KernelTree.Listener;
 
@@ -48,11 +47,11 @@ import static org.apache.jackrabbit.mk.u
  */
 public class KernelRoot implements Root {
 
-    private final NodeStore store;
+    private final KernelNodeStore store;
     private final String workspaceName;
 
     /** Base node state of this tree */
-    private KernelNodeState base;
+    private NodeState base;
 
     /** Root state of this tree */
     private KernelTree root;
@@ -60,10 +59,10 @@ public class KernelRoot implements Root 
     /** Log of changes to this tree */
     private ChangeLog changeLog = new ChangeLog();
 
-    public KernelRoot(NodeStore store, String workspaceName) {
+    public KernelRoot(KernelNodeStore store, String workspaceName) {
         this.store = store;
         this.workspaceName = workspaceName;
-        this.base = (KernelNodeState) store.getRoot().getChildNode(workspaceName);  // FIXME
don't cast to implementation
+        this.base = store.getRoot().getChildNode(workspaceName);
         this.root = new KernelTree(base, changeLog);
     }
 
@@ -100,19 +99,15 @@ public class KernelRoot implements Root 
 
     @Override
     public void refresh() {
-        base = (KernelNodeState) store.getRoot().getChildNode(workspaceName);  // FIXME don't
cast to implementation
+        base = store.getRoot().getChildNode(workspaceName);
     }
 
     @Override
     public void commit() throws CommitFailedException {
-        MicroKernel kernel = ((KernelNodeStore) store).kernel;  // FIXME don't cast to implementation
         try {
-            String targetPath = base.getPath();
-            String targetRevision = base.getRevision();
-            kernel.commit(targetPath, changeLog.toJsop(), targetRevision, null);
-
+            store.save(this, base);
             changeLog = new ChangeLog();
-            base = (KernelNodeState) store.getRoot().getChildNode(workspaceName);  // FIXME
don't cast to implementation
+            base = store.getRoot().getChildNode(workspaceName);
             root = new KernelTree(base, changeLog);
         } catch (MicroKernelException e) {
             throw new CommitFailedException(e);
@@ -121,14 +116,17 @@ public class KernelRoot implements Root 
 
 
     //------------------------------------------------------------< internal >---
+
     /**
-     * Return the base node state of this tree
-     * @return base node state
+     * JSOP representation of the changes done to this tree
+     * @return  changes in JSOP representation
      */
-    NodeState getBaseNodeState() {
-        return base;
+    String getChanges() {
+        return changeLog.toJsop();
     }
 
+    //------------------------------------------------------------< private >---
+
     /**
      * Get a transient node state for the node identified by
      * {@code path}



Mime
View raw message