jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1002639 [1/3] - in /jackrabbit/trunk: jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/ jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/ser...
Date Wed, 29 Sep 2010 14:11:54 GMT
Author: angela
Date: Wed Sep 29 14:11:53 2010
New Revision: 1002639

URL: http://svn.apache.org/viewvc?rev=1002639&view=rev
Log:
JCR-2453 - Break the spi2dav dependency to jcr-server

Added:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/EventUtil.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/JcrRemotingConstants.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/JcrValueType.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/NodeTypeConstants.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/NodeTypeUtil.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/QueryUtil.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/ValueUtil.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/XMLUtil.java   (with props)
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/ItemResourceConstants.java
      - copied, changed from r987195, jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java
Removed:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeConstants.java
Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonDiffHandler.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrValueType.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeProperty.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/search/SearchResultProperty.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/JcrPrivilegeReport.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/NodeTypesReport.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/RegisteredNamespacesReport.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java
    jackrabbit/trunk/jackrabbit-spi2dav/pom.xml
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/DefinitionUtil.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/ItemInfoImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/LockInfoImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/NodeInfoImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/PropertyInfoImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QueryResultRowImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/QValueFactoryImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/ValueLoader.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/DefaultEventType.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/property/DavPropertyNameSet.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/version/report/ReportInfo.java

Added: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/EventUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/EventUtil.java?rev=1002639&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/EventUtil.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/EventUtil.java Wed Sep 29 14:11:53 2010
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.commons.webdav;
+
+import javax.jcr.observation.Event;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * <code>EventConstants</code>...
+ */
+public abstract class EventUtil {
+
+
+    /**
+     * Element representing the 'nodeadded' event type.
+     * @see javax.jcr.observation.Event#NODE_ADDED
+     */
+    public static final String EVENT_NODEADDED = "nodeadded";
+
+    /**
+     * Element representing the 'noderemoved' event type.
+     * @see javax.jcr.observation.Event#NODE_REMOVED
+     */
+    public static final String EVENT_NODEREMOVED = "noderemoved";
+
+    /**
+     * Element representing the 'propertyadded' event type.
+     * @see javax.jcr.observation.Event#PROPERTY_ADDED
+     */
+    public static final String EVENT_PROPERTYADDED = "propertyadded";
+
+    /**
+     * Element representing the 'propertyremoved' event type.
+     * @see javax.jcr.observation.Event#PROPERTY_REMOVED
+     */
+    public static final String EVENT_PROPERTYREMOVED = "propertyremoved";
+
+    /**
+     * Element representing the 'propertychanged' event type.
+     * @see javax.jcr.observation.Event#PROPERTY_CHANGED
+     */
+    public static final String EVENT_PROPERTYCHANGED = "propertychanged";
+
+    /**
+     * Element representing the 'nodemoved' event type.
+     * @see javax.jcr.observation.Event#NODE_MOVED
+     */
+    public static final String EVENT_NODEMOVED = "nodemoved";
+
+    /**
+     * Element representing the 'persist' event type.
+     * @see javax.jcr.observation.Event#PERSIST
+     */
+    public static final String EVENT_PERSIST = "persist";
+
+    /**
+     * String array listing the xml local names of all type of jcr events.
+     */
+    public static final String[] EVENT_ALL = new String[] {
+            EVENT_NODEADDED,
+            EVENT_NODEREMOVED,
+            EVENT_PROPERTYADDED,
+            EVENT_PROPERTYREMOVED,
+            EVENT_PROPERTYCHANGED,
+            EVENT_NODEMOVED,
+            EVENT_PERSIST};
+
+    private static Map<String, Integer> NAME_TO_JCR = new HashMap<String, Integer>();
+    static {
+        NAME_TO_JCR.put(EVENT_NODEADDED, Event.NODE_ADDED);
+        NAME_TO_JCR.put(EVENT_NODEREMOVED, Event.NODE_REMOVED);
+        NAME_TO_JCR.put(EVENT_PROPERTYADDED, Event.PROPERTY_ADDED);
+        NAME_TO_JCR.put(EVENT_PROPERTYREMOVED, Event.PROPERTY_REMOVED);
+        NAME_TO_JCR.put(EVENT_PROPERTYCHANGED, Event.PROPERTY_CHANGED);
+        NAME_TO_JCR.put(EVENT_NODEMOVED, Event.NODE_MOVED);
+        NAME_TO_JCR.put(EVENT_PERSIST, Event.PERSIST);
+
+    }
+
+    /**
+     * Tests if the specified eventName can be mapped to a JCR event type.
+     * 
+     * @param eventName
+     * @return true if the specified eventName can be mapped to a JCR event type.
+     */
+    public static boolean isValidEventName(String eventName) {
+        return NAME_TO_JCR.containsKey(eventName);
+    }
+
+    /**
+     * Static utility method to convert the localName of a <code>EventType</code>
+     * as present in the Xml body into the corresponding JCR event constant defined by
+     * {@link javax.jcr.observation.Event}.
+     *
+     * @param eventName
+     * @return Any of the event types defined by {@link Event} or <code>null</code>.
+     * @throws IllegalArgumentException if the specified evenName is invalid.
+     */
+    public static int getJcrEventType(String eventName) {
+        if (NAME_TO_JCR.containsKey(eventName)) {
+            return NAME_TO_JCR.get(eventName);
+        } else {
+            throw new IllegalArgumentException("Invalid eventName : " + eventName);
+        }
+    }
+
+    /**
+     * Static utility method to retrieve a String representation of the type
+     * defined by a {@link javax.jcr.observation.Event JCR event}.
+     *
+     * @param jcrEventType
+     * @return Event name of the given JCR event type.
+     * @throws IllegalArgumentException if the given int does not represent a
+     * valid type constants as defined by {@link Event}.<br>
+     * Valid values are
+     * <ul>
+     * <li>{@link Event#NODE_ADDED}</li>
+     * <li>{@link Event#NODE_REMOVED}</li>
+     * <li>{@link Event#PROPERTY_ADDED}</li>
+     * <li>{@link Event#PROPERTY_REMOVED}</li>
+     * <li>{@link Event#PROPERTY_CHANGED}</li>
+     * <li>{@link Event#NODE_MOVED}</li>
+     * <li>{@link Event#PERSIST}</li>
+     * </ul>
+     */
+    public static String getEventName(int jcrEventType) {
+        String eventName;
+        switch (jcrEventType) {
+            case Event.NODE_ADDED:
+                eventName = EVENT_NODEADDED;
+                break;
+            case Event.NODE_REMOVED:
+                eventName = EVENT_NODEREMOVED;
+                break;
+            case Event.PROPERTY_ADDED:
+                eventName = EVENT_PROPERTYADDED;
+                break;
+            case Event.PROPERTY_CHANGED:
+                eventName = EVENT_PROPERTYCHANGED;
+                break;
+            case Event.PROPERTY_REMOVED:
+                eventName = EVENT_PROPERTYREMOVED;
+                break;
+            case Event.NODE_MOVED:
+                eventName = EVENT_NODEMOVED;
+                break;
+            case Event.PERSIST:
+                eventName = EVENT_PERSIST;
+                break;
+            default: // no default
+                throw new IllegalArgumentException("Invalid JCR event type: " + jcrEventType);
+        }
+        return eventName;
+    }
+
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/EventUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/EventUtil.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/JcrRemotingConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/JcrRemotingConstants.java?rev=1002639&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/JcrRemotingConstants.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/JcrRemotingConstants.java Wed Sep 29 14:11:53 2010
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.commons.webdav;
+
+/**
+ * <code>JcrRemotingConstants</code> provides string constants for WebDAV
+ * resources representing repository items.
+ */
+public interface JcrRemotingConstants {
+
+    /**
+     * Namespace prefix used for Jackrabbit specific WebDAV extensions related
+     * to JCR remoting.
+     * @see #NS_URI
+     */
+    public static final String NS_PREFIX = "dcr";
+    
+    /**
+     * Namespace uri used for Jackrabbit specific WebDAV extensions related
+     * to JCR remoting.
+     * @see #NS_PREFIX
+     */
+    public static final String NS_URI = "http://www.day.com/jcr/webdav/1.0";
+
+    /**
+     * The resource path of the root-item-resource.
+     */
+    public static final String ROOT_ITEM_PATH = "/";
+    /**
+     * Placeholder resource path for the JCR root node.
+     */
+    public static final String ROOT_ITEM_RESOURCEPATH = "/jcr:root";
+
+    /**
+     * The version storage item resource path.
+     */
+    public static final String VERSIONSTORAGE_PATH = "/jcr:system/jcr:versionStorage";
+
+    public static final String IMPORT_UUID_BEHAVIOR = "ImportUUIDBehavior";
+
+    // xml element names
+    public static final String XML_PRIMARYNODETYPE = "primarynodetype";
+    public static final String XML_VALUE = "value";
+    /**
+     * 'type' attribute for the {@link #XML_VALUE value} element, reflecting the
+     * {@link javax.jcr.PropertyType type} of the value being transported.
+     */
+    public static final String ATTR_VALUE_TYPE = "type";
+    public static final String XML_LENGTH = "length";
+    public static final String XML_EXCLUSIVE_SESSION_SCOPED = "exclusive-session-scoped";
+
+    // xml elements used to reflect the workspaces ns-registry
+    public static final String XML_NAMESPACE = "namespace";
+    public static final String XML_PREFIX = "prefix";
+    public static final String XML_URI = "uri";
+
+    // xml elements used for repository-descriptors report
+    public static final String XML_DESCRIPTOR = "descriptor";
+    public static final String XML_DESCRIPTORKEY = "descriptorkey";
+    public static final String XML_DESCRIPTORVALUE = "descriptorvalue";
+
+    /**
+     * The 'removeexisting' element is not defined by RFC 3253. If it is present
+     * in the UPDATE request body, uuid conflicts should be solved by removing
+     * the existing nodes.
+     *
+     * @see javax.jcr.Node#restore(javax.jcr.version.Version, boolean)
+     * @see javax.jcr.Workspace#restore(javax.jcr.version.Version[], boolean)
+     */
+    public static final String XML_REMOVEEXISTING = "removeexisting";
+
+    /**
+     * The 'relpath' element is not defined by RFC 3253. If it is present
+     * in the UPDATE request body, the server is forced to used the text contained
+     * as 'relPath' argument for the {@link javax.jcr.Node#restore(javax.jcr.version.Version, String, boolean)
+     * Node.restore} call.
+     *
+     * @see javax.jcr.Node#restore(javax.jcr.version.Version, String, boolean)
+     */
+    public static final String XML_RELPATH = "relpath";
+
+    // oroperty local name of the workspace for which the repository session has been created.
+    public static final String JCR_WORKSPACE_NAME_LN = "workspaceName";
+
+    // general property local names
+    public static final String JCR_NAME_LN = "name";
+    public static final String JCR_PATH_LN = "path";
+    public static final String JCR_DEPTH_LN = "depth";
+    public static final String JCR_PARENT_LN = "parent";
+    public static final String JCR_ISNEW_LN = "isnew";
+    public static final String JCR_ISMODIFIED_LN = "ismodified";
+    public static final String JCR_DEFINITION_LN = "definition";
+    public static final String JCR_SELECTOR_NAME_LN = "selectorName";
+
+    // property local names used for resources representing jcr-nodes
+    public static final String JCR_PRIMARYNODETYPE_LN = XML_PRIMARYNODETYPE;
+    public static final String JCR_MIXINNODETYPES_LN = "mixinnodetypes";
+    public static final String JCR_INDEX_LN = "index";
+    public static final String JCR_REFERENCES_LN = "references";
+    /**
+     * @since JCR 2.0
+     */
+    public static final String JCR_WEAK_REFERENCES_LN = "weakreferences";
+    public static final String JCR_UUID_LN = "uuid";
+    public static final String JCR_PRIMARYITEM_LN = "primaryitem";
+
+    // property local names used for resources representing jcr-properties
+    public static final String JCR_TYPE_LN = "type";
+    public static final String JCR_VALUE_LN = "value";
+    public static final String JCR_VALUES_LN = "values";
+    public static final String JCR_LENGTH_LN = "length";
+    public static final String JCR_LENGTHS_LN = "lengths";
+
+    public static final String JCR_NAMESPACES_LN = "namespaces";
+
+    // property local names used for resource representing a version history
+    public static final String JCR_VERSIONABLEUUID_LN = "versionableuuid";
+
+    // property local names related to query
+    public static final String JCR_QUERY_RESULT_LN = "search-result-property";
+
+    // name of the xml element containing the result columns.
+    public static final String XML_QUERY_RESULT_COLUMN = "column";
+
+    public static final String REPORT_EXPORT_VIEW = "exportview";
+    public static final String REPORT_PRIVILEGES = "privileges";
+    public static final String REPORT_LOCATE_BY_UUID = "locate-by-uuid";
+    public static final String REPORT_LOCATE_CORRESPONDING_NODE = "locate-corresponding-node";
+    public static final String REPORT_NODETYPES = "nodetypes";
+    public static final String REPORT_REGISTERED_NAMESPACES = "registerednamespaces";
+    public static final String REPORT_REPOSITORY_DESCRIPTORS = "repositorydescriptors";
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/JcrRemotingConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/JcrRemotingConstants.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/JcrValueType.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/JcrValueType.java?rev=1002639&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/JcrValueType.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/JcrValueType.java Wed Sep 29 14:11:53 2010
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.commons.webdav;
+
+import javax.jcr.PropertyType;
+import java.util.HashMap;
+import java.util.Map;
+
+/** <code>JcrValueType</code>... */
+public class JcrValueType {
+
+    /**
+     * Fragment for build the content type of request entities representing
+     * a JCR-value. The fragment must be completed as follows:
+     * <pre>
+     * jcr-value/ + Value.getType().toLowerCase()
+     * </pre>
+     *
+     * resulting in the following types:
+     * <pre>
+     * jcr-value/binary
+     * jcr-value/boolean
+     * jcr-value/date
+     * jcr-value/decimal
+     * jcr-value/double
+     * jcr-value/long
+     * jcr-value/name
+     * jcr-value/path
+     * jcr-value/reference
+     * jcr-value/string
+     * jcr-value/undefined
+     * jcr-value/uri
+     * jcr-value/weakreference
+     * </pre>
+     */
+    private static final String VALUE_CONTENT_TYPE_FRAGMENT = "jcr-value/";
+
+    /**
+     * Hardcoded lookup from content type as created by {@link #contentTypeFromType(int)}.
+     * Reason: As of JCR 2.0 there is no trivial rule to obtain the the TYPENAME
+     * constant from a lower-cased string: WeakReference uses camel-case and URI
+     * is all upper case...
+     */
+    private static final Map<String, Integer> TYPE_LOOKUP = new HashMap<String,Integer>();
+    static {
+        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.BINARY), PropertyType.BINARY);
+        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.BOOLEAN), PropertyType.BOOLEAN);
+        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.DATE), PropertyType.DATE);
+        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.DECIMAL), PropertyType.DECIMAL);
+        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.DOUBLE), PropertyType.DOUBLE);
+        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.LONG), PropertyType.LONG);
+        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.NAME), PropertyType.NAME);
+        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.PATH), PropertyType.PATH);
+        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.REFERENCE), PropertyType.REFERENCE);
+        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.STRING), PropertyType.STRING);
+        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.UNDEFINED), PropertyType.UNDEFINED);
+        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.URI), PropertyType.URI);
+        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.WEAKREFERENCE), PropertyType.WEAKREFERENCE);
+    }
+
+    public static String contentTypeFromType(int propertyType) {
+        return VALUE_CONTENT_TYPE_FRAGMENT + PropertyType.nameFromValue(propertyType).toLowerCase();
+    }
+
+    public static int typeFromContentType(String contentType) {
+        if (contentType != null) {
+            // remove charset if present
+            int pos = contentType.indexOf(';');
+            String ct = (pos == -1) ? contentType : contentType.substring(0, pos);
+            if (TYPE_LOOKUP.containsKey(ct)) {
+                return TYPE_LOOKUP.get(ct);
+            }
+        }
+
+        // some invalid content type argument that does not match any of the
+        // strings created by contentTypeFromType(int propertyType)
+        // -> Fallback to UNDEFINED
+        return PropertyType.UNDEFINED;
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/JcrValueType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/JcrValueType.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/NodeTypeConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/NodeTypeConstants.java?rev=1002639&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/NodeTypeConstants.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/NodeTypeConstants.java Wed Sep 29 14:11:53 2010
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.commons.webdav;
+
+/**
+ * <code>NodeTypeConstants</code> used to represent nodetype definitions in
+ * Xml.
+ *
+ * @see javax.jcr.nodetype.NodeType
+ */
+public interface NodeTypeConstants {
+
+    public static final String XML_NODETYPENAME = "nodetypename";
+
+    public static final String XML_REPORT_ALLNODETYPES = "all-nodetypes";
+    public static final String XML_REPORT_MIXINNODETYPES = "mixin-nodetypes";
+    public static final String XML_REPORT_PRIMARYNODETYPES = "primary-nodetypes";
+    public static final String XML_NODETYPES = "nodetypes";
+    public static final String XML_NODETYPE = "nodetype";
+
+    //------< copied from org.apache.jackrabbit.core.nodetype.xml.Constants >---
+
+    /** Name of the node type definition root element. */
+    String NODETYPES_ELEMENT = "nodeTypes";
+
+    /** Name of the node type definition element. */
+    String NODETYPE_ELEMENT = "nodeType";
+
+    /** Name of the child node definition element. */
+    String CHILDNODEDEFINITION_ELEMENT = "childNodeDefinition";
+
+    /** Name of the property definition element. */
+    String PROPERTYDEFINITION_ELEMENT = "propertyDefinition";
+
+    /** Name of the <code>isMixin</code> attribute. */
+    String ISMIXIN_ATTRIBUTE = "isMixin";
+
+    /** Name of the <code>hasOrderableChildNodes</code> attribute. */
+    String HASORDERABLECHILDNODES_ATTRIBUTE = "hasOrderableChildNodes";
+
+    /**
+     * Name of the <code>isAbstract</code> attribute.
+     * @since JCR 2.0
+     */
+    String ISABSTRACT_ATTRIBUTE = "isAbstract";
+
+    /**
+     * Name of the <code>isQueryable</code> attribute.
+     * @since JCR 2.0
+     */
+    String ISQUERYABLE_ATTRIBUTE = "isQueryable";
+
+    /** Name of the primary item name attribute. */
+    String PRIMARYITEMNAME_ATTRIBUTE = "primaryItemName";
+
+    /** Name of the supertypes element. */
+    String SUPERTYPES_ELEMENT = "supertypes";
+
+    /** Name of the supertype element. */
+    String SUPERTYPE_ELEMENT = "supertype";
+
+    /** Name of the <code>name</code> attribute. */
+    String NAME_ATTRIBUTE = "name";
+
+    /** Name of the <code>autoCreated</code> attribute. */
+    String AUTOCREATED_ATTRIBUTE = "autoCreated";
+
+    /** Name of the <code>mandatory</code> attribute. */
+    String MANDATORY_ATTRIBUTE = "mandatory";
+
+    /** Name of the <code>onParentVersion</code> attribute. */
+    String ONPARENTVERSION_ATTRIBUTE = "onParentVersion";
+
+    /** Name of the <code>protected</code> attribute. */
+    String PROTECTED_ATTRIBUTE = "protected";
+
+    /** Name of the required type attribute. */
+    String REQUIREDTYPE_ATTRIBUTE = "requiredType";
+
+    /** Name of the value constraints element. */
+    String VALUECONSTRAINTS_ELEMENT = "valueConstraints";
+
+    /** Name of the value constraint element. */
+    String VALUECONSTRAINT_ELEMENT = "valueConstraint";
+
+    /** Name of the default values element. */
+    String DEFAULTVALUES_ELEMENT = "defaultValues";
+
+    /** Name of the default value element. */
+    String DEFAULTVALUE_ELEMENT = "defaultValue";
+
+    /** Name of the <code>multiple</code> attribute. */
+    String MULTIPLE_ATTRIBUTE = "multiple";
+
+    /** Name of the required primary types element. */
+    String REQUIREDPRIMARYTYPES_ELEMENT = "requiredPrimaryTypes";
+
+    /** Name of the required primary type element. */
+    String REQUIREDPRIMARYTYPE_ELEMENT = "requiredPrimaryType";
+
+    /** Name of the default primary type attribute. */
+    String DEFAULTPRIMARYTYPE_ATTRIBUTE = "defaultPrimaryType";
+
+    /** Name of the <code>sameNameSiblings</code> attribute. */
+    String SAMENAMESIBLINGS_ATTRIBUTE = "sameNameSiblings";
+
+    /**
+     * Name of the availableQueryOperators element.
+     * @since JCR 2.0
+     */
+    String AVAILABLE_QUERY_OPERATORS_ELEMENT = "availableQueryOperators";
+
+    /**
+     * Name of the availableQueryOperator element.
+     * @since JCR 2.0
+     */
+    String AVAILABLE_QUERY_OPERATOR_ELEMENT = "availableQueryOperator";
+
+    /**
+     * Name of the fullTextSearchable attribute.
+     * @since JCR 2.0
+     */
+    String FULL_TEXT_SEARCHABLE_ATTRIBUTE = "fullTextSearchable";
+
+    /**
+     * Name of the queryOrderable attribute.
+     * @since JCR 2.0
+     */
+    String QUERY_ORDERABLE_ATTRIBUTE = "queryOrderable";
+
+    //----------< attr. not defined by copied from o.a.j.core.n.x.Constants >---
+    /**
+     * Name of the declaring nodetype. This value is not needed during
+     * discovery of nodetype definitions. However if the definition of an item is
+     * retrieved (instead of being calculated on the client), this information is
+     * needed
+     */
+    String DECLARINGNODETYPE_ATTRIBUTE = "declaringNodeType";
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/NodeTypeConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/NodeTypeConstants.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/NodeTypeUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/NodeTypeUtil.java?rev=1002639&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/NodeTypeUtil.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/NodeTypeUtil.java Wed Sep 29 14:11:53 2010
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.commons.webdav;
+
+import org.apache.jackrabbit.util.XMLUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * <code>NodeTypeUtil</code>...
+ */
+public class NodeTypeUtil implements NodeTypeConstants {
+
+    public static Element ntNameToXml(String nodeTypeName, Document document) {
+        Element ntElem = document.createElementNS(JcrRemotingConstants.NS_URI, JcrRemotingConstants.NS_PREFIX + ":" + XML_NODETYPE);
+        Element nameElem = document.createElementNS(JcrRemotingConstants.NS_URI, JcrRemotingConstants.NS_PREFIX + ":" + XML_NODETYPENAME);
+        Text txt = document.createTextNode(nodeTypeName);
+        nameElem.appendChild(txt);
+        ntElem.appendChild(nameElem);
+        return ntElem;
+    }
+
+    public static Collection<String> ntNamesFromXml(Object propValue) {
+        // assume property has be built from xml
+        if (propValue instanceof List) {
+            return retrieveNodeTypeNames(((List<?>)propValue));
+        } else if (propValue instanceof Element) {
+            List<Element> l = Collections.singletonList((Element) propValue);
+            return retrieveNodeTypeNames(l);
+        } else {
+            // Property value cannot be parsed into node type names.
+            return Collections.emptySet();
+        }
+    }
+
+    private static Set<String> retrieveNodeTypeNames(List<?> elementList) {
+        Set<String> nodetypeNames = new HashSet<String>();
+        for (Object content : elementList) {
+            if (!(content instanceof Element)) {
+                continue;
+            }
+            Element el = (Element) content;
+            if (XML_NODETYPE.equals(el.getLocalName()) && JcrRemotingConstants.NS_URI.equals(el.getNamespaceURI())) {
+                String nodetypeName = XMLUtil.getChildText(el, XML_NODETYPENAME, JcrRemotingConstants.NS_URI);
+                if (nodetypeName != null && !"".equals(nodetypeName)) {
+                    nodetypeNames.add(nodetypeName);
+                }
+            } // else: 'dcr:nodetype' element expected -> ignoring element
+        }
+        return nodetypeNames;
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/NodeTypeUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/NodeTypeUtil.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/QueryUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/QueryUtil.java?rev=1002639&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/QueryUtil.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/QueryUtil.java Wed Sep 29 14:11:53 2010
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.commons.webdav;
+
+import org.apache.jackrabbit.util.XMLUtil;
+import org.apache.jackrabbit.value.ValueHelper;
+import org.w3c.dom.Element;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.ValueFormatException;
+import java.util.List;
+
+/**
+ * <code>QueryUtil</code>...
+ */
+public class QueryUtil implements JcrRemotingConstants {
+
+    public static void parseResultPropertyValue(Object propValue,
+                                                List<String> columnNames,
+                                                List<String> selectorNames,
+                                                List<Value> values,
+                                                ValueFactory valueFactory)
+            throws ValueFormatException, RepositoryException {
+        if (propValue instanceof List) {
+            for (Object o : ((List<?>) propValue)) {
+                if (o instanceof Element) {
+                    parseColumnElement((Element) o, columnNames, selectorNames, values, valueFactory);
+                }
+            }
+        } else if (propValue instanceof Element) {
+            parseColumnElement((Element) propValue, columnNames, selectorNames, values, valueFactory);
+        } else {
+            throw new IllegalArgumentException("SearchResultProperty requires a list of 'dcr:column' xml elements.");
+        }
+    }
+
+    private static void parseColumnElement(Element columnElement,
+                                           List<String> columnNames,
+                                           List<String> selectorNames,
+                                           List<Value> values,
+                                           ValueFactory valueFactory)
+            throws ValueFormatException, RepositoryException {
+        if (!XML_QUERY_RESULT_COLUMN.equals(columnElement.getLocalName()) && NS_URI.equals(columnElement.getNamespaceURI())) {
+            // dcr:column element expected within search result -> can't parse
+            return;
+        }
+
+        columnNames.add(XMLUtil.getChildText(columnElement, JCR_NAME_LN, NS_URI));
+        selectorNames.add(XMLUtil.getChildText(columnElement, JCR_SELECTOR_NAME_LN, NS_URI));
+
+        Value jcrValue;
+        Element valueElement = XMLUtil.getChildElement(columnElement, JCR_VALUE_LN, NS_URI);
+        if (valueElement != null) {
+            String typeStr = XMLUtil.getAttribute(valueElement, ATTR_VALUE_TYPE, NS_URI);
+            jcrValue = ValueHelper.deserialize(XMLUtil.getText(valueElement),
+                    PropertyType.valueFromName(typeStr), true, valueFactory);
+        } else {
+            jcrValue = null;
+        }
+        values.add(jcrValue);
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/QueryUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/QueryUtil.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/ValueUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/ValueUtil.java?rev=1002639&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/ValueUtil.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/ValueUtil.java Wed Sep 29 14:11:53 2010
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.commons.webdav;
+
+import org.apache.jackrabbit.util.XMLUtil;
+import org.apache.jackrabbit.value.ValueHelper;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.ValueFormatException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <code>ValuesUtil</code>...
+ */
+public class ValueUtil {
+
+    public static Element valueToXml(Value jcrValue, Document document) throws RepositoryException {
+
+        String type = PropertyType.nameFromValue(jcrValue.getType());
+        String serializedValue = ValueHelper.serialize(jcrValue, true);
+
+        Element xmlValue = document.createElementNS(JcrRemotingConstants.NS_URI, JcrRemotingConstants.NS_PREFIX + ":" + JcrRemotingConstants.XML_VALUE);
+
+        Text txt = document.createTextNode(serializedValue);
+        xmlValue.appendChild(txt);
+
+        Attr attr = document.createAttributeNS(JcrRemotingConstants.NS_URI, JcrRemotingConstants.NS_PREFIX + ":" + JcrRemotingConstants.ATTR_VALUE_TYPE);
+        attr.setValue(type);
+        xmlValue.setAttributeNodeNS(attr);
+
+        return xmlValue;
+    }
+
+    public static Value[] valuesFromXml(Object propValue, int defaultType, ValueFactory valueFactory) throws RepositoryException {
+        Value[] jcrValues;
+        // retrieve jcr-values from child 'value'-element(s)
+        List<Element> valueElements = new ArrayList<Element>();
+        if (propValue == null) {
+            jcrValues = new Value[0];
+        } else { /* not null propValue */
+            if (isValueElement(propValue)) {
+                valueElements.add((Element) propValue);
+            } else if (propValue instanceof List) {
+                for (Object el : ((List<?>) propValue)) {
+                    /* make sure, only Elements with name 'value' are used for
+                    * the 'value' field. any other content (other elements, text,
+                    * comment etc.) is ignored. NO bad-request/conflict error is
+                    * thrown.
+                    */
+                    if (isValueElement(el)) {
+                        valueElements.add((Element) el);
+                    }
+                }
+            }
+            /* fill the 'value' with the valid 'value' elements found before */
+            jcrValues = new Value[valueElements.size()];
+            int i = 0;
+            for (Element element : valueElements) {
+                jcrValues[i] = getJcrValue(element, defaultType, valueFactory);
+                i++;
+            }
+        }
+        return jcrValues;
+    }
+
+    private static boolean isValueElement(Object obj) {
+        return obj instanceof Element && JcrRemotingConstants.XML_VALUE.equals(((Element)obj).getLocalName());
+    }
+
+    /**
+     *
+     * @param valueElement
+     * @param defaultType
+     * @return
+     * @throws javax.jcr.ValueFormatException
+     * @throws javax.jcr.RepositoryException
+     */
+    private static Value getJcrValue(Element valueElement, int defaultType,
+                                     ValueFactory valueFactory)
+        throws ValueFormatException, RepositoryException {
+        if (valueElement == null) {
+            return null;
+        }
+        // make sure the value is never 'null'
+        String value = XMLUtil.getText(valueElement, "");
+        String typeStr = XMLUtil.getAttribute(valueElement, JcrRemotingConstants.ATTR_VALUE_TYPE, JcrRemotingConstants.NS_URI);
+        int type = (typeStr == null) ? defaultType : PropertyType.valueFromName(typeStr);
+        // deserialize value ->> see #valueToXml where values are serialized
+        return ValueHelper.deserialize(value, type, true, valueFactory);
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/ValueUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/webdav/ValueUtil.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/XMLUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/XMLUtil.java?rev=1002639&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/XMLUtil.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/XMLUtil.java Wed Sep 29 14:11:53 2010
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.util;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.CharacterData;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * <code>XMLUtil</code>...
+ */
+public class XMLUtil {
+
+    /**
+     * @param node
+     * @return true if the given node is of type text or CDATA.
+     */
+    public static boolean isText(Node node) {
+        int ntype = node.getNodeType();
+        return ntype == Node.TEXT_NODE || ntype == Node.CDATA_SECTION_NODE;
+    }
+
+    /**
+     * Concatenates the values of all child nodes of type 'Text' or 'CDATA'/
+     *
+     * @param element
+     * @return String representing the value of all Text and CDATA child nodes or
+     * <code>null</code> if the length of the resulting String is 0.
+     * @see #isText(org.w3c.dom.Node)
+     */
+    public static String getText(Element element) {
+        StringBuffer content = new StringBuffer();
+        if (element != null) {
+            NodeList nodes = element.getChildNodes();
+            for (int i = 0; i < nodes.getLength(); i++) {
+                Node child = nodes.item(i);
+                if (isText(child)) {
+                    // cast to super class that contains Text and CData
+                    content.append(((CharacterData) child).getData());
+                }
+            }
+        }
+        return (content.length()==0) ? null : content.toString();
+    }
+
+    /**
+     * Same as {@link #getText(Element)} except that 'defaultValue' is returned
+     * instead of <code>null</code>, if the element does not contain any text.
+     *
+     * @param element
+     * @param defaultValue
+     * @return the text contained in the specified element or
+     * <code>defaultValue</code> if the element does not contain any text.
+     */
+    public static String getText(Element element, String defaultValue) {
+        String txt = getText(element);
+        return (txt == null) ? defaultValue : txt;
+    }
+
+    /**
+     * Calls {@link #getText(Element)} on the first child element that matches
+     * the given local name and namespace.
+     *
+     * @param parent
+     * @param childLocalName
+     * @param childNamespaceURI
+     * @return text contained in the first child that matches the given local name
+     * and namespace or <code>null</code>.
+     * @see #getText(Element)
+     */
+    public static String getChildText(Element parent, String childLocalName, String childNamespaceURI) {
+        Element child = getChildElement(parent, childLocalName, childNamespaceURI);
+        return (child == null) ? null : getText(child);
+    }
+
+    /**
+     * Returns the first child element that matches the given local name and
+     * namespace. If no child element is present or no child element matches,
+     * <code>null</code> is returned.
+     *
+     * @param parent
+     * @param childLocalName
+     * @param childNamespaceURI
+     * @return first child element matching the specified names or <code>null</code>.
+     */
+    public static Element getChildElement(Node parent, String childLocalName, String childNamespaceURI) {
+        if (parent != null) {
+            NodeList children = parent.getChildNodes();
+            for (int i = 0; i < children.getLength(); i++) {
+                Node child = children.item(i);
+                if (child.getNodeType() == Node.ELEMENT_NODE && childLocalName.equals(child.getLocalName()) && childNamespaceURI.equals(child.getNamespaceURI())) {
+                    return (Element)child;
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Returns the value of the named attribute of the current element.
+     *
+     * @param parent
+     * @param localName attribute local name or 'nodeName' if no namespace is
+     * specified.
+     * @param  namespaceURI or <code>null</code>
+     * @return attribute value, or <code>null</code> if not found
+     */
+    public static String getAttribute(Element parent, String localName, String namespaceURI) {
+        if (parent == null) {
+            return null;
+        }
+        Attr attribute;
+        if (namespaceURI == null) {
+            attribute = parent.getAttributeNode(localName);
+        } else {
+            attribute = parent.getAttributeNodeNS(namespaceURI, localName);
+        }
+        if (attribute != null) {
+            return attribute.getValue();
+        } else {
+            return null;
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/XMLUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/XMLUtil.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonDiffHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonDiffHandler.java?rev=1002639&r1=1002638&r2=1002639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonDiffHandler.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonDiffHandler.java Wed Sep 29 14:11:53 2010
@@ -17,11 +17,11 @@
 package org.apache.jackrabbit.server.remoting.davex;
 
 import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.commons.webdav.JcrValueType;
 import org.apache.jackrabbit.server.util.RequestData;
 import org.apache.jackrabbit.commons.json.JsonHandler;
 import org.apache.jackrabbit.commons.json.JsonParser;
 import org.apache.jackrabbit.util.Text;
-import org.apache.jackrabbit.webdav.jcr.JcrValueType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.ContentHandler;

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java?rev=1002639&r1=1002638&r2=1002639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java Wed Sep 29 14:11:53 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.webdav.jcr;
 
+import org.apache.jackrabbit.commons.webdav.JcrRemotingConstants;
 import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.lock.Scope;
 import org.apache.jackrabbit.webdav.observation.ObservationResource;
@@ -25,13 +26,11 @@ import org.apache.jackrabbit.webdav.secu
 import org.apache.jackrabbit.webdav.version.DeltaVResource;
 import org.apache.jackrabbit.webdav.xml.Namespace;
 
-import javax.jcr.PropertyType;
-
 /**
  * <code>ItemResourceConstants</code> provides constants for any resources
  * representing repository items.
  */
-public interface ItemResourceConstants {
+public interface ItemResourceConstants extends JcrRemotingConstants {
 
     /**
      * Methods common to all item resources.
@@ -39,47 +38,9 @@ public interface ItemResourceConstants {
     public static final String METHODS = DavResource.METHODS + ", " + ObservationResource.METHODS + ", " + SearchResource.METHODS + ", " +DeltaVResource.METHODS;
 
     /**
-     * The resource path of the root-item-resource.
-     */
-    public static final String ROOT_ITEM_PATH = "/";
-    /**
-     * Placeholder resource path for the JCR root node.
-     */
-    public static final String ROOT_ITEM_RESOURCEPATH = "/jcr:root";
-
-    /**
-     * The version storage item resource path.
-     */
-    public static final String VERSIONSTORAGE_PATH = "/jcr:system/jcr:versionStorage";
-
-    /**
      * The namespace for all jcr specific extensions.
      */
-    public static final Namespace NAMESPACE = Namespace.getNamespace("dcr", "http://www.day.com/jcr/webdav/1.0");
-
-    public static final String IMPORT_UUID_BEHAVIOR = "ImportUUIDBehavior";
-
-    // xml element names
-    public static final String XML_PRIMARYNODETYPE = "primarynodetype";
-    public static final String XML_VALUE = "value";
-    /**
-     * 'type' attribute for the {@link #XML_VALUE value} element, reflecting the
-     * {@link PropertyType type} of the value being transported.
-     */
-    public static final String ATTR_VALUE_TYPE = "type";
-    public static final String XML_LENGTH = "length";
-    public static final String XML_EXCLUSIVE_SESSION_SCOPED = "exclusive-session-scoped";
-
-    // xml elements used to reflect the workspaces ns-registry
-    // TODO: to be reviewed...
-    public static final String XML_NAMESPACE = "namespace";
-    public static final String XML_PREFIX = "prefix";
-    public static final String XML_URI = "uri";
-
-    // xml elements used for repository-descriptors report
-    public static final String XML_DESCRIPTOR = "descriptor";
-    public static final String XML_DESCRIPTORKEY = "descriptorkey";
-    public static final String XML_DESCRIPTORVALUE = "descriptorvalue";
+    public static final Namespace NAMESPACE = Namespace.getNamespace(NS_PREFIX, NS_URI);
 
     /**
      * Extension to the WebDAV 'exclusive' lock, that allows to distinguish
@@ -89,65 +50,43 @@ public interface ItemResourceConstants {
      */
     public static final Scope EXCLUSIVE_SESSION = Scope.create(XML_EXCLUSIVE_SESSION_SCOPED, NAMESPACE);
 
-    /**
-     * The 'removeexisting' element is not defined by RFC 3253. If it is present
-     * in the UPDATE request body, uuid conflicts should be solved by removing
-     * the existing nodes.
-     *
-     * @see javax.jcr.Node#restore(javax.jcr.version.Version, boolean)
-     * @see javax.jcr.Workspace#restore(javax.jcr.version.Version[], boolean)
-     * @see org.apache.jackrabbit.webdav.version.UpdateInfo
-     */
-    public static final String XML_REMOVEEXISTING = "removeexisting";
-
-    /**
-     * The 'relpath' element is not defined by RFC 3253. If it is present
-     * in the UPDATE request body, the server is forced to used the text contained
-     * as 'relPath' argument for the {@link javax.jcr.Node#restore(javax.jcr.version.Version, String, boolean)
-     * Node.restore} call.
-     *
-     * @see javax.jcr.Node#restore(javax.jcr.version.Version, String, boolean)
-     * @see org.apache.jackrabbit.webdav.version.UpdateInfo
-     */
-    public static final String XML_RELPATH = "relpath";
-
     // name of the workspace for which the repository session has been created.
-    public static final DavPropertyName JCR_WORKSPACE_NAME = DavPropertyName.create("workspaceName", NAMESPACE);
+    public static final DavPropertyName JCR_WORKSPACE_NAME = DavPropertyName.create(JCR_WORKSPACE_NAME_LN, NAMESPACE);
 
     // general property names
-    public static final DavPropertyName JCR_NAME = DavPropertyName.create("name", NAMESPACE);
-    public static final DavPropertyName JCR_PATH = DavPropertyName.create("path", NAMESPACE);
-    public static final DavPropertyName JCR_DEPTH = DavPropertyName.create("depth", NAMESPACE);
-    public static final DavPropertyName JCR_PARENT = DavPropertyName.create("parent", NAMESPACE);
-    public static final DavPropertyName JCR_ISNEW = DavPropertyName.create("isnew", NAMESPACE);
-    public static final DavPropertyName JCR_ISMODIFIED = DavPropertyName.create("ismodified", NAMESPACE);
-    public static final DavPropertyName JCR_DEFINITION = DavPropertyName.create("definition", NAMESPACE);
-    public static final DavPropertyName JCR_SELECTOR_NAME = DavPropertyName.create("selectorName", NAMESPACE);
+    public static final DavPropertyName JCR_NAME = DavPropertyName.create(JCR_NAME_LN, NAMESPACE);
+    public static final DavPropertyName JCR_PATH = DavPropertyName.create(JCR_PATH_LN, NAMESPACE);
+    public static final DavPropertyName JCR_DEPTH = DavPropertyName.create(JCR_DEPTH_LN, NAMESPACE);
+    public static final DavPropertyName JCR_PARENT = DavPropertyName.create(JCR_PARENT_LN, NAMESPACE);
+    public static final DavPropertyName JCR_ISNEW = DavPropertyName.create(JCR_ISNEW_LN, NAMESPACE);
+    public static final DavPropertyName JCR_ISMODIFIED = DavPropertyName.create(JCR_ISMODIFIED_LN, NAMESPACE);
+    public static final DavPropertyName JCR_DEFINITION = DavPropertyName.create(JCR_DEFINITION_LN, NAMESPACE);
+    public static final DavPropertyName JCR_SELECTOR_NAME = DavPropertyName.create(JCR_SELECTOR_NAME_LN, NAMESPACE);
 
     // property names used for resources representing jcr-nodes
-    public static final DavPropertyName JCR_PRIMARYNODETYPE = DavPropertyName.create(XML_PRIMARYNODETYPE, NAMESPACE);
-    public static final DavPropertyName JCR_MIXINNODETYPES = DavPropertyName.create("mixinnodetypes", NAMESPACE);
-    public static final DavPropertyName JCR_INDEX = DavPropertyName.create("index", NAMESPACE);
-    public static final DavPropertyName JCR_REFERENCES = DavPropertyName.create("references", NAMESPACE);
+    public static final DavPropertyName JCR_PRIMARYNODETYPE = DavPropertyName.create(JCR_PRIMARYNODETYPE_LN, NAMESPACE);
+    public static final DavPropertyName JCR_MIXINNODETYPES = DavPropertyName.create(JCR_MIXINNODETYPES_LN, NAMESPACE);
+    public static final DavPropertyName JCR_INDEX = DavPropertyName.create(JCR_INDEX_LN, NAMESPACE);
+    public static final DavPropertyName JCR_REFERENCES = DavPropertyName.create(JCR_REFERENCES_LN, NAMESPACE);
     /**
      * @since JCR 2.0
      */
-    public static final DavPropertyName JCR_WEAK_REFERENCES = DavPropertyName.create("weakreferences", NAMESPACE);
-    public static final DavPropertyName JCR_UUID = DavPropertyName.create("uuid", NAMESPACE);
-    public static final DavPropertyName JCR_PRIMARYITEM = DavPropertyName.create("primaryitem", NAMESPACE);
+    public static final DavPropertyName JCR_WEAK_REFERENCES = DavPropertyName.create(JCR_WEAK_REFERENCES_LN, NAMESPACE);
+    public static final DavPropertyName JCR_UUID = DavPropertyName.create(JCR_UUID_LN, NAMESPACE);
+    public static final DavPropertyName JCR_PRIMARYITEM = DavPropertyName.create(JCR_PRIMARYITEM_LN, NAMESPACE);
 
     // property names used for resources representing jcr-properties
-    public static final DavPropertyName JCR_TYPE = DavPropertyName.create("type", NAMESPACE);
-    public static final DavPropertyName JCR_VALUE = DavPropertyName.create("value", NAMESPACE);
-    public static final DavPropertyName JCR_VALUES = DavPropertyName.create("values", NAMESPACE);
-    public static final DavPropertyName JCR_LENGTH = DavPropertyName.create("length", NAMESPACE);
-    public static final DavPropertyName JCR_LENGTHS = DavPropertyName.create("lengths", NAMESPACE);
+    public static final DavPropertyName JCR_TYPE = DavPropertyName.create(JCR_TYPE_LN, NAMESPACE);
+    public static final DavPropertyName JCR_VALUE = DavPropertyName.create(JCR_VALUE_LN, NAMESPACE);
+    public static final DavPropertyName JCR_VALUES = DavPropertyName.create(JCR_VALUES_LN, NAMESPACE);
+    public static final DavPropertyName JCR_LENGTH = DavPropertyName.create(JCR_LENGTH_LN, NAMESPACE);
+    public static final DavPropertyName JCR_LENGTHS = DavPropertyName.create(JCR_LENGTHS_LN, NAMESPACE);
 
     // property names used for resource representing a workspace
-    public static final DavPropertyName JCR_NAMESPACES = DavPropertyName.create("namespaces", NAMESPACE);
+    public static final DavPropertyName JCR_NAMESPACES = DavPropertyName.create(JCR_NAMESPACES_LN, NAMESPACE);
 
     // property names used for resource representing a version history
-    public static final DavPropertyName JCR_VERSIONABLEUUID = DavPropertyName.create("versionableuuid", NAMESPACE);
+    public static final DavPropertyName JCR_VERSIONABLEUUID = DavPropertyName.create(JCR_VERSIONABLEUUID_LN, NAMESPACE);
 
     //-----------------------------------------< JSR170 specific privileges >---
     /**

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrValueType.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrValueType.java?rev=1002639&r1=1002638&r2=1002639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrValueType.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrValueType.java Wed Sep 29 14:11:53 2010
@@ -16,84 +16,10 @@
  */
 package org.apache.jackrabbit.webdav.jcr;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.jcr.PropertyType;
-import java.util.HashMap;
-import java.util.Map;
-
-/** <code>JcrValueType</code>... */
-public final class JcrValueType {
-
-    private static Logger log = LoggerFactory.getLogger(JcrValueType.class);
-
-    /**
-     * Fragment for build the content type of request entities representing
-     * a JCR-value. The fragment must be completed as follows:
-     * <pre>
-     * jcr-value/ + Value.getType().toLowerCase()
-     * </pre>
-     *
-     * resulting in the following types:
-     * <pre>
-     * jcr-value/binary
-     * jcr-value/boolean
-     * jcr-value/date
-     * jcr-value/decimal
-     * jcr-value/double
-     * jcr-value/long
-     * jcr-value/name
-     * jcr-value/path
-     * jcr-value/reference
-     * jcr-value/string
-     * jcr-value/undefined
-     * jcr-value/uri
-     * jcr-value/weakreference
-     * </pre>
-     */
-    private static final String VALUE_CONTENT_TYPE_FRAGMENT = "jcr-value/";
-
-    /**
-     * Hardcoded lookup from content type as created by {@link #contentTypeFromType(int)}.
-     * Reason: As of JCR 2.0 there is no trivial rule to obtain the the TYPENAME
-     * constant from a lower-cased string: WeakReference uses camel-case and URI
-     * is all upper case...
-     */
-    private static final Map<String, Integer> TYPE_LOOKUP = new HashMap<String,Integer>();
-    static {
-        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.BINARY), PropertyType.BINARY);
-        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.BOOLEAN), PropertyType.BOOLEAN);
-        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.DATE), PropertyType.DATE);
-        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.DECIMAL), PropertyType.DECIMAL);
-        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.DOUBLE), PropertyType.DOUBLE);
-        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.LONG), PropertyType.LONG);
-        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.NAME), PropertyType.NAME);
-        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.PATH), PropertyType.PATH);
-        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.REFERENCE), PropertyType.REFERENCE);
-        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.STRING), PropertyType.STRING);
-        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.UNDEFINED), PropertyType.UNDEFINED);
-        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.URI), PropertyType.URI);
-        TYPE_LOOKUP.put(contentTypeFromType(PropertyType.WEAKREFERENCE), PropertyType.WEAKREFERENCE);
-    }
-
-    public static String contentTypeFromType(int propertyType) {
-        return VALUE_CONTENT_TYPE_FRAGMENT + PropertyType.nameFromValue(propertyType).toLowerCase();
-    }
-
-    public static int typeFromContentType(String contentType) {
-        if (contentType != null) {
-            // remove charset if present
-            int pos = contentType.indexOf(';');
-            String ct = (pos == -1) ? contentType : contentType.substring(0, pos);
-            if (TYPE_LOOKUP.containsKey(ct)) {
-                return TYPE_LOOKUP.get(ct);
-            }
-        }
+/** <code>JcrValueType</code>...
+ *
+ * @deprecate As of Jackrabbit 2.2. Please Use {@link org.apache.jackrabbit.commons.webdav.JcrValueType} instead.
+ */
+public final class JcrValueType extends org.apache.jackrabbit.commons.webdav.JcrValueType {
 
-        // some invalid content type argument that does not match any of the
-        // strings created by contentTypeFromType(int propertyType)
-        log.warn("Cannot extract property type from content type " + contentType + " -> Fallback is UNDEFINED.");
-        return PropertyType.UNDEFINED;
-    }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java?rev=1002639&r1=1002638&r2=1002639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java Wed Sep 29 14:11:53 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.webdav.jcr.nodetype;
 
+import org.apache.jackrabbit.commons.webdav.NodeTypeConstants;
 import org.apache.jackrabbit.webdav.xml.XmlSerializable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeProperty.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeProperty.java?rev=1002639&r1=1002638&r2=1002639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeProperty.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeProperty.java Wed Sep 29 14:11:53 2010
@@ -16,19 +16,17 @@
  */
 package org.apache.jackrabbit.webdav.jcr.nodetype;
 
+import org.apache.jackrabbit.commons.webdav.NodeTypeConstants;
+import org.apache.jackrabbit.commons.webdav.NodeTypeUtil;
 import org.apache.jackrabbit.webdav.property.AbstractDavProperty;
 import org.apache.jackrabbit.webdav.property.DavProperty;
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
-import org.apache.jackrabbit.webdav.xml.DomUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 import javax.jcr.nodetype.NodeType;
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Set;
 
 /**
@@ -36,8 +34,6 @@ import java.util.Set;
  */
 public class NodeTypeProperty extends AbstractDavProperty<Set<String>> implements NodeTypeConstants {
 
-    private static Logger log = LoggerFactory.getLogger(NodeTypeProperty.class);
-
     private final Set<String> nodetypeNames = new HashSet<String>();
 
     public NodeTypeProperty(DavPropertyName name, NodeType nodeType, boolean isProtected) {
@@ -73,43 +69,17 @@ public class NodeTypeProperty extends Ab
         if (property instanceof NodeTypeProperty) {
             nodetypeNames.addAll(((NodeTypeProperty) property).nodetypeNames);
         } else {
-            // assume property has be built from xml
-            Object propValue = property.getValue();
-            if (propValue instanceof List) {
-                retrieveNodeTypeNames(((List<?>)propValue));
-            } else if (propValue instanceof Element) {
-                List<Element> l = Collections.singletonList((Element) propValue);
-                retrieveNodeTypeNames(l);
-            } else {
-                log.debug("NodeTypeProperty '" + property.getName() + "' has no/unparsable value.");
-            }
-        }
-    }
-
-    private void retrieveNodeTypeNames(List<?> elementList) {
-        for (Object content : elementList) {
-            if (!(content instanceof Element)) {
-                continue;
-            }
-            Element el = (Element) content;
-            if (XML_NODETYPE.equals(el.getLocalName()) && NodeTypeConstants.NAMESPACE.isSame(el.getNamespaceURI())) {
-                String nodetypeName = DomUtil.getChildText(el, XML_NODETYPENAME, NodeTypeConstants.NAMESPACE);
-                if (nodetypeName != null && !"".equals(nodetypeName)) {
-                    nodetypeNames.add(nodetypeName);
-                }
-            } else {
-                log.debug("'dcr:nodetype' element expected -> ignoring element '" + ((Element) content).getNodeName() + "'");
-            }
+            nodetypeNames.addAll(NodeTypeUtil.ntNamesFromXml(property.getValue()));
         }
     }
 
     /**
-     * Return a set of nodetype names present in this property.
+     * Return a set of node type names present in this property.
      *
-     * @return set of nodetype names
+     * @return set of node type names
      */
     public Set<String> getNodeTypeNames() {
-        return nodetypeNames;
+        return Collections.unmodifiableSet(nodetypeNames);
     }
 
     /**
@@ -118,7 +88,7 @@ public class NodeTypeProperty extends Ab
      * @return a Set of nodetype names (String).
      */
     public Set<String> getValue() {
-        return nodetypeNames;
+        return Collections.unmodifiableSet(nodetypeNames);
     }
 
     /**
@@ -128,8 +98,7 @@ public class NodeTypeProperty extends Ab
     public Element toXml(Document document) {
         Element elem = getName().toXml(document);
         for (String name : getNodeTypeNames()) {
-            Element ntElem = DomUtil.addChildElement(elem, XML_NODETYPE, NodeTypeConstants.NAMESPACE);
-            DomUtil.addChildElement(ntElem, XML_NODETYPENAME, NodeTypeConstants.NAMESPACE, name);
+            elem.appendChild(NodeTypeUtil.ntNameToXml(name, document));
         }
         return elem;
     }

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java?rev=1002639&r1=1002638&r2=1002639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java Wed Sep 29 14:11:53 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.webdav.jcr.observation;
 
+import org.apache.jackrabbit.commons.webdav.EventUtil;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
 import org.apache.jackrabbit.webdav.DavServletResponse;
@@ -63,48 +64,6 @@ public class SubscriptionImpl implements
     private static Logger log = LoggerFactory.getLogger(SubscriptionImpl.class);
     private static final long DEFAULT_TIMEOUT = 300000; // 5 minutes
 
-    /**
-     * Element representing the 'nodeadded' event type.
-     * @see javax.jcr.observation.Event#NODE_ADDED
-     */
-    private static final String EVENT_NODEADDED = "nodeadded";
-
-    /**
-     * Element representing the 'noderemoved' event type.
-     * @see javax.jcr.observation.Event#NODE_REMOVED
-     */
-    private static final String EVENT_NODEREMOVED = "noderemoved";
-
-    /**
-     * Element representing the 'propertyadded' event type.
-     * @see javax.jcr.observation.Event#PROPERTY_ADDED
-     */
-    private static final String EVENT_PROPERTYADDED = "propertyadded";
-
-    /**
-     * Element representing the 'propertyremoved' event type.
-     * @see javax.jcr.observation.Event#PROPERTY_REMOVED
-     */
-    private static final String EVENT_PROPERTYREMOVED = "propertyremoved";
-
-    /**
-     * Element representing the 'propertychanged' event type.
-     * @see javax.jcr.observation.Event#PROPERTY_CHANGED
-     */
-    private static final String EVENT_PROPERTYCHANGED = "propertychanged";
-
-    /**
-     * Element representing the 'nodemoved' event type.
-     * @see javax.jcr.observation.Event#NODE_MOVED
-     */
-    private static final String EVENT_NODEMOVED = "nodemoved";
-
-    /**
-     * Element representing the 'persist' event type.
-     * @see javax.jcr.observation.Event#PERSIST
-     */
-    private static final String EVENT_PERSIST = "persist";
-
     private SubscriptionInfo info;
     private long expirationTime;
 
@@ -401,32 +360,7 @@ public class SubscriptionImpl implements
      * </ul>
      */
     public static EventType getEventType(int jcrEventType) {
-        String localName;
-        switch (jcrEventType) {
-            case Event.NODE_ADDED:
-                localName = EVENT_NODEADDED;
-                break;
-            case Event.NODE_REMOVED:
-                localName = EVENT_NODEREMOVED;
-                break;
-            case Event.PROPERTY_ADDED:
-                localName = EVENT_PROPERTYADDED;
-                break;
-            case Event.PROPERTY_CHANGED:
-                localName = EVENT_PROPERTYCHANGED;
-                break;
-            case Event.PROPERTY_REMOVED:
-                localName = EVENT_PROPERTYREMOVED;
-                break;
-            case Event.NODE_MOVED:
-                localName = EVENT_NODEMOVED;
-                break;
-            case Event.PERSIST:
-                localName = EVENT_PERSIST;
-                break;
-            default: // no default
-                throw new IllegalArgumentException("Invalid JCR event type: " + jcrEventType);
-        }
+        String localName = EventUtil.getEventName(jcrEventType);
         return DefaultEventType.create(localName, NAMESPACE);
     }
 
@@ -434,15 +368,7 @@ public class SubscriptionImpl implements
      * @return The DAV event type representation for all known JCR event types.
      */
     public static EventType[] getAllEventTypes() {
-        EventType[] types = new EventType[] {
-                getEventType(javax.jcr.observation.Event.NODE_ADDED),
-                getEventType(javax.jcr.observation.Event.NODE_REMOVED),
-                getEventType(javax.jcr.observation.Event.PROPERTY_ADDED),
-                getEventType(javax.jcr.observation.Event.PROPERTY_CHANGED),
-                getEventType(javax.jcr.observation.Event.PROPERTY_REMOVED),
-                getEventType(javax.jcr.observation.Event.NODE_MOVED),
-                getEventType(javax.jcr.observation.Event.PERSIST)
-        };
+        EventType[] types = DefaultEventType.create(EventUtil.EVENT_ALL, NAMESPACE);
         return types;
     }
 
@@ -470,26 +396,11 @@ public class SubscriptionImpl implements
         if (eventType == null || !NAMESPACE.equals(eventType.getNamespace())) {
             throw new DavException(DavServletResponse.SC_UNPROCESSABLE_ENTITY, "Invalid JCR event type: "+ eventType + ": Namespace mismatch.");
         }
-        int eType;
         String eventName = eventType.getName();
-        if (EVENT_NODEADDED.equals(eventName)) {
-            eType = Event.NODE_ADDED;
-        } else if (EVENT_NODEREMOVED.equals(eventName)) {
-            eType = Event.NODE_REMOVED;
-        } else if (EVENT_PROPERTYADDED.equals(eventName)) {
-            eType = Event.PROPERTY_ADDED;
-        } else if (EVENT_PROPERTYCHANGED.equals(eventName)) {
-            eType = Event.PROPERTY_CHANGED;
-        } else if (EVENT_PROPERTYREMOVED.equals(eventName)) {
-            eType = Event.PROPERTY_REMOVED;
-        } else if (EVENT_NODEMOVED.equals(eventName)) {
-            eType = Event.NODE_MOVED;
-        } else if (EVENT_PERSIST.equals(eventName)) {
-            eType = Event.PERSIST;
-        } else {
+        if (!EventUtil.isValidEventName(eventName)) {
             throw new DavException(DavServletResponse.SC_UNPROCESSABLE_ENTITY, "Invalid event type: "+eventName);
         }
-        return eType;
+        return EventUtil.getJcrEventType(eventName);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java?rev=1002639&r1=1002638&r2=1002639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java Wed Sep 29 14:11:53 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.webdav.jcr.property;
 
+import org.apache.jackrabbit.commons.webdav.ValueUtil;
 import org.apache.jackrabbit.value.ValueHelper;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavServletResponse;
@@ -23,7 +24,6 @@ import org.apache.jackrabbit.webdav.jcr.
 import org.apache.jackrabbit.webdav.property.AbstractDavProperty;
 import org.apache.jackrabbit.webdav.property.DavProperty;
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
-import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -34,13 +34,12 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
 import javax.jcr.ValueFactory;
-import java.util.ArrayList;
-import java.util.List;
 
 /**
- * <code>ValuesProperty</code> extends {@link org.apache.jackrabbit.webdav.property.DavProperty} providing
- * utilities to handle the multiple values of the property item represented
- * by this resource.
+ * <code>ValuesProperty</code> implements {@link org.apache.jackrabbit.webdav.property.DavProperty}
+ * providing utilities to handle the value(s) of a JCR property item resource.
+ * In case the property is multivalued the DavProperty value consists of
+ * an element named {@link #JCR_VALUES} otherwise its name is {@link #JCR_VALUE}.
  */
 public class ValuesProperty extends AbstractDavProperty<Value[]> implements ItemResourceConstants {
 
@@ -90,38 +89,7 @@ public class ValuesProperty extends Abst
             throw new DavException(DavServletResponse.SC_BAD_REQUEST, "ValuesProperty may only be created with a property that has name="+JCR_VALUES.getName());
         }
 
-        // retrieve jcr-values from child 'value'-element(s)
-        List<Element> valueElements = new ArrayList<Element>();
-        Object propValue = property.getValue();
-        if (propValue == null) {
-            jcrValues = new Value[0];
-        } else { /* not null propValue */
-            if (isValueElement(propValue)) {
-                valueElements.add((Element) propValue);
-            } else if (propValue instanceof List) {
-                for (Object el : ((List<?>) property.getValue())) {
-                    /* make sure, only Elements with name 'value' are used for
-                    * the 'value' field. any other content (other elements, text,
-                    * comment etc.) is ignored. NO bad-request/conflict error is
-                    * thrown.
-                    */
-                    if (isValueElement(el)) {
-                        valueElements.add((Element) el);
-                    }
-                }
-            }
-            /* fill the 'value' with the valid 'value' elements found before */
-            jcrValues = new Value[valueElements.size()];
-            int i = 0;
-            for (Element element : valueElements) {
-                jcrValues[i] = getJcrValue(element, defaultType, valueFactory);
-                i++;
-            }
-        }
-    }
-
-    private static boolean isValueElement(Object obj) {
-        return obj instanceof Element && XML_VALUE.equals(((Element)obj).getLocalName());
+        jcrValues = ValueUtil.valuesFromXml(property.getValue(), defaultType, valueFactory);
     }
 
     private void checkPropertyName(DavPropertyName reqName) throws ValueFormatException {
@@ -131,32 +99,10 @@ public class ValuesProperty extends Abst
     }
 
     /**
-     *
-     * @param valueElement
-     * @param defaultType
-     * @return
-     * @throws ValueFormatException
-     * @throws RepositoryException
-     */
-    private static Value getJcrValue(Element valueElement, int defaultType,
-                                     ValueFactory valueFactory)
-        throws ValueFormatException, RepositoryException {
-        if (valueElement == null) {
-            return null;
-        }
-        // make sure the value is never 'null'
-        String value = DomUtil.getText(valueElement, "");
-        String typeStr = DomUtil.getAttribute(valueElement, ATTR_VALUE_TYPE, ItemResourceConstants.NAMESPACE);
-        int type = (typeStr == null) ? defaultType : PropertyType.valueFromName(typeStr);
-        // deserialize value ->> see #toXml where values are serialized
-        return ValueHelper.deserialize(value, type, true, valueFactory);
-    }
-
-    /**
      * Converts the value of this property to a {@link javax.jcr.Value value array}.
      *
      * @return Array of Value objects
-     * @throws ValueFormatException if convertion of the internal jcr values to
+     * @throws ValueFormatException if converting the internal jcr values to
      * the specified value type fails.
      */
     public Value[] getJcrValues(int propertyType, ValueFactory valueFactory) throws ValueFormatException {
@@ -165,7 +111,7 @@ public class ValuesProperty extends Abst
         for (int i = 0; i < jcrValues.length; i++) {
             vs[i] = ValueHelper.convert(jcrValues[i], propertyType, valueFactory);
         }
-        return jcrValues;
+        return vs;
     }
 
     /**
@@ -234,10 +180,7 @@ public class ValuesProperty extends Abst
         Element elem = getName().toXml(document);
         try {
             for (Value v : jcrValues) {
-                String type = PropertyType.nameFromValue(v.getType());
-                String serializedValue = ValueHelper.serialize(v, true);
-                Element xmlValue = DomUtil.createElement(document, XML_VALUE, ItemResourceConstants.NAMESPACE, serializedValue);
-                DomUtil.setAttribute(xmlValue, ATTR_VALUE_TYPE, ItemResourceConstants.NAMESPACE, type);
+                Element xmlValue = ValueUtil.valueToXml(v, document);
                 elem.appendChild(xmlValue);
             }
         } catch (RepositoryException e) {



Mime
View raw message