Debian Codegraph @

jackrabbit-webapp/src/main/webapp/remoting/read_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 batchRead() {
33
34 var path = document.getElementById("path").value;
35 var depth = document.getElementById("depth").value;
36 var resultType = document.getElementById("resultType");
37
38 // TODO retrieve url from servlet context
39 var action = "<%= href %>";
40 if (path.length && path != "/") {
41 action += path;
42 }
43 if (depth) {
44 action += "." + depth;
45 }
46
47 var req = getXMLHttpRequest(action + ".json");
48 var result = document.getElementById("result");
49
50 if (req && req.status == 200) {
51 if (resultType[4].selected) {
52 // tree
53 var obj = eval("(" + req.responseText + ")");
54 var thref = "<%= href %>" + ((path.length && path != "/") ? path : "");
55 result.innerHTML = JsonFormatter.tree(obj, thref);
56 } else if (resultType[3].selected) {
57 // cleaned from special props
58 var obj = eval("(" + req.responseText + ")");
59 result.innerHTML = JsonFormatter.format(obj, true);
60 } else if (resultType[2].selected) {
61 // indention (pretty printing)
62 var obj = eval("(" + req.responseText + ")");
63 result.innerHTML = JsonFormatter.format(obj, false);
64 } else {
65 // raw (default)
66 result.innerHTML = req.responseText;
67 }
68 } else {
69 var error = "ERROR: " + ((req) ? (req.status + " : "+ req.responseText) : "Failed to create XMLHttpRequest.");
70 result.innerHTML = error;
71 }
72 return true;
73 }
74 </script>
75 <div id="content">
76 <h2>Examples: Batch Read</h2>
77 <p>
78 Enter the path of an existing node and the desired depth.
79 </p>
80 <table>
81 <tr>
82 <td>Node Path</td>
83 <td><input type="text" name="path" id="path" value="/"></td>
84 </tr>
85 <tr>
86 <td>Depth</td>
87 <td><input type="text" name="depth" id="depth" value="0"></td>
88 </tr>
89 <tr>
90 <td>Result type</td>
91 <td><select name="resultType" id="resultType">
92 <option value="">--- select ---</option>
93 <option value="raw">raw</option>
94 <option value="indented">indented</option>
95 <option value="indented_clean">indented (cleaned)</option>
96 <option value="tree">tree</option>
97 </select></td>
98 </tr>
99 <tr><td><input type="button" value="Submit" onclick="batchRead()"></td></tr>
100 </table>
101 <p>
102 <pre id ="result" class="code"></pre>
103 </div>
104 <jsp:include page="footer.jsp"/>