jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r368683 [6/8] - in /incubator/jackrabbit/trunk/contrib/jcr-server: client/ client/src/java/org/apache/jackrabbit/webdav/client/methods/ server/ server/src/java/org/apache/jackrabbit/server/ server/src/java/org/apache/jackrabbit/server/io/ s...
Date Fri, 13 Jan 2006 11:13:30 GMT
Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/Position.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/Position.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/Position.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/Position.java Fri Jan 13 03:11:35 2006
@@ -16,9 +16,14 @@
 package org.apache.jackrabbit.webdav.ordering;
 
 import org.apache.log4j.Logger;
-import org.jdom.Element;
+import org.apache.jackrabbit.webdav.xml.XmlSerializable;
+import org.apache.jackrabbit.webdav.xml.ElementIterator;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
-import java.util.HashMap;
+import java.util.Set;
+import java.util.HashSet;
 
 /**
  * <code>Position</code> encapsulates the position in ordering information
@@ -30,25 +35,20 @@
  * @see OrderingConstants#XML_POSITION
  * @see OrderPatch
  */
-public class Position implements OrderingConstants {
+public class Position implements OrderingConstants, XmlSerializable {
 
     private static Logger log = Logger.getLogger(Position.class);
 
-    public static final int TYPE_FIRST = 1;
-    public static final int TYPE_LAST = 2;
-    public static final int TYPE_BEFORE = 4;
-    public static final int TYPE_AFTER = 8;
-
-    private static final HashMap xmlTypeMap = new HashMap(4);
+    private static final Set VALID_TYPES = new HashSet();
     static {
-        xmlTypeMap.put(XML_FIRST, new Integer(TYPE_FIRST));
-        xmlTypeMap.put(XML_LAST, new Integer(TYPE_LAST));
-        xmlTypeMap.put(XML_BEFORE, new Integer(TYPE_BEFORE));
-        xmlTypeMap.put(XML_AFTER, new Integer(TYPE_AFTER));
+        VALID_TYPES.add(XML_FIRST);
+        VALID_TYPES.add(XML_LAST);
+        VALID_TYPES.add(XML_AFTER);
+        VALID_TYPES.add(XML_BEFORE);
     }
 
-    private int type;
-    private String segment;
+    private final String type;
+    private final String segment;
 
     /**
      * Create a new <code>Position</code> object with the specified type.
@@ -61,38 +61,14 @@
      * or {@link #XML_LAST}.
      */
     public Position(String type) {
+        if (!VALID_TYPES.contains(type)) {
+            throw new IllegalArgumentException("Invalid type: " + type);
+        }
         if (!(XML_FIRST.equals(type) || XML_LAST.equals(type))) {
             throw new IllegalArgumentException("If type is other than 'first' or 'last' a segment must be specified");
         }
-        setType(type);
-    }
-
-    /**
-     * Create a new <code>Position</code> object from the specified position
-     * element. The element must fulfill the following structure:<br>
-     * <pre>
-     * &lt;!ELEMENT position (first | last | before | after) &gt;
-     * &lt;!ELEMENT segment (#PCDATA) &gt;
-     * &lt;!ELEMENT first EMPTY &gt;
-     * &lt;!ELEMENT last EMPTY &gt;
-     * &lt;!ELEMENT before segment &gt;
-     * &lt;!ELEMENT after segment &gt;
-     * </pre>
-     *
-     * @param position Xml element defining the position.
-     * @throws IllegalArgumentException if the given Xml element is not valid.
-     */
-    public Position(Element position) {
-        if (position.getChildren().size() != 1) {
-            throw new IllegalArgumentException("The 'position' element must contain exactly a single child indicating the type.");
-        }
-        Element typeElem = (Element)position.getChildren().get(0);
-        String type = typeElem.getName();
-        String segmentText = null;
-        if (typeElem.getChildren().size() > 0) {
-            segmentText = typeElem.getChildText(XML_SEGMENT);
-        }
-        init(type, segmentText);
+        this.type = type;
+        this.segment = null;
     }
 
     /**
@@ -105,20 +81,13 @@
      * form a valid pair.
      */
     public Position(String type, String segment) {
-        init(type, segment);
+        if (!VALID_TYPES.contains(type)) {
+            throw new IllegalArgumentException("Invalid type: " + type);
     }
-
-    /**
-     * Initialize the internal fields.
-     *
-     * @param type
-     * @param segment
-     */
-    private void init(String type, String segment) {
         if ((XML_AFTER.equals(type) || XML_BEFORE.equals(type)) && (segment == null || "".equals(segment))) {
             throw new IllegalArgumentException("If type is other than 'first' or 'last' a segment must be specified");
         }
-        setType(type);
+        this.type = type;
         this.segment = segment;
     }
 
@@ -129,20 +98,11 @@
      *
      * @return type
      */
-    public int getType() {
+    public String getType() {
         return type;
     }
 
     /**
-     * Set the type.
-     *
-     * @param xmlType
-     */
-    private void setType(String xmlType) {
-        type = ((Integer)xmlTypeMap.get(xmlType)).intValue();
-    }
-
-    /**
      * Returns the segment used to create this <code>Position</code> object or
      * <code>null</code> if no segment is present with the type.
      *
@@ -151,5 +111,48 @@
      */
     public String getSegment() {
         return segment;
+    }
+
+    //------------------------------------------< XmlSerializable interface >---
+    /**
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     * @param document
+     */
+    public Element toXml(Document document) {
+        Element pos = DomUtil.createElement(document, XML_POSITION, NAMESPACE);
+        DomUtil.addChildElement(pos, type, NAMESPACE, segment);
+        return pos;
+    }
+
+    //-----------------------------------------------------< static methods >---
+    /**
+     * Create a new <code>Position</code> object from the specified position
+     * element. The element must fulfill the following structure:<br>
+     * <pre>
+     * &lt;!ELEMENT position (first | last | before | after) &gt;
+     * &lt;!ELEMENT segment (#PCDATA) &gt;
+     * &lt;!ELEMENT first EMPTY &gt;
+     * &lt;!ELEMENT last EMPTY &gt;
+     * &lt;!ELEMENT before segment &gt;
+     * &lt;!ELEMENT after segment &gt;
+     * </pre>
+     *
+     * @param positionElement Xml element defining the position.
+     * @throws IllegalArgumentException if the given Xml element is not valid.
+     */
+    public static Position createFromXml(Element positionElement) {
+        if (!DomUtil.matches(positionElement, XML_POSITION, NAMESPACE)) {
+            throw new IllegalArgumentException("The 'DAV:position' element required.");
+        }
+        ElementIterator it = DomUtil.getChildren(positionElement);
+        while (it.hasNext()) {
+            Element el = it.nextElement();
+            String type = el.getLocalName();
+            // read the text of DAV:segment child element inside the type
+            String segmentText = DomUtil.getChildText(el, XML_SEGMENT, NAMESPACE);
+            // stop after the first iteration
+            new Position(type, segmentText);
+        }
+        throw new IllegalArgumentException("The 'DAV:position' element required with exact one child indicating the type.");
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/AbstractDavProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/AbstractDavProperty.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/AbstractDavProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/AbstractDavProperty.java Fri Jan 13 03:11:35 2006
@@ -16,10 +16,14 @@
 package org.apache.jackrabbit.webdav.property;
 
 import org.apache.log4j.Logger;
-import org.jdom.Element;
+import org.apache.jackrabbit.webdav.xml.XmlSerializable;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.Document;
 
-import java.util.Arrays;
-import java.util.List;
+import java.util.Iterator;
+import java.util.Collection;
 
 /**
  * <code>AbstractDavProperty</code> provides generic METHODS used by various
@@ -80,16 +84,16 @@
      * Return a JDOM element representation of this property. The value of the
      * property will be added as text or as child element.
      * <pre>
-     * new DavProperty("displayname", "WebDAV Directory").toXml()
+     * new DavProperty("displayname", "WebDAV Directory").toXml
      * gives a element like:
      * &lt;D:displayname&gt;WebDAV Directory&lt;/D:displayname&gt;
      *
-     * new DavProperty("resourcetype", new Element("collection")).toXml()
+     * new DavProperty("resourcetype", new Element("collection")).toXml
      * gives a element like:
      * &lt;D:resourcetype&gt;&lt;D:collection/&gt;&lt;/D:resourcetype&gt;
      *
      * Element[] customVals = { new Element("bla", customNamespace), new Element("bli", customNamespace) };
-     * new DavProperty("custom-property", customVals, customNamespace).toXml()
+     * new DavProperty("custom-property", customVals, customNamespace).toXml
      * gives an element like
      * &lt;Z:custom-property&gt;
      *    &lt;Z:bla/&gt;
@@ -98,20 +102,39 @@
      * </pre>
      *
      * @return a JDOM element of this property
-     * @see DavProperty#toXml()
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     * @param document
      */
-    public Element toXml() {
-	Element elem = getName().toXml();
+    public Element toXml(Document document) {
+	Element elem = getName().toXml(document);
         Object value = getValue();
+        // todo: improve....
 	if (value != null) {
-	    if (value instanceof Element) {
-		elem.addContent((Element) value);
-	    } else if (value instanceof Element[]) {
-                elem.addContent(Arrays.asList((Element[])value));
-            } else if (value instanceof List) {
-                elem.addContent((List)value);
+	    if (value instanceof XmlSerializable) {
+                elem.appendChild(((XmlSerializable)value).toXml(document));
+            } else if (value instanceof Node) {
+                Node n = document.importNode((Node)value, true);
+		elem.appendChild(n);
+	    } else if (value instanceof Node[]) {
+                for (int i = 0; i < ((Node[])value).length; i++) {
+                    Node n = document.importNode(((Node[])value)[i], true);
+                    elem.appendChild(n);
+                }
+            } else if (value instanceof Collection) {
+                Iterator it = ((Collection)value).iterator();
+                while (it.hasNext()) {
+                    Object entry = it.next();
+                    if (entry instanceof XmlSerializable) {
+                        elem.appendChild(((XmlSerializable)entry).toXml(document));
+                    } else if (entry instanceof Node) {
+                        Node n = document.importNode((Node)entry, true);
+                        elem.appendChild(n);
+                    } else {
+                        DomUtil.setText(elem, entry.toString());
+                    }
+                }
             } else {
-                elem.setText(value.toString());
+                DomUtil.setText(elem, value.toString());
 	    }
 	}
 	return elem;

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavProperty.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavProperty.java Fri Jan 13 03:11:35 2006
@@ -15,42 +15,35 @@
  */
 package org.apache.jackrabbit.webdav.property;
 
-import org.jdom.Element;
 import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.xml.XmlSerializable;
 
 /**
  * The <code>Property</code> class represents a Property of a WebDAV
  * resource. The {@link #hashCode()} and {@link #equals(Object)} METHODS are
  * overridden in a way, that the name and value of the property are
  * respected. this means, an property is equal to another, if the names
- * and values are equal.
- */
-public interface DavProperty extends DavConstants {
-
-    /**
-     * Return a JDOM element representation of this property. The value of the
-     * property will be added as text or as child element.
+ * and values are equal.<br>
+ * The XML representation of a <code>DavProperty</code>:
      * <pre>
-     * new DavProperty("displayname", "WebDAV Directory").toXml()
+     * new DavProperty("displayname", "WebDAV Directory").toXml
      * gives a element like:
      * &lt;D:displayname&gt;WebDAV Directory&lt;/D:displayname&gt;
      *
-     * new DavProperty("resourcetype", new Element("collection")).toXml()
+     * new DavProperty("resourcetype", new Element("collection")).toXml
      * gives a element like:
      * &lt;D:resourcetype&gt;&lt;D:collection/&gt;&lt;/D:resourcetype&gt;
      *
      * Element[] customVals = { new Element("bla", customNamespace), new Element("bli", customNamespace) };
-     * new DavProperty("custom-property", customVals, customNamespace).toXml()
+     * new DavProperty("custom-property", customVals, customNamespace).toXml
      * gives an element like
      * &lt;Z:custom-property&gt;
      *    &lt;Z:bla/&gt;
      *    &lt;Z:bli/&gt;
      * &lt;/Z:custom-property&gt;
      * </pre>
-     *
-     * @return a JDOM element of this property
      */
-    public Element toXml();
+public interface DavProperty extends XmlSerializable, DavConstants {
 
     /**
      * Returns the name of this property

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyName.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyName.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyName.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyName.java Fri Jan 13 03:11:35 2006
@@ -15,9 +15,12 @@
  */
 package org.apache.jackrabbit.webdav.property;
 
-import org.jdom.Namespace;
-import org.jdom.Element;
 import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.xml.XmlSerializable;
+import org.apache.jackrabbit.webdav.xml.Namespace;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
 import java.util.HashMap;
 
@@ -25,7 +28,7 @@
  * The <code>DavPropertyName</code> class reflects a Webdav property name. It
  * holds together the actualy name of the property and its namespace.
  */
-public class DavPropertyName implements DavConstants {
+public class DavPropertyName implements DavConstants, XmlSerializable {
 
     /** internal 'cache' of created property names */
     private static final HashMap cache = new HashMap();
@@ -107,11 +110,11 @@
 	if (nameElement == null) {
 	    throw new IllegalArgumentException("Cannot build DavPropertyName from a 'null' element.");
 	}
-	Namespace ns = nameElement.getNamespace();
+	String ns = nameElement.getNamespaceURI();
 	if (ns == null) {
-	    return create(nameElement.getName());
+	    return create(nameElement.getLocalName(), Namespace.EMPTY_NAMESPACE);
 	} else {
-	    return create(nameElement.getName(), ns);
+	    return create(nameElement.getLocalName(), Namespace.getNamespace(nameElement.getPrefix(), ns));
 	}
     }
 
@@ -148,7 +151,6 @@
         return namespace;
     }
 
-
     /**
      * Computes the hash code using this propertys name and namespace.
      *
@@ -181,7 +183,7 @@
      * @return a human readable string representation
      */
     public String toString() {
-        return "{" + namespace.getURI() + "}" + name;
+        return DomUtil.getQualifiedName(name, namespace);
     }
 
     /**
@@ -189,9 +191,11 @@
      * DavPropertyName.
      *
      * @return A JDOM Element.
+     * @param document
      */
-    public Element toXml() {
-        return new Element(name, namespace);
+    public Element toXml(Document document) {
+        return DomUtil.createElement(document, name, namespace);
     }
+
 }
 

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyNameIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyNameIterator.java?rev=368683&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyNameIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyNameIterator.java Fri Jan 13 03:11:35 2006
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.webdav.property;
+
+import java.util.Iterator;
+
+/**
+ * <code>DavPropertyNameIterator</code>...
+ */
+public interface DavPropertyNameIterator extends Iterator {
+
+    public DavPropertyName nextPropertyName();
+
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyNameIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyNameIterator.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyNameSet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyNameSet.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyNameSet.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyNameSet.java Fri Jan 13 03:11:35 2006
@@ -16,37 +16,36 @@
 package org.apache.jackrabbit.webdav.property;
 
 import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.DavConstants;
-import org.jdom.Element;
+import org.apache.jackrabbit.webdav.xml.ElementIterator;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.w3c.dom.Element;
 
 import java.util.HashSet;
 import java.util.Collection;
-import java.util.List;
 import java.util.Iterator;
 
 /**
  * <code>DavPropertyNameSet</code> represents a Set of {@link DavPropertyName}
  * objects.
  */
-public class DavPropertyNameSet extends HashSet {
+public class DavPropertyNameSet extends PropContainer {
 
     private static Logger log = Logger.getLogger(DavPropertyNameSet.class);
+    private final HashSet set = new HashSet();
 
     /**
      * Create a new empty set.
-     * @see HashSet()
      */
     public DavPropertyNameSet() {
-        super();
     }
 
     /**
-     * Create a new set from the given collection.
-     * @param c
-     * @see HashSet(Collection)
+     * Create a new <code>DavPropertyNameSet</code> with the given initial values.
+     *
+     * @param initialSet
      */
-    public DavPropertyNameSet(Collection c) {
-        super(c);
+    public DavPropertyNameSet(DavPropertyNameSet initialSet) {
+        addAll(initialSet);
     }
 
     /**
@@ -58,19 +57,14 @@
      * or is not a DAV:prop element.
      */
     public DavPropertyNameSet(Element propElement) {
-        super();
-        if (propElement == null || !propElement.getName().equals(DavConstants.XML_PROP)) {
+        if (!DomUtil.matches(propElement, XML_PROP, NAMESPACE)) {
             throw new IllegalArgumentException("'DAV:prop' element expected.");
         }
 
         // fill the set
-        List props = propElement.getChildren();
-        for (int j = 0; j < props.size(); j++) {
-            Element prop = (Element) props.get(j);
-            String propName = prop.getName();
-            if (propName != null && !"".equals(propName)) {
-                add(DavPropertyName.create(propName, prop.getNamespace()));
-            }
+        ElementIterator it = DomUtil.getChildren(propElement);
+        while (it.hasNext()) {
+            add(DavPropertyName.createFromXml(it.nextElement()));
         }
     }
 
@@ -83,42 +77,104 @@
      * element.
      */
     public boolean add(DavPropertyName propertyName) {
-        return super.add(propertyName);
+        return set.add(propertyName);
     }
 
     /**
-     * Add the given object to this set. In case the object is not a {@link DavPropertyName}
-     * this method returns false.
+     * Add the property names contained in the specified set to this set.
      *
-     * @param o
-     * @return true if adding the object was successful.
-     * @see #add(DavPropertyName)
-     */
-    public boolean add(Object o) {
-        if (o instanceof DavPropertyName) {
-            return add((DavPropertyName) o);
-        } else {
+     * @param propertyNames
+     * @return true if the set has been modified by this call.
+     */
+    public boolean addAll(DavPropertyNameSet propertyNames) {
+        return set.addAll(propertyNames.getContent());
+    }
+
+    /**
+     * Removes the specified {@link DavPropertyName} object from this set.
+     *
+     * @param propertyName
+     * @return true if the given property name could be removed.
+     * @see HashSet#remove(Object)
+     */
+    public boolean remove(DavPropertyName propertyName) {
+        return set.remove(propertyName);
+    }
+
+    /**
+     * @return Iterator over all <code>DavPropertyName</code>s contained in this
+     * set.
+     */
+    public DavPropertyNameIterator iterator() {
+        return new PropertyNameIterator();
+    }
+
+    //------------------------------------------------------< PropContainer >---
+    /**
+     * @see PropContainer#contains(DavPropertyName)
+     */
+    public boolean contains(DavPropertyName name) {
+        return set.contains(name);
+    }
+
+    /**
+     * @param contentEntry NOTE that an instance of <code>DavPropertyName</code>
+     * in order to successfully add the given entry.
+     * @return true if contentEntry is an instance of <code>DavPropertyName</code>
+     * that could be added to this set. False otherwise.
+     * @see PropContainer#addContent(Object)
+     */
+    public boolean addContent(Object contentEntry) {
+        if (contentEntry instanceof DavPropertyName) {
+            return add((DavPropertyName)contentEntry);
+        }
             return false;
         }
+
+    /**
+     * @see PropContainer#isEmpty()
+     */
+    public boolean isEmpty() {
+        return set.isEmpty();
     }
 
     /**
-     * Returns the xml representation of this property name set with the
-     * following format:
-     * <pre>
-     * &lt;!ELEMENT prop (ANY) &gt;
-     * where ANY consists of a list of elements each reflecting the xml
-     * representation of an entry in this set.
-     * </pre>
-     *
-     * @return xml representation
+     * @see PropContainer#getContentSize()
      */
-    public Element toXml() {
-        Element prop = new Element(DavConstants.XML_PROP, DavConstants.NAMESPACE);
-        Iterator it = super.iterator();
-        while (it.hasNext()) {
-            prop.addContent(((DavPropertyName)it.next()).toXml());
+    public int getContentSize() {
+        return set.size();
+    }
+
+    /**
+     * @see PropContainer#getContent()
+     */
+    public Collection getContent() {
+        return set;
+    }
+
+    //--------------------------------------------------------< inner class >---
+    private class PropertyNameIterator implements DavPropertyNameIterator {
+
+        private Iterator iter;
+
+        private PropertyNameIterator() {
+            this.iter = set.iterator();
+        }
+
+        public DavPropertyName nextPropertyName() {
+            return (DavPropertyName)iter.next();
+        }
+
+        public void remove() {
+            iter.remove();
+        }
+
+        public boolean hasNext() {
+            return iter.hasNext();
+        }
+
+        public Object next() {
+            return iter.next();
         }
-        return prop;
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertySet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertySet.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertySet.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertySet.java Fri Jan 13 03:11:35 2006
@@ -15,21 +15,25 @@
  */
 package org.apache.jackrabbit.webdav.property;
 
-import org.jdom.Namespace;
-import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.xml.Namespace;
 
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 /**
  * The <code>DavPropertySet</code> class represents a set of WebDAV
  * property.
  */
-public class DavPropertySet {
+public class DavPropertySet extends PropContainer {
 
     /**
      * the set of property
      */
-    private final HashMap map = new HashMap();
+    private final Map map = new HashMap();
 
     /**
      * Adds a new property to this set.
@@ -145,47 +149,62 @@
     }
 
     /**
+     * Return the names of all properties present in this set.
+     *
+     * @return array of {@link DavPropertyName property names} present in this set.
+     */
+    public DavPropertyName[] getPropertyNames() {
+        Set keySet = map.keySet();
+	return (DavPropertyName[]) keySet.toArray(new DavPropertyName[keySet.size()]);
+    }
+
+    //------------------------------------------------------< PropContainer >---
+    /**
      * Checks if this set contains the property with the specified name.
      *
      * @param name The name of the property
-     *
      * @return <code>true</code> if this set contains the property;
      *         <code>false</code> otherwise.
+     * @see PropContainer#contains(DavPropertyName)
      */
     public boolean contains(DavPropertyName name) {
         return map.containsKey(name);
     }
 
     /**
-     * Checks if this set contains the property with the specified name and the
-     * default WebDAV {@link org.apache.jackrabbit.webdav.DavConstants#NAMESPACE namespace}.
-     *
-     * @param name The name of the property
-     *
-     * @return <code>true</code> if this set contains the property;
-     *         <code>false</code> otherwise.
-     */
-    public boolean contains(String name) {
-        return contains(DavPropertyName.create(name, DavConstants.NAMESPACE));
+     * @param contentEntry NOTE, that the given object must be an instance of
+     * <code>DavProperty</code> in order to be successfully added to this set.
+     * @return true if the specified object is an instance of <code>DavProperty</code>
+     * and false otherwise.
+     * @see PropContainer#addContent(Object)
+     */
+    public boolean addContent(Object contentEntry) {
+        if (contentEntry instanceof DavProperty) {
+            add((DavProperty)contentEntry);
+            return true;
+        }
+        return false;
     }
 
     /**
-     * Return true if this property set is empty.
-     *
-     * @return true if the internal map contains no elements.
+     * @see PropContainer#isEmpty()
      */
     public boolean isEmpty() {
         return map.isEmpty();
     }
 
     /**
-     * Return the names of all properties present in this set.
-     *
-     * @return array of {@link DavPropertyName property names} present in this set.
+     * @see PropContainer#getContentSize()
      */
-    public DavPropertyName[] getPropertyNames() {
-        Set keySet = map.keySet();
-	return (DavPropertyName[]) keySet.toArray(new DavPropertyName[keySet.size()]);
+    public int getContentSize() {
+        return map.size();
+    }
+
+    /**
+     * @see PropContainer#getContent()
+     */
+    public Collection getContent() {
+        return map.values();
     }
 
     //---------------------------------------------------------- Inner class ---

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DefaultDavProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DefaultDavProperty.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DefaultDavProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DefaultDavProperty.java Fri Jan 13 03:11:35 2006
@@ -16,10 +16,12 @@
 package org.apache.jackrabbit.webdav.property;
 
 import org.apache.log4j.Logger;
-import org.jdom.Namespace;
-import org.jdom.Element;
-import org.jdom.Content;
-import org.jdom.Text;
+import org.apache.jackrabbit.webdav.xml.Namespace;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import java.util.List;
 
 /**
  * <code>DefaultDavProperty</code>...
@@ -119,21 +121,21 @@
 	}
 	DavPropertyName name = DavPropertyName.createFromXml(propertyElement);
 	Object value;
-	int size = propertyElement.getContentSize();
-	switch (size) {
-	    case 0:
+
+        if (!DomUtil.hasContent(propertyElement)) {
 		value = null;
-		break;
-	    case 1:
-		Content c = propertyElement.getContent(0);
-		if (c instanceof Text) {
-		    value = ((Text)c).getText();
 		} else {
+            List c = DomUtil.getContent(propertyElement);
+            if (c.size() == 1) {
+                Node n = (Node)c.get(0);
+                if (n instanceof Element) {
+                    value = n;
+                } else {
+                    value = n.getNodeValue();
+                }
+            } else /* size > 1 */ {
 		    value = c;
 		}
-		break;
-	    default:
-		value = propertyElement.getContent();
 	}
 	return new DefaultDavProperty(name, value, false);
     }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java Fri Jan 13 03:11:35 2006
@@ -16,8 +16,9 @@
 package org.apache.jackrabbit.webdav.property;
 
 import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.util.XmlUtil;
-import org.jdom.Element;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
 import java.util.List;
 import java.util.Iterator;
@@ -84,8 +85,8 @@
             Iterator it = ((List)val).iterator();
             while (it.hasNext()) {
                 Object o = it.next();
-                if (o instanceof Element && XML_HREF.equals(((Element)o).getName())) {
-                    String href = ((Element)o).getText();
+                if (o instanceof Element && XML_HREF.equals(((Element)o).getLocalName())) {
+                    String href = DomUtil.getText((Element)o);
                     if (href != null) {
                         hrefList.add(href);
                     } else {
@@ -95,8 +96,8 @@
                     log.warn("DAV: href element expected in the content of " + getName().toString());
                 }
             }
-        } else if (val instanceof Element && XML_HREF.equals(((Element)val).getName())) {
-            String href = ((Element)val).getText();
+        } else if (val instanceof Element && XML_HREF.equals(((Element)val).getLocalName())) {
+            String href = DomUtil.getTextTrim((Element)val);
             if (href != null) {
                 hrefList.add(href);
             } else {
@@ -117,19 +118,20 @@
      * webdav property name.
      *
      * @return Xml representation
-     * @see XmlUtil#hrefToXml(String)
+     * @see org.apache.jackrabbit.webdav.xml.DomUtil#hrefToXml(String,org.w3c.dom.Document)
+     * @param document
      */
-    public Element toXml() {
-        Element elem = getName().toXml();
+    public Element toXml(Document document) {
+        Element elem = getName().toXml(document);
         Object value = getValue();
         if (value != null) {
             if (value instanceof String[]) {
                 String[] hrefs = (String[]) value;
                 for (int i = 0; i < hrefs.length; i++) {
-                    elem.addContent(XmlUtil.hrefToXml(hrefs[i]));
+                    elem.appendChild(DomUtil.hrefToXml(hrefs[i], document));
                 }
             } else {
-                elem.addContent(XmlUtil.hrefToXml(value.toString()));
+                elem.appendChild(DomUtil.hrefToXml(value.toString(), document));
             }
         }
         return elem;
@@ -147,9 +149,10 @@
 
     /**
      * Return an array of String containg the text of those DAV:href elements
-     * that would be returned as child elements of this property on {@link #toXml()}
+     * that would be returned as child elements of this property on
+     * {@link org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)}
      *
-     * @return
+     * @return array of href String
      */
     public List getHrefs() {
         return (value != null) ? Arrays.asList(value) : new ArrayList();

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/PropContainer.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/PropContainer.java?rev=368683&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/PropContainer.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/PropContainer.java Fri Jan 13 03:11:35 2006
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.webdav.property;
+
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.webdav.xml.XmlSerializable;
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * <code>PropContainer</code>...
+ */
+public abstract class PropContainer implements XmlSerializable, DavConstants {
+
+    private static Logger log = Logger.getLogger(PropContainer.class);
+
+    /**
+     * Tries to add the specified object to the <code>PropContainer</code> and
+     * returns a boolean indicating whether the content could be added to the
+     * internal set/map.
+     *
+     * @param contentEntry
+     * @return true if the object could be added; false otherwise
+     */
+    public abstract boolean addContent(Object contentEntry);
+
+    /**
+     * Returns true if the PropContainer does not yet contain any content elements.
+     *
+     * @return true if this container is empty.
+     */
+    public abstract boolean isEmpty();
+
+    /**
+     * Returns the number of property related content elements that are present
+     * in this <code>PropContainer</code>.
+     *
+     * @return number of content elements
+     */
+    public abstract int getContentSize();
+
+    /**
+     * Returns the collection that contains all the content elements of this
+     * <code>PropContainer</code>.
+     *
+     * @return collection representing the contents of this <code>PropContainer</code>.
+     */
+    public abstract Collection getContent();
+
+    /**
+     * Returns true if this <code>PropContainer</code> contains a content element
+     * that matches the given <code>DavPropertyName</code>.
+     *
+     * @param name
+     * @return true if any of the content elements (be it a DavProperty or a
+     * DavPropertyName only) matches the given name.
+     */
+    public abstract boolean contains(DavPropertyName name);
+
+    /**
+     * Returns the xml representation of a property related set with the
+     * following format:
+     * <pre>
+     * &lt;!ELEMENT prop (ANY) &gt;
+     * where ANY consists of a list of elements each reflecting the xml
+     * representation of the entries returned by {@link #getContent()}.
+     * </pre>
+     * 
+     * @see XmlSerializable#toXml(Document)
+     */
+    public Element toXml(Document document) {
+        Element prop = DomUtil.createElement(document, XML_PROP, NAMESPACE);
+        Iterator it = getContent().iterator();
+        while (it.hasNext()) {
+            Object content = it.next();
+            if (content instanceof XmlSerializable) {
+                prop.appendChild(((XmlSerializable)content).toXml(document));
+            } else {
+                log.debug("Unexpected content in PropContainer: should be XmlSerializable.");
+            }
+        }
+        return prop;
+    }
+
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/PropContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/PropContainer.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/ResourceType.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/ResourceType.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/ResourceType.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/ResourceType.java Fri Jan 13 03:11:35 2006
@@ -20,9 +20,12 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.jdom.Element;
-import org.jdom.Namespace;
 import org.apache.jackrabbit.webdav.version.DeltaVConstants;
+import org.apache.jackrabbit.webdav.xml.XmlSerializable;
+import org.apache.jackrabbit.webdav.xml.Namespace;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
 /**
  * The <code>ResourceType</code> class represents the webdav resource
@@ -98,33 +101,21 @@
     }
 
     /**
-     * Return the JDOM element representation of this property
+     * Returns a Set of resource types each implementing the XmlSerializable
+     * interface.
      *
-     * @return a JDOM element
-     */
-    public Element toXml() {
-        Element elem = getName().toXml();
-        elem.addContent((Set)getValue());
-        return elem;
-    }
-
-    /**
-     * Returns the Xml representation of this property as a
-     * <code>Set</code> of <code>Element</code>s.
-     *
-     * @return a <code>Set</code> of <code>Element</code>s
-     * representing this property.
+     * @return a <code>Set</code> of resource types representing this property.
      * @see DavProperty#getValue()
      */
     public Object getValue() {
-        Set elements = new HashSet();
+        Set rTypes = new HashSet();
         for (int i=0; i<resourceTypes.length; i++) {
-            Element elem = resourceTypeToXml(resourceTypes[i]);
-            if (elem != null) {
-                elements.add(elem);
+            Object n = NAMES.get(resourceTypes[i]);
+            if (n != null) {
+               rTypes.add(n);
             }
         }
-        return elements;
+        return rTypes;
     }
 
     /**
@@ -137,22 +128,6 @@
     }
 
     /**
-     * Returns the Xml representation of an individual resource type,
-     * or <code>null</code> if the resource type has no Xml
-     * representation (e.g. {@link #DEFAULT_RESOURCE}).<p/>{@link #getValue()} uses
-     * this method to build the full set of Xml elements for the property's resource
-     * types. Subclasses should override this method to add support for resource
-     * types they define.
-     *
-     * @return Xml element representing the internal type or <code>null</code>
-     * if the resource has no element name assigned (default resource type).
-     */
-    private static Element resourceTypeToXml(int resourceType) {
-        TypeName name = (TypeName) NAMES.get(resourceType);
-        return (name != null) ? new Element(name.localName, name.namespace) : null;
-    }
-
-    /**
      * Returns true if the given integer defines a valid resource type.
      *
      * @param resourceType to be validated.
@@ -197,7 +172,7 @@
      * Private inner class used to register predefined and user defined resource
      * types.
      */
-    private static class TypeName {
+    private static class TypeName implements XmlSerializable {
 
         private final String localName;
         private final Namespace namespace;
@@ -206,7 +181,7 @@
         private TypeName(String localName, Namespace namespace) {
             this.localName = localName;
             this.namespace = namespace;
-            hashCode = ("{" + namespace.getURI() + "}" + localName).hashCode();
+            hashCode = DomUtil.getQualifiedName(localName, namespace).hashCode();
         }
 
         public int hashCode() {
@@ -219,5 +194,10 @@
             }
             return false;
         }
+
+        public Element toXml(Document document) {
+            return DomUtil.createElement(document, localName, namespace);
+        }
+
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/search/QueryGrammerSet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/search/QueryGrammerSet.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/search/QueryGrammerSet.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/search/QueryGrammerSet.java Fri Jan 13 03:11:35 2006
@@ -17,12 +17,14 @@
 
 import org.apache.jackrabbit.webdav.property.DavProperty;
 import org.apache.jackrabbit.webdav.property.AbstractDavProperty;
-import org.jdom.Element;
-import org.jdom.Namespace;
+import org.apache.jackrabbit.webdav.xml.Namespace;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
-import java.util.List;
-import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
 
 /**
  * <code>QueryGrammerSet</code> is a {@link DavProperty} that
@@ -31,41 +33,24 @@
  */
 public class QueryGrammerSet extends AbstractDavProperty implements SearchConstants {
 
-    private List queryLanguages = new ArrayList();
+    private final Set queryGrammers = new HashSet();
 
     /**
      * Create a new empty <code>QueryGrammerSet</code>. Supported query grammers
      * may be added by calling {@link #addQueryLanguage(String, Namespace).
      */
     public QueryGrammerSet() {
-       this(null);
-    }
-
-    /**
-     * Create a new <code>QueryGrammerSet</code> from the given query languages
-     * string array. The default {@link SearchConstants#NAMESPACE} is assumed.
-     * @param qLanguages
-     */
-    public QueryGrammerSet(String[] qLanguages) {
         super(QUERY_GRAMMER_SET, true);
-        if (qLanguages != null) {
-            for (int i = 0; i < qLanguages.length; i++) {
-                queryLanguages.add(new Element(qLanguages[i], SearchConstants.NAMESPACE));
-            }
-        }
     }
 
     /**
-     * Add another query language to this set.
+     * Add another query queryGrammer to this set.
      *
-     * @param qLanguage
+     * @param grammerName
      * @param namespace
      */
-    public void addQueryLanguage(String qLanguage, Namespace namespace) {
-        if (namespace == null) {
-            namespace = SearchConstants.NAMESPACE;
-        }
-        queryLanguages.add(new Element(qLanguage, namespace));
+    public void addQueryLanguage(String grammerName, Namespace namespace) {
+        queryGrammers.add(new Grammer(grammerName, namespace));
     }
 
     /**
@@ -75,12 +60,12 @@
      * @return names of the supported query languages
      */
     public String[] getQueryLanguages() {
-        int size = queryLanguages.size();
+        int size = queryGrammers.size();
         if (size > 0) {
             String[] qLangStr = new String[size];
-            Element[] elements = (Element[]) queryLanguages.toArray(new Element[size]);
-            for (int i = 0; i < elements.length; i++) {
-                qLangStr[i] = elements[i].getNamespaceURI() + elements[i].getName();
+            Grammer[] grammers = (Grammer[]) queryGrammers.toArray(new Grammer[size]);
+            for (int i = 0; i < grammers.length; i++) {
+                qLangStr[i] = grammers[i].namespace.getURI() + grammers[i].localName;
             }
             return qLangStr;
         } else {
@@ -94,26 +79,56 @@
      *
      * @return Xml representation
      * @see SearchConstants#QUERY_GRAMMER_SET
-     * @see org.apache.jackrabbit.webdav.property.DavProperty#toXml()
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     * @param document
      */
-    public Element toXml() {
-        Element elem = getName().toXml();
-        Iterator qlIter = queryLanguages.iterator();
+    public Element toXml(Document document) {
+        Element elem = getName().toXml(document);
+        Iterator qlIter = queryGrammers.iterator();
         while (qlIter.hasNext()) {
-            Element grammer = new Element(XML_GRAMMER, SearchConstants.NAMESPACE).addContent((Element)qlIter.next());
-            Element sqg = new Element(XML_QUERY_GRAMMAR, SearchConstants.NAMESPACE).addContent(grammer);
-            elem.addContent(sqg);
+            Element sqg = DomUtil.addChildElement(elem, XML_QUERY_GRAMMAR, SearchConstants.NAMESPACE);
+            Element grammer = DomUtil.addChildElement(sqg, XML_GRAMMER, SearchConstants.NAMESPACE);
+            Grammer qGrammer = (Grammer)qlIter.next();
+            DomUtil.addChildElement(grammer, qGrammer.localName, qGrammer.namespace);
         }
         return elem;
     }
 
     /**
-     * Returns the list of supported query languages.
+     * Returns the set of supported query grammers.
      *
      * @return list of supported query languages.
      * @see org.apache.jackrabbit.webdav.property.DavProperty#getValue()
      */
     public Object getValue() {
-        return queryLanguages;
+        return queryGrammers;
+    }
+
+
+    private class Grammer {
+
+        private final String localName;
+        private final Namespace namespace;
+        private final int hashCode;
+
+        Grammer(String localName, Namespace namespace) {
+            this.localName = localName;
+            this.namespace = namespace;
+            hashCode = DomUtil.getQualifiedName(localName, namespace).hashCode();
+        }
+
+        public int hashCode() {
+            return hashCode;
+        }
+
+        public boolean equals(Object obj) {
+            if (obj == this) {
+                return true;
+            }
+            if (obj instanceof Grammer) {
+                return obj.hashCode() == hashCode();
+            }
+            return false;
+        }
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/search/SearchConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/search/SearchConstants.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/search/SearchConstants.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/search/SearchConstants.java Fri Jan 13 03:11:35 2006
@@ -17,7 +17,7 @@
 
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
 import org.apache.jackrabbit.webdav.DavConstants;
-import org.jdom.Namespace;
+import org.apache.jackrabbit.webdav.xml.Namespace;
 
 /**
  * <code>SearchConstants</code> interface provide constants for request

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/search/SearchInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/search/SearchInfo.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/search/SearchInfo.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/search/SearchInfo.java Fri Jan 13 03:11:35 2006
@@ -16,7 +16,11 @@
 package org.apache.jackrabbit.webdav.search;
 
 import org.apache.log4j.Logger;
-import org.jdom.*;
+import org.apache.jackrabbit.webdav.xml.XmlSerializable;
+import org.apache.jackrabbit.webdav.xml.Namespace;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
 /**
  * <code>SearchInfo</code> parses the 'searchrequest' element of a SEARCH
@@ -41,11 +45,13 @@
  * </pre>
  *
  */
-public class SearchInfo implements SearchConstants {
+public class SearchInfo implements SearchConstants, XmlSerializable {
 
     private static Logger log = Logger.getLogger(SearchInfo.class);
 
-    private final Element languageElem;
+    private final String language;
+    private final Namespace languageNamespace;
+    private final String query;
 
     /**
      * Create a new <code>SearchInfo</code> instance.
@@ -55,27 +61,9 @@
      * @param query
      */
     public SearchInfo(String language, Namespace languageNamespace, String query) {
-        languageElem = new Element(language, languageNamespace).setText(query);
-    }
-
-    /**
-     * Create a new <code>SearchInfo</code> from the specifying document
-     * retrieved from the request body.
-     *
-     * @param searchDocument
-     * @throws IllegalArgumentException if the root element's name is other than
-     * 'searchrequest' or if it does not contain a single child element specifying
-     * the query language to be used.
-     */
-    public SearchInfo(Document searchDocument) {
-        Element searchRequest = searchDocument.getRootElement();
-        if (searchRequest == null || !XML_SEARCHREQUEST.equals(searchRequest.getName()))  {
-            throw new IllegalArgumentException("The root element must be 'searchrequest'.");
-        } else if (searchRequest.getChildren().size() != 1) {
-            throw new IllegalArgumentException("A single child element is expected with the 'searchrequest'.");
-        }
-        Element child = (Element)searchRequest.getChildren().get(0);
-        languageElem = (Element) child.detach();
+        this.language = language;
+        this.languageNamespace = languageNamespace;
+        this.query = query;
     }
 
     /**
@@ -84,7 +72,7 @@
      * @return name of the query language
      */
     public String getLanguageName() {
-        return languageElem.getName();
+        return language;
     }
 
     /**
@@ -93,7 +81,7 @@
      * @return namespace of the requestes language.
      */
     public Namespace getLanguageNameSpace() {
-        return languageElem.getNamespace();
+        return languageNamespace;
     }
 
     /**
@@ -102,17 +90,39 @@
      * @return query string
      */
     public String getQuery() {
-        return languageElem.getText();
+        return query;
     }
 
     /**
      * Return the xml representation of this <code>SearchInfo</code> instance.
      *
      * @return xml representation
+     * @param document
      */
-    public Document toXml() {
-        Element sRequestElem = new Element(XML_SEARCHREQUEST, NAMESPACE);
-        sRequestElem.addContent(languageElem);
-        return new Document(sRequestElem);
+    public Element toXml(Document document) {
+        Element sRequestElem = DomUtil.createElement(document, XML_SEARCHREQUEST, NAMESPACE);
+        DomUtil.addChildElement(sRequestElem, language, languageNamespace, query);
+        return sRequestElem;
+    }
+
+    /**
+     * Create a new <code>SearchInfo</code> from the specifying document
+     * retrieved from the request body.
+     *
+     * @param searchRequest
+     * @throws IllegalArgumentException if the root element's name is other than
+     * 'searchrequest' or if it does not contain a single child element specifying
+     * the query language to be used.
+     */
+    public static SearchInfo createFromXml(Element searchRequest) {
+        if (searchRequest == null || !XML_SEARCHREQUEST.equals(searchRequest.getLocalName()))  {
+            throw new IllegalArgumentException("The root element must be 'searchrequest'.");
+        }
+        Element first = DomUtil.getFirstChildElement(searchRequest);
+        if (first != null) {
+            return new SearchInfo(first.getLocalName(), DomUtil.getNamespace(first), DomUtil.getText(first));
+        } else {
+            throw new IllegalArgumentException("A single child element is expected with the 'DAV:searchrequest'.");
+        }
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionConstants.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionConstants.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionConstants.java Fri Jan 13 03:11:35 2006
@@ -16,10 +16,10 @@
 package org.apache.jackrabbit.webdav.transaction;
 
 import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.xml.Namespace;
 import org.apache.jackrabbit.webdav.lock.Type;
 import org.apache.jackrabbit.webdav.lock.Scope;
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
-import org.jdom.Namespace;
 
 /**
  * <code>TransactionConstants</code> interface provide constants for request
@@ -119,7 +119,7 @@
     /**
      * "transaction" lock type constant.
      * @see #XML_TRANSACTION
-     * @see Type#create(String, org.jdom.Namespace)
+     * @see Type#create(String, Namespace)
      */
     public static final Type TRANSACTION = Type.create(XML_TRANSACTION, TransactionConstants.NAMESPACE);
 
@@ -127,7 +127,7 @@
      * "local" lock scope constant.
      *
      * @see #XML_LOCAL
-     * @see Scope#create(String, org.jdom.Namespace)
+     * @see Scope#create(String, Namespace)
      */
     public static final Scope LOCAL = Scope.create(XML_LOCAL, TransactionConstants.NAMESPACE);
 
@@ -135,7 +135,7 @@
      * "global" lock scope constant.
      * 
      * @see #XML_GLOBAL
-     * @see Scope#create(String, org.jdom.Namespace)
+     * @see Scope#create(String, Namespace)
      */
     public static final Scope GLOBAL = Scope.create(XML_GLOBAL, TransactionConstants.NAMESPACE);
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionInfo.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionInfo.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionInfo.java Fri Jan 13 03:11:35 2006
@@ -16,7 +16,10 @@
 package org.apache.jackrabbit.webdav.transaction;
 
 import org.apache.log4j.Logger;
-import org.jdom.Element;
+import org.apache.jackrabbit.webdav.xml.XmlSerializable;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
 /**
  * <code>TransactionInfo</code> class encapsultes the information present
@@ -26,11 +29,20 @@
  * @see TransactionConstants#XML_TRANSACTIONINFO
  * @see TransactionConstants#XML_TRANSACTION
  */
-public class TransactionInfo implements TransactionConstants {
+public class TransactionInfo implements TransactionConstants, XmlSerializable {
 
     private static Logger log = Logger.getLogger(TransactionInfo.class);
 
-    private Element status;
+    private final boolean isCommit;
+
+    /**
+     * Creates a <code>TransactionInfo</code> object
+     *
+     * @param isCommit
+     */
+    public TransactionInfo(boolean isCommit) {
+        this.isCommit = isCommit;
+    }
 
     /**
      * Creates a <code>TransactionInfo</code> object from the given 'transactionInfo'
@@ -47,34 +59,41 @@
      * is not valid.
      */
     public TransactionInfo(Element transactionInfo) {
-        if (transactionInfo == null || !XML_TRANSACTIONINFO.equals(transactionInfo.getName())) {
+        if (transactionInfo == null || !XML_TRANSACTIONINFO.equals(transactionInfo.getLocalName())) {
             throw new IllegalArgumentException("transactionInfo element expected.");
         }
-        Element tStatus = transactionInfo.getChild(XML_TRANSACTIONSTATUS, NAMESPACE);
-        if (tStatus == null) {
+        Element txStatus = DomUtil.getChildElement(transactionInfo, XML_TRANSACTIONSTATUS, NAMESPACE);
+        if (txStatus != null) {
+            // retrieve status: commit or rollback
+            isCommit = DomUtil.hasChildElement(txStatus, XML_COMMIT, NAMESPACE);
+        } else {
             throw new IllegalArgumentException("transactionInfo must contain a single 'transactionstatus' element.");
         }
-
-        // retrieve status: commit or rollback
-        status = tStatus.getChild(XML_COMMIT, NAMESPACE);
-        if (status == null) {
-            status = tStatus.getChild(XML_ROLLBACK, NAMESPACE);
-        }
-
-        if (status == null) {
-            throw new IllegalArgumentException("'jcr:transactionstatus' element must contain either a '" + XML_COMMIT + "' or a '" + XML_ROLLBACK + "' elements.");
-        }
     }
 
     /**
-     * Returns either 'commit' or 'rollback' with are the only allowed status
-     * types.
+     * Returns true, if this info requires a 'commit' action, false otherwise
+     * (i.e. 'rollback' is requested).
      *
-     * @return 'commit' or 'rollback'
+     * @return true if a 'commit' element was present. false otherwise.
      * @see #XML_COMMIT
      * @see #XML_ROLLBACK
      */
-    public String getStatus() {
-        return status.getName();
+    public boolean isCommit() {
+        return isCommit;
     }
+
+    //------------------------------------------< XmlSerializable interface >---
+    /**
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     * @param document
+     */
+    public Element toXml(Document document) {
+        Element elem = DomUtil.createElement(document, XML_TRANSACTIONINFO, NAMESPACE);
+        Element st = DomUtil.addChildElement(elem, XML_TRANSACTIONSTATUS, NAMESPACE);
+        String lName = (isCommit) ? XML_COMMIT : XML_ROLLBACK;
+        DomUtil.addChildElement(st, lName, NAMESPACE);
+        return elem;
+    }
+
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TxLockManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TxLockManager.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TxLockManager.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TxLockManager.java Fri Jan 13 03:11:35 2006
@@ -3,8 +3,11 @@
  */
 package org.apache.jackrabbit.webdav.transaction;
 
-import org.apache.jackrabbit.webdav.*;
-import org.apache.jackrabbit.webdav.lock.*;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.lock.ActiveLock;
+import org.apache.jackrabbit.webdav.lock.LockManager;
+import org.apache.jackrabbit.webdav.lock.Scope;
+import org.apache.jackrabbit.webdav.lock.Type;
 
 /**
  * <code>TxLockManager</code> manages locks with locktype

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/util/package.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/util/package.html?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/util/package.html (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/util/package.html Fri Jan 13 03:11:35 2006
@@ -1,3 +1,3 @@
 <body>
-Utility classes used for Text handling and creation of common Xml elements.
+Common utility classes.
 </body>

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVConstants.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVConstants.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVConstants.java Fri Jan 13 03:11:35 2006
@@ -17,7 +17,7 @@
 
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
 import org.apache.jackrabbit.webdav.DavConstants;
-import org.jdom.Namespace;
+import org.apache.jackrabbit.webdav.xml.Namespace;
 
 /**
  * <code>DeltaVConstants</code> defines the following headers and properties

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVServletRequest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVServletRequest.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVServletRequest.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVServletRequest.java Fri Jan 13 03:11:35 2006
@@ -61,7 +61,7 @@
      * Returns the request body and the Depth header as <code>ReportInfo</code>
      * object. The default depth, if no {@link org.apache.jackrabbit.webdav.DavConstants#HEADER_DEPTH
      * Depth header}, is {@link org.apache.jackrabbit.webdav.DavConstants#DEPTH_0}.
-     * If the requuest body could not be parsed into an {@link org.jdom.Element}
+     * If the requuest body could not be parsed into an {@link org.w3c.dom.Element}
      * <code>null</code> is returned.
      *
      * @return <code>ReportInfo</code> or <code>null</code>

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelInfo.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelInfo.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelInfo.java Fri Jan 13 03:11:35 2006
@@ -16,9 +16,11 @@
 package org.apache.jackrabbit.webdav.version;
 
 import org.apache.log4j.Logger;
-import org.jdom.Element;
-
-import java.util.Iterator;
+import org.apache.jackrabbit.webdav.xml.XmlSerializable;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
 /**
  * <code>LabelInfo</code> encapsulates the request body of a LABEL request
@@ -37,8 +39,10 @@
  * &lt;!ELEMENT label-name (#PCDATA)&gt;
  * PCDATA value: string
  * </pre>
+ * Please note, that the given implementation only recognizes the predefined elements 'add',
+ * 'set' and 'remove'.
  */
-public class LabelInfo implements DeltaVConstants {
+public class LabelInfo implements DeltaVConstants, XmlSerializable {
 
     private static Logger log = Logger.getLogger(LabelInfo.class);
 
@@ -46,11 +50,48 @@
     public static final int TYPE_REMOVE = 1;
     public static final int TYPE_ADD = 2;
 
-    private final Element labelElement;
+    public static String[] typeNames = new String[] { XML_LABEL_SET , XML_LABEL_REMOVE, XML_LABEL_ADD};
+
     private final int depth;
+    private final int type;
+    private final String labelName;
+
+    public LabelInfo(String labelName, String type) {
+        if (labelName == null) {
+            throw new IllegalArgumentException("Label name must not be null.");
+        }
+        boolean validType = false;
+        int i = 0;
+        while (i < typeNames.length) {
+            if (typeNames[i].equals(type)) {
+                validType = true;
+                break;
+            }
+            i++;
+        }
+        if (!validType) {
+            throw new IllegalArgumentException("Invalid type: " + type);
+        }
+        this.type = i;
+        this.labelName = labelName;
+        this.depth = DavConstants.DEPTH_0;
+    }
 
-    private int type;
-    private String labelName;
+    public LabelInfo(String labelName, int type) {
+        this(labelName, type, DavConstants.DEPTH_0);
+    }
+
+    public LabelInfo(String labelName, int type, int depth) {
+        if (labelName == null) {
+            throw new IllegalArgumentException("Label name must not be null.");
+        }
+        if (type < TYPE_SET || type > TYPE_ADD) {
+            throw new IllegalArgumentException("Invalid type: " + type);
+        }
+        this.labelName = labelName;
+        this.type = type;
+        this.depth = depth;
+    }
 
     /**
      * Create a new <code>LabelInfo</code> from the given element and depth
@@ -66,30 +107,24 @@
      * or DAV:remove elements.
      */
     public LabelInfo(Element labelElement, int depth) {
-        if (labelElement == null || !labelElement.getName().equals(DeltaVConstants.XML_LABEL)) {
-            throw new IllegalArgumentException("label element expected");
+        if (!DomUtil.matches(labelElement, DeltaVConstants.XML_LABEL, DeltaVConstants.NAMESPACE)) {
+            throw new IllegalArgumentException("DAV:label element expected");
         }
 
-        this.labelElement = (Element) labelElement.detach();
-
-        Iterator childrenIter = labelElement.getChildren().iterator();
-        while (childrenIter.hasNext()) {
-            Element child = (Element) childrenIter.next();
-            if (!NAMESPACE.equals(child.getNamespace())) {
-                continue;
+        String label = null;
+        int type = -1;
+        for (int i = 0; i < typeNames.length && type == -1; i++) {
+            if (DomUtil.hasChildElement(labelElement, typeNames[i], NAMESPACE)) {
+                type = i;
+                Element el = DomUtil.getChildElement(labelElement, typeNames[i], NAMESPACE);
+                label = DomUtil.getChildText(el, XML_LABEL_NAME, NAMESPACE);
             }
-            String name = child.getName();
-            if (XML_LABEL_ADD.equals(name)) {
-                type = TYPE_ADD;
-                setLabelName(child);
-            } else if (XML_LABEL_REMOVE.equals(name)) {
-                type = TYPE_REMOVE;
-                setLabelName(child);
-            } else if (XML_LABEL_SET.equals(name)) {
-                type = TYPE_SET;
-                setLabelName(child);
             }
+        if (label == null) {
+            throw new IllegalArgumentException("DAV:label element must contain at least one set, add or remove element defining a label-name.");
         }
+        this.labelName = label;
+        this.type = type;
         this.depth = depth;
     }
 
@@ -99,14 +134,14 @@
      *
      * @param labelElement
      * @throws IllegalArgumentException
-     * @see #LabelInfo(org.jdom.Element, int)
+     * @see #LabelInfo(org.w3c.dom.Element;, int)
      */
     public LabelInfo(Element labelElement) {
         this(labelElement, 0);
     }
 
     /**
-     * Return the 'label-name' or <code>null</code>
+     * Return the text present inside the 'DAV:label-name' element or <code>null</code>
      *
      * @return 'label-name' or <code>null</code>
      */
@@ -115,21 +150,6 @@
     }
 
     /**
-     * Retrieve the text of the 'label-name' child element of the specified
-     * parent element.
-     *
-     * @param parent the is intended to contain a valid 'label-name' child.
-     * @throws IllegalArgumentException if the labelName has been set before.
-     */
-    private void setLabelName(Element parent) {
-        // test if any label name is present
-        if (labelName != null) {
-            throw new IllegalArgumentException("The DAV:label element may contain at most one DAV:add, DAV:set, or DAV:remove element");
-        }
-        labelName = parent.getChildText(XML_LABEL_NAME, NAMESPACE);
-    }
-
-    /**
      * Return the type of the LABEL request. This might either be {@link #TYPE_SET},
      * {@link #TYPE_ADD} or {@link #TYPE_REMOVE}.
      *
@@ -149,11 +169,14 @@
     }
 
     /**
-     * Return the DAV:label element
-     *
-     * @return the DAV:label element
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     * @param document
      */
-    public Element getLabelElement() {
-        return labelElement;
+    public Element toXml(Document document) {
+        Element label = DomUtil.createElement(document, XML_LABEL, NAMESPACE);
+        Element typeElem = DomUtil.addChildElement(label, typeNames[type], NAMESPACE);
+        DomUtil.addChildElement(typeElem, XML_LABEL_NAME, NAMESPACE, labelName);
+        return label;
     }
+
 }

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelSetProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelSetProperty.java?rev=368683&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelSetProperty.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelSetProperty.java Fri Jan 13 03:11:35 2006
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.webdav.version;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.webdav.property.AbstractDavProperty;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+
+/**
+ * <code>LabelSetProperty</code>...
+ */
+public class LabelSetProperty extends AbstractDavProperty {
+
+    private static Logger log = Logger.getLogger(LabelSetProperty.class);
+
+    private final String[] value;
+
+    /**
+     * Create a new <code>LabelSetProperty</code>.
+     *
+     * @param labels
+     */
+    public LabelSetProperty(String[] labels) {
+        super(VersionResource.LABEL_NAME_SET, true);
+        this.value = labels;
+    }
+
+
+    public Object getValue() {
+        return value;
+    }
+
+    /**
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     * @param document
+     */
+    public Element toXml(Document document) {
+        Element elem = getName().toXml(document);
+        for (int i = 0; i < value.length; i++) {
+            DomUtil.addChildElement(elem, DeltaVConstants.XML_LABEL_NAME, DeltaVConstants.NAMESPACE, value[i]);
+        }
+        return elem;
+    }
+
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelSetProperty.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelSetProperty.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/MergeInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/MergeInfo.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/MergeInfo.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/MergeInfo.java Fri Jan 13 03:11:35 2006
@@ -17,8 +17,15 @@
 
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.xml.XmlSerializable;
+import org.apache.jackrabbit.webdav.xml.ElementIterator;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
-import org.jdom.Element;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * <code>MergeInfo</code> encapsulates the information present in the DAV:merge
@@ -36,11 +43,12 @@
  * prop: see <a href="http://www.ietf.org/rfc/rfc2518.txt">RFC 2518, Section 12.11</a>
  * </pre>
  */
-public class MergeInfo implements DeltaVConstants {
+public class MergeInfo implements DeltaVConstants, XmlSerializable {
 
     private static Logger log = Logger.getLogger(MergeInfo.class);
 
-    private Element mergeElement;
+    private final Element mergeElement;
+    private final DavPropertyNameSet propertyNameSet;
 
     /**
      * Create a new <code>MergeInfo</code>
@@ -50,10 +58,19 @@
      * or not a DAV:merge element.
      */
     public MergeInfo(Element mergeElement) {
-        if (mergeElement == null || !mergeElement.getName().equals(XML_MERGE)) {
+        if (!DomUtil.matches(mergeElement, XML_MERGE, NAMESPACE)) {
             throw new IllegalArgumentException("'DAV:merge' element expected");
         }
-        this.mergeElement = (Element) mergeElement.detach();
+
+        // if property name set if present
+        Element propElem = DomUtil.getChildElement(mergeElement, DavConstants.XML_PROP, DavConstants.NAMESPACE);
+        if (propElem != null) {
+            propertyNameSet = new DavPropertyNameSet(propElem);
+            mergeElement.removeChild(propElem);
+        } else {
+            propertyNameSet = new DavPropertyNameSet();
+        }
+        this.mergeElement = mergeElement;
     }
 
     /**
@@ -62,12 +79,19 @@
      *
      * @return href present in the DAV:source child element or <code>null</code>.
      */
-    public String getSourceHref() {
-        Element source = mergeElement.getChild(DavConstants.XML_SOURCE, DavConstants.NAMESPACE);
-        if (source != null) {
-            return source.getChildText(DavConstants.XML_HREF, DavConstants.NAMESPACE);
+    public String[] getSourceHrefs() {
+        List sourceHrefs = new ArrayList();
+        Element srcElem = DomUtil.getChildElement(mergeElement, DavConstants.XML_SOURCE, DavConstants.NAMESPACE);
+        if (srcElem != null) {
+            ElementIterator it = DomUtil.getChildren(srcElem, DavConstants.XML_HREF, DavConstants.NAMESPACE);
+            while (it.hasNext()) {
+                String href = DomUtil.getTextTrim(it.nextElement());
+                if (href != null) {
+                    sourceHrefs.add(href);
         }
-        return null;
+            }
+        }
+        return (String[])sourceHrefs.toArray(new String[sourceHrefs.size()]);
     }
 
     /**
@@ -76,7 +100,7 @@
      * @return true if the DAV:merge element contains a DAV:no-auto-merge child.
      */
     public boolean isNoAutoMerge() {
-        return mergeElement.getChild(XML_N0_AUTO_MERGE, NAMESPACE) != null;
+        return DomUtil.hasChildElement(mergeElement, XML_N0_AUTO_MERGE, NAMESPACE);
     }
 
     /**
@@ -85,24 +109,22 @@
      * @return true if the DAV:merge element contains a DAV:no-checkout child
      */
     public boolean isNoCheckout() {
-        return mergeElement.getChild(XML_N0_CHECKOUT, NAMESPACE) != null;
+        return DomUtil.hasChildElement(mergeElement, XML_N0_CHECKOUT, NAMESPACE);
     }
 
     /**
      * Returns a {@link DavPropertyNameSet}. If the DAV:merge element contains
      * a DAV:prop child element the properties specified therein are included
-     * in the set. Otherwise an empty set is returned.
+     * in the set. Otherwise an empty set is returned.<br>
+     *
+     * <b>WARNING:</b> modifying the DavPropertyNameSet returned by this method does
+     * not modify this <code>UpdateInfo</code>.
      *
      * @return set listing the properties specified in the DAV:prop element indicating
      * those properties that must be reported in the response body.
      */
     public DavPropertyNameSet getPropertyNameSet() {
-        Element propElement = mergeElement.getChild(DavConstants.XML_PROP, DavConstants.NAMESPACE);
-        if (propElement != null) {
-            return new DavPropertyNameSet(propElement);
-        } else {
-            return new DavPropertyNameSet();
-        }
+        return propertyNameSet;
     }
 
     /**
@@ -114,4 +136,17 @@
     public Element getMergeElement() {
         return mergeElement;
     }
+
+    /**
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     * @param document
+     */
+    public Element toXml(Document document) {
+        Element elem = (Element)document.importNode(mergeElement, true);
+        if (!propertyNameSet.isEmpty()) {
+            elem.appendChild(propertyNameSet.toXml(document));
+        }
+        return elem;
+    }
+
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/OptionsInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/OptionsInfo.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/OptionsInfo.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/OptionsInfo.java Fri Jan 13 03:11:35 2006
@@ -15,11 +15,17 @@
  */
 package org.apache.jackrabbit.webdav.version;
 
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.webdav.xml.ElementIterator;
+import org.apache.jackrabbit.webdav.xml.Namespace;
+import org.apache.jackrabbit.webdav.xml.XmlSerializable;
 import org.apache.log4j.Logger;
-import org.jdom.Element;
-import org.jdom.Namespace;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 
-import java.util.List;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
 
 /**
  * <code>OptionsInfo</code> represents the Xml request body, that may be present
@@ -32,50 +38,88 @@
  * ANY value: A sequence of elements each at most onces.
  * </pre>
  *
+ * Note, that this is a simplified implementation of the very generic
+ * definition: We assume that the DAV:options element only contains empty child
+ * elements, such as e.g. {@link DeltaVConstants#XML_VH_COLLECTION_SET DAV:version-history-collection-set}
+ * or {@link DeltaVConstants#XML_WSP_COLLECTION_SET DAV:workspace-collection-set}.
+ *
  * @see DeltaVConstants#XML_VH_COLLECTION_SET
  * @see DeltaVConstants#XML_WSP_COLLECTION_SET
  * @see DeltaVConstants#XML_ACTIVITY_COLLECTION_SET
  */
-public class OptionsInfo {
+public class OptionsInfo implements XmlSerializable {
 
     private static Logger log = Logger.getLogger(OptionsInfo.class);
 
-    private final Element optionsElement;
+    private final Set entriesLocalNames = new HashSet();
 
     /**
-     * Create a new <code>UpdateInfo</code> object.
+     * Create a new OptionsInfo with the specified entries. Each entry will
+     * be converted to an empty Xml element when calling <code>toXml</code>.
+     * As namespace {@link DeltaVConstants#NAMESPACE} is used.
      *
-     * @param optionsElement
-     * @throws IllegalArgumentException if the updateElement is <code>null</code>
-     * or not a DAV:update element or if the element does not match the required
-     * structure.
+     * @param entriesLocalNames
      */
-    public OptionsInfo(Element optionsElement) {
-         if (optionsElement == null || !optionsElement.getName().equals(DeltaVConstants.XML_OPTIONS)) {
-            throw new IllegalArgumentException("DAV:options element expected");
+    public OptionsInfo(String[] entriesLocalNames) {
+       if (entriesLocalNames != null) {
+           for (int i = 0; i < entriesLocalNames.length; i++) {
+               this.entriesLocalNames.add(entriesLocalNames[i]);
+           }
         }
-        this.optionsElement = (Element) optionsElement.detach();
     }
 
     /**
-     * Returns the set of elements present in the {@link DeltaVConstants#XML_OPTIONS DAV:options}
-     * element. These elements define the information the client wishes to retrieve
-     * the OPTIONS request.
-     *
-     * @return set of child elements
+     * Private constructor used to create an OptionsInfo from Xml.
      */
-    public List getElements() {
-        return optionsElement.getChildren();
-    }
+    private OptionsInfo() {}
 
     /**
      * Returns true if a child element with the given name and namespace is present.
      *
-     * @param name
+     * @param localName
      * @param namespace
      * @return true if such a child element exists in the options element.
      */
-    public boolean containsElement(String name, Namespace namespace) {
-        return optionsElement.getChild(name, namespace) != null;
+    public boolean containsElement(String localName, Namespace namespace) {
+        if (DeltaVConstants.NAMESPACE.equals(namespace)) {
+            return entriesLocalNames.contains(localName);
+        }
+        return false;
+    }
+
+    /**
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     * @param document
+     */
+    public Element toXml(Document document) {
+        Element optionsElem = DomUtil.createElement(document, DeltaVConstants.XML_OPTIONS, DeltaVConstants.NAMESPACE);
+        Iterator it = entriesLocalNames.iterator();
+        while (it.hasNext()) {
+            String localName = (String)it.next();
+            DomUtil.addChildElement(optionsElem, localName, DeltaVConstants.NAMESPACE);
+        }
+        return optionsElem;
+    }
+
+    /**
+     * Build an <code>OptionsInfo</code> object from the root element present
+     * in the request body.
+     *
+     * @param optionsElement
+     * @return
+     * @throws IllegalArgumentException if the optionsElement is <code>null</code>
+     * or not a DAV:options element.
+     */
+    public static OptionsInfo createFromXml(Element optionsElement) {
+        if (!DomUtil.matches(optionsElement, DeltaVConstants.XML_OPTIONS, DeltaVConstants.NAMESPACE)) {
+            throw new IllegalArgumentException("DAV:options element expected");
+        }
+        OptionsInfo oInfo = new OptionsInfo();
+        ElementIterator it = DomUtil.getChildren(optionsElement);
+        while (it.hasNext()) {
+            // todo: not correct since assuming its the deltaV-namespace
+            oInfo.entriesLocalNames.add(it.nextElement().getLocalName());
+        }
+        return oInfo;
     }
 }



Mime
View raw message