| 1 |
<%@ page import="java.net.URI" %> |
| 2 |
<%@ page import="org.apache.jackrabbit.j2ee.JcrRemotingServlet" %> |
| 3 |
<%@ page import="org.apache.jackrabbit.util.Text" %> |
| 4 |
<%-- |
| 5 |
Licensed to the Apache Software Foundation (ASF) under one or more |
| 6 |
contributor license agreements. See the NOTICE file distributed with |
| 7 |
this work for additional information regarding copyright ownership. |
| 8 |
The ASF licenses this file to You under the Apache License, Version 2.0 |
| 9 |
(the "License"); you may not use this file except in compliance with |
| 10 |
the License. You may obtain a copy of the License at |
| 11 |
|
| 12 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
|
| 14 |
Unless required by applicable law or agreed to in writing, software |
| 15 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
See the License for the specific language governing permissions and |
| 18 |
limitations under the License. |
| 19 |
--%><% |
| 20 |
|
| 21 |
URI uri = new URI(request.getRequestURL().toString()); |
| 22 |
String href = |
| 23 |
uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort() |
| 24 |
+ request.getContextPath() |
| 25 |
+ JcrRemotingServlet.getPathPrefix(pageContext.getServletContext()); |
| 26 |
href = Text.encodeIllegalXMLCharacters(href); |
| 27 |
href += "/default/jcr:root"; |
| 28 |
|
| 29 |
%><jsp:include page="header.jsp"/> |
| 30 |
<script src="json.js"></script> |
| 31 |
<script language="javascript"> |
| 32 |
function simpleWrite() { |
| 33 |
var path = document.getElementById("path").value; |
| 34 |
var title = document.getElementById("title").value; |
| 35 |
var text = document.getElementById("text").value; |
| 36 |
|
| 37 |
var headers = new Object(); |
| 38 |
headers["Content-type"] = "application/x-www-form-urlencoded"; |
| 39 |
headers["Authorization"] = "Basic YWRtaW46YWRtaW4="; |
| 40 |
|
| 41 |
var params = ""; |
| 42 |
if (title) { |
| 43 |
params += encodeURIComponent("title") + "=" + encodeURIComponent(title); |
| 44 |
} |
| 45 |
if (text) { |
| 46 |
if (params) { |
| 47 |
params += "&"; |
| 48 |
} |
| 49 |
params += encodeURIComponent("text") + "=" + encodeURIComponent(text); |
| 50 |
} |
| 51 |
|
| 52 |
var url = "<%= href %>" + path; |
| 53 |
var req = getXMLHttpRequest(url, "POST", headers, params); |
| 54 |
var result = document.getElementById("result"); |
| 55 |
|
| 56 |
if (req && (req.status == 200 || req.status == 201)) { |
| 57 |
var res = "Success<br><ul>" + |
| 58 |
"<li><a href=\"" + url + "\" target=\"_blank\">Node</a> at "+ path +"</li>"; |
| 59 |
if (title) { |
| 60 |
res += "<li><a href=\"" + url + "/title\">Title</a></li>"; |
| 61 |
} |
| 62 |
if (text) { |
| 63 |
res += "<li><a href=\"" + url + "/text\">Text</a></li>"; |
| 64 |
} |
| 65 |
res += "</ul>"; |
| 66 |
result.innerHTML = res; |
| 67 |
} else { |
| 68 |
var error = "ERROR: " + ((req) ? (req.status + " : "+ req.responseText) : "Failed to create XMLHttpRequest."); |
| 69 |
result.innerHTML = error; |
| 70 |
} |
| 71 |
return true; |
| 72 |
} |
| 73 |
|
| 74 |
</script> |
| 75 |
<div id="content"> |
| 76 |
<h2>Examples: Simplified Writing</h2> |
| 77 |
<p>If the JCR node at the specified absolute path allows to set a properties |
| 78 |
with name <i>title</i> or <i>text</i>, submitting the form below will |
| 79 |
will set those properties to the given values.</p> |
| 80 |
<p>If no JCR node exists at the specified absolute path, the missing |
| 81 |
intermediate nodes will be created if an applicable node type for the |
| 82 |
specified node name(s) can be determined.</p> |
| 83 |
<table> |
| 84 |
<tr> |
| 85 |
<td>Node Path</td> |
| 86 |
<td><input type="text" id="path" value=""></td> |
| 87 |
</tr> |
| 88 |
<tr> |
| 89 |
<td valign="top">Title</td> |
| 90 |
<td><input type="text" id="title" value=""></td> |
| 91 |
</tr> |
| 92 |
<tr> |
| 93 |
<td valign="top">Text</td> |
| 94 |
<td><textarea rows="5" cols="40" id="text"></textarea></td> |
| 95 |
</tr> |
| 96 |
<tr><td><input type="button" value="Submit" onclick="simpleWrite()"></td></tr> |
| 97 |
</table> |
| 98 |
<p> |
| 99 |
<pre id ="result" class="code"></pre> |
| 100 |
</div> |
| 101 |
<jsp:include page="footer.jsp"/> |