jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r1169743 - in /jackrabbit/sandbox/microkernel/src/main: java/org/apache/jackrabbit/mk/server/ resources/org/apache/jackrabbit/mk/server/
Date Mon, 12 Sep 2011 13:46:31 GMT
Author: dpfister
Date: Mon Sep 12 13:46:31 2011
New Revision: 1169743

URL: http://svn.apache.org/viewvc?rev=1169743&view=rev
Log:
HTTP interface to microkernel
- add getLength/read/waitForCommit

Added:
    jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/getLength.html
    jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/read.html
      - copied, changed from r1169728, jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/write.html
    jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/waitForCommit.html
      - copied, changed from r1169728, jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/getRevisions.html
Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/server/MicroKernelServlet.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/server/MicroKernelServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/server/MicroKernelServlet.java?rev=1169743&r1=1169742&r2=1169743&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/server/MicroKernelServlet.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/server/MicroKernelServlet.java
Mon Sep 12 13:46:31 2011
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.mk.server;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicReference;
@@ -74,10 +75,13 @@ class MicroKernelServlet implements Serv
     static {
         COMMANDS.put("getHeadRevision", new GetHeadRevision());
         COMMANDS.put("getRevisions", new GetRevisions());
+        COMMANDS.put("waitForCommit", new WaitForCommit());
         COMMANDS.put("getJournal", new GetJournal());
         COMMANDS.put("nodeExists", new NodeExists());
         COMMANDS.put("getNodes", new GetNodes());
         COMMANDS.put("commit", new Commit());
+        COMMANDS.put("getLength", new GetLength());
+        COMMANDS.put("read", new Read());
         COMMANDS.put("write", new Write());
     }
     
@@ -102,6 +106,27 @@ class MicroKernelServlet implements Serv
         }        
     }
     
+    static class WaitForCommit implements Command {
+
+        public void execute(MicroKernel mk, Request request, Response response)
+                throws IOException, MicroKernelException {
+
+            String headRevision = mk.getHeadRevision();
+
+            String oldHead = request.getParameter("old_revision_id", headRevision);
+            long maxWaitMillis = request.getParameter("max_wait_millis", 0L);
+
+            String currentHead;
+
+            try {
+                currentHead = mk.waitForCommit(oldHead, maxWaitMillis);
+            } catch (InterruptedException e) {
+                throw new MicroKernelException(e);
+            }
+            response.getOutputStream().write(currentHead.getBytes());
+        }
+    }
+
     static class GetJournal implements Command {
 
         public void execute(MicroKernel mk, Request request, Response response)
@@ -164,6 +189,38 @@ class MicroKernelServlet implements Serv
         }        
     }
 
+    static class GetLength implements Command {
+
+        public void execute(MicroKernel mk, Request request, Response response)
+                throws IOException, MicroKernelException {
+
+            String blobId = request.getParameter("blob_id");
+            long length = mk.getLength(blobId);
+            response.getOutputStream().write(Long.toString(length).getBytes());
+        }
+    }
+
+    static class Read implements Command {
+
+        public void execute(MicroKernel mk, Request request, Response response)
+                throws IOException, MicroKernelException {
+
+            String blobId = request.getParameter("blob_id");
+            OutputStream out = response.getOutputStream();
+            byte[] buf = new byte[8192];
+            long pos = 0;
+
+            for (;;) {
+                int count = mk.read(blobId, pos, buf, 0, buf.length);
+                if (count == -1) {
+                    break;
+                }
+                out.write(buf, 0, count);
+                pos += count;
+            }
+        }
+    }
+
     static class Write implements Command {
 
         public void execute(MicroKernel mk, Request request, Response response)

Added: jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/getLength.html
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/getLength.html?rev=1169743&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/getLength.html
(added)
+++ jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/getLength.html
Mon Sep 12 13:46:31 2011
@@ -0,0 +1,27 @@
+<html>
+<head>
+<title>&micro;icroKernel prototype: getLength</title>
+<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
+<link rel="stylesheet" type="text/css" href="main.css"/>
+</head>
+
+<body>
+    <script src="header.js"></script>
+    <div class="content">
+        <h1>Blob Operations: getLength</h1>
+        <form method="POST" target="result">
+        <table class="formtable">
+            <tr>
+                <td>Blob ID</td>
+                <td><input class="text" type="text" name="blob_id" id="blob_id"
value=""></td>
+            </tr>
+            <tr><td>&nbsp;</td><td>
+            <input type="submit"><br></td></tr></table>
+        </form>
+        <p>
+            <iframe name="result" height="400" width="950" src="about:blank"></iframe>
+        </p>
+        <script src="footer.js"></script>
+    </div>
+</body>
+</html>

Copied: jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/read.html
(from r1169728, jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/write.html)
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/read.html?p2=jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/read.html&p1=jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/write.html&r1=1169728&r2=1169743&rev=1169743&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/write.html
(original)
+++ jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/read.html
Mon Sep 12 13:46:31 2011
@@ -1,6 +1,6 @@
 <html>
 <head>
-<title>&micro;icroKernel prototype: write</title>
+<title>&micro;icroKernel prototype: read</title>
 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
 <link rel="stylesheet" type="text/css" href="main.css"/>
 </head>
@@ -8,12 +8,12 @@
 <body>
     <script src="header.js"></script>
     <div class="content">
-        <h1>Blob Operations: write</h1>
-        <form method="POST" enctype="multipart/form-data" target="result">
+        <h1>Blob Operations: read</h1>
+        <form method="POST" target="result">
         <table class="formtable">
             <tr>
-                <td>File</td>
-                <td><input class="file" type="file" name="file" id="file"/></td>
+                <td>Blob ID</td>
+                <td><input class="text" type="text" name="blob_id" id="blob_id"
value=""></td>
             </tr>
             <tr><td>&nbsp;</td><td>
             <input type="submit"><br></td></tr></table>

Copied: jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/waitForCommit.html
(from r1169728, jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/getRevisions.html)
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/waitForCommit.html?p2=jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/waitForCommit.html&p1=jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/getRevisions.html&r1=1169728&r2=1169743&rev=1169743&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/getRevisions.html
(original)
+++ jackrabbit/sandbox/microkernel/src/main/resources/org/apache/jackrabbit/mk/server/waitForCommit.html
Mon Sep 12 13:46:31 2011
@@ -1,6 +1,6 @@
 <html>
 <head>
-<title>&micro;icroKernel prototype: getRevisions</title>
+<title>&micro;icroKernel prototype: waitForCommit</title>
 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
 <link rel="stylesheet" type="text/css" href="main.css"/>
 </head>
@@ -8,16 +8,16 @@
 <body>
     <script src="header.js"></script>
     <div class="content">
-        <h1>Revision Operations: getRevisions</h1>
+        <h1>Revision Operations: waitForCommit</h1>
         <form method="POST" target="result">
         <table class="formtable">
             <tr>
-                <td>Since</td>
-                <td><input class="text" type="text" name="since" id="since" value="0"></td>
+                <td>Revision ID</td>
+                <td><input class="text" type="text" name="revision_id" id="revision_id"
value=""></td>
             </tr>
             <tr>
-                <td>Max Entries</td>
-                <td><input class="text" type="text" name="max_entries" id="max_entries"
value="10"></td>
+                <td>Max Wait Millis</td>
+                <td><input class="text" type="text" name="max_wait_millis" id="max_wait_millis"
value="10000"></td>
             </tr>
             <tr><td>&nbsp;</td><td>
             <input type="submit"><br></td></tr></table>



Mime
View raw message