Return-Path: X-Original-To: apmail-jackrabbit-oak-dev-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D38609652 for ; Mon, 25 Jun 2012 12:26:55 +0000 (UTC) Received: (qmail 74503 invoked by uid 500); 25 Jun 2012 12:26:55 -0000 Delivered-To: apmail-jackrabbit-oak-dev-archive@jackrabbit.apache.org Received: (qmail 74460 invoked by uid 500); 25 Jun 2012 12:26:55 -0000 Mailing-List: contact oak-dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-dev@jackrabbit.apache.org Received: (qmail 74450 invoked by uid 99); 25 Jun 2012 12:26:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Jun 2012 12:26:55 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jukka.zitting@gmail.com designates 74.125.82.170 as permitted sender) Received: from [74.125.82.170] (HELO mail-we0-f170.google.com) (74.125.82.170) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Jun 2012 12:26:47 +0000 Received: by werm13 with SMTP id m13so5593816wer.1 for ; Mon, 25 Jun 2012 05:26:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=4RqscPYIbrU8qdAIMPbg1hMdEDem3p5oC9Btt1bKj7E=; b=Az0UelZFxsWW9LZcU+yxSmVv0uyFNzO/MkBHzPW8SJkZYV5mzh28H+dLzsPhvNdSBc UBnJROEv3UA9xVqn4zgDekwyPf6Tqb7ifnu0zILJ73UhyKTwUaSB43XtVlCAY/FO0dzJ VE9/zoOrgjbUKuKdB4VlfLURY/l7QymUGghLS2jPsQRq4gQonQAURg87QXYx5ZSTTRXw VtikLtcrkEuUHiGY0EmSH/bnih+V/q5eCSj4tOV55KqE0XK211mBkN8Z/cWQJQp8/QAY /2SylfrL84/RiTapfCGLz8rHhobdj58j1dcO7PIqQwIYVFVBcNmGsJySvjPSO5RDQXfk WK0w== Received: by 10.216.213.143 with SMTP id a15mr6663017wep.156.1340627185458; Mon, 25 Jun 2012 05:26:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.180.85.167 with HTTP; Mon, 25 Jun 2012 05:26:05 -0700 (PDT) From: Jukka Zitting Date: Mon, 25 Jun 2012 14:26:05 +0200 Message-ID: Subject: Native HTTP bindings for Oak To: Oak devs Content-Type: text/plain; charset=ISO-8859-1 Hi, As suggested in OAK-104 [1] and discussed briefly before, I think it would be useful for Oak to have a native HTTP binding that allows remote clients to talk directly with oak-core without having to go through the JCR layer. The main benefit of such a lower-level HTTP binding is that it can better leverage the "everything is (JSON) content" nature of Oak internals than a higher-level layer like our existing WebDAV(ex) components that only assume a generic JCR content repository. This makes the binding much more straightforward and probably helps avoid performance or scalability bottlenecks down the line. It also makes it easier to support a wider range of functionality without having to add custom integration code for all features. For example, instead of accessing separate namespace registration code, a client could register a new namespace simply by posting it as a normal content modification to the appropriate place in the content tree, like this: $ curl -d foo=http://foo.example.com/ns http://localhost:8080/content/jcr:system/jcr:namespaces Unlike a MicroKernel remoting layer, the Oak HTTP binding would still have all the commit validation and access control logic in place, so one couldn't use it to bypass the rules that govern more traditional JCR-based access. I'm not yet sure about what the binding should look like in detail, but my general idea is to follow JSOP protocol ideas [2] and try to keep things as simple and easy as possible for clients like JavaScript libraries [3] and command line tools like curl. The initial draft code I committed just recently to the new oak-http component uses a basic URL to Node mapping and a simple JSON / binary JSON rendering based on the contents of the HTTP Accept header. It would be nice to support different kinds of content renderings and also to allow similar content renderings to be POSTed or PUT to the server. The binding should also accept basic HTML form POSTs with the application/x-www-form-urlencoded media type. By default the HTTP binding could simply use a fresh new session for each HTTP request, but it should be possible for a client to request a longer-lived session for more complex content modifications (import, batch jobs, etc.) or for getting a stable snapshot for larger reads (export, query, etc.) that shouldn't change while reading. I was thinking of handling such cases by allowing the client to generate such a session with a specific POST request that responds with a redirect to a temporary session URL that exposes the normal content tree as seen through that session. We'd use a lease mechanism to control the lifetime of such server-side sessions. As an example, something like the following interaction could be used to acquire a new session (with a initial lifetime of one hour, lease=3600), make some changes to the content tree within that session, and finally commit those changes and release the session (lease=0). $ curl -d lease=3600 http://localhost:8080/session http://localhost:8080/session/a9c49810bebf11e1afa70800200c9a66 $ curl -d bar=baz http://localhost:8080/session/a9c49810bebf11e1afa70800200c9a66/foo {"bar":"baz"} $ curl -d save=true -d lease=0 http://localhost:8080/session/a9c49810bebf11e1afa70800200c9a66 [1] https://issues.apache.org/jira/browse/OAK-104 [2] http://wiki.apache.org/jackrabbit/Jsop [3] https://issues.apache.org/jira/browse/OAK-103 BR, Jukka Zitting