jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1653478 - in /jackrabbit/site/live/oak/docs/oak-mongo-js: index.html oak-mongo.js.html oak.html
Date Wed, 21 Jan 2015 11:00:36 GMT
Author: mreutegg
Date: Wed Jan 21 11:00:35 2015
New Revision: 1653478

URL: http://svn.apache.org/r1653478
Log:
OAK-301: Document Oak

Modified:
    jackrabbit/site/live/oak/docs/oak-mongo-js/index.html
    jackrabbit/site/live/oak/docs/oak-mongo-js/oak-mongo.js.html
    jackrabbit/site/live/oak/docs/oak-mongo-js/oak.html

Modified: jackrabbit/site/live/oak/docs/oak-mongo-js/index.html
URL: http://svn.apache.org/viewvc/jackrabbit/site/live/oak/docs/oak-mongo-js/index.html?rev=1653478&r1=1653477&r2=1653478&view=diff
==============================================================================
--- jackrabbit/site/live/oak/docs/oak-mongo-js/index.html (original)
+++ jackrabbit/site/live/oak/docs/oak-mongo-js/index.html Wed Jan 21 11:00:35 2015
@@ -54,7 +54,7 @@
 <br clear="both">
 
 <footer>
-    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.3-dev</a>
on Thu Jan 15 2015 15:27:35 GMT+0100 (CET)
+    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.3-dev</a>
on Wed Jan 21 2015 11:56:41 GMT+0100 (CET)
 </footer>
 
 <script> prettyPrint(); </script>

Modified: jackrabbit/site/live/oak/docs/oak-mongo-js/oak-mongo.js.html
URL: http://svn.apache.org/viewvc/jackrabbit/site/live/oak/docs/oak-mongo-js/oak-mongo.js.html?rev=1653478&r1=1653477&r2=1653478&view=diff
==============================================================================
--- jackrabbit/site/live/oak/docs/oak-mongo-js/oak-mongo.js.html (original)
+++ jackrabbit/site/live/oak/docs/oak-mongo-js/oak-mongo.js.html Wed Jan 21 11:00:35 2015
@@ -445,7 +445,125 @@ var oak = (function(global){
         return checkOrFixHistory(path, true, verbose);
     };
 
+    /**
+     * Returns the commit value entry for the change with the given revision.
+     * *
+     * @memberof oak
+     * @method getCommitValue
+     * @param {string} path the path of a document.
+     * @param {string} revision the revision of a change on the document.
+     * @returns {object} the commit entry for the given revision or null if
+     *          there is none.
+     */
+    api.getCommitValue = function(path, revision) {
+        var doc = this.findOne(path);
+        if (!doc) {
+            return null;
+        }
+        if (revision === undefined) {
+            print("No revision specified");
+        }
+        // check _revisions
+        var entry = getRevisionEntry(doc, path, revision);
+        if (entry) {
+            return entry;
+        }
+
+        // get commit root
+        entry = getEntry(doc, "_commitRoot", revision);
+        if (!entry) {
+            var prev = findPreviousDocument(path, "_commitRoot", revision);
+            if (prev) {
+                entry = getEntry(prev, "_commitRoot", revision);
+            }
+        }
+        if (!entry) {
+            return null;
+        }
+        var commitRootPath = getCommitRootPath(path, parseInt(entry[revision]));
+        doc = this.findOne(commitRootPath);
+        if (!doc) {
+            return null;
+        }
+        return getRevisionEntry(doc, commitRootPath, revision);
+    };
+    
     //~--------------------------------------------------&lt; internal >
+    
+    var getRevisionEntry = function (doc, path, revision) {
+        var entry = getEntry(doc, "_revisions", revision);
+        if (entry) {
+            return entry;
+        }
+        var prev = findPreviousDocument(path, "_revisions", revision);
+        if (prev) {
+            entry = getEntry(prev, "_revisions", revision);
+            if (entry) {
+                return entry;
+            }
+        }
+    };
+    
+    var getCommitRootPath = function(path, depth) {
+        if (depth == 0) {
+            return "/";
+        }
+        var idx = 0;
+        while (depth-- > 0 && idx != -1) {
+            idx = path.indexOf("/", idx + 1);
+        }
+        if (idx == -1) {
+            idx = path.length;
+        }
+        return path.substring(0, idx);
+    };
+    
+    var getEntry = function(doc, name, revision) {
+        var result = null;
+        if (doc && doc[name] && doc[name][revision]) {
+            result = {};
+            result[revision] = doc[name][revision];
+        }
+        return result;
+    };
+    
+    var findPreviousDocument = function(path, name, revision) {
+        var rev = new Revision(revision);
+        if (path === undefined) {
+            print("No path specified");
+            return;
+        }
+        if (path.length > 165) {
+            print("Path too long");
+            return;
+        }
+        var doc = api.findOne(path);
+        if (!doc) {
+            return null;
+        }
+        var result = null;
+        forEachPrev(doc, function traverse(d, high, low, height) {
+            var highRev = new Revision(high);
+            var lowRev = new Revision(low);
+            if (highRev.getClusterId() != rev.getClusterId() 
+                    || lowRev.isNewerThan(rev) 
+                    || rev.isNewerThan(highRev)) {
+                return;
+            }
+            
+            var id = prevDocIdFor(path, high, height);
+
+            var prev = db.nodes.findOne({_id: id });
+            if (prev) {
+                if (prev[name] && prev[name][revision]) {
+                    result = prev;
+                } else {
+                    forEachPrev(prev, traverse);
+                }
+            }
+        });
+        return result;
+    };
 
     var checkOrFixHistory = function(path, fix, verbose) {
         if (path === undefined) {
@@ -481,12 +599,7 @@ var oak = (function(global){
 
 
         forEachPrev(doc, function traverse(d, high, low, height) {
-            var p = "p" + path;
-            if (p.charAt(p.length - 1) != "/") {
-                p += "/";
-            }
-            p += high + "/" + height;
-            var id = (pathDepth(path) + 2) + ":" + p;
+            var id = prevDocIdFor(path, high, height);
             var prev = db.nodes.findOne({_id: id });
             if (prev) {
                 if (result.prevDocs) {
@@ -632,6 +745,15 @@ var oak = (function(global){
         }
         return depth;
     };
+    
+    var prevDocIdFor = function(path, high, height) {
+        var p = "p" + path;
+        if (p.charAt(p.length - 1) != "/") {
+            p += "/";
+        }
+        p += high + "/" + height;
+        return (pathDepth(path) + 2) + ":" + p;
+    };
 
     var pathFilter = function (depth, prefix){
         return new RegExp("^"+ depth + ":" + prefix);
@@ -674,7 +796,7 @@ var oak = (function(global){
 <br clear="both">
 
 <footer>
-    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.3-dev</a>
on Thu Jan 15 2015 15:27:35 GMT+0100 (CET)
+    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.3-dev</a>
on Wed Jan 21 2015 11:56:41 GMT+0100 (CET)
 </footer>
 
 <script> prettyPrint(); </script>

Modified: jackrabbit/site/live/oak/docs/oak-mongo-js/oak.html
URL: http://svn.apache.org/viewvc/jackrabbit/site/live/oak/docs/oak-mongo-js/oak.html?rev=1653478&r1=1653477&r2=1653478&view=diff
==============================================================================
--- jackrabbit/site/live/oak/docs/oak-mongo-js/oak.html (original)
+++ jackrabbit/site/live/oak/docs/oak-mongo-js/oak.html Wed Jan 21 11:00:35 2015
@@ -1613,6 +1613,170 @@ below given path or total size taken by
         
             
 <dt>
+    <h4 class="name" id="getCommitValue"><span class="type-signature">&lt;static>
</span>getCommitValue<span class="signature">(path, revision)</span><span
class="type-signature"> &rarr; {object}</span></h4>
+    
+    
+</dt>
+<dd>
+    
+    
+    <div class="description">
+        Returns the commit value entry for the change with the given revision.
+*
+    </div>
+    
+
+    
+    
+    
+    
+    
+        <h5>Parameters:</h5>
+        
+
+<table class="params">
+    <thead>
+	<tr>
+		
+		<th>Name</th>
+		
+		
+		<th>Type</th>
+		
+		
+		
+		
+		
+		<th class="last">Description</th>
+	</tr>
+	</thead>
+	
+	<tbody>
+	
+	
+        <tr>
+            
+                <td class="name"><code>path</code></td>
+            
+            
+            <td class="type">
+            
+                
+<span class="param-type">string</span>
+
+
+            
+            </td>
+            
+            
+            
+            
+            
+            <td class="description last">the path of a document.</td>
+        </tr>
+	
+	
+	
+        <tr>
+            
+                <td class="name"><code>revision</code></td>
+            
+            
+            <td class="type">
+            
+                
+<span class="param-type">string</span>
+
+
+            
+            </td>
+            
+            
+            
+            
+            
+            <td class="description last">the revision of a change on the document.</td>
+        </tr>
+	
+	
+	</tbody>
+</table>
+    
+    
+    
+<dl class="details">
+    
+        
+    
+    
+    
+
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    <dt class="tag-source">Source:</dt>
+    <dd class="tag-source"><ul class="dummy"><li>
+        <a href="oak-mongo.js.html">oak-mongo.js</a>, <a href="oak-mongo.js.html#line421">line
421</a>
+    </li></ul></dd>
+    
+    
+    
+    
+    
+    
+    
+</dl>
+
+    
+    
+
+    
+
+    
+    
+    
+    
+    
+    <h5>Returns:</h5>
+    
+            
+<div class="param-desc">
+    the commit entry for the given revision or null if
+         there is none.
+</div>
+
+
+
+<dl>
+	<dt>
+		Type
+	</dt>
+	<dd>
+		
+<span class="param-type">object</span>
+
+
+	</dd>
+</dl>
+
+        
+    
+    
+</dd>
+
+        
+            
+<dt>
     <h4 class="name" id="indexStats"><span class="type-signature">&lt;static>
</span>indexStats<span class="signature">()</span><span class="type-signature">
&rarr; {Array}</span></h4>
     
     
@@ -2464,7 +2628,7 @@ is inactive.
 <br clear="both">
 
 <footer>
-    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.3-dev</a>
on Thu Jan 15 2015 15:27:35 GMT+0100 (CET)
+    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.3-dev</a>
on Wed Jan 21 2015 11:56:41 GMT+0100 (CET)
 </footer>
 
 <script> prettyPrint(); </script>



Mime
View raw message