jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r397818 - /jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/Position.java
Date Fri, 28 Apr 2006 09:23:35 GMT
Author: angela
Date: Fri Apr 28 02:23:25 2006
New Revision: 397818

URL: http://svn.apache.org/viewcvs?rev=397818&view=rev
Log:
- DAV:after, DAV:before must contain the segment within a separate DAV:segment element (wrong
serialization of Position).
- Position retrieved from xml is never returned.

Modified:
    jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/Position.java

Modified: jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/Position.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/Position.java?rev=397818&r1=397817&r2=397818&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/Position.java
(original)
+++ jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/Position.java
Fri Apr 28 02:23:25 2006
@@ -120,9 +120,12 @@
      * @param document
      */
     public Element toXml(Document document) {
-        Element pos = DomUtil.createElement(document, XML_POSITION, NAMESPACE);
-        DomUtil.addChildElement(pos, type, NAMESPACE, segment);
-        return pos;
+        Element positionElement = DomUtil.createElement(document, XML_POSITION, NAMESPACE);
+        Element typeElement = DomUtil.addChildElement(positionElement, type, NAMESPACE);
+        if (segment != null) {
+            DomUtil.addChildElement(typeElement, XML_SEGMENT, NAMESPACE, segment);
+        }
+        return positionElement;
     }
 
     //-----------------------------------------------------< static methods >---
@@ -146,14 +149,15 @@
             throw new IllegalArgumentException("The 'DAV:position' element required.");
         }
         ElementIterator it = DomUtil.getChildren(positionElement);
-        while (it.hasNext()) {
+        if (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);
+            return new Position(type, segmentText);
+        } else {
+            throw new IllegalArgumentException("The 'DAV:position' element required with
exact one child indicating the type.");
         }
-        throw new IllegalArgumentException("The 'DAV:position' element required with exact
one child indicating the type.");
     }
 }



Mime
View raw message