Author: angela
Date: Thu Feb 12 12:59:22 2009
New Revision: 743713
URL: http://svn.apache.org/viewvc?rev=743713&view=rev
Log:
- JCR-1958: Enhanced JCR remoting (work in progress)
> examples
> short overview
Added:
jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/images/asf-logo.png (with props)
jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/
jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/footer.jsp (with props)
jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/header.jsp (with props)
jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/index.jsp (with props)
jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/json.js
jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/read.jsp (with props)
jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/read_batch.jsp (with props)
jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write.jsp (with props)
jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write_batch.jsp (with props)
jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write_simple.jsp (with props)
Modified:
jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml
jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/css/default.css
jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/webdav-remoting.jsp
Modified: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml?rev=743713&r1=743712&r2=743713&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml (original)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml Thu Feb 12 12:59:22 2009
@@ -263,7 +263,7 @@
<servlet>
<servlet-name>JCRWebdavServer</servlet-name>
<description>
- The webdav servlet that connects HTTP request to the repository.
+ The servlet used to remote JCR calls over HTTP.
</description>
<servlet-class>org.apache.jackrabbit.j2ee.JcrRemotingServlet</servlet-class>
<init-param>
Modified: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/css/default.css
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/css/default.css?rev=743713&r1=743712&r2=743713&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/css/default.css (original)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/css/default.css Thu Feb 12 12:59:22 2009
@@ -16,7 +16,7 @@
*/
body { font-family: Verdana, Helvetica, Arial, sans-serif;
- font-size: small;
+ font-size: small; color: #000000;
background-color: #e0e0e0;
margin: 1em 100px 1em 100px;
padding: 0; }
@@ -76,6 +76,9 @@
td { font-size: small; }
+pre.code { font-family: monospace; font-size: small;
+ padding: 25px; }
+
/* FOOTER */
#footer { clear: both;
Added: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/images/asf-logo.png
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/images/asf-logo.png?rev=743713&view=auto
==============================================================================
Binary file - no diff available.
Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/images/asf-logo.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Added: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/footer.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/footer.jsp?rev=743713&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/footer.jsp (added)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/footer.jsp Thu Feb 12 12:59:22 2009
@@ -0,0 +1,25 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%>
+ <div id="footer">
+ <p>
+ Powered by
+ <a href="http://jackrabbit.apache.org/">Apache Jackrabbit</a>.
+ </p>
+ </div>
+ </div>
+ </body>
+</html>
Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/footer.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/footer.jsp
------------------------------------------------------------------------------
svn:keywords = author date id revision
Added: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/header.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/header.jsp?rev=743713&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/header.jsp (added)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/header.jsp Thu Feb 12 12:59:22 2009
@@ -0,0 +1,64 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%>
+<%@page import="org.apache.jackrabbit.util.Text"%>
+<%
+String context = Text.encodeIllegalXMLCharacters(request.getContextPath());
+%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+ <head>
+ <title>JCR Remoting Server</title>
+ <link rel="stylesheet"
+ href="<%= context %>/css/default.css"
+ type="text/css"/>
+ <link rel="shortcut icon"
+ href="<%= context %>/images/favicon.ico"
+ type="image/vnd.microsoft.icon" />
+ </head>
+ <body>
+ <div id="page">
+ <div id="banner">
+ <p id="jcr">
+ <a href="<%= context %>/">
+ <img src="<%= context %>/images/jlogo.gif" alt="Apache Jackrabbit"/>
+ </a>
+ </p>
+ <p id="asf">
+ <a href="http://www.apache.org/">
+ <img src="<%= context %>/images/asf-logo.png" alt="Apache Software Foundation"/>
+ </a>
+ </p>
+ </div>
+ <div id="navigation">
+ <ul>
+ <li>JCR Remoting Server
+ <ul>
+ <li><a href="<%= context %>/remoting/index.jsp">Introduction</a></li>
+ <li><a href="<%= context %>/remoting/read.jsp">Read</a></li>
+ <li><a href="<%= context %>/remoting/write.jsp">Write</a></li>
+ </ul>
+ </li>
+ <li>Examples
+ <ul>
+ <li><a href="<%= context %>/remoting/read_batch.jsp">Batch Read</a></li>
+ <li><a href="<%= context %>/remoting/write_batch.jsp">Batch Write</a></li>
+ <li><a href="<%= context %>/remoting/write_simple.jsp">Simple Write</a></li>
+ </ul>
+ </li>
+ </ul>
+ </div>
Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/header.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/header.jsp
------------------------------------------------------------------------------
svn:keywords = author date id revision
Added: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/index.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/index.jsp?rev=743713&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/index.jsp (added)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/index.jsp Thu Feb 12 12:59:22 2009
@@ -0,0 +1,38 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%><%
+%><jsp:include page="header.jsp"/>
+ <div id="content">
+ <h2>JCR Remoting Server - Introduction</h2>
+ <p>Ths section shortly overviews the batch read/write extensions
+ added to the JCR remoting feature.
+ <ul>
+ <li>Read</li>
+ <ul>
+ <li><a href="read.jsp#default_read">Default Reading</a></li>
+ <li><a href="read.jsp#batch_read">Batch Read</a></li>
+ </ul>
+ <li>Write</li>
+ <ul>
+ <li><a href="write.jsp#default_write">Default Writing</a></li>
+ <li><a href="write.jsp#batch_write">Batch Write</a></li>
+ <li><a href="write.jsp#simple_write">Direct Content Editing</a></li>
+ </ul>
+ </ul>
+ </p>
+ <p>Some principals are demonstrated in the corresponding example section.</p>
+ </div>
+<jsp:include page="footer.jsp"/>
\ No newline at end of file
Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/index.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/index.jsp
------------------------------------------------------------------------------
svn:keywords = author date id revision
Added: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/json.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/json.js?rev=743713&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/json.js (added)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/json.js Thu Feb 12 12:59:22 2009
@@ -0,0 +1,222 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+function getXMLHttpRequest(url, method, headers, params) {
+ var xmlhttp = null;
+ if (window.XMLHttpRequest) {
+ // code for all new browsers
+ xmlhttp = new XMLHttpRequest();
+ } else if (window.ActiveXObject) {
+ // code for IE
+ try {
+ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
+ } catch (e) {
+ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ }
+ if (xmlhttp) {
+ if (!method) {
+ method = "GET";
+ }
+ xmlhttp.open(method, url, false);
+ if (headers) {
+ for (var hdr in headers) {
+ xmlhttp.setRequestHeader(hdr, headers[hdr]);
+ }
+ }
+ xmlhttp.send(params);
+ return xmlhttp;
+ } else {
+ alert("Your browser does not support XMLHTTP.");
+ return null;
+ }
+}
+
+var JsonFormatter = null;
+(function() {
+
+ JsonFormatter = new Object();
+ JsonFormatter.clear = false;
+
+ JsonFormatter.tree = function(jsonObj, baseHref) {
+ if (!jsonObj) {
+ return "";
+ }
+ var indentionLevel = 0;
+ return JsonFormatter.objectTree("", jsonObj, indentionLevel, baseHref);
+ }
+
+ JsonFormatter.format = function(jsonObj, clearSpecial) {
+ if (!jsonObj) {
+ return "";
+ }
+ var indentionLevel = 0;
+ clear = clearSpecial;
+ return JsonFormatter.object(jsonObj, indentionLevel);
+ }
+
+ JsonFormatter.addLineBreak = function(str) {
+ return str += "<br>";
+ }
+
+ JsonFormatter.addIndention = function(str, indention, indStr) {
+ for (var i = 0; i < indention; i++) {
+ str += indStr;
+ }
+ return str;
+ }
+
+ JsonFormatter.object = function(value, indentionLevel) {
+ if (value instanceof Array) {
+ return JsonFormatter.array(value, indentionLevel);
+ }
+
+ var str = "{";
+ str = JsonFormatter.addLineBreak(str);
+ indentionLevel++;
+ var delim = false;
+
+ for (var i in value) {
+ var v = value[i];
+ if (clear && i.charAt(0) == ':') {
+ // skip special prop.
+ // TODO: evaluate and add to display info.
+ } else {
+ var fnctn = JsonFormatter[typeof v];
+ if (fnctn) {
+ v = fnctn(v, indentionLevel);
+ if (typeof v == 'string') {
+ if (delim) {
+ str += ",";
+ str = JsonFormatter.addLineBreak(str);
+ }
+ str = JsonFormatter.addIndention(str, indentionLevel, "\t");
+ str += JsonFormatter.string(i) + ' : ' + v;
+ delim = true;
+ }
+ }
+ }
+ }
+ indentionLevel--;
+ str = JsonFormatter.addLineBreak(str);
+ str = JsonFormatter.addIndention(str, indentionLevel, "\t");
+ str += "}";
+ return str;
+ }
+
+ JsonFormatter.array = function(value, indentionLevel) {
+ var str = "[";
+ var delim = false;
+ for (var i in value) {
+ var arrVal = value[i];
+ var fnctn = JsonFormatter[typeof arrVal];
+ if (fnctn) {
+ arrVal = fnctn(arrVal);
+ if (delim) {
+ str += ", ";
+ }
+ str += arrVal;
+ delim = true;
+ }
+ }
+ str += "]";
+ return str;
+ }
+
+ JsonFormatter.boolean = function(value, indentionLevel) {
+ return String(value);
+ }
+
+ JsonFormatter.string = function(value, indentionLevel) {
+ return '"' + value + '"';
+
+ }
+
+ JsonFormatter.number = function(value, indentionLevel) {
+ return String(value);
+ }
+
+ JsonFormatter.extractPropertyType = function(key, value) {
+ if (key == "::NodeIteratorSize") {
+ return null;
+ } else if (key.charAt(0) == ':' && typeof value == 'string') {
+ return value;
+ } else {
+ return null;
+ }
+ }
+
+ JsonFormatter.buildKey = function(key, propType, href) {
+ var keyStr = key;
+ if (propType) {
+ var href = "javascript:alert('PropertyType = " + propType + "');";
+ keyStr = "<a href=\"" +href+ "\" alt=\""+ propType +"\" >" + key + "</a>";
+ } else if (key.charAt(0) == ':') {
+ // binary
+ var propname = key.substring(1, key.length);
+ var binHref = href + "/" + propname;
+ keyStr = "<a href=\"" +binHref+ "\" alt=\"Binary\" >" + propname + "</a>";
+ }
+ return keyStr;
+ }
+
+ JsonFormatter.objectTree = function(key, value, indentionLevel, href) {
+ var str = "+ " + key; // + node-name
+ if (href && href.charAt(href.length - 1) == '/') {
+ href += key;
+ } else {
+ href += "/" + key;
+ }
+
+ indentionLevel++;
+ var propType;
+ var childSize;
+ var delim = false;
+
+ for (var i in value) {
+ var v = value[i];
+ var pt = JsonFormatter.extractPropertyType(i, v);
+ if (pt) {
+ propType = pt;
+ continue;
+ } else if (i == "::NodeIteratorSize") {
+ continue;
+ }
+ str = JsonFormatter.addLineBreak(str);
+ str = JsonFormatter.addIndention(str, indentionLevel, " ");
+ if (v instanceof Array) {
+ // value array - propname
+ var key = JsonFormatter.buildKey(i, propType, href);
+ propType = null;
+ str += "- " + key + ' = ' + JsonFormatter.array(v, indentionLevel);
+ } else if (v instanceof Object) {
+ str += JsonFormatter.objectTree(i, v, indentionLevel, href);
+ } else {
+ // simple value - propname
+ var fnctn = JsonFormatter[typeof v];
+ if (fnctn) {
+ v = fnctn(v, indentionLevel);
+ var key = JsonFormatter.buildKey(i, propType, href);
+ propType = null;
+ str += "- " + key + ' = ' + v;
+ }
+ }
+ }
+ indentionLevel--;
+ return str;
+ }
+})();
Added: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/read.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/read.jsp?rev=743713&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/read.jsp (added)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/read.jsp Thu Feb 12 12:59:22 2009
@@ -0,0 +1,65 @@
+<%@ page import="java.net.URI" %>
+<%@ page import="org.apache.jackrabbit.j2ee.JcrRemotingServlet" %>
+<%@ page import="org.apache.jackrabbit.util.Text" %>
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%><%
+
+URI uri = new URI(request.getRequestURL().toString());
+String href =
+ uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort()
+ + request.getContextPath()
+ + JcrRemotingServlet.getPathPrefix(pageContext.getServletContext());
+href = Text.encodeIllegalXMLCharacters(href);
+href += "/default/jcr:root";
+
+%><jsp:include page="header.jsp"/>
+<div id="content">
+ <h2>Read</h2>
+ <h3><a name="default_read">Default Reading</a></h3>
+ <p>Reading remotely from the repository generally follows the rules described in
+ <a href="http://jackrabbit.apache.org/JCR_Webdav_Protocol.doc">JCR_Webdav_Protocol.zip</a>.
+ </p>
+ <h3><a name="batch_read">Batch Read</a></h3>
+ <p>Batch read is triggered by adding a <b>'.json'</b> extension to the resource
+ href. Optionally the client may explicitely specify the desired batch
+ read depth by appending <b>'.depth.json'</b> extension. If no json extension
+ is present the GET request is processed by applied the default
+ remoting rules.
+ </p>
+ <p>The response to a batch read request contains a plain text representing
+ a JSON object. Its member either represent nodes or properties.
+ <ul>
+ <li>The name element of the Item path is added as key</li>
+ <li>The value of a Node entry is a JSON object.</li>
+ <li>The value of a Property entry is either a JSON array or a simple JSON value.</li>
+ </ul>
+ </p>
+ <p>In order to cope with property types that cannot be expressed with JSON
+ a couple of special rules are defined:
+ <ul>
+ <li>Binary properties: The key gets a leading ":", the value represents the
+ length of the property. In order to retrieve the binary value, the
+ client must follow the default rules (see above).</li>
+ <li>Date, Name, Path and Reference properties: The type information is passed with a separate JSON pair.</li>
+ <li>The value of a Property entry is either a JSON array or a simple JSON value.</li>
+ </ul>
+ </p>
+ See <a href="read_batch.jsp">Example: Batch Write</a> for a demostration of
+ the batch read functionality.
+ </p>
+</div>
+<jsp:include page="footer.jsp"/>
\ No newline at end of file
Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/read.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/read.jsp
------------------------------------------------------------------------------
svn:keywords = author date id revision
Added: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/read_batch.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/read_batch.jsp?rev=743713&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/read_batch.jsp (added)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/read_batch.jsp Thu Feb 12 12:59:22 2009
@@ -0,0 +1,104 @@
+<%@ page import="java.net.URI" %>
+<%@ page import="org.apache.jackrabbit.j2ee.JcrRemotingServlet" %>
+<%@ page import="org.apache.jackrabbit.util.Text" %>
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%><%
+
+URI uri = new URI(request.getRequestURL().toString());
+String href =
+ uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort()
+ + request.getContextPath()
+ + JcrRemotingServlet.getPathPrefix(pageContext.getServletContext());
+href = Text.encodeIllegalXMLCharacters(href);
+href += "/default/jcr:root";
+
+%><jsp:include page="header.jsp"/>
+<script src="json.js"></script>
+<script language="javascript">
+ function batchRead() {
+
+ var path = document.getElementById("path").value;
+ var depth = document.getElementById("depth").value;
+ var resultType = document.getElementById("resultType");
+
+ // TODO retrieve url from servlet context
+ var action = "<%= href %>";
+ if (path.length && path != "/") {
+ action += path;
+ }
+ if (depth) {
+ action += "." + depth;
+ }
+
+ var req = getXMLHttpRequest(action + ".json");
+ var result = document.getElementById("result");
+
+ if (req && req.status == 200) {
+ if (resultType[4].selected) {
+ // tree
+ var obj = eval("(" + req.responseText + ")");
+ var thref = "<%= href %>" + ((path.length && path != "/") ? path : "");
+ result.innerHTML = JsonFormatter.tree(obj, thref);
+ } else if (resultType[3].selected) {
+ // cleaned from special props
+ var obj = eval("(" + req.responseText + ")");
+ result.innerHTML = JsonFormatter.format(obj, true);
+ } else if (resultType[2].selected) {
+ // indention (pretty printing)
+ var obj = eval("(" + req.responseText + ")");
+ result.innerHTML = JsonFormatter.format(obj, false);
+ } else {
+ // raw (default)
+ result.innerHTML = req.responseText;
+ }
+ } else {
+ var error = "ERROR: " + ((req) ? (req.status + " : "+ req.responseText) : "Failed to create XMLHttpRequest.");
+ result.innerHTML = error;
+ }
+ return true;
+ }
+</script>
+<div id="content">
+ <h2>Examples: Batch Read</h2>
+ <p>
+ Enter the path of an existing node and the desired depth.
+ </p>
+ <table>
+ <tr>
+ <td>Node Path</td>
+ <td><input type="text" name="path" id="path" value="/"></td>
+ </tr>
+ <tr>
+ <td>Depth</td>
+ <td><input type="text" name="depth" id="depth" value="0"></td>
+ </tr>
+ <tr>
+ <td>Result type</td>
+ <td><select name="resultType" id="resultType">
+ <option value="">--- select ---</option>
+ <option value="raw">raw</option>
+ <option value="indented">indented</option>
+ <option value="indented_clean">indented (cleaned)</option>
+ <option value="tree">tree</option>
+ </select></td>
+ </tr>
+ <tr><td><input type="button" value="Submit" onclick="batchRead()"></td></tr>
+ </table>
+ <p>
+ <pre id ="result" class="code"></pre>
+</div>
+<jsp:include page="footer.jsp"/>
\ No newline at end of file
Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/read_batch.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/read_batch.jsp
------------------------------------------------------------------------------
svn:keywords = author date id revision
Added: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write.jsp?rev=743713&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write.jsp (added)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write.jsp Thu Feb 12 12:59:22 2009
@@ -0,0 +1,161 @@
+<%@ page import="java.net.URI" %>
+<%@ page import="org.apache.jackrabbit.j2ee.JcrRemotingServlet" %>
+<%@ page import="org.apache.jackrabbit.util.Text" %>
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%><%
+
+URI uri = new URI(request.getRequestURL().toString());
+String href =
+ uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort()
+ + request.getContextPath()
+ + JcrRemotingServlet.getPathPrefix(pageContext.getServletContext());
+href = Text.encodeIllegalXMLCharacters(href);
+href += "/default/jcr:root";
+
+%><jsp:include page="header.jsp"/>
+<div id="content">
+ <h2>Write</h2>
+ <h3><a name="default_write">Default Writing</a></h3>
+ <p>Writing remotely to the repository generally follows the rules described in
+ <a href="http://jackrabbit.apache.org/JCR_Webdav_Protocol.doc">JCR_Webdav_Protocol.zip</a>.
+ </p>
+ <h3><a name="batch_write">Batch Write</a></h3>
+ <p>A set of transient modifications can in addition be sent by using the
+ extended batch write: A single POST request that contains a custom
+ <strong>:diff</strong> parameter describing the changes to be applied.
+ The expected format is described in the
+ <a href ="http://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java">JavaDoc</a>.
+ </p>
+ Some cases however can be easily demonstrated. The following examples can
+ be tested with the form provided at
+ <a href="write_batch.jsp">Example: Batch Write</a>.
+ </p>
+ <h4>Examples</h4>
+ <p>The following examples illustrate the basics of the diff format. It does
+ not cover the special treatment of properties with type <i>Date</i>,
+ <i>Name</i>, <i>Path</i>, <i>Reference</i> and <i>Binary</i> (see below).</p>
+ <p style="font-size:smaller">Set properties</p>
+ <pre class="code">
+^prop1 : "stringvalue"
+^prop1 : "changedvalue"
+^prop2 : true
+^prop3 : 100.010
+^prop4 : 1234567890
+^prop5 : ["multi","valued","string prop"]
+^. : "change existing property at path."
+^/abs/path/to/the/new/prop : "some value."</pre>
+ <p style="font-size:smaller">Add new nodes (optionally including child items)</p>
+ <pre class="code">
++node : {"title" : "title property of the new node"}
++node2 : {"childN" : {}, "childN2" : {}}
++/abs/path/to/the/new/node : {"text" : "some text"}</pre>
+ <p style="font-size:smaller">Move or rename nodes</p>
+ <pre class="code">
+>node : rename
+>rename : /moved/to/another/destination</pre>
+ <p style="font-size:smaller">Reorder nodes</p>
+ <pre class="code">
+>childN : childN2#after
+>childN : #first
+>childN : #last
+>childN : childN2#before</pre>
+ <p style="font-size:smaller">Remove items</p>
+ <pre class="code">
+-prop4 :
+-node2 :
+-/moved/to/another/destination :</pre>
+ <h4>Dealing with Special Property Types</h4>
+ <p>Property types that can not be covered unambigously, need some special
+ handling (see JavaDoc). This affects JCR properties being of type
+ <ul>
+ <li>Date,</li>
+ <li>Name,</li>
+ <li>Path,</li>
+ <li>Reference,</li>
+ <li>Binary.</li>
+ </ul>
+ In order to set properties of any of the types listed, the value part in the
+ :diff param must be left empty and a separate request parameter must be
+ included. Its name equals the corresponding key in the :diff, its value represents
+ the property value. In addition the desired property type must be specified
+ using the conversion defined with
+ <a href="http://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrValueType.java">JcrValueType#contentTypeFromType(int)</a>.
+ </p>
+ <p style="font-size:smaller">Set a Date property</p>
+ <pre>
+POST /jackrabbit/server/default/jcr%3aroot/testNode HTTP/1.1
+Content-Type: multipart/form-data; boundary=kTmAb2lkjCtxbMVFzHEplAJjHCUo5aQndaUu
+
+--kTmAb2lkjCtxbMVFzHEplAJjHCUo5aQndaUu
+Content-Disposition: form-data; <b>name="dateProp"</b>
+Content-Type: <b>jcr-value/date</b>
+
+<b>2009-02-12T10:19:40.778+01:00</b>
+--kTmAb2lkjCtxbMVFzHEplAJjHCUo5aQndaUu
+Content-Disposition: form-data; <b>name=":diff"</b>
+Content-Type: text/plain
+
+<b>^dateProp : </b>
+--kTmAb2lkjCtxbMVFzHEplAJjHCUo5aQndaUu--
+ </pre>
+ <p>Setting <i>Binary</i>, <i>Name</i>, <i>Path</i> or <i>Reference</i>
+ properties works accordingly.
+ </p>
+
+ <h3><a name="simple_write">Direct Content Editing</a></h3>
+ <p>The functionality present with batch reading also enables very simplified
+ content editing using common HTML forms.</p>
+ <p>The :diff parameter is omitted altogether and each request parameter is
+ treated as property
+ <ul>
+ <li>param name : property name</li>
+ <li>param value : property value</li>
+ </ul>
+ whereas the form action indicates the path of the parent node.
+ </p>
+ <p>If no node exists at the specified path an attempt is made to create the
+ missing intermediate nodes. The primary node type of the new node is
+ either retrieved from the corresponding <i>jcr:primaryType</i> param or
+ automatically determined by the implementation.</p>
+ <p>Setting a property can be tested at
+ <a href="write_simple.jsp">Example: Simplified Writing</a>
+ </p>
+ <h4>Examples</h4>
+ <p>The following examples illustrate the simplified writing.</p>
+ <p style="font-size:smaller">Set string property
+ <ul>
+ <li style="font-size:smaller">Existing or non-existing node at /testnode</li>
+ <li style="font-size:smaller">Set property 'propName' with value "any string value"</li>
+ </ul>
+ </p>
+ <pre class="code">
+<form method="POST" action="<%= href %>/testnode">
+ <input type="text" name="propName" value="any string value"/>
+</form></pre>
+ <p style="font-size:smaller">Add node with a defined node type and set a property</p>
+ <ul>
+ <li style="font-size:smaller">Non-existing node at /testnode/nonexisting</li>
+ <li style="font-size:smaller">Define its primary type to be "nt:unstructured"</li>
+ <li style="font-size:smaller">Set property 'propName' with value "any string value"</li>
+ </ul>
+ <pre class="code">
+<form method="POST" action="<%= href %>/nonexisting">
+ <input type="text" name="jcr:primaryType" value="nt:unstructured"/>
+ <input type="text" name="propName" value="any string value"/>
+</form></pre>
+</div>
+<jsp:include page="footer.jsp"/>
\ No newline at end of file
Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write.jsp
------------------------------------------------------------------------------
svn:keywords = author date id revision
Added: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write_batch.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write_batch.jsp?rev=743713&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write_batch.jsp (added)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write_batch.jsp Thu Feb 12 12:59:22 2009
@@ -0,0 +1,84 @@
+<%@ page import="java.net.URI" %>
+<%@ page import="org.apache.jackrabbit.j2ee.JcrRemotingServlet" %>
+<%@ page import="org.apache.jackrabbit.util.Text" %>
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%><%
+
+URI uri = new URI(request.getRequestURL().toString());
+String href =
+ uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort()
+ + request.getContextPath()
+ + JcrRemotingServlet.getPathPrefix(pageContext.getServletContext());
+href = Text.encodeIllegalXMLCharacters(href);
+href += "/default/jcr:root";
+
+%><jsp:include page="header.jsp"/>
+<script src="json.js"></script>
+<script language="javascript">
+ function batchWrite() {
+ var path = document.getElementById("path").value;
+ var diff = document.getElementById(":diff").value;
+
+ if (!diff) {
+ alert("Please enter the Diff.");
+ return false;
+ }
+
+ var headers = new Object();
+ headers["Content-type"] = "application/x-www-form-urlencoded";
+ headers["Authorization"] = "Basic YWRtaW46YWRtaW4=";
+
+ var params = encodeURIComponent(":diff") + "=" + encodeURIComponent(diff);
+
+ var url = "<%= href %>" + path;
+ var req = getXMLHttpRequest(url, "POST", headers, params);
+ var result = document.getElementById("result");
+
+ if (req && (req.status == 200 || req.status == 201)) {
+ result.innerHTML = "Success<br><a href=\"" + url + "\" target=\"_blank\">View Result</a>";
+ } else {
+ var error = "ERROR: " + ((req) ? (req.status + " : "+ req.responseText) : "Failed to create XMLHttpRequest.");
+ result.innerHTML = error;
+ }
+ return true;
+ }
+
+</script>
+<div id="content">
+ <h2>Examples: Batch Write</h2>
+ <p>
+ Enter the path of an existing node or property (depending on the desired
+ actions) and enter the <i>:diff</i> value.
+ </p>
+ <p>See the introduction to batched <a href="write.jsp#batch_write">writing</a>
+ for examples.
+ </p>
+ <table>
+ <tr>
+ <td>Item Path</td>
+ <td><input type="text" id="path" value=""></td>
+ </tr>
+ <tr>
+ <td valign="top">Diff</td>
+ <td><textarea rows="10" cols="40" id=":diff"></textarea></td>
+ </tr>
+ <tr><td><input type="button" value="Submit" onclick="batchWrite()"></td></tr>
+ </table>
+ <p>
+ <pre id ="result" class="code"></pre>
+</div>
+<jsp:include page="footer.jsp"/>
\ No newline at end of file
Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write_batch.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write_batch.jsp
------------------------------------------------------------------------------
svn:keywords = author date id revision
Added: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write_simple.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write_simple.jsp?rev=743713&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write_simple.jsp (added)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write_simple.jsp Thu Feb 12 12:59:22 2009
@@ -0,0 +1,101 @@
+<%@ page import="java.net.URI" %>
+<%@ page import="org.apache.jackrabbit.j2ee.JcrRemotingServlet" %>
+<%@ page import="org.apache.jackrabbit.util.Text" %>
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%><%
+
+URI uri = new URI(request.getRequestURL().toString());
+String href =
+ uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort()
+ + request.getContextPath()
+ + JcrRemotingServlet.getPathPrefix(pageContext.getServletContext());
+href = Text.encodeIllegalXMLCharacters(href);
+href += "/default/jcr:root";
+
+%><jsp:include page="header.jsp"/>
+<script src="json.js"></script>
+<script language="javascript">
+ function simpleWrite() {
+ var path = document.getElementById("path").value;
+ var title = document.getElementById("title").value;
+ var text = document.getElementById("text").value;
+
+ var headers = new Object();
+ headers["Content-type"] = "application/x-www-form-urlencoded";
+ headers["Authorization"] = "Basic YWRtaW46YWRtaW4=";
+
+ var params = "";
+ if (title) {
+ params += encodeURIComponent("title") + "=" + encodeURIComponent(title);
+ }
+ if (text) {
+ if (params) {
+ params += "&";
+ }
+ params += encodeURIComponent("text") + "=" + encodeURIComponent(text);
+ }
+
+ var url = "<%= href %>" + path;
+ var req = getXMLHttpRequest(url, "POST", headers, params);
+ var result = document.getElementById("result");
+
+ if (req && (req.status == 200 || req.status == 201)) {
+ var res = "Success<br><ul>" +
+ "<li><a href=\"" + url + "\" target=\"_blank\">Node</a> at "+ path +"</li>";
+ if (title) {
+ res += "<li><a href=\"" + url + "/title\">Title</a></li>";
+ }
+ if (text) {
+ res += "<li><a href=\"" + url + "/text\">Text</a></li>";
+ }
+ res += "</ul>";
+ result.innerHTML = res;
+ } else {
+ var error = "ERROR: " + ((req) ? (req.status + " : "+ req.responseText) : "Failed to create XMLHttpRequest.");
+ result.innerHTML = error;
+ }
+ return true;
+ }
+
+</script>
+<div id="content">
+ <h2>Examples: Simplified Writing</h2>
+ <p>If the JCR node at the specified absolute path allows to set a properties
+ with name <i>title</i> or <i>text</i>, submitting the form below will
+ will set those properties to the given values.</p>
+ <p>If no JCR node exists at the specified absolute path, the missing
+ intermediate nodes will be created if an applicable node type for the
+ specified node name(s) can be determined.</p>
+ <table>
+ <tr>
+ <td>Node Path</td>
+ <td><input type="text" id="path" value=""></td>
+ </tr>
+ <tr>
+ <td valign="top">Title</td>
+ <td><input type="text" id="title" value=""></td>
+ </tr>
+ <tr>
+ <td valign="top">Text</td>
+ <td><textarea rows="5" cols="40" id="text"></textarea></td>
+ </tr>
+ <tr><td><input type="button" value="Submit" onclick="simpleWrite()"></td></tr>
+ </table>
+ <p>
+ <pre id ="result" class="code"></pre>
+</div>
+<jsp:include page="footer.jsp"/>
\ No newline at end of file
Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write_simple.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remoting/write_simple.jsp
------------------------------------------------------------------------------
svn:keywords = author date id revision
Modified: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/webdav-remoting.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/webdav-remoting.jsp?rev=743713&r1=743712&r2=743713&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/webdav-remoting.jsp (original)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/webdav-remoting.jsp Thu Feb 12 12:59:22 2009
@@ -18,7 +18,7 @@
--%><%@page import="org.apache.jackrabbit.util.Text"%>
<%@ page import="org.apache.jackrabbit.j2ee.JcrRemotingServlet" %>
<%
-request.setAttribute("title", "JCR Remoting Server (incl. Batch Read/Write)");
+request.setAttribute("title", "JCR Remoting Server with Batch Read/Write");
URI uri = new URI(request.getRequestURL().toString());
String href =
@@ -61,7 +61,8 @@
Composes a JSON object for a node (and its child items) up to a explicitely
specified or configuration determined depth.
<br>
-See <a href ="http://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java">JavaDoc</a> for details.
+See <a href ="http://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java">JavaDoc</a> for details
+or try the <a href="remoting/index.jsp">Examples</a>.
</p>
<h3>Batch Write</h3>
@@ -70,7 +71,8 @@
a block of modifications (SPI Batch) within a single POST request containing a
custom ":diff" parameter.
<br>
-See the <a href ="http://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java">JavaDoc</a> for details.
+See the <a href ="http://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java">JavaDoc</a> for details
+or try the <a href="remoting/index.jsp">Examples</a>.
</p>
<h3>JCR Remoting Client</h3>
|