Debian Codegraph @

jackrabbit-webapp/src/main/webapp/remoting/write_batch.jsp

raw
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 batchWrite() {
33 var path = document.getElementById("path").value;
34 var diff = document.getElementById(":diff").value;
35
36 if (!diff) {
37 alert("Please enter the Diff.");
38 return false;
39 }
40
41 var headers = new Object();
42 headers["Content-type"] = "application/x-www-form-urlencoded";
43 headers["Authorization"] = "Basic YWRtaW46YWRtaW4=";
44
45 var params = encodeURIComponent(":diff") + "=" + encodeURIComponent(diff);
46
47 var url = "<%= href %>" + path;
48 var req = getXMLHttpRequest(url, "POST", headers, params);
49 var result = document.getElementById("result");
50
51 if (req && (req.status == 200 || req.status == 201)) {
52 result.innerHTML = "Success<br><a href=\"" + url + "\" target=\"_blank\">View Result</a>";
53 } else {
54 var error = "ERROR: " + ((req) ? (req.status + " : "+ req.responseText) : "Failed to create XMLHttpRequest.");
55 result.innerHTML = error;
56 }
57 return true;
58 }
59
60 </script>
61 <div id="content">
62 <h2>Examples: Batch Write</h2>
63 <p>
64 Enter the path of an existing node or property (depending on the desired
65 actions) and enter the <i>:diff</i> value.
66 </p>
67 <p>See the introduction to batched <a href="write.jsp#batch_write">writing</a>
68 for examples.
69 </p>
70 <table>
71 <tr>
72 <td>Item Path</td>
73 <td><input type="text" id="path" value=""></td>
74 </tr>
75 <tr>
76 <td valign="top">Diff</td>
77 <td><textarea rows="10" cols="40" id=":diff"></textarea></td>
78 </tr>
79 <tr><td><input type="button" value="Submit" onclick="batchWrite()"></td></tr>
80 </table>
81 <p>
82 <pre id ="result" class="code"></pre>
83 </div>
84 <jsp:include page="footer.jsp"/>