Debian Codegraph @

jackrabbit-webapp/src/main/webapp/remoting/write.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 <div id="content">
31 <h2>Write</h2>
32 <h3><a name="default_write">Default Writing</a></h3>
33 <p>Writing remotely to the repository generally follows the rules described in
34 <a href="http://jackrabbit.apache.org/JCR_Webdav_Protocol.doc">JCR_Webdav_Protocol.zip</a>.
35 </p>
36 <h3><a name="batch_write">Batch Write</a></h3>
37 <p>A set of transient modifications can in addition be sent by using the
38 extended batch write: A single POST request that contains a custom
39 <strong>:diff</strong> parameter describing the changes to be applied.
40 The expected format is described in the
41 <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>.
42 </p>
43 Some cases however can be easily demonstrated. The following examples can
44 be tested with the form provided at
45 <a href="write_batch.jsp">Example: Batch Write</a>.
46 </p>
47 <h4>Examples</h4>
48 <p>The following examples illustrate the basics of the diff format. It does
49 not cover the special treatment of properties with type <i>Date</i>,
50 <i>Name</i>, <i>Path</i>, <i>Reference</i> and <i>Binary</i> (see below).</p>
51 <p style="font-size:smaller">Set properties</p>
52 <pre class="code">
53 ^prop1 : "stringvalue"
54 ^prop1 : "changedvalue"
55 ^prop2 : true
56 ^prop3 : 100.010
57 ^prop4 : 1234567890
58 ^prop5 : ["multi","valued","string prop"]
59 ^. : "change existing property at path."
60 ^/abs/path/to/the/new/prop : "some value."</pre>
61 <p style="font-size:smaller">Add new nodes (optionally including child items)</p>
62 <pre class="code">
63 +node : {"title" : "title property of the new node"}
64 +node2 : {"childN" : {}, "childN2" : {}}
65 +/abs/path/to/the/new/node : {"text" : "some text"}</pre>
66 <p style="font-size:smaller">Move or rename nodes</p>
67 <pre class="code">
68 >node : rename
69 >rename : /moved/to/another/destination</pre>
70 <p style="font-size:smaller">Reorder nodes</p>
71 <pre class="code">
72 >childN : childN2#after
73 >childN : #first
74 >childN : #last
75 >childN : childN2#before</pre>
76 <p style="font-size:smaller">Remove items</p>
77 <pre class="code">
78 -prop4 :
79 -node2 :
80 -/moved/to/another/destination :</pre>
81 <h4>Dealing with Special Property Types</h4>
82 <p>Property types that can not be covered unambigously, need some special
83 handling (see JavaDoc). This affects JCR properties being of type
84 <ul>
85 <li>Date,</li>
86 <li>Name,</li>
87 <li>Path,</li>
88 <li>Reference,</li>
89 <li>Binary.</li>
90 </ul>
91 In order to set properties of any of the types listed, the value part in the
92 :diff param must be left empty and a separate request parameter must be
93 included. Its name equals the corresponding key in the :diff, its value represents
94 the property value. In addition the desired property type must be specified
95 using the conversion defined with
96 <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>.
97 </p>
98 <p style="font-size:smaller">Set a Date property</p>
99 <pre>
100 POST /jackrabbit/server/default/jcr%3aroot/testNode HTTP/1.1
101 Content-Type: multipart/form-data; boundary=kTmAb2lkjCtxbMVFzHEplAJjHCUo5aQndaUu
102
103 --kTmAb2lkjCtxbMVFzHEplAJjHCUo5aQndaUu
104 Content-Disposition: form-data; <b>name="dateProp"</b>
105 Content-Type: <b>jcr-value/date</b>
106
107 <b>2009-02-12T10:19:40.778+01:00</b>
108 --kTmAb2lkjCtxbMVFzHEplAJjHCUo5aQndaUu
109 Content-Disposition: form-data; <b>name=":diff"</b>
110 Content-Type: text/plain
111
112 <b>^dateProp : </b>
113 --kTmAb2lkjCtxbMVFzHEplAJjHCUo5aQndaUu--
114 </pre>
115 <p>Setting <i>Binary</i>, <i>Name</i>, <i>Path</i> or <i>Reference</i>
116 properties works accordingly.
117 </p>
118
119 <h3><a name="simple_write">Direct Content Editing</a></h3>
120 <p>The functionality present with batch reading also enables very simplified
121 content editing using common HTML forms.</p>
122 <p>The :diff parameter is omitted altogether and each request parameter is
123 treated as property
124 <ul>
125 <li>param name : property name</li>
126 <li>param value : property value</li>
127 </ul>
128 whereas the form action indicates the path of the parent node.
129 </p>
130 <p>If no node exists at the specified path an attempt is made to create the
131 missing intermediate nodes. The primary node type of the new node is
132 either retrieved from the corresponding <i>jcr:primaryType</i> param or
133 automatically determined by the implementation.</p>
134 <p>Setting a property can be tested at
135 <a href="write_simple.jsp">Example: Simplified Writing</a>
136 </p>
137 <h4>Examples</h4>
138 <p>The following examples illustrate the simplified writing.</p>
139 <p style="font-size:smaller">Set string property
140 <ul>
141 <li style="font-size:smaller">Existing or non-existing node at /testnode</li>
142 <li style="font-size:smaller">Set property 'propName' with value "any string value"</li>
143 </ul>
144 </p>
145 <pre class="code">
146 &lt;form method="POST" action="<%= href %>/testnode"&gt;
147 &lt;input type="text" name="propName" value="any string value"/&gt;
148 &lt;/form&gt;</pre>
149 <p style="font-size:smaller">Add node with a defined node type and set a property</p>
150 <ul>
151 <li style="font-size:smaller">Non-existing node at /testnode/nonexisting</li>
152 <li style="font-size:smaller">Define its primary type to be "nt:unstructured"</li>
153 <li style="font-size:smaller">Set property 'propName' with value "any string value"</li>
154 </ul>
155 <pre class="code">
156 &lt;form method="POST" action="<%= href %>/nonexisting"&gt;
157 &lt;input type="text" name="jcr:primaryType" value="nt:unstructured"/&gt;
158 &lt;input type="text" name="propName" value="any string value"/&gt;
159 &lt;/form&gt;</pre>
160 </div>
161 <jsp:include page="footer.jsp"/>