Index: jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java =================================================================== --- jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java (revision 629142) +++ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java (working copy) @@ -81,6 +81,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.io.InputStreamReader; +import java.io.BufferedReader; import java.util.ArrayList; import java.util.Date; import java.util.Iterator; @@ -400,8 +402,31 @@ if (in == null) { // PUT: not possible without request body throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Cannot create a new non-collection resource without request body."); + } + // PUT : create new or overwrite existing property. + String ct = inputContext.getContentType(); + if (ct != null && ct.startsWith(ItemResourceConstants.VALUE_CONTENT_TYPE_FRAGMENT)) { + // no need to create value/values property. instead + // prop-value can be retrieved directly: + int pos = ct.indexOf('/'); + int pos2 = ct.indexOf(';'); + + String typename = ct.substring(pos+1, pos+2).toUpperCase() + ct.substring(pos+2, (pos2 > -1) ? pos2 : ct.length()); + String charSet = (pos2 > -1) ? ct.substring(pos2) : "UTF-8"; + int type = PropertyType.valueFromName(typename); + if (type == PropertyType.BINARY) { + n.setProperty(memberName, inputContext.getInputStream()); + } else { + BufferedReader r = new BufferedReader(new InputStreamReader(inputContext.getInputStream(), charSet)); + String line; + StringBuffer value = new StringBuffer(); + while ((line = r.readLine()) != null) { + value.append(line); + } + n.setProperty(memberName, value.toString(), type); + } } else { - // PUT : create new or overwrite existing property. + // try to parse the request body into a 'values' property. tmpFile = File.createTempFile(TMP_PREFIX + Text.escape(memberName), null, null); FileOutputStream out = new FileOutputStream(tmpFile); IOUtil.spool(in, out); Index: jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java =================================================================== --- jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java (revision 629142) +++ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java (working copy) @@ -59,6 +59,28 @@ public static final String IMPORT_UUID_BEHAVIOR = "ImportUUIDBehavior"; + /** + * Fragment for build the content type of request entities representing + * a JCR-value. The fragment must be completed as follows: + *
+     * jcr-value/ + Value.getType().toLowerCase()
+     * 
+ * + * resulting in the following types: + *
+     * jcr-value/string
+     * jcr-value/boolean
+     * jcr-value/long
+     * jcr-value/double
+     * jcr-value/date
+     * jcr-value/binary
+     * jcr-value/date
+     * jcr-value/name
+     * jcr-value/path
+     * 
+ */ + public static final String VALUE_CONTENT_TYPE_FRAGMENT = "jcr-value/"; + // xml element names public static final String XML_PRIMARYNODETYPE = "primarynodetype"; public static final String XML_VALUE = "value";