jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r368683 [2/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/server/src/java/org/apache/jackrabbit/server/io/ExportContextImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportContextImpl.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportContextImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ExportContextImpl.java Fri Jan 13 03:11:35 2006
@@ -49,6 +49,7 @@
     private final OutputContext outputCtx;
 
     private File outFile;
+    private OutputStream outStream;
 
     public ExportContextImpl(Item exportRoot, OutputContext outputCtx) throws IOException {
         super(exportRoot, (outputCtx != null) ? outputCtx.hasStream() : false, null);
@@ -70,7 +71,14 @@
         checkCompleted();
         if (hasStream()) {
             try {
-                return new FileOutputStream(outFile);
+                // clean up the stream retrieved by the preceeding handler, that
+                // did not behave properly and failed to export although initially
+                // willing to handle the export.
+                if (outStream != null) {
+                    outStream.close();
+                }
+                outStream = new FileOutputStream(outFile);
+                return outStream;
             } catch (IOException e) {
                 // unexpected error... ignore and return null
             }
@@ -145,19 +153,35 @@
     public void informCompleted(boolean success) {
         checkCompleted();
         completed = true;
+        // make sure the outputStream gets closed (and don't assume the handlers
+        // took care of this.
+        if (outStream != null) {
+            try {
+                outStream.close();
+            } catch (IOException e) {
+                // ignore
+            }
+        }
         if (success) {
             // write properties and data to the output-context
             if (outputCtx != null) {
+                boolean hasContentLength = false;
                 Iterator it = properties.keySet().iterator();
                 while (it.hasNext()) {
                     String name = it.next().toString();
                     String value = properties.get(name).toString();
                     outputCtx.setProperty(name, value);
+                    // check for content-length
+                    hasContentLength = DavConstants.HEADER_CONTENT_LENGTH.equals(name);
                 }
 
                 if (outputCtx.hasStream() && outFile != null) {
                     OutputStream out = outputCtx.getOutputStream();
                     try {
+                        // make sure the content-length is set
+                        if (!hasContentLength) {
+                            outputCtx.setContentLength(outFile.length());
+                        }
                         FileInputStream in = new FileInputStream(outFile);
                         IOUtil.spool(in, out);
                     } catch (IOException e) {

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java Fri Jan 13 03:11:35 2006
@@ -15,12 +15,20 @@
 */
 package org.apache.jackrabbit.server.jcr;
 
-import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.*;
-import org.apache.jackrabbit.webdav.jcr.JcrDavException;
 import org.apache.jackrabbit.server.SessionProvider;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletRequest;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.DavSessionProvider;
+import org.apache.jackrabbit.webdav.WebdavRequest;
+import org.apache.jackrabbit.webdav.jcr.JcrDavException;
+import org.apache.log4j.Logger;
 
-import javax.jcr.*;
+import javax.jcr.LoginException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletResponse;
 import java.util.HashMap;

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java Fri Jan 13 03:11:35 2006
@@ -16,15 +16,27 @@
 package org.apache.jackrabbit.webdav.jcr;
 
 import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.property.*;
-import org.apache.jackrabbit.webdav.*;
-import org.apache.jackrabbit.webdav.jcr.version.report.*;
 import org.apache.jackrabbit.webdav.transaction.TxLockEntry;
 import org.apache.jackrabbit.webdav.version.report.SupportedReportSetProperty;
 import org.apache.jackrabbit.webdav.version.report.ReportType;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
+import org.apache.jackrabbit.webdav.property.HrefProperty;
+import org.apache.jackrabbit.webdav.jcr.version.report.NodeTypesReport;
+import org.apache.jackrabbit.webdav.jcr.version.report.LocateByUuidReport;
+import org.apache.jackrabbit.webdav.jcr.version.report.RegisteredNamespacesReport;
+import org.apache.jackrabbit.webdav.jcr.version.report.RepositoryDescriptorsReport;
 import org.apache.jackrabbit.util.Text;
 
-import javax.jcr.*;
+import javax.jcr.Item;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Workspace;
 
 /**
  * <code>AbstractItemResource</code> covers common functionality for the various
@@ -71,7 +83,7 @@
      * Returns true if there exists a {@link Item repository item} with the given
      * resource path, false otherwise.
      *
-     * @see DavResource#exists()
+     * @see org.apache.jackrabbit.webdav.DavResource#exists()
      */
     public boolean exists() {
         return item != null;
@@ -85,7 +97,7 @@
      * which is exposed with the {@link #JCR_NAME &#123;http://www.day.com/jcr/webdav/1.0&#125;name}
      * property.
      *
-     * @see DavResource#getDisplayName() )
+     * @see org.apache.jackrabbit.webdav.DavResource#getDisplayName() )
      */
     public String getDisplayName() {
         String resPath = getResourcePath();
@@ -100,7 +112,7 @@
      * @return the collection this resource is internal member of. Except for the
      * repository root, the returned collection always represent the parent
      * repository node.
-     * @see DavResource#getCollection()
+     * @see org.apache.jackrabbit.webdav.DavResource#getCollection()
      */
     public DavResource getCollection() {
         DavResource collection = null;
@@ -127,7 +139,7 @@
      * @param destination
      * @throws DavException
      * @see DavResource#move(DavResource)
-     * @see Session#move(String, String)
+     * @see javax.jcr.Session#move(String, String)
      */
     public void move(DavResource destination) throws DavException {
         if (!exists()) {

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java Fri Jan 13 03:11:35 2006
@@ -15,36 +15,68 @@
  */
 package org.apache.jackrabbit.webdav.jcr;
 
-import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.*;
 import org.apache.jackrabbit.server.io.IOUtil;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavLocatorFactory;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.MultiStatus;
+import org.apache.jackrabbit.webdav.MultiStatusResponse;
 import org.apache.jackrabbit.webdav.io.OutputContext;
-import org.apache.jackrabbit.webdav.search.SearchResource;
+import org.apache.jackrabbit.webdav.jcr.search.SearchResourceImpl;
+import org.apache.jackrabbit.webdav.jcr.transaction.TxLockManagerImpl;
+import org.apache.jackrabbit.webdav.lock.ActiveLock;
+import org.apache.jackrabbit.webdav.lock.LockDiscovery;
+import org.apache.jackrabbit.webdav.lock.LockInfo;
+import org.apache.jackrabbit.webdav.lock.LockManager;
+import org.apache.jackrabbit.webdav.lock.Scope;
+import org.apache.jackrabbit.webdav.lock.SupportedLock;
+import org.apache.jackrabbit.webdav.lock.Type;
+import org.apache.jackrabbit.webdav.observation.EventDiscovery;
+import org.apache.jackrabbit.webdav.observation.ObservationResource;
+import org.apache.jackrabbit.webdav.observation.Subscription;
+import org.apache.jackrabbit.webdav.observation.SubscriptionDiscovery;
+import org.apache.jackrabbit.webdav.observation.SubscriptionInfo;
+import org.apache.jackrabbit.webdav.observation.SubscriptionManager;
+import org.apache.jackrabbit.webdav.property.DavProperty;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
+import org.apache.jackrabbit.webdav.property.DavPropertySet;
+import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
+import org.apache.jackrabbit.webdav.property.HrefProperty;
+import org.apache.jackrabbit.webdav.property.ResourceType;
 import org.apache.jackrabbit.webdav.search.QueryGrammerSet;
 import org.apache.jackrabbit.webdav.search.SearchInfo;
-import org.apache.jackrabbit.webdav.transaction.TransactionResource;
-import org.apache.jackrabbit.webdav.transaction.TransactionInfo;
+import org.apache.jackrabbit.webdav.search.SearchResource;
 import org.apache.jackrabbit.webdav.transaction.TransactionConstants;
+import org.apache.jackrabbit.webdav.transaction.TransactionInfo;
+import org.apache.jackrabbit.webdav.transaction.TransactionResource;
 import org.apache.jackrabbit.webdav.transaction.TxLockManager;
-import org.apache.jackrabbit.webdav.jcr.transaction.TxLockManagerImpl;
-import org.apache.jackrabbit.webdav.jcr.search.SearchResourceImpl;
-import org.apache.jackrabbit.webdav.observation.*;
-import org.apache.jackrabbit.webdav.version.*;
+import org.apache.jackrabbit.webdav.version.DeltaVConstants;
+import org.apache.jackrabbit.webdav.version.DeltaVResource;
+import org.apache.jackrabbit.webdav.version.OptionsInfo;
+import org.apache.jackrabbit.webdav.version.OptionsResponse;
+import org.apache.jackrabbit.webdav.version.SupportedMethodSetProperty;
 import org.apache.jackrabbit.webdav.version.report.Report;
 import org.apache.jackrabbit.webdav.version.report.ReportInfo;
 import org.apache.jackrabbit.webdav.version.report.ReportType;
 import org.apache.jackrabbit.webdav.version.report.SupportedReportSetProperty;
-import org.apache.jackrabbit.webdav.lock.*;
-import org.apache.jackrabbit.webdav.property.*;
-import org.apache.jackrabbit.webdav.property.ResourceType;
+import org.apache.log4j.Logger;
 
-import javax.jcr.Session;
-import javax.jcr.RepositoryException;
 import javax.jcr.Item;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
 
 /**
  * <code>AbstractResource</code> provides functionality common to all
@@ -467,14 +499,15 @@
         OptionsResponse oR = null;
         if (optionsInfo != null) {
             oR = new OptionsResponse();
-            // currently on DAV:version-history-collection-set and
+            // currently only DAV:version-history-collection-set and
             // DAV:workspace-collection-set is supported.
             if (optionsInfo.containsElement(DeltaVConstants.XML_VH_COLLECTION_SET, DeltaVConstants.NAMESPACE)) {
                 String[] hrefs = new String[] {
                     getLocatorFromItemPath(ItemResourceConstants.VERSIONSTORAGE_PATH).getHref(true)
                 };
                 oR.addEntry(DeltaVConstants.XML_VH_COLLECTION_SET, DeltaVConstants.NAMESPACE, hrefs);
-            } else if (optionsInfo.containsElement(DeltaVConstants.XML_WSP_COLLECTION_SET, DeltaVConstants.NAMESPACE)) {
+            }
+            if (optionsInfo.containsElement(DeltaVConstants.XML_WSP_COLLECTION_SET, DeltaVConstants.NAMESPACE)) {
                 // workspaces cannot be created anywhere.
                 oR.addEntry(DeltaVConstants.XML_WSP_COLLECTION_SET, DeltaVConstants.NAMESPACE, new String[0]);
             }
@@ -497,17 +530,10 @@
         }
 
         if (supportedReports.isSupportedReport(reportInfo)) {
-            try {
-                Report report = ReportType.getType(reportInfo).createReport();
-                report.setInfo(reportInfo);
-                report.setResource(this);
+            Report report = ReportType.getType(reportInfo).createReport(this, reportInfo);
                 return report;
-            } catch (IllegalArgumentException e) {
-                // should never occur.
-                throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
-            }
         } else {
-            throw new DavException(DavServletResponse.SC_UNPROCESSABLE_ENTITY, "Unkown report "+ reportInfo.getReportElement().getNamespacePrefix() + reportInfo.getReportElement().getName() +"requested.");
+            throw new DavException(DavServletResponse.SC_UNPROCESSABLE_ENTITY, "Unkown report "+ reportInfo.getReportName() +"requested.");
         }
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DavResourceFactoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DavResourceFactoryImpl.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DavResourceFactoryImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DavResourceFactoryImpl.java Fri Jan 13 03:11:35 2006
@@ -16,7 +16,6 @@
 package org.apache.jackrabbit.webdav.jcr;
 
 import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.*;
 import org.apache.jackrabbit.webdav.transaction.TransactionResource;
 import org.apache.jackrabbit.webdav.transaction.TransactionDavServletRequest;
 import org.apache.jackrabbit.webdav.observation.SubscriptionManager;
@@ -26,10 +25,22 @@
 import org.apache.jackrabbit.webdav.jcr.version.VersionItemCollection;
 import org.apache.jackrabbit.webdav.jcr.version.VersionHistoryItemCollection;
 import org.apache.jackrabbit.webdav.jcr.transaction.TxLockManagerImpl;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavServletRequest;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.DavMethods;
 
-import javax.jcr.*;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 
 /**
  * <code>DavResourceFactoryImpl</code>...
@@ -152,7 +163,7 @@
      * @param locator
      * @param session
      * @return DavResource representing a repository item.
-     * @throws RepositoryException if {@link Session#getItem(String)} fails.
+     * @throws RepositoryException if {@link javax.jcr.Session#getItem(String)} fails.
      */
     private DavResource createResourceForItem(DavResourceLocator locator, DavSession session) throws RepositoryException {
         DavResource resource;

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java Fri Jan 13 03:11:35 2006
@@ -15,24 +15,66 @@
  */
 package org.apache.jackrabbit.webdav.jcr;
 
-import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.property.*;
-import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.util.Text;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavResourceIterator;
+import org.apache.jackrabbit.webdav.DavResourceIteratorImpl;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.MultiStatusResponse;
 import org.apache.jackrabbit.webdav.io.InputContext;
-import org.apache.jackrabbit.webdav.jcr.nodetype.NodeTypeProperty;
 import org.apache.jackrabbit.webdav.jcr.lock.JcrActiveLock;
+import org.apache.jackrabbit.webdav.jcr.nodetype.NodeTypeProperty;
 import org.apache.jackrabbit.webdav.jcr.version.report.ExportViewReport;
 import org.apache.jackrabbit.webdav.jcr.version.report.LocateCorrespondingNodeReport;
-import org.apache.jackrabbit.webdav.ordering.*;
-import org.apache.jackrabbit.webdav.lock.*;
-import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.util.Text;
+import org.apache.jackrabbit.webdav.lock.ActiveLock;
+import org.apache.jackrabbit.webdav.lock.LockInfo;
+import org.apache.jackrabbit.webdav.lock.Scope;
+import org.apache.jackrabbit.webdav.lock.Type;
+import org.apache.jackrabbit.webdav.ordering.OrderPatch;
+import org.apache.jackrabbit.webdav.ordering.OrderingConstants;
+import org.apache.jackrabbit.webdav.ordering.OrderingResource;
+import org.apache.jackrabbit.webdav.ordering.OrderingType;
+import org.apache.jackrabbit.webdav.ordering.Position;
+import org.apache.jackrabbit.webdav.property.DavProperty;
+import org.apache.jackrabbit.webdav.property.DavPropertyIterator;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
+import org.apache.jackrabbit.webdav.property.DavPropertySet;
+import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
+import org.apache.jackrabbit.webdav.property.HrefProperty;
+import org.apache.log4j.Logger;
 
-import javax.jcr.*;
+import javax.jcr.AccessDeniedException;
+import javax.jcr.ImportUUIDBehavior;
+import javax.jcr.Item;
+import javax.jcr.ItemExistsException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.lock.Lock;
 import javax.jcr.nodetype.NodeType;
-import java.util.*;
-import java.io.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Set;
 
 /**
  * <code>DefaultItemCollection</code> represents a JCR node item.
@@ -640,7 +682,7 @@
             throws RepositoryException {
 
         String destPath = null;
-        if (position.getType() == Position.TYPE_FIRST) {
+        if (OrderingConstants.XML_FIRST.equals(position.getType())) {
             if (childNodes.hasNext()) {
                 Node firstChild = childNodes.nextNode();
                 destPath = firstChild.getPath();
@@ -649,7 +691,7 @@
             if (destPath == null) {
                 throw new ItemNotFoundException("No 'first' item found for reordering.");
             }
-        } else if (position.getType() == Position.TYPE_AFTER) {
+        } else if (OrderingConstants.XML_AFTER.equals(position.getType())) {
             String afterRelPath = Text.getName(position.getSegment());
             boolean found = false;
             // jcr only knows order-before > retrieve the node that follows the

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java Fri Jan 13 03:11:35 2006
@@ -15,18 +15,39 @@
  */
 package org.apache.jackrabbit.webdav.jcr;
 
-import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.property.*;
-import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.value.ValueHelper;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavResourceIterator;
+import org.apache.jackrabbit.webdav.DavResourceIteratorImpl;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.MultiStatusResponse;
 import org.apache.jackrabbit.webdav.io.InputContext;
-import org.apache.jackrabbit.webdav.jcr.property.ValuesProperty;
 import org.apache.jackrabbit.webdav.jcr.property.LengthsProperty;
-import org.apache.jackrabbit.webdav.lock.*;
-import org.apache.jackrabbit.value.ValueHelper;
+import org.apache.jackrabbit.webdav.jcr.property.ValuesProperty;
+import org.apache.jackrabbit.webdav.lock.ActiveLock;
+import org.apache.jackrabbit.webdav.lock.Scope;
+import org.apache.jackrabbit.webdav.lock.Type;
+import org.apache.jackrabbit.webdav.property.DavProperty;
+import org.apache.jackrabbit.webdav.property.DavPropertyIterator;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
+import org.apache.jackrabbit.webdav.property.DavPropertySet;
+import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
+import org.apache.log4j.Logger;
 
-import javax.jcr.*;
-import java.io.*;
-import java.util.*;
+import javax.jcr.Item;
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
 
 /**
  * <code>DefaultItemResource</code> represents JCR property item.

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java Fri Jan 13 03:11:35 2006
@@ -15,9 +15,9 @@
  */
 package org.apache.jackrabbit.webdav.jcr;
 
-import org.jdom.Namespace;
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
 import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.xml.Namespace;
 import org.apache.jackrabbit.webdav.version.DeltaVResource;
 import org.apache.jackrabbit.webdav.lock.Scope;
 import org.apache.jackrabbit.webdav.search.SearchResource;

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java Fri Jan 13 03:11:35 2006
@@ -18,13 +18,30 @@
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavServletResponse;
-import org.jdom.Element;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
-import javax.jcr.*;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.lock.LockException;
 import javax.jcr.version.VersionException;
-import javax.jcr.nodetype.*;
+import javax.jcr.AccessDeniedException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.InvalidSerializedDataException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.MergeException;
+import javax.jcr.NamespaceException;
+import javax.jcr.RepositoryException;
+import javax.jcr.ReferentialIntegrityException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.LoginException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.ValueFormatException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
 import java.util.HashMap;
 
 /**
@@ -74,17 +91,27 @@
     }
 
     /**
+     * @return true
+     */
+    public boolean hasErrorCondition() {
+        return true;
+    }
+
+    /**
      * Returns a DAV:error Xml element containing the exceptions class and the
      * message as child elements.
      *
      * @return Xml representation of this exception.
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     * @param document
      */
-    public Element getError() {
-        Element error = super.getError();
-        Element excep = new Element("exception", ItemResourceConstants.NAMESPACE);
-        excep.addContent(new Element("class", ItemResourceConstants.NAMESPACE).setText(exceptionClass.getName()));
-        excep.addContent(new Element("message", ItemResourceConstants.NAMESPACE).setText(getMessage()));
-        error.addContent(excep);
+    public Element toXml(Document document) {
+        Element error = DomUtil.createElement(document, XML_ERROR, DavConstants.NAMESPACE);
+        Element excep = DomUtil.createElement(document, "exception", ItemResourceConstants.NAMESPACE);
+        DomUtil.addChildElement(excep, "class", ItemResourceConstants.NAMESPACE, exceptionClass.getName());
+        DomUtil.addChildElement(excep, "message", ItemResourceConstants.NAMESPACE, getMessage());
+        error.appendChild(excep);
         return error;
     }
+
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java Fri Jan 13 03:11:35 2006
@@ -15,18 +15,27 @@
  */
 package org.apache.jackrabbit.webdav.jcr;
 
-import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavResourceIterator;
+import org.apache.jackrabbit.webdav.DavResourceIteratorImpl;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavSession;
 import org.apache.jackrabbit.webdav.io.InputContext;
-import org.apache.jackrabbit.webdav.jcr.version.report.RegisteredNamespacesReport;
 import org.apache.jackrabbit.webdav.jcr.version.report.NodeTypesReport;
+import org.apache.jackrabbit.webdav.jcr.version.report.RegisteredNamespacesReport;
 import org.apache.jackrabbit.webdav.jcr.version.report.RepositoryDescriptorsReport;
-import org.apache.jackrabbit.webdav.version.report.SupportedReportSetProperty;
 import org.apache.jackrabbit.webdav.version.report.ReportType;
+import org.apache.jackrabbit.webdav.version.report.SupportedReportSetProperty;
+import org.apache.log4j.Logger;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
 
 /**
  * <code>RootCollection</code> represent the WebDAV root resource that does not

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java Fri Jan 13 03:11:35 2006
@@ -15,15 +15,23 @@
  */
 package org.apache.jackrabbit.webdav.jcr;
 
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.MultiStatusResponse;
+import org.apache.jackrabbit.webdav.jcr.property.NamespacesProperty;
+import org.apache.jackrabbit.webdav.property.DavProperty;
+import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
+import org.apache.jackrabbit.webdav.property.DavPropertySet;
 import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.*;
-import org.apache.jackrabbit.webdav.property.*;
-import org.jdom.Element;
 
+import javax.jcr.Item;
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.RepositoryException;
-import javax.jcr.Item;
-import java.util.*;
+import java.util.Iterator;
+import java.util.Properties;
 
 /**
  * <code>RootItemCollection</code> represents the root node of the underlying
@@ -89,53 +97,34 @@
      */
     public void setProperty(DavProperty property) throws DavException {
         if (JCR_NAMESPACES.equals(property.getName())) {
-            Object v = property.getValue();
-            if (v instanceof List) {
-                Map changeMap = new HashMap();
-                // retrieve list of prefix/uri pairs that build the new values of
-                // the ns-registry
-                Iterator it = ((List)v).iterator();
-                while (it.hasNext()) {
-                    Object listEntry = it.next();
-                    if (listEntry instanceof Element) {
-                        Element e = (Element)listEntry;
-                        if (XML_NAMESPACE.equals(e.getName())) {
-                            String prefix = e.getChildText(XML_PREFIX, NAMESPACE);
-                            String uri = e.getChildText(XML_URI, NAMESPACE);
-                            changeMap.put(prefix, uri);
-                        }
-                    }
-                }
+            NamespacesProperty nsp = new NamespacesProperty(property);
                 try {
+                Properties changes = nsp.getNamespaces();
                     NamespaceRegistry nsReg = getRepositorySession().getWorkspace().getNamespaceRegistry();
                     String[] registeredPrefixes = nsReg.getPrefixes();
                     for (int i = 0; i < registeredPrefixes.length; i++) {
                         String prfx = registeredPrefixes[i];
-                        if (!changeMap.containsKey(prfx)) {
+                    if (!changes.containsKey(prfx)) {
                             // prefix not present amongst the new values any more > unregister
                             nsReg.unregisterNamespace(prfx);
-                        } else if (changeMap.get(prfx).equals(nsReg.getURI(prfx))) {
+                    } else if (changes.get(prfx).equals(nsReg.getURI(prfx))) {
                             // present with same uri-value >> no action required
-                            changeMap.remove(prfx);
+                        changes.remove(prfx);
                         }
                     }
 
                     // try to register any prefix/uri pair that has a changed uri or
                     // it has not been present before.
-                    Iterator prefixIt = changeMap.keySet().iterator();
+                Iterator prefixIt = changes.keySet().iterator();
                     while (prefixIt.hasNext()) {
                         String prefix = (String)prefixIt.next();
-                        String uri = (String)changeMap.get(prefix);
+                    String uri = (String)changes.get(prefix);
                         nsReg.registerNamespace(prefix, uri);
                     }
                 } catch (RepositoryException e) {
                     throw new JcrDavException(e);
                 }
             } else {
-                log.warn("Unexpected structure of dcr:namespace property.");
-                throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR);
-            }
-        } else {
             super.setProperty(property);
         }
     }
@@ -165,15 +154,8 @@
         try {
             // init workspace specific properties
             NamespaceRegistry nsReg = getRepositorySession().getWorkspace().getNamespaceRegistry();
-            String[] prefixes = nsReg.getPrefixes();
-            Element[] nsElems = new Element[prefixes.length];
-            for (int i = 0; i < prefixes.length; i++) {
-                Element elem = new Element(XML_NAMESPACE, NAMESPACE);
-                elem.addContent(new Element(XML_PREFIX, NAMESPACE).setText(prefixes[i]));
-                elem.addContent(new Element(XML_URI, NAMESPACE)).setText(nsReg.getURI(prefixes[i]));
-                nsElems[i] = elem;
-            }
-            properties.add(new DefaultDavProperty(JCR_NAMESPACES, nsElems, false));
+            DavProperty namespacesProp = new NamespacesProperty(nsReg);
+            properties.add(namespacesProp);
         } catch (RepositoryException e) {
             log.error("Failed to access NamespaceRegistry: " + e.getMessage());
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java Fri Jan 13 03:11:35 2006
@@ -15,15 +15,45 @@
  */
 package org.apache.jackrabbit.webdav.jcr;
 
-import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.property.*;
-import org.apache.jackrabbit.webdav.*;
-import org.apache.jackrabbit.webdav.version.*;
-import org.apache.jackrabbit.webdav.version.report.*;
 import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavLocatorFactory;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.MultiStatus;
+import org.apache.jackrabbit.webdav.MultiStatusResponse;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
+import org.apache.jackrabbit.webdav.property.DavPropertySet;
+import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
+import org.apache.jackrabbit.webdav.property.HrefProperty;
+import org.apache.jackrabbit.webdav.version.LabelInfo;
+import org.apache.jackrabbit.webdav.version.MergeInfo;
+import org.apache.jackrabbit.webdav.version.UpdateInfo;
+import org.apache.jackrabbit.webdav.version.VersionControlledResource;
+import org.apache.jackrabbit.webdav.version.VersionHistoryResource;
+import org.apache.jackrabbit.webdav.version.VersionResource;
+import org.apache.jackrabbit.webdav.version.VersionableResource;
+import org.apache.jackrabbit.webdav.version.report.ReportType;
+import org.apache.jackrabbit.webdav.version.report.SupportedReportSetProperty;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.log4j.Logger;
+import org.w3c.dom.Element;
 
-import javax.jcr.*;
-import javax.jcr.observation.*;
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+import javax.jcr.Workspace;
+import javax.jcr.observation.Event;
+import javax.jcr.observation.EventIterator;
+import javax.jcr.observation.EventListener;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
 import java.util.List;
@@ -295,7 +325,8 @@
         MultiStatus ms = new MultiStatus();
         try {
             Node node = (Node)item;
-            boolean removeExisting = updateInfo.getUpdateElement().getChild(XML_REMOVEEXISTING, NAMESPACE) != null;
+            Element udElem = updateInfo.getUpdateElement();
+            boolean removeExisting = DomUtil.hasChildElement(udElem, XML_REMOVEEXISTING, NAMESPACE);
 
             // register eventListener in order to be able to report the modified resources.
             EventListener el = new EListener(updateInfo.getPropertyNameSet(), ms);
@@ -311,7 +342,7 @@
                     versions[i] = vh.getVersion(getItemName(itemPath));
                 }
                 if (versions.length == 1) {
-                    String relPath = updateInfo.getUpdateElement().getChildText(XML_RELPATH, NAMESPACE);
+                    String relPath = DomUtil.getChildText(udElem, XML_RELPATH, NAMESPACE);
                     if (relPath == null) {
                         node.restore(versions[0], removeExisting);
                     } else {
@@ -378,7 +409,8 @@
             EventListener el = new EListener(mergeInfo.getPropertyNameSet(), ms);
             registerEventListener(el, node.getPath());
 
-            String workspaceName = getLocatorFromHref(mergeInfo.getSourceHref()).getWorkspaceName();
+            // todo: RFC allows multiple href elements inside the DAV:source element
+            String workspaceName = getLocatorFromHref(mergeInfo.getSourceHrefs()[0]).getWorkspaceName();
             NodeIterator failed = node.merge(workspaceName, !mergeInfo.isNoAutoMerge());
 
             // unregister the event listener again

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java Fri Jan 13 03:11:35 2006
@@ -17,8 +17,11 @@
 
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.lock.AbstractActiveLock;
+import org.apache.jackrabbit.webdav.lock.ActiveLock;
+import org.apache.jackrabbit.webdav.lock.Type;
+import org.apache.jackrabbit.webdav.lock.Scope;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
-import org.apache.jackrabbit.webdav.lock.*;
 import org.apache.jackrabbit.JcrConstants;
 
 import javax.jcr.lock.Lock;

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java Fri Jan 13 03:11:35 2006
@@ -17,7 +17,9 @@
 package org.apache.jackrabbit.webdav.jcr.nodetype;
 
 import org.apache.log4j.Logger;
-import org.jdom.Element;
+import org.apache.jackrabbit.webdav.xml.XmlSerializable;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.ItemDefinition;
@@ -26,7 +28,7 @@
 /**
  * <code>ItemDefinitionImpl</code>...
  */
-abstract public class ItemDefinitionImpl implements ItemDefinition, NodeTypeConstants {
+abstract public class ItemDefinitionImpl implements ItemDefinition, NodeTypeConstants, XmlSerializable {
 
     private static Logger log = Logger.getLogger(ItemDefinitionImpl.class);
 
@@ -41,7 +43,6 @@
 	if (definition == null) {
             throw new IllegalArgumentException("PropDef argument can not be null");
         }
-
         name = definition.getName();
 	declaringNodeType = definition.getDeclaringNodeType();
 	isAutoCreated = definition.isAutoCreated();
@@ -92,14 +93,15 @@
 	return isProtected;
     }
 
-    //-------------------------------------< implementation specific method >---
+    //------------------------------------------< XmlSerializable interface >---
     /**
      * Returns the Xml representation of a {@link ItemDefinition} object.
      *
      * @return Xml representation of the specified {@link ItemDefinition def}.
+     * @param document
      */
-    public Element toXml() {
-	Element elem = new Element(getElementName());
+    public Element toXml(Document document) {
+	Element elem = document.createElement(getElementName());
         elem.setAttribute(NAME_ATTRIBUTE, getName());
         elem.setAttribute(AUTOCREATED_ATTRIBUTE, Boolean.toString(isAutoCreated()));
         elem.setAttribute(MANDATORY_ATTRIBUTE, Boolean.toString(isMandatory()));
@@ -108,10 +110,11 @@
         return elem;
     }
 
+    //-------------------------------------< implementation specific method >---
     /**
      * Returns the name of the root element
      *
      * @return the name of the root element
      */
-    public abstract String getElementName();
+    abstract String getElementName();
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java Fri Jan 13 03:11:35 2006
@@ -17,7 +17,9 @@
 package org.apache.jackrabbit.webdav.jcr.nodetype;
 
 import org.apache.log4j.Logger;
-import org.jdom.Element;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeDefinition;
@@ -76,12 +78,11 @@
      * Returns xml representation
      *
      * @return xml representation
+     * @param document
      */
-    public Element toXml() {
-        Element elem = super.toXml();
-
+    public Element toXml(Document document) {
+        Element elem = super.toXml(document);
         elem.setAttribute(SAMENAMESIBLINGS_ATTRIBUTE, Boolean.toString(allowsSameNameSiblings()));
-
         // defaultPrimaryType can be 'null'
         NodeType defaultPrimaryType = getDefaultPrimaryType();
         if (defaultPrimaryType != null) {
@@ -89,12 +90,14 @@
         }
         // reqPrimaryTypes: minimal set is nt:base.
         NodeType[] nts = getRequiredPrimaryTypes();
-        Element reqPrimaryTypes = new Element(REQUIREDPRIMARYTYPES_ELEMENT);
+        Element reqPrimaryTypes = document.createElement(REQUIREDPRIMARYTYPES_ELEMENT);
 	for (int i = 0; i < nts.length; i++) {
-	    reqPrimaryTypes.addContent(new Element(REQUIREDPRIMARYTYPE_ELEMENT).setText(nts[i].getName()));
-	}
-        elem.addContent(reqPrimaryTypes);
+            Element rptElem = document.createElement(REQUIREDPRIMARYTYPE_ELEMENT);
+            DomUtil.setText(rptElem, nts[i].getName());
+	    reqPrimaryTypes.appendChild(rptElem);
 
+	}
+        elem.appendChild(reqPrimaryTypes);
         return elem;
     }
 
@@ -103,7 +106,7 @@
      *
      * @return always returns {@link #CHILDNODEDEFINITION_ELEMENT}.
      */
-    public String getElementName() {
+    String getElementName() {
 	return CHILDNODEDEFINITION_ELEMENT;
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeConstants.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeConstants.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeConstants.java Fri Jan 13 03:11:35 2006
@@ -15,8 +15,8 @@
  */
 package org.apache.jackrabbit.webdav.jcr.nodetype;
 
-import org.jdom.Namespace;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
+import org.apache.jackrabbit.webdav.xml.Namespace;
 
 /**
  * <code>NodeTypeConstants</code> used to represent nodetype definitions in
@@ -31,16 +31,11 @@
 
     public static final String XML_NODETYPENAME = "nodetypename";
 
-    public static final String XML_REPORT_ALLNODETYPES = "allnodetypes";
-    public static final String XML_REPORT_MIXINNODETYPES = "mixinnodetypes";
-    public static final String XML_REPORT_PRIMARYNODETYPES = "primarynodetypes";
-
-    // report response
-    /** Name of the node type definition root element. */
-    public static final String XML_NODETYPES = "nodeTypes";
-
-    /** Name of the node type definition element. */
-    public static final String XML_NODETYPE = "nodeType";
+    public static final String XML_REPORT_ALLNODETYPES = "all-nodetypes";
+    public static final String XML_REPORT_MIXINNODETYPES = "mixin-nodetypes";
+    public static final String XML_REPORT_PRIMARYNODETYPES = "primary-nodetypes";
+    public static final String XML_NODETYPES = "nodetypes";
+    public static final String XML_NODETYPE = "nodetype";
 
     //------< copied from org.apache.jackrabbit.core.nodetype.xml.Constants >---
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeProperty.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeProperty.java Fri Jan 13 03:11:35 2006
@@ -15,32 +15,44 @@
  */
 package org.apache.jackrabbit.webdav.jcr.nodetype;
 
-import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.property.DavPropertyName;
-import org.apache.jackrabbit.webdav.property.DavProperty;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.property.AbstractDavProperty;
-import org.jdom.Element;
+import org.apache.jackrabbit.webdav.property.DavProperty;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 
 import javax.jcr.nodetype.NodeType;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
 
 /**
  * <code>NodeTypeProperty</code>...
  */
-public class NodeTypeProperty extends AbstractDavProperty {
+public class NodeTypeProperty extends AbstractDavProperty implements NodeTypeConstants {
 
     private static Logger log = Logger.getLogger(NodeTypeProperty.class);
 
-    private final NodeTypeElement[] value;
+    private final Set nodetypeNames = new HashSet();
 
     public NodeTypeProperty(DavPropertyName name, NodeType nodeType, boolean isProtected) {
-        super(name, isProtected);
-        value = new NodeTypeElement[] {new NodeTypeElement(nodeType)};
+        this(name, new NodeType[] {nodeType}, isProtected);
     }
 
     public NodeTypeProperty(DavPropertyName name, NodeType[] nodeTypes, boolean isProtected) {
         super(name, isProtected);
-        value = NodeTypeElement.create(nodeTypes);
+        for (int i = 0; i < nodeTypes.length; i++) {
+            NodeType nt = nodeTypes[i];
+            if (nt != null) {
+                nodetypeNames.add(nodeTypes[i].getName());
+            }
+        }
     }
 
     /**
@@ -51,24 +63,35 @@
      * @throws IllegalArgumentException if the content of the specified property
      * contains elements other than {@link NodeTypeConstants#XML_NODETYPE}.
      */
-    public NodeTypeProperty(DavProperty property) {
+    public NodeTypeProperty(DavProperty property) throws DavException {
         super(property.getName(), property.isProtected());
+        Object propValue = property.getValue();
+        Iterator it;
+        if (propValue instanceof List) {
+            it = ((List)propValue).iterator();
+        } else if (propValue instanceof Element) {
+            List l = new ArrayList();
+            l.add(propValue);
+            it = l.iterator();
+        } else {
+            log.warn("Cannot build NodeTypeProperty from the given property.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Cannot build NodeTypeProperty from the given property.");
+        }
 
-        if (property.getValue() instanceof List) {
-            List ntElemList = new ArrayList();
-            Iterator it = ((List) property.getValue()).iterator();
             while (it.hasNext()) {
                 Object content = it.next();
-                if (content instanceof Element) {
-                    ntElemList.add(new NodeTypeElement((Element)content));
+            if (!(content instanceof Element)) {
+                continue;
                 }
+            Element el = (Element)content;
+            if (XML_NODETYPE.equals(el.getLocalName()) && NodeTypeConstants.NAMESPACE.isSame(el.getNamespaceURI())) {
+                String nodetypeName = DomUtil.getText(el);
+                if (nodetypeName != null && !"".equals(nodetypeName)) {
+                    nodetypeNames.add(nodetypeName);
             }
-            value = (NodeTypeElement[]) ntElemList.toArray(new NodeTypeElement[ntElemList.size()]);
-        } else if (property.getValue() instanceof Element) {
-	    NodeTypeElement ntElem = new NodeTypeElement((Element)property.getValue());
-	    value = new NodeTypeElement [] {ntElem};
 	} else {
-            value = new NodeTypeElement[0];
+                log.debug("'dcr:nodetype' element expected -> ignoring element '" + ((Element)content).getNodeName() + "'");
+            }
         }
     }
 
@@ -78,27 +101,29 @@
      * @return set of nodetype names
      */
     public Set getNodeTypeNames() {
-        HashSet names = new HashSet();
-        Object val = getValue();
-        if (val instanceof NodeTypeElement[]) {
-            NodeTypeElement[] elems = (NodeTypeElement[])val;
-            for (int i = 0; i < elems.length; i++) {
-                String ntName = elems[i].getNodeTypeName();
-                if (ntName != null) {
-                    names.add(ntName);
-                }
-            }
-        }
-        return names;
+        return nodetypeNames;
     }
 
     /**
-     * Returns the value of this property which is an array of {@link NodeTypeElement}
-     * objects.
+     * Returns the value of this property which is a Set of nodetype names.
      *
-     * @return an array of {@link NodeTypeElement}s
+     * @return a Set of nodetype names (String).
      */
     public Object getValue() {
-        return value;
+        return nodetypeNames;
+    }
+
+    /**
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     */
+    public Element toXml(Document document) {
+        Element elem = getName().toXml(document);
+        Iterator it = getNodeTypeNames().iterator();
+        while (it.hasNext()) {
+            String name = it.next().toString();
+            Element ntElem = DomUtil.addChildElement(elem, XML_NODETYPE, NodeTypeConstants.NAMESPACE);
+            DomUtil.addChildElement(ntElem, XML_NODETYPENAME, NodeTypeConstants.NAMESPACE, name);
+        }
+        return elem;
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/PropertyDefinitionImpl.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/PropertyDefinitionImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/PropertyDefinitionImpl.java Fri Jan 13 03:11:35 2006
@@ -17,7 +17,9 @@
 package org.apache.jackrabbit.webdav.jcr.nodetype;
 
 import org.apache.log4j.Logger;
-import org.jdom.Element;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
 import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.Value;
@@ -87,9 +89,10 @@
      * Return xml representation
      *
      * @return xml representation
+     * @param document
      */
-    public Element toXml() {
-	Element elem = super.toXml();
+    public Element toXml(Document document) {
+	Element elem = super.toXml(document);
 
         elem.setAttribute(MULTIPLE_ATTRIBUTE, Boolean.toString(isMultiple()));
         elem.setAttribute(REQUIREDTYPE_ATTRIBUTE, PropertyType.nameFromValue(getRequiredType()));
@@ -97,25 +100,28 @@
         // default values may be 'null'
         Value[] values = getDefaultValues();
         if (values != null) {
-            Element dvElement = new Element(DEFAULTVALUES_ELEMENT);
+            Element dvElement = document.createElement(DEFAULTVALUES_ELEMENT);
             for (int i = 0; i < values.length; i++) {
                 try {
-                    Element valElem = new Element(DEFAULTVALUE_ELEMENT).setText(values[i].getString());
-                    dvElement.addContent(valElem);
+                    Element valElem = document.createElement(DEFAULTVALUE_ELEMENT);
+                    DomUtil.setText(valElem, values[i].getString());
+                    dvElement.appendChild(valElem);
                 } catch (RepositoryException e) {
                     // should not occur
                     log.error(e.getMessage());
                 }
             }
-            elem.addContent(dvElement);
+            elem.appendChild(dvElement);
         }
         // value constraints array is never null.
-        Element constrElem = new Element(VALUECONSTRAINTS_ELEMENT);
+        Element constrElem = document.createElement(VALUECONSTRAINTS_ELEMENT);
         String[] constraints = getValueConstraints();
         for (int i = 0; i < constraints.length; i++) {
-            constrElem.addContent(new Element(VALUECONSTRAINT_ELEMENT).setText(constraints[i]));
+            Element vcElem = document.createElement(VALUECONSTRAINT_ELEMENT);
+            DomUtil.setText(vcElem, constraints[i]);
+            constrElem.appendChild(vcElem);
         }
-        elem.addContent(constrElem);
+        elem.appendChild(constrElem);
 
         return elem;
     }
@@ -125,7 +131,7 @@
      * 
      * @return always returns {@link #PROPERTYDEFINITION_ELEMENT}
      */
-    public String getElementName() {
+    String getElementName() {
 	return PROPERTYDEFINITION_ELEMENT;
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java Fri Jan 13 03:11:35 2006
@@ -15,18 +15,30 @@
  */
 package org.apache.jackrabbit.webdav.jcr.observation;
 
-import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.DavResourceLocator;
-import org.apache.jackrabbit.webdav.DavConstants;
-import org.apache.jackrabbit.webdav.observation.*;
-import org.apache.jackrabbit.webdav.util.XmlUtil;
 import org.apache.jackrabbit.uuid.UUID;
-import org.jdom.Element;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.observation.EventBundle;
+import org.apache.jackrabbit.webdav.observation.EventDiscovery;
+import org.apache.jackrabbit.webdav.observation.EventType;
+import org.apache.jackrabbit.webdav.observation.Filter;
+import org.apache.jackrabbit.webdav.observation.ObservationConstants;
+import org.apache.jackrabbit.webdav.observation.ObservationResource;
+import org.apache.jackrabbit.webdav.observation.Subscription;
+import org.apache.jackrabbit.webdav.observation.SubscriptionInfo;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 
-import javax.jcr.observation.*;
-import javax.jcr.observation.EventListener;
 import javax.jcr.RepositoryException;
-import java.util.*;
+import javax.jcr.observation.Event;
+import javax.jcr.observation.EventIterator;
+import javax.jcr.observation.EventListener;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
 /**
  * The <code>Subscription</code> class encapsulates a single subscription with
@@ -42,6 +54,7 @@
     private static final long DEFAULT_TIMEOUT = 300000; // 5 minutes
 
     private SubscriptionInfo info;
+    private long expirationTime;
 
     private final DavResourceLocator locator;
     private final String subscriptionId = UUID.randomUUID().toString();
@@ -70,25 +83,27 @@
 
     /**
      * Return the Xml representation of this <code>Subscription</code> as required
-     * for the {@link org.apache.jackrabbit.webdav.observation.SubscriptionDiscovery} webdav property that in included
-     * in the response body of a sucessful SUBSCRIBE request or as part of a
-     * PROPFIND response.
+     * for the {@link org.apache.jackrabbit.webdav.observation.SubscriptionDiscovery}
+     * webdav property that in included in the response body of a sucessful SUBSCRIBE
+     * request or as part of a PROPFIND response.
      *
      * @return Xml representation
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     * @param document
      */
-    public Element toXml() {
-        Element subscr = new Element(XML_SUBSCRIPTION, NAMESPACE);
-        Element[] elems = info.toXml();
-        for (int i = 0; i < elems.length; i++) {
-            subscr.addContent(elems[i]);
-        }
+    public Element toXml(Document document) {
+        Element subscr = DomUtil.createElement(document, XML_SUBSCRIPTION, NAMESPACE);
 
-        Element id = new Element(XML_SUBSCRIPTIONID);
-        id.addContent(XmlUtil.hrefToXml(subscriptionId));
-        subscr.addContent(id);
+        subscr.appendChild(info.toXml(document));
+        subscr.appendChild(DomUtil.depthToXml(info.isDeep(), document));
+        subscr.appendChild(DomUtil.timeoutToXml(info.getTimeOut(), document));
+
+        Element id = DomUtil.addChildElement(subscr, XML_SUBSCRIPTIONID, NAMESPACE);
+        id.appendChild(DomUtil.hrefToXml(subscriptionId, document));
         return subscr;
     }
 
+    //--------------------------------------------< implementation specific >---
     /**
      * Modify the {@link SubscriptionInfo} for this subscription.
      *
@@ -98,36 +113,49 @@
         this.info = info;
         // validate the timeout and adjust value, if it is invalid or missing
         long timeout = info.getTimeOut();
-        if (timeout == DavConstants.UNDEFINED_TIMEOUT) {
-            info.setTimeOut(DEFAULT_TIMEOUT);
+        if (timeout <= 0) {
+            timeout = DEFAULT_TIMEOUT;
         }
+        expirationTime = System.currentTimeMillis() + timeout;
     }
 
     /**
      * @return JCR compliant integer representation of the event types defined
      * for this {@link SubscriptionInfo}.
      */
-    int getEventTypes() {
-        Iterator xmlTypes = info.getEventTypes().iterator();
-        int eventTypes = 0;
-        while (xmlTypes.hasNext()) {
-            eventTypes |= nametoTypeConstant(((Element)xmlTypes.next()).getName());
+    int getEventTypes() throws DavException {
+        EventType[] eventTypes = info.getEventTypes();
+        int events = 0;
+        for (int i = 0; i < eventTypes.length; i++) {
+            events |= getEventType(eventTypes[i].getName());
         }
-        return eventTypes;
+        return events;
     }
 
     /**
      * @return a String array with size > 0 or <code>null</code>
      */
     String[] getUuidFilters() {
-        return info.getFilters(XML_UUID);
+        return getFilterValues(XML_UUID);
     }
 
     /**
      * @return a String array with size > 0 or <code>null</code>
      */
     String[] getNodetypeNameFilters() {
-        return info.getFilters(XML_NODETYPE_NAME);
+        return getFilterValues(XML_NODETYPE_NAME);
+    }
+
+    private String[] getFilterValues(String filterLocalName) {
+        Filter[] filters = info.getFilters(filterLocalName, NAMESPACE);
+        List values = new ArrayList();
+        for (int i = 0; i < filters.length; i++) {
+            String val = filters[i].getValue();
+            if (val != null) {
+                values.add(val);
+            }
+        }
+        return (values.size() > 0) ? (String[])values.toArray(new String[values.size()]) : null;
     }
 
     /**
@@ -173,7 +201,7 @@
      * @return true if this <code>Subscription</code> is expired
      */
     boolean isExpired() {
-        return System.currentTimeMillis() > info.getTimeOut() + System.currentTimeMillis();
+        return System.currentTimeMillis() > expirationTime;
     }
 
     /**
@@ -189,7 +217,7 @@
         Iterator it = eventBundles.iterator();
         while (it.hasNext()) {
             EventBundle eb = (EventBundle) it.next();
-            ed.addEventBundle(eb.toXml());
+            ed.addEventBundle(eb);
         }
         // clear list
         eventBundles.clear();
@@ -208,7 +236,7 @@
     public synchronized void onEvent(EventIterator events) {
         // TODO: correct not to accept events after expiration? without unsubscribing?
         if (!isExpired()) {
-            eventBundles.add(new EventBundle(events));
+            eventBundles.add(new EventBundleImpl(events));
         }
     }
 
@@ -217,12 +245,12 @@
      * Static utility method in order to convert the types defined by
      * {@link javax.jcr.observation.Event} into their Xml representation.
      *
-     * @param jcrEventType
+     * @param eventType The jcr event type
      * @return Xml representation of the event type.
      */
-    static Element typeConstantToXml(int jcrEventType) {
+    private static String getEventName(int eventType) {
         String eventName;
-        switch (jcrEventType) {
+        switch (eventType) {
             case Event.NODE_ADDED:
                 eventName = EVENT_NODEADDED;
                 break;
@@ -240,7 +268,7 @@
                 eventName = EVENT_PROPERTYREMOVED;
                 break;
         }
-        return new Element(eventName, NAMESPACE);
+        return eventName;
     }
 
     /**
@@ -248,25 +276,25 @@
      * Xml request body into the corresponding constant defined by
      * {@link javax.jcr.observation.Event}.
      *
-     * @param eventTypeName
+     * @param eventName
      * @return event type as defined by {@link javax.jcr.observation.Event}.
-     * @throws IllegalArgumentException if the given element cannot be translated
+     * @throws DavException if the given element cannot be translated
      * to any of the events defined by {@link javax.jcr.observation.Event}.
      */
-    static int nametoTypeConstant(String eventTypeName) {
+    private static int getEventType(String eventName) throws DavException {
         int eType;
-        if (EVENT_NODEADDED.equals(eventTypeName)) {
+        if (EVENT_NODEADDED.equals(eventName)) {
             eType = Event.NODE_ADDED;
-        } else if (EVENT_NODEREMOVED.equals(eventTypeName)) {
+        } else if (EVENT_NODEREMOVED.equals(eventName)) {
             eType = Event.NODE_REMOVED;
-        } else if (EVENT_PROPERTYADDED.equals(eventTypeName)) {
+        } else if (EVENT_PROPERTYADDED.equals(eventName)) {
             eType = Event.PROPERTY_ADDED;
-        } else if (EVENT_PROPERTYCHANGED.equals(eventTypeName)) {
+        } else if (EVENT_PROPERTYCHANGED.equals(eventName)) {
             eType = Event.PROPERTY_CHANGED;
-        } else if (EVENT_PROPERTYREMOVED.equals(eventTypeName)) {
+        } else if (EVENT_PROPERTYREMOVED.equals(eventName)) {
             eType = Event.PROPERTY_REMOVED;
         } else {
-            throw new IllegalArgumentException("Invalid event type: "+eventTypeName);
+            throw new DavException(DavServletResponse.SC_UNPROCESSABLE_ENTITY, "Invalid event type: "+eventName);
         }
         return eType;
     }
@@ -279,20 +307,19 @@
      *
      * @see SubscriptionImpl#discoverEvents()
      */
-    private class EventBundle {
+    private class EventBundleImpl implements EventBundle {
 
         private final EventIterator events;
 
-        private EventBundle(EventIterator events) {
+        private EventBundleImpl(EventIterator events) {
             this.events = events;
         }
 
-        private Element toXml() {
-            Element bundle = new Element(XML_EVENTBUNDLE, NAMESPACE);
+        public Element toXml(Document document) {
+            Element bundle = DomUtil.createElement(document, XML_EVENTBUNDLE, NAMESPACE);
             while (events.hasNext()) {
                 Event event = events.nextEvent();
-
-                Element eventElem = new Element(XML_EVENT, NAMESPACE);
+                Element eventElem = DomUtil.addChildElement(bundle, XML_EVENT, NAMESPACE);
                 // href
                 String eHref = "";
                 try {
@@ -302,15 +329,15 @@
                     // should not occur....
                     log.error(e.getMessage());
                 }
-                eventElem.addContent(XmlUtil.hrefToXml(eHref));
+                eventElem.appendChild(DomUtil.hrefToXml(eHref, document));
                 // eventtype
-                Element eType = new Element(XML_EVENTTYPE, NAMESPACE).addContent(typeConstantToXml(event.getType()));
-                eventElem.addContent(eType);
+                Element eType = DomUtil.addChildElement(eventElem, XML_EVENTTYPE, NAMESPACE);
+                DomUtil.addChildElement(eType, getEventName(event.getType()), NAMESPACE);
                 // user id
-                Element eUserId = new Element(XML_EVENTUSERID, NAMESPACE).setText(event.getUserID());
-                eventElem.addContent(eUserId);
+                DomUtil.addChildElement(eventElem, XML_EVENTUSERID, NAMESPACE, event.getUserID());
             }
             return bundle;
         }
+
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java Fri Jan 13 03:11:35 2006
@@ -15,14 +15,25 @@
  */
 package org.apache.jackrabbit.webdav.jcr.observation;
 
-import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavSession;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
-import org.apache.jackrabbit.webdav.observation.*;
+import org.apache.jackrabbit.webdav.observation.EventDiscovery;
+import org.apache.jackrabbit.webdav.observation.ObservationResource;
+import org.apache.jackrabbit.webdav.observation.Subscription;
+import org.apache.jackrabbit.webdav.observation.SubscriptionDiscovery;
+import org.apache.jackrabbit.webdav.observation.SubscriptionInfo;
+import org.apache.jackrabbit.webdav.observation.SubscriptionManager;
+import org.apache.log4j.Logger;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.observation.ObservationManager;
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
 
 /**
  * <code>SubscriptionManager</code> collects all subscriptions requested, handles

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/LengthsProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/LengthsProperty.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/LengthsProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/LengthsProperty.java Fri Jan 13 03:11:35 2006
@@ -18,7 +18,9 @@
 
 import org.apache.jackrabbit.webdav.property.AbstractDavProperty;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
-import org.jdom.Element;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
 /**
  * <code>LengthsProperty</code> extends {@link org.apache.jackrabbit.webdav.property.DavProperty} providing
@@ -27,7 +29,7 @@
  */
 public class LengthsProperty extends AbstractDavProperty implements ItemResourceConstants {
 
-    private final Element[] value;
+    private final long[] value;
 
     /**
      * Create a new <code>LengthsProperty</code> from the given long array.
@@ -36,22 +38,29 @@
      */
     public LengthsProperty(long[] lengths) {
 	super(JCR_LENGTHS, true);
-
-	Element[] elems = new Element[lengths.length];
-	for (int i = 0; i < lengths.length; i++) {
-	    elems[i] = new Element(XML_LENGTH, ItemResourceConstants.NAMESPACE);
-	    elems[i].addContent(String.valueOf(lengths[i]));
-	}
-	this.value = elems;
+	this.value = lengths;
     }
 
     /**
-     * Returns an array of {@link Element}s representing the value of this
+     * Returns an array of {@link long}s representing the value of this
      * property.
      *
-     * @return an array of {@link Element}s
+     * @return an array of {@link long}s
      */
     public Object getValue() {
 	return value;
     }
+
+    /**
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     */
+    public Element toXml(Document document) {
+        Element elem = getName().toXml(document);
+        for (int i = 0; i < value.length; i++) {
+            String txtContent = String.valueOf(value[i]);
+	    DomUtil.addChildElement(elem, XML_LENGTH, ItemResourceConstants.NAMESPACE, txtContent);
+	}
+        return elem;
+    }
+
 }

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/NamespacesProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/NamespacesProperty.java?rev=368683&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/NamespacesProperty.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/NamespacesProperty.java Fri Jan 13 03:11:35 2006
@@ -0,0 +1,101 @@
+/*
+ * 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.jcr.property;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.property.AbstractDavProperty;
+import org.apache.jackrabbit.webdav.property.DavProperty;
+import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.RepositoryException;
+import java.util.Properties;
+import java.util.List;
+import java.util.Iterator;
+import java.util.Enumeration;
+
+/**
+ * <code>NamespacesProperty</code>...
+ */
+public class NamespacesProperty extends AbstractDavProperty implements ItemResourceConstants {
+
+    private static Logger log = Logger.getLogger(NamespacesProperty.class);
+
+    private final Properties value;
+
+    public NamespacesProperty(NamespaceRegistry nsReg) throws RepositoryException {
+        super(JCR_NAMESPACES, false);
+        String[] prefixes = nsReg.getPrefixes();
+        value = new Properties();
+        for (int i = 0; i < prefixes.length; i++) {
+            value.setProperty(prefixes[i], nsReg.getURI(prefixes[i]));
+        }
+    }
+
+    public NamespacesProperty(DavProperty property) throws DavException {
+        super(JCR_NAMESPACES, false);
+        Object v = property.getValue();
+        if (!(v instanceof List)) {
+            log.warn("Unexpected structure of dcr:namespace property.");
+            throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR);
+        }
+        value = new Properties();
+        // retrieve list of prefix/uri pairs that build the new values of
+        // the ns-registry
+        Iterator it = ((List)v).iterator();
+        while (it.hasNext()) {
+            Object listEntry = it.next();
+            if (listEntry instanceof Element) {
+                Element e = (Element)listEntry;
+                if (XML_NAMESPACE.equals(e.getLocalName())) {
+                    String prefix = DomUtil.getChildText(e, XML_PREFIX, ItemResourceConstants.NAMESPACE);
+                    String uri = DomUtil.getChildText(e, XML_URI, ItemResourceConstants.NAMESPACE);
+                    value.setProperty(prefix, uri);
+                }
+            }
+        }
+    }
+
+    public Properties getNamespaces() {
+        return value;
+    }
+
+    public Object getValue() {
+        return value;
+    }
+
+    /**
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     */
+    public Element toXml(Document document) {
+        Element elem = getName().toXml(document);
+        Enumeration prefixes = value.propertyNames();
+        while (prefixes.hasMoreElements()) {
+            String prefix = (String)prefixes.nextElement();
+            String uri = value.getProperty(prefix);
+            Element nsElem = DomUtil.addChildElement(elem, XML_NAMESPACE, ItemResourceConstants.NAMESPACE);
+            DomUtil.addChildElement(nsElem, XML_PREFIX, ItemResourceConstants.NAMESPACE, prefix);
+            DomUtil.addChildElement(nsElem, XML_URI, ItemResourceConstants.NAMESPACE, uri);
+        }
+        return elem;
+    }
+
+}
\ No newline at end of file

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

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

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java Fri Jan 13 03:11:35 2006
@@ -19,12 +19,16 @@
 import org.apache.jackrabbit.webdav.property.AbstractDavProperty;
 import org.apache.jackrabbit.webdav.property.DavProperty;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.value.ValueHelper;
-import org.jdom.Element;
+import org.apache.log4j.Logger;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
 import javax.jcr.RepositoryException;
+import javax.jcr.PropertyType;
 import java.util.List;
 import java.util.Iterator;
 import java.util.ArrayList;
@@ -36,7 +40,9 @@
  */
 public class ValuesProperty extends AbstractDavProperty implements ItemResourceConstants {
 
-    private final Element[] value;
+    private static Logger log = Logger.getLogger(ValuesProperty.class);
+
+    private final Value[] jcrValues;
 
     /**
      * Create a new <code>ValuesProperty</code> from the given {@link javax.jcr.Value Value
@@ -46,14 +52,8 @@
      */
     public ValuesProperty(Value[] values) throws ValueFormatException, RepositoryException {
 	super(JCR_VALUES, false);
-
-	Element[] propValue = new Element[values.length];
-	for (int i = 0; i < values.length; i++) {
-	    propValue[i] = new Element(XML_VALUE, ItemResourceConstants.NAMESPACE);
-	    propValue[i].addContent(ValueHelper.serialize(values[i], false));
-	}
 	// finally set the value to the DavProperty
-	value = propValue;
+	jcrValues = values;
     }
     
     /**
@@ -61,17 +61,20 @@
      *
      * @param property
      */
-    public ValuesProperty(DavProperty property) {
+    public ValuesProperty(DavProperty property) throws RepositoryException {
 	super(JCR_VALUES, false);
 
 	if (!JCR_VALUES.equals(property.getName())) {
 	    throw new IllegalArgumentException("ValuesProperty may only be created with a property that has name="+JCR_VALUES.getName());
 	}
 
-	Element[] elems = new Element[0];
-	if (property.getValue() instanceof List) {
+	List valueElements = new ArrayList();
+        Object propValue = property.getValue();
+        if (propValue != null) {
+            if (isValueElement(propValue)) {
+                valueElements.add(propValue);
+            } else if (propValue instanceof List) {
 	    Iterator elemIt = ((List)property.getValue()).iterator();
-	    ArrayList valueElements = new ArrayList();
 	    while (elemIt.hasNext()) {
 		Object el = elemIt.next();
 		/* make sure, only Elements with name 'value' are used for
@@ -79,41 +82,61 @@
 		* comment etc.) is ignored. NO bad-request/conflict error is
 		* thrown.
 		*/
-		if (el instanceof Element && XML_VALUE.equals(((Element)el).getName())) {
+                    if (isValueElement(propValue)) {
 		    valueElements.add(el);
 		}
 	    }
+            }
+        }
 	    /* fill the 'value' with the valid 'value' elements found before */
-	    elems = (Element[])valueElements.toArray(new Element[valueElements.size()]);
-	} else {
-	    new IllegalArgumentException("ValuesProperty may only be created with a property that has a list of 'value' elements as content.");
+        Element[] elems = (Element[])valueElements.toArray(new Element[valueElements.size()]);
+	jcrValues = new Value[elems.length];
+	for (int i = 0; i < elems.length; i++) {
+            String value = DomUtil.getText(elems[i]);
+	    jcrValues[i] = ValueHelper.deserialize(value, PropertyType.STRING, false);
 	}
-	// finally set the value to the DavProperty
-	value = elems;
+	}
+
+    private static boolean isValueElement(Object obj) {
+        return obj instanceof Element && XML_VALUE.equals(((Element)obj).getLocalName());
     }
 
     /**
      * Converts the value of this property to a {@link javax.jcr.Value value array}.
      *
      * @return Array of Value objects
-     * @throws RepositoryException
+     * @throws ValueFormatException if convertion of the internal jcr values to
+     * the specified value type fails.
      */
-    public Value[] getValues(int propertyType) throws ValueFormatException, RepositoryException {
-	Element[] propValue = (Element[])getValue();
-	Value[] values = new Value[propValue.length];
-	for (int i = 0; i < propValue.length; i++) {
-	    values[i] = ValueHelper.deserialize(propValue[i].getText(), propertyType, false);
+    public Value[] getValues(int propertyType) throws ValueFormatException {
+        Value[] vs = new Value[jcrValues.length];
+        for (int i = 0; i < jcrValues.length; i++) {
+            vs[i] = ValueHelper.convert(jcrValues[i], propertyType);
 	}
-	return values;
+	return jcrValues;
     }
 
     /**
-     * Returns an array of {@link Element}s representing the value of this
+     * Returns an array of {@link Value}s representing the value of this
      * property.
      *
-     * @return an array of {@link Element}s
+     * @return an array of {@link Value}s
+     * @see #getValues(int)
      */
     public Object getValue() {
-	return value;
+	return jcrValues;
+    }
+
+    public Element toXml(Document document) {
+        Element elem = getName().toXml(document);
+        for (int i = 0; i < jcrValues.length; i++) {
+            try {
+                DomUtil.addChildElement(elem, XML_VALUE, ItemResourceConstants.NAMESPACE, jcrValues[i].getString());
+            } catch (RepositoryException e) {
+                log.error("Unexpected Error while converting jcr value to String: " + e.getMessage());
     }
+        }
+        return elem;
+    }
+
 }



Mime
View raw message