From commits-return-12187-apmail-jackrabbit-commits-archive=jackrabbit.apache.org@jackrabbit.apache.org Thu Oct 6 12:56:10 2011 Return-Path: X-Original-To: apmail-jackrabbit-commits-archive@www.apache.org Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 77DD47BF2 for ; Thu, 6 Oct 2011 12:56:10 +0000 (UTC) Received: (qmail 93332 invoked by uid 500); 6 Oct 2011 12:56:10 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 93252 invoked by uid 500); 6 Oct 2011 12:56:10 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 93245 invoked by uid 99); 6 Oct 2011 12:56:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Oct 2011 12:56:10 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Oct 2011 12:56:07 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id DC05723889E3; Thu, 6 Oct 2011 12:55:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1179606 - /jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java Date: Thu, 06 Oct 2011 12:55:45 -0000 To: commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111006125545.DC05723889E3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jukka Date: Thu Oct 6 12:55:45 2011 New Revision: 1179606 URL: http://svn.apache.org/viewvc?rev=1179606&view=rev Log: JCR-3005: Make it possible to get multiple nodes in one call via davex Allow also POST requests for the multi read feature. Add documentation. Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java?rev=1179606&r1=1179605&r2=1179606&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java Thu Oct 6 12:55:45 2011 @@ -66,6 +66,7 @@ import org.slf4j.LoggerFactory; * that provides improved * * functionality and supports cross workspace copy and cloning. @@ -128,6 +129,24 @@ import org.slf4j.LoggerFactory; * JSON value must not have any trailing ".0" removed. * * + *

Multi Read

+ *

+ * Since Jackrabbit 2.3.1 it is also possible to request multiple subtrees + * in a single request. This is done by sending a GET or a POST request to + * a workspace request and specifying the paths of the selected subtrees + * as ":path" parameters of the request. The response is a JSON object + * whose "nodes" property contains all the selected nodes keyed by + * path. Missing nodes are not included in the response. Each included + * node is serialized as defined above for batch read. + * The configured default subtree depth can be overridden by specifying the + * optional ":depth" parameter. + *

+ * Example: + *

+ * $ curl 'http://localhost:8080/server/default?:path=/node1&:path=/node2'
+ * {"nodes":{"/node1":{...},"/node2":{...}}}
+ * 
+ * *

Batch Write

* * The complete SPI Batch is sent to the server in a single request, currently a @@ -324,7 +343,9 @@ public abstract class JcrRemotingServlet @Override protected void doPost(WebdavRequest webdavRequest, WebdavResponse webdavResponse, DavResource davResource) throws IOException, DavException { - if (canHandle(DavMethods.DAV_POST, webdavRequest, davResource)) { + if (doGetMultiple(webdavRequest, webdavResponse, davResource)) { + // request was handled by the multi-get handler + } else if (canHandle(DavMethods.DAV_POST, webdavRequest, davResource)) { // special remoting request: the defined parameters are exclusive // and cannot be combined. Session session = getRepositorySession(webdavRequest); @@ -557,9 +578,22 @@ public abstract class JcrRemotingServlet return (File) servletCtx.getAttribute(ATTR_TMP_DIRECTORY); } + /** + * Conditionally processes a multi read request. + * + * @since Apache Jackrabbit 2.3.1 + * @param request request object + * @param response response object + * @param resource resource object + * @return true if this was a multi read request, + * false otherwise + * @throws IOException if the response could not be written + * @throws DavException if another error occurred + */ protected boolean doGetMultiple( WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException { + // Check if this is a multi-GET request String[] paths = request.getParameterValues(PARAM_PATH); if (paths == null || resource.getLocator().getWorkspaceName() == null @@ -567,7 +601,7 @@ public abstract class JcrRemotingServlet return false; } - // Get the depth + // Get the depth (TODO: support depth per node type) int depth = brConfig.getDefaultDepth(); String depthParam = request.getParameter(PARAM_DEPTH); if (depthParam != null) { @@ -600,6 +634,7 @@ public abstract class JcrRemotingServlet } } + // Send the response response.setContentType("text/plain;charset=utf-8"); response.setStatus(DavServletResponse.SC_OK); try {