jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r368683 [3/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/webdav/jcr/search/SearchResourceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java Fri Jan 13 03:11:35 2006
@@ -16,16 +16,28 @@
 package org.apache.jackrabbit.webdav.jcr.search;
 
 import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.xml.Namespace;
 import org.apache.jackrabbit.webdav.search.SearchResource;
 import org.apache.jackrabbit.webdav.search.QueryGrammerSet;
 import org.apache.jackrabbit.webdav.search.SearchInfo;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.MultiStatus;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.MultiStatusResponse;
 import org.apache.jackrabbit.JcrConstants;
-import org.jdom.Namespace;
 
-import javax.jcr.*;
-import javax.jcr.query.*;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.InvalidQueryException;
+import javax.jcr.query.RowIterator;
+import javax.jcr.query.Row;
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.Value;
 
 /**
  * <code>SearchResourceImpl</code>...
@@ -47,17 +59,16 @@
      * @see SearchResource#getQueryGrammerSet()
      */
     public QueryGrammerSet getQueryGrammerSet()  {
-        QueryGrammerSet qgs;
+        QueryGrammerSet qgs = new QueryGrammerSet();
         try {
             QueryManager qMgr = session.getRepositorySession().getWorkspace().getQueryManager();
             String[] langs = qMgr.getSupportedQueryLanguages();
-            qgs = new QueryGrammerSet();
             for (int i = 0; i < langs.length; i++) {
                 // todo: define proper namespace
-                qgs.addQueryLanguage(langs[i], Namespace.NO_NAMESPACE);
+                qgs.addQueryLanguage(langs[i], Namespace.EMPTY_NAMESPACE);
             }
         } catch (RepositoryException e) {
-            qgs = new QueryGrammerSet(new String[0]);
+            log.debug(e.getMessage());
         }
         return qgs;
     }
@@ -90,7 +101,7 @@
      * </ul>
      * @param sInfo defining the query to be executed
      * @return <code>Query</code> object.
-     * @throws InvalidQueryException if the query defined by <code>sInfo</code> is invalid
+     * @throws javax.jcr.query.InvalidQueryException if the query defined by <code>sInfo</code> is invalid
      * @throws RepositoryException the query manager cannot be accessed or if
      * another error occurs.
      * @throws DavException if <code>sInfo</code> is <code>null</code> and
@@ -159,7 +170,7 @@
             // create a new ms-response for this row of the result set
             DavResourceLocator loc = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), itemPath, false);
             String href = loc.getHref(true);
-            MultiStatusResponse resp = new MultiStatusResponse(href);
+            MultiStatusResponse resp = new MultiStatusResponse(href, null);
             // build the s-r-property
             SearchResultProperty srp = new SearchResultProperty(columnNames, values);
             resp.add(srp);

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResultProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResultProperty.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResultProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResultProperty.java Fri Jan 13 03:11:35 2006
@@ -20,17 +20,22 @@
 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.w3c.dom.Element;
+import org.w3c.dom.Document;
 
 import javax.jcr.Value;
 import javax.jcr.RepositoryException;
 import javax.jcr.PropertyType;
-import java.util.*;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
 
 /**
  * <code>SearchResultProperty</code>...
  */
+// todo: find proper solution for transporting search results...
 public class SearchResultProperty extends AbstractDavProperty implements ItemResourceConstants {
 
     private static Logger log = Logger.getLogger(SearchResultProperty.class);
@@ -80,12 +85,12 @@
             while (elemIt.hasNext()) {
                 Object el = elemIt.next();
                 if (el instanceof Element) {
-                    String txt = ((Element)el).getText();
-                    if (JCR_NAME.getName().equals(((Element)el).getName())) {
+                    String txt = DomUtil.getText((Element)el);
+                    if (JCR_NAME.getName().equals(((Element)el).getLocalName())) {
                         name = txt;
-                    } else if (JCR_VALUE.getName().equals(((Element)el).getName())) {
+                    } else if (JCR_VALUE.getName().equals(((Element)el).getLocalName())) {
                         value = txt;
-                    } else if (JCR_TYPE.getName().equals(((Element)el).getName())) {
+                    } else if (JCR_TYPE.getName().equals(((Element)el).getLocalName())) {
                         int type = PropertyType.valueFromName(txt);
                         if (name == null) {
                             throw new IllegalArgumentException("SearchResultProperty requires a set of 'dcr:name','dcr:value' and 'dcr:type' xml elements.");
@@ -100,7 +105,7 @@
                 }
             }
         } else {
-            new IllegalArgumentException("SearchResultProperty requires a set of 'dcr:name','dcr:value' and 'dcr:type' xml elements.");
+            new IllegalArgumentException("SearchResultProperty requires a list of 'dcr:name','dcr:value' and 'dcr:type' xml elements.");
         }
 
         columnNames = (String[]) colList.toArray(new String[colList.size()]);
@@ -128,10 +133,19 @@
         return values;
     }
 
+
     /**
-     * Return the value of this webdav property i.e. an list of xml
-     * {@link Element}s. For every value in the query result row represented by
-     * this webdav property a dcr:name, dcr:value and dcr:type element is created.
+     * Same as {@link #getValues()}
+     *
+     * @return Array of JCR Value object
+     */
+    public Object getValue() {
+        return values;
+    }
+
+    /**
+     * Return the xml representation of this webdav property. For every value in
+     * the query result row a dcr:name, dcr:value and dcr:type element is created.
      * Example:
      * <pre>
      * -----------------------------------------------------------
@@ -157,11 +171,10 @@
      * &lt;dcr:type&gt;Long&lt;dcr:value/&gt;
      * </pre>
      *
-     * @return value of this webdav property consisting of an list of xml elements.
-     * @see org.apache.jackrabbit.webdav.property.DavProperty#getValue()
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(org.w3c.dom.Document)
      */
-    public Object getValue() {
-        List value = new ArrayList();
+    public Element toXml(Document document) {
+        Element elem = getName().toXml(document);
         for (int i = 0; i < columnNames.length; i++) {
             String propertyName = columnNames[i];
             Value propertyValue = values[i];
@@ -175,10 +188,18 @@
             }
             String type = (propertyValue == null) ? PropertyType.TYPENAME_STRING : PropertyType.nameFromValue(propertyValue.getType());
 
-            value.add(JCR_NAME.toXml().setText(propertyName));
-            value.add(JCR_VALUE.toXml().setText(valueStr));
-            value.add(JCR_TYPE.toXml().setText(type));
+            Element child = JCR_NAME.toXml(document);
+            DomUtil.setText(child, propertyName);
+            elem.appendChild(child);
+
+            child = JCR_VALUE.toXml(document);
+            DomUtil.setText(child, valueStr);
+            elem.appendChild(child);
+
+            child = JCR_TYPE.toXml(document);
+            DomUtil.setText(child, type);
+            elem.appendChild(child);
         }
-        return value;
+        return elem;
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/transaction/TxLockManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/transaction/TxLockManagerImpl.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/transaction/TxLockManagerImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/transaction/TxLockManagerImpl.java Fri Jan 13 03:11:35 2006
@@ -209,7 +209,7 @@
             removeExpired(tx, responsibleMap, resource);
             throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "Transaction lock for resource '" + resource.getResourcePath() + "' was already expired.");
         } else {
-            if (TransactionConstants.XML_COMMIT.equals(lockInfo.getStatus())) {
+            if (lockInfo.isCommit()) {
                 tx.commit(resource);
             } else {
                 tx.rollback(resource);

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionHistoryItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionHistoryItemCollection.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionHistoryItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionHistoryItemCollection.java Fri Jan 13 03:11:35 2006
@@ -16,14 +16,20 @@
 package org.apache.jackrabbit.webdav.jcr.version;
 
 import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.version.*;
 import org.apache.jackrabbit.webdav.property.HrefProperty;
 import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
 import org.apache.jackrabbit.webdav.property.ResourceType;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
 import org.apache.jackrabbit.webdav.jcr.DefaultItemCollection;
-import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.version.VersionHistoryResource;
+import org.apache.jackrabbit.webdav.version.VersionResource;
+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 javax.jcr.RepositoryException;
 import javax.jcr.Item;

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java Fri Jan 13 03:11:35 2006
@@ -19,16 +19,29 @@
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
 import org.apache.jackrabbit.webdav.jcr.DefaultItemCollection;
-import org.apache.jackrabbit.webdav.*;
-import org.apache.jackrabbit.webdav.property.*;
-import org.apache.jackrabbit.webdav.version.*;
 import org.apache.jackrabbit.webdav.version.report.ReportType;
+import org.apache.jackrabbit.webdav.version.VersionResource;
+import org.apache.jackrabbit.webdav.version.LabelInfo;
+import org.apache.jackrabbit.webdav.version.VersionHistoryResource;
+import org.apache.jackrabbit.webdav.version.LabelSetProperty;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.property.HrefProperty;
 import org.apache.jackrabbit.JcrConstants;
-import org.jdom.Element;
 
-import javax.jcr.*;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
+import javax.jcr.Item;
+import javax.jcr.RepositoryException;
+import javax.jcr.PropertyIterator;
+import javax.jcr.Property;
+import javax.jcr.Node;
 import java.util.List;
 import java.util.ArrayList;
 
@@ -71,7 +84,7 @@
      * Modify the labels defined for the underlying repository version.
      *
      * @param labelInfo
-     * @throws DavException
+     * @throws org.apache.jackrabbit.webdav.DavException
      * @see VersionResource#label(org.apache.jackrabbit.webdav.version.LabelInfo)
      * @see VersionHistory#addVersionLabel(String, String, boolean)
      * @see VersionHistory#removeVersionLabel(String)
@@ -166,11 +179,7 @@
 
                 // required, protected DAV:label-name-set property
                 String[] labels = getVersionHistoryItem().getVersionLabels(v);
-                Element[] labelElems = new Element[labels.length];
-                for (int i = 0; i < labels.length; i++) {
-                    labelElems[i] = new Element(DeltaVConstants.XML_LABEL_NAME, NAMESPACE).setText(labels[i]);
-                }
-                properties.add(new DefaultDavProperty(LABEL_NAME_SET, labelElems, true));
+                properties.add(new LabelSetProperty(labels));
 
                 // required DAV:predecessor-set (protected) and DAV:successor-set (computed) properties
                 addHrefProperty(VersionResource.PREDECESSOR_SET, v.getPredecessors(), true);

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java Fri Jan 13 03:11:35 2006
@@ -18,21 +18,29 @@
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
-import org.apache.jackrabbit.webdav.version.report.*;
 import org.apache.jackrabbit.webdav.version.DeltaVResource;
+import org.apache.jackrabbit.webdav.version.report.Report;
+import org.apache.jackrabbit.webdav.version.report.ReportType;
+import org.apache.jackrabbit.webdav.version.report.ReportInfo;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavSession;
 import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.util.Text;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.input.SAXBuilder;
+import org.xml.sax.SAXException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
 import javax.jcr.Session;
 import javax.jcr.RepositoryException;
 import javax.jcr.PathNotFoundException;
-import java.io.*;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
 
 /**
  * <code>ExportViewReport</code> handles REPORT requests for the 'exportview'
@@ -78,59 +86,62 @@
     }
 
     /**
-     * @param resource The resource this report is generated from. NOTE: the
-     * {@link org.apache.jackrabbit.webdav.DavResource#getResourcePath() resource path}
-     * of the resource is used as 'absPath' argument for exporting the specified
-     * view.
-     * @throws IllegalArgumentException if the resource is <code>null</code> or
-     * if the session object provided with the resource is <code>null</code>.
-     * @see Report#setResource(org.apache.jackrabbit.webdav.version.DeltaVResource)
+     * Always returns <code>false</code>.
+     *
+     * @return false
+     */
+    public boolean isMultiStatusReport() {
+        return false;
+    }
+
+    /**
+     * @see Report#init(org.apache.jackrabbit.webdav.version.DeltaVResource, org.apache.jackrabbit.webdav.version.report.ReportInfo)
      */
-    public void setResource(DeltaVResource resource) {
+    public void init(DeltaVResource resource, ReportInfo info) throws DavException {
+        if (!getType().isRequestedReportType(info)) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "dcr:exportview element expected.");
+        }
         if (resource == null) {
-            throw new IllegalArgumentException("Resource must not be null.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Resource must not be null.");
         }
+
+        this.info = info;
+
         DavSession davSession = resource.getSession();
         if (davSession == null || davSession.getRepositorySession() == null) {
-            throw new IllegalArgumentException("The resource must provide a non-null session object in order to create the exportview report.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "The resource must provide a non-null session object in order to create the exportview report.");
         }
         session = davSession.getRepositorySession();
         absItemPath = resource.getLocator().getJcrPath();
+        try {
+            if (!session.itemExists(absItemPath)) {
+                throw new JcrDavException(new PathNotFoundException(absItemPath + " does not exist."));
     }
-
-    /**
-     * @param info
-     * @throws IllegalArgumentException if the specified {@link ReportInfo info}
-     * object does not contain a {@link ItemResourceConstants#NAMESPACE dcr}:exportview element.
-     * @see Report#setInfo(org.apache.jackrabbit.webdav.version.report.ReportInfo)
-     */
-    public void setInfo(ReportInfo info) {
-        if (info == null || !REPORT_NAME.equals(info.getReportElement().getName())) {
-            throw new IllegalArgumentException("dcr:exportview element expected.");
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
         }
-        this.info = info;
     }
 
     /**
      * Creates a Xml document from the generated view.
      *
-     * @return Xml document representing the output of the specified view.
-     * @throws DavException if the report document could not be created.
-     * @see org.apache.jackrabbit.webdav.version.report.Report#toXml()
+     * @param document
+     * @return Xml element representing the output of the specified view.
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
      */
-    public Document toXml() throws DavException {
-        Element reportElem = info.getReportElement();
-        boolean skipBinary = reportElem.getChild("skipbinary", ItemResourceConstants.NAMESPACE) != null;
-        boolean noRecurse = reportElem.getChild("norecurse", ItemResourceConstants.NAMESPACE) != null;
+    public Element toXml(Document document) {
+        boolean skipBinary = info.containsContentElement("skipbinary", ItemResourceConstants.NAMESPACE);
+        boolean noRecurse = info.containsContentElement("norecurse", ItemResourceConstants.NAMESPACE);
 
+        // todo improve...
         try {
             // create tmpFile in default system-tmp directory
             String prefix = "_tmp_" + Text.getName(absItemPath);
             File tmpfile = File.createTempFile(prefix, null, null);
             tmpfile.deleteOnExit();
-            FileOutputStream out = new FileOutputStream(tmpfile);
 
-            if (reportElem.getChild("sysview", ItemResourceConstants.NAMESPACE) != null) {
+            FileOutputStream out = new FileOutputStream(tmpfile);
+            if (info.containsContentElement("sysview", ItemResourceConstants.NAMESPACE)) {
                 session.exportSystemView(absItemPath, out, skipBinary, noRecurse);
             } else {
                 // default is docview
@@ -138,20 +149,24 @@
             }
             out.close();
 
-            SAXBuilder builder = new SAXBuilder(false);
             InputStream in = new FileInputStream(tmpfile);
-            return builder.build(in);
+            Document tmpDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in);
+
+            // import the root node of the generated xml to the given document.
+            Element rootElem = (Element)document.importNode(tmpDoc.getDocumentElement(), true);
+            return rootElem;
 
+        } catch (RepositoryException e) {
+            log.error(e.getMessage());
         } catch (FileNotFoundException e) {
-            throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR);
+            log.error(e.getMessage());
         } catch (IOException e) {
-            throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR);
-        } catch (PathNotFoundException e) {
-            throw new DavException(DavServletResponse.SC_NOT_FOUND);
-        } catch (RepositoryException e) {
-            throw new JcrDavException(e);
-        } catch (JDOMException e) {
-            throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR);
+            log.error(e.getMessage());
+        } catch (ParserConfigurationException e) {
+            log.error(e.getMessage());
+        } catch (SAXException e) {
+            log.error(e.getMessage());
         }
+        return null;
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java Fri Jan 13 03:11:35 2006
@@ -16,13 +16,22 @@
 package org.apache.jackrabbit.webdav.jcr.version.report;
 
 import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.version.report.*;
 import org.apache.jackrabbit.webdav.version.DeltaVResource;
+import org.apache.jackrabbit.webdav.version.report.Report;
+import org.apache.jackrabbit.webdav.version.report.ReportType;
+import org.apache.jackrabbit.webdav.version.report.ReportInfo;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
-import org.apache.jackrabbit.webdav.*;
-import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
-import org.jdom.Document;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.webdav.MultiStatus;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
@@ -48,8 +57,7 @@
      */
     public static final ReportType LOCATE_BY_UUID_REPORT = ReportType.register(REPORT_NAME, ItemResourceConstants.NAMESPACE, LocateByUuidReport.class);
 
-    private DeltaVResource resource;
-    private ReportInfo info;
+    private MultiStatus ms;
 
     /**
      * Returns {@link #LOCATE_BY_UUID_REPORT} report type.
@@ -62,60 +70,55 @@
     }
 
     /**
-     * @param resource
-     * @throws IllegalArgumentException if the resource is <code>null</code> or
-     * if the session object provided with the resource is <code>null</code>.
-     * @see Report#setResource(org.apache.jackrabbit.webdav.version.DeltaVResource)
+     * Always returns <code>true</code>.
+     *
+     * @return true
+     * @see org.apache.jackrabbit.webdav.version.report.Report#isMultiStatusReport()
      */
-    public void setResource(DeltaVResource resource) {
-        if (resource == null) {
-            throw new IllegalArgumentException("Resource must not be null.");
-        }
-        DavSession davSession = resource.getSession();
-        if (davSession == null || davSession.getRepositorySession() == null) {
-            throw new IllegalArgumentException("The resource must provide a non-null session object in order to create the locate-by-uuid report.");
-        }
-        this.resource = resource;
+    public boolean isMultiStatusReport() {
+        return true;
     }
 
     /**
-     * @param info
-     * @throws IllegalArgumentException if the specified {@link ReportInfo info}
-     * object does not contain a {@link ItemResourceConstants#NAMESPACE dcr}:locate-by-uuid element.
-     * @see Report#setInfo(org.apache.jackrabbit.webdav.version.report.ReportInfo)
+     * @see Report#init(org.apache.jackrabbit.webdav.version.DeltaVResource, org.apache.jackrabbit.webdav.version.report.ReportInfo)
      */
-    public void setInfo(ReportInfo info) {
-        if (info == null || !REPORT_NAME.equals(info.getReportElement().getName())) {
-            throw new IllegalArgumentException("dcr:locate-by-uuid element expected.");
+    public void init(DeltaVResource resource, ReportInfo info) throws DavException {
+        if (!getType().isRequestedReportType(info)) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "dcr:locate-by-uuid element expected.");
+        }
+        if (!info.containsContentElement(DavConstants.XML_HREF, DavConstants.NAMESPACE)) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "dcr:locate-by-uuid element must at least contain a single DAV:href child.");
         }
-        this.info = info;
+        if (resource == null) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Resource must not be null.");
+        }
+        DavSession davSession = resource.getSession();
+        if (davSession == null || davSession.getRepositorySession() == null) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "The resource must provide a non-null session object in order to create the locate-by-uuid report.");
     }
 
-    /**
-     * Creates a Xml document from the generated view.
-     *
-     * @return Xml document representing the output of the specified view.
-     * @throws DavException if the report document could not be created.
-     * @see org.apache.jackrabbit.webdav.version.report.Report#toXml()
-     */
-    public Document toXml() throws DavException {
-        String uuid = info.getReportElement().getChildText(DavConstants.XML_HREF, DavConstants.NAMESPACE);
-        DavPropertyNameSet propNameSet = info.getPropertyNameSet();
-
         try {
-            DavSession session = resource.getSession();
+            Element hrefElem = info.getContentElement(DavConstants.XML_HREF, DavConstants.NAMESPACE);
+            String uuid = DomUtil.getTextTrim(hrefElem);
             DavResourceLocator resourceLoc = resource.getLocator();
-
-            Node n = session.getRepositorySession().getNodeByUUID(uuid);
+            Node n = davSession.getRepositorySession().getNodeByUUID(uuid);
             DavResourceLocator loc = resourceLoc.getFactory().createResourceLocator(resourceLoc.getPrefix(), resourceLoc.getWorkspacePath(), n.getPath(), false);
-            DavResource res = resource.getFactory().createResource(loc, session);
-
-            MultiStatus ms = new MultiStatus();
-            ms.addResourceProperties(res, propNameSet, info.getDepth());
-            return ms.toXml();
-
+            DavResource locatedResource = resource.getFactory().createResource(loc, davSession);
+            ms = new MultiStatus();
+            ms.addResourceProperties(locatedResource, info.getPropertyNameSet(), info.getDepth());
         } catch (RepositoryException e) {
             throw new JcrDavException(e);
         }
+    }
+
+    /**
+     * Creates a Xml document from the generated view.
+     *
+     * @param document
+     * @return Xml element representing the output of the specified view.
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     */
+    public Element toXml(Document document) {
+        return ms.toXml(document);
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java Fri Jan 13 03:11:35 2006
@@ -21,17 +21,22 @@
 import org.apache.jackrabbit.webdav.version.report.ReportInfo;
 import org.apache.jackrabbit.webdav.version.DeltaVResource;
 import org.apache.jackrabbit.webdav.version.DeltaVConstants;
-import org.apache.jackrabbit.webdav.*;
-import org.apache.jackrabbit.webdav.util.XmlUtil;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
-import org.jdom.Document;
-import org.jdom.Element;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
-import javax.jcr.Item;
-import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
 
 /**
  * <code>LocateCorrespondingNodeReport</code> is used to identify the resource that
@@ -61,8 +66,7 @@
 
     private static final String REPORT_NAME = "locate-corresponding-node";
 
-    private DeltaVResource resource;
-    private String workspaceHref;
+    private String correspHref;
 
     /**
      * The corresponding-node report type
@@ -80,40 +84,54 @@
     }
 
     /**
-     * @see Report#setResource(org.apache.jackrabbit.webdav.version.DeltaVResource)
+     * Always returns <code>false</code>.
+     *
+     * @return false
+     * @see org.apache.jackrabbit.webdav.version.report.Report#isMultiStatusReport()
      */
-    public void setResource(DeltaVResource resource) {
+    public boolean isMultiStatusReport() {
+        return false;
+    }
+
+    /**
+     * @see Report#init(org.apache.jackrabbit.webdav.version.DeltaVResource, org.apache.jackrabbit.webdav.version.report.ReportInfo)
+     */
+    public void init(DeltaVResource resource, ReportInfo info) throws DavException {
         if (resource == null) {
-            throw new IllegalArgumentException("Resource must not be null.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Resource must not be null.");
         }
         DavSession davSession = resource.getSession();
         if (davSession == null || davSession.getRepositorySession() == null) {
-            throw new IllegalArgumentException("The resource must provide a non-null session object in order to create the dcr:locate-corresponding-node report.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "The resource must provide a non-null session object in order to create the dcr:locate-corresponding-node report.");
         }
-        this.resource = resource;
+        if (!getType().isRequestedReportType(info)) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "dcr:locate-corresponding-node expected.");
     }
 
-    /**
-     * @see Report#setInfo(org.apache.jackrabbit.webdav.version.report.ReportInfo)
-     */
-    public void setInfo(ReportInfo info) {
-        if (info == null || !REPORT_NAME.equals(info.getReportElement().getName())) {
-            throw new IllegalArgumentException("dcr:locate-corresponding-node expected.");
-        }
-        Element workspace = info.getReportElement().getChild(DeltaVConstants.WORKSPACE.getName(), DeltaVConstants.WORKSPACE.getNamespace());
-        if (workspace != null) {
-            workspaceHref = workspace.getChildText(DavConstants.XML_HREF, DavConstants.NAMESPACE);
+        Element workspace = info.getContentElement(DeltaVConstants.WORKSPACE.getName(), DeltaVConstants.WORKSPACE.getNamespace());
+        String workspaceHref = DomUtil.getChildTextTrim(workspace, DavConstants.XML_HREF, DavConstants.NAMESPACE);
+        if (workspaceHref == null || "".equals(workspaceHref)) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Request body must define the href of a source workspace");
+        }
+        try {
+            this.correspHref = getCorrespondingResourceHref(resource, workspaceHref);
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
         }
     }
 
     /**
-     * @see org.apache.jackrabbit.webdav.version.report.Report#toXml()
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
      */
-    public Document toXml() throws DavException {
-        if (resource == null || workspaceHref == null) {
-            throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "Error while running dcr:locate-corresponding-node report: resource must not be null and request body must define the href of a source workspace");
+    public Element toXml(Document document) {
+        Element elem = DomUtil.createElement(document, "locate-corresponding-node-report", ItemResourceConstants.NAMESPACE);
+        if (correspHref != null) {
+            elem.appendChild(DomUtil.hrefToXml(correspHref, document));
         }
-        try {
+        return elem;
+        }
+
+    private static String getCorrespondingResourceHref(DeltaVResource resource, String workspaceHref) throws RepositoryException {
             DavResourceLocator rLoc = resource.getLocator();
             String itemPath = rLoc.getJcrPath();
             Session s = resource.getSession().getRepositorySession();
@@ -122,15 +140,9 @@
                 String workspaceName = rLoc.getFactory().createResourceLocator(rLoc.getPrefix(), workspaceHref).getWorkspaceName();
                 String corrPath = ((Node)item).getCorrespondingNodePath(workspaceName);
                 DavResourceLocator corrLoc = rLoc.getFactory().createResourceLocator(rLoc.getPrefix(), "/" + workspaceName, corrPath, false);
-
-                Element e = new Element("locate-corresponding-node-report", ItemResourceConstants.NAMESPACE);
-                e.addContent(XmlUtil.hrefToXml(corrLoc.getHref(true)));
-                return new Document(e);
+            return corrLoc.getHref(true);
             } else {
-                throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "Error while running dcr:locate-corresponding-node report: resource must represent a jcr node.");
-            }
-        } catch (RepositoryException e) {
-            throw new JcrDavException(e);
+            throw new PathNotFoundException("Node with path " + itemPath + " does not exist.");
         }
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/NodeTypesReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/NodeTypesReport.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/NodeTypesReport.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/NodeTypesReport.java Fri Jan 13 03:11:35 2006
@@ -16,23 +16,33 @@
 package org.apache.jackrabbit.webdav.jcr.version.report;
 
 import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.version.report.*;
 import org.apache.jackrabbit.webdav.version.DeltaVResource;
+import org.apache.jackrabbit.webdav.version.report.Report;
+import org.apache.jackrabbit.webdav.version.report.ReportType;
+import org.apache.jackrabbit.webdav.version.report.ReportInfo;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.jcr.nodetype.NodeTypeConstants;
 import org.apache.jackrabbit.webdav.jcr.nodetype.PropertyDefinitionImpl;
 import org.apache.jackrabbit.webdav.jcr.nodetype.NodeDefinitionImpl;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
 import org.apache.jackrabbit.util.IteratorHelper;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.Namespace;
-
-import javax.jcr.nodetype.*;
-import javax.jcr.*;
-import java.util.*;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+
+import javax.jcr.Session;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeTypeIterator;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.nodetype.NodeTypeManager;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
 
 /**
  * <code>NodeTypesReport</code> allows to retrieve the definition of a single
@@ -40,8 +50,8 @@
  * <pre>
  * &lt;!ELEMENT nodetypes ( nodetype+ | all-nodetypes | mixin-nodetypes | primary-nodetypes ) &gt;
  *
- * &lt;!ELEMENT nodetype ( nodetype-name ) &gt;
- * &lt;!ELEMENT nodetype-name (#PCDATA) &gt;
+ * &lt;!ELEMENT nodetype ( nodetypename ) &gt;
+ * &lt;!ELEMENT nodetypename (#PCDATA) &gt;
  *
  * &lt;!ELEMENT all-nodetypes EMPTY &gt;
  * &lt;!ELEMENT mixin-nodetypes EMPTY &gt;
@@ -64,7 +74,7 @@
     public static final ReportType NODETYPES_REPORT = ReportType.register("nodetypes", NodeTypeConstants.NAMESPACE, NodeTypesReport.class);
 
     private Session session;
-    private ReportInfo info;
+    private NodeTypeIterator ntIter;
 
     /**
      * Returns {@link #NODETYPES_REPORT} type.
@@ -76,79 +86,70 @@
     }
 
     /**
-     * @param resource
-     * @throws IllegalArgumentException if the resource or the session retrieved
-     * from the specified resource is <code>null</code>
-     * @see Report#setResource(org.apache.jackrabbit.webdav.version.DeltaVResource)
+     * Always returns <code>false</code>.
+     *
+     * @return false
+     * @see org.apache.jackrabbit.webdav.version.report.Report#isMultiStatusReport()
+     */
+    public boolean isMultiStatusReport() {
+        return false;
+    }
+
+    /**
+     * @see Report#init(org.apache.jackrabbit.webdav.version.DeltaVResource, org.apache.jackrabbit.webdav.version.report.ReportInfo)
      */
-    public void setResource(DeltaVResource resource) {
+    public void init(DeltaVResource resource, ReportInfo info) throws DavException {
         if (resource == null) {
-            throw new IllegalArgumentException("Resource must not be null.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Resource must not be null.");
         }
-        DavSession session = resource.getSession();
-        if (session == null || session.getRepositorySession() == null) {
-            throw new IllegalArgumentException("The resource must provide a non-null session object in order to create the nodetypes report.");
+        if (!getType().isRequestedReportType(info)) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "dcr:nodetypes element expected.");
         }
-        this.session = session.getRepositorySession();
+        DavSession davSession = resource.getSession();
+        if (davSession == null || davSession.getRepositorySession() == null) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "The resource must provide a non-null session object in order to create the nodetypes report.");
     }
-
-    /**
-     * @param info
-     * @throws IllegalArgumentException if the specified info does not contain
-     * a {@link org.apache.jackrabbit.webdav.jcr.ItemResourceConstants#NAMESPACE dcr}:{@link NodeTypeConstants#XML_NODETYPES nodetypes} element.
-     * @see Report#setInfo(org.apache.jackrabbit.webdav.version.report.ReportInfo)
-     */
-    public void setInfo(ReportInfo info) {
-        if (info == null || !"nodetypes".equals(info.getReportElement().getName())) {
-            throw new IllegalArgumentException("dcr:nodetypes element expected.");
+        session = davSession.getRepositorySession();
+        try {
+            ntIter = getNodeTypes(session, info);
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+        if (session == null || ntIter == null) {
+            throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR);
         }
-        this.info = info;
     }
 
     /**
      * Returns a Xml representation of the node type definition(s) according
      * to the info object.
      *
+     * @param document
      * @return Xml representation of the node type definition(s)
-     * @throws DavException if the specified nodetypes are not known or if another
-     * error occurs while retrieving the nodetype definitions.
-     * @see org.apache.jackrabbit.webdav.version.report.Report#toXml()
-     */
-    public Document toXml() throws DavException {
-        if (info == null || session == null) {
-            throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "Error while running nodetypes report");
-        }
-        try {
-            Element report = new Element(XML_NODETYPES);
-            // make sure all namespace declarations are present on the root element.
-            // since the nodetype-manager uses session-local jcr names, prefix/namespace
-            // pairs are retrieved from the session and not from the namespace registry.
-            String[] prefixes = session.getNamespacePrefixes();
-            for (int i = 0; i < prefixes.length; i++) {
-                report.addNamespaceDeclaration(Namespace.getNamespace(prefixes[i], session.getNamespaceURI(prefixes[i])));
-            }
-            // retrieve the requested nodetypes
-            NodeTypeIterator ntIter = getNodeTypes();
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     */
+    public Element toXml(Document document) {
+        Element report = document.createElement(NODETYPES_ELEMENT);
+        // loop over the nodetypes to be returned in the report
             while (ntIter.hasNext()) {
                 NodeType nt = ntIter.nextNodeType();
-                Element ntDef = new Element(XML_NODETYPE);
+            Element ntDef = document.createElement(NODETYPE_ELEMENT);
                 ntDef.setAttribute(NAME_ATTRIBUTE, nt.getName());
                 ntDef.setAttribute(ISMIXIN_ATTRIBUTE, Boolean.toString(nt.isMixin()));
                 ntDef.setAttribute(HASORDERABLECHILDNODES_ATTRIBUTE, Boolean.toString(nt.hasOrderableChildNodes()));
 
 		// declared supertypes
 		NodeType[] snts = nt.getDeclaredSupertypes();
-                Element supertypes = new Element(SUPERTYPES_ELEMENT);
+            Element supertypes = DomUtil.addChildElement(ntDef, SUPERTYPES_ELEMENT, null);
 		for (int i = 0; i < snts.length; i++) {
-		    supertypes.addContent(new Element(SUPERTYPE_ELEMENT).setText(snts[i].getName()));
+                DomUtil.addChildElement(supertypes, SUPERTYPE_ELEMENT, null, snts[i].getName());
 		}
-		ntDef.addContent(supertypes);
 
 		// declared childnode defs
 		NodeDefinition[] cnd = nt.getChildNodeDefinitions();
 		for (int i = 0; i < cnd.length; i++) {
 		    if (cnd[i].getDeclaringNodeType().getName().equals(nt.getName())) {
-			ntDef.addContent(NodeDefinitionImpl.create(cnd[i]).toXml());
+                    ntDef.appendChild(NodeDefinitionImpl.create(cnd[i]).toXml(document));
 		    }
 		}
 
@@ -156,7 +157,7 @@
 		PropertyDefinition[] pd = nt.getPropertyDefinitions();
 		for (int i = 0; i < pd.length; i++) {
 		    if (pd[i].getDeclaringNodeType().getName().equals(nt.getName())) {
-			ntDef.addContent(PropertyDefinitionImpl.create(pd[i]).toXml());
+                    ntDef.appendChild(PropertyDefinitionImpl.create(pd[i]).toXml(document));
 		    }
 		}
 
@@ -164,14 +165,9 @@
                 if (primaryItemName != null) {
                     ntDef.setAttribute(PRIMARYITEMNAME_ATTRIBUTE, primaryItemName);
                 }
-                report.addContent(ntDef);
-            }
-
-            Document reportDoc = new Document(report);
-            return reportDoc;
-        } catch (RepositoryException e) {
-            throw new JcrDavException(e);
+            report.appendChild(ntDef);
         }
+        return report;
     }
 
     /**
@@ -182,35 +178,33 @@
      * @throws RepositoryException
      * @throws DavException
      */
-    private NodeTypeIterator getNodeTypes() throws RepositoryException, DavException {
+    private static NodeTypeIterator getNodeTypes(Session session, ReportInfo info) throws RepositoryException, DavException {
         NodeTypeIterator ntIter = null;
         NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
-        Iterator it = info.getReportElement().getChildren().iterator();
-        while (it.hasNext() && ntIter == null) {
-            Element elem = (Element) it.next();
-            if (elem.getNamespace().equals(NAMESPACE)) {
-                String name = elem.getName();
-                if (XML_REPORT_ALLNODETYPES.equals(name)) {
+
+        // check the simple types first...
+        if (info.containsContentElement(XML_REPORT_ALLNODETYPES, NAMESPACE)) {
                     ntIter = ntMgr.getAllNodeTypes();
-                } else if (XML_REPORT_MIXINNODETYPES.equals(name)) {
+        } else if (info.containsContentElement(XML_REPORT_MIXINNODETYPES, NAMESPACE)) {
                     ntIter = ntMgr.getMixinNodeTypes();
-                } else if (XML_REPORT_PRIMARYNODETYPES.equals(name)) {
+        } else if (info.containsContentElement(XML_REPORT_PRIMARYNODETYPES, NAMESPACE)) {
                     ntIter = ntMgr.getPrimaryNodeTypes();
                 }
-            }
-        }
         // None of the simple types. test if a report for individual nodetypes
         // was request. If not, the request body is not valid.
         if (ntIter == null) {
             List ntList = new ArrayList();
-            List elemList = info.getReportElement().getChildren(XML_NODETYPE, NAMESPACE);
+            List elemList = info.getContentElements(XML_NODETYPE, NAMESPACE);
             if (elemList.isEmpty()) {
                 // throw exception if the request body does not contain a single nodetype element
                 throw new DavException(DavServletResponse.SC_BAD_REQUEST, "NodeTypes report: request body has invalid format.");
             }
+
+            // todo: find better solution...
             Iterator elemIter = elemList.iterator();
             while (elemIter.hasNext()) {
-                String nodetypeName = ((Element)elemIter.next()).getChildText(XML_NODETYPENAME, NAMESPACE);
+                Element el = ((Element)elemIter.next());
+                String nodetypeName = DomUtil.getChildTextTrim(el, XML_NODETYPENAME, NAMESPACE);
                 if (nodetypeName != null) {
                     ntList.add(ntMgr.getNodeType(nodetypeName));
                 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RegisteredNamespacesReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RegisteredNamespacesReport.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RegisteredNamespacesReport.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RegisteredNamespacesReport.java Fri Jan 13 03:11:35 2006
@@ -16,19 +16,20 @@
 package org.apache.jackrabbit.webdav.jcr.version.report;
 
 import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.version.report.*;
 import org.apache.jackrabbit.webdav.version.DeltaVResource;
+import org.apache.jackrabbit.webdav.version.report.Report;
+import org.apache.jackrabbit.webdav.version.report.ReportType;
+import org.apache.jackrabbit.webdav.version.report.ReportInfo;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.DavSession;
-import org.apache.jackrabbit.webdav.jcr.JcrDavException;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
-import org.jdom.Document;
-import org.jdom.Element;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
-import javax.jcr.*;
-import java.util.ArrayList;
-import java.util.List;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.RepositoryException;
 
 /**
  * <code>RegisteredNamespacesReport</code> let the client retrieve the namespaces
@@ -59,7 +60,6 @@
     public static final ReportType REGISTERED_NAMESPACES_REPORT = ReportType.register("registerednamespaces", ItemResourceConstants.NAMESPACE, RegisteredNamespacesReport.class);
 
     private NamespaceRegistry nsReg;
-    private ReportInfo info;
 
     /**
      * Returns {@link #REGISTERED_NAMESPACES_REPORT} type.
@@ -71,66 +71,61 @@
     }
 
     /**
-     * @param resource
-     * @throws IllegalArgumentException if the resource or the session retrieved
-     * from the specified resource is <code>null</code>
-     * @see org.apache.jackrabbit.webdav.version.report.Report#setResource(org.apache.jackrabbit.webdav.version.DeltaVResource)
+     * Always returns <code>false</code>.
+     *
+     * @return false
+     * @see org.apache.jackrabbit.webdav.version.report.Report#isMultiStatusReport()
+     */
+    public boolean isMultiStatusReport() {
+        return false;
+    }
+
+    /**
+     * @see Report#init(org.apache.jackrabbit.webdav.version.DeltaVResource, org.apache.jackrabbit.webdav.version.report.ReportInfo)
      */
-    public void setResource(DeltaVResource resource) {
+    public void init(DeltaVResource resource, ReportInfo info) throws DavException {
+        if (info == null) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "ReportInfo must not be null.");
+        }
         if (resource == null) {
-            throw new IllegalArgumentException("Resource must not be null.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Resource must not be null.");
+        }
+        if (!getType().isRequestedReportType(info)) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "registerednamespaces element expected.");
         }
         try {
             DavSession session = resource.getSession();
             if (session == null || session.getRepositorySession() == null) {
-                throw new IllegalArgumentException("The resource must provide a non-null session object in order to create the registerednamespaces report.");
+                throw new DavException(DavServletResponse.SC_BAD_REQUEST, "The resource must provide a non-null session object in order to create the registerednamespaces report.");
             }
             nsReg = session.getRepositorySession().getWorkspace().getNamespaceRegistry();
         } catch (RepositoryException e) {
-            log.error(e.getMessage());
+            throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR);
         }
     }
 
     /**
-     * @param info
-     * @throws IllegalArgumentException if the specified info does not contain
-     * a {@link ItemResourceConstants#NAMESPACE dcr}:registerednamespaces element.
-     * @see org.apache.jackrabbit.webdav.version.report.Report#setInfo(org.apache.jackrabbit.webdav.version.report.ReportInfo)
-     */
-    public void setInfo(ReportInfo info) {
-        if (info == null || !"registerednamespaces".equals(info.getReportElement().getName())) {
-            throw new IllegalArgumentException("registerednamespaces element expected.");
-        }
-        this.info = info;
-    }
-
-    /**
-     * Returns a Xml representation of the node type definition(s) according
-     * to the info object.
+     * Returns a Xml representation of the registered namespace(s).
      *
-     * @return Xml representation of the node type definition(s)
-     * @throws org.apache.jackrabbit.webdav.DavException if the specified nodetypes are not known or if another
-     * error occurs while retrieving the nodetype definitions.
-     * @see org.apache.jackrabbit.webdav.version.report.Report#toXml()
+     * @return Xml representation of the registered namespace(s)
+     * error occurs while retrieving the namespaces.
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     * @param document
      */
-    public Document toXml() throws DavException {
-        if (info == null || nsReg == null) {
-            throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "Error while running registerednamespaces report");
-        }
+    public Element toXml(Document document)  {
+        Element report = DomUtil.createElement(document, "registerednamespaces-report", NAMESPACE);
         try {
 	    String[] prefixes = nsReg.getPrefixes();
-	    List namespaceList = new ArrayList();
 	    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])));
-		namespaceList.add(elem);
-	    }
-	    Element report = new Element("registerednamespaces-report", NAMESPACE).addContent(namespaceList);
-            Document reportDoc = new Document(report);
-            return reportDoc;
+                Element elem = DomUtil.addChildElement(report, XML_NAMESPACE, NAMESPACE);
+                DomUtil.addChildElement(elem, XML_PREFIX, NAMESPACE, prefixes[i]);
+                DomUtil.addChildElement(elem, XML_URI, NAMESPACE, nsReg.getURI(prefixes[i]));
+            }
         } catch (RepositoryException e) {
-            throw new JcrDavException(e);
+            // should not occur.
+            log.error(e.getMessage());
         }
+        return report;
     }
+
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java Fri Jan 13 03:11:35 2006
@@ -16,17 +16,19 @@
 package org.apache.jackrabbit.webdav.jcr.version.report;
 
 import org.apache.log4j.Logger;
-import org.apache.jackrabbit.webdav.version.report.*;
 import org.apache.jackrabbit.webdav.version.DeltaVResource;
+import org.apache.jackrabbit.webdav.version.report.Report;
+import org.apache.jackrabbit.webdav.version.report.ReportType;
+import org.apache.jackrabbit.webdav.version.report.ReportInfo;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
-import org.jdom.Document;
-import org.jdom.Element;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
-import javax.jcr.*;
-import java.util.ArrayList;
-import java.util.List;
+import javax.jcr.Repository;
 
 /**
  * <code>RepositoryDescriptorsReport</code> allows to retrieve the repository
@@ -45,7 +47,7 @@
  * </pre>
  *
  * @see javax.jcr.Repository#getDescriptorKeys()
- * @see Repository#getDescriptor(String)
+ * @see javax.jcr.Repository#getDescriptor(String)
  */
 public class RepositoryDescriptorsReport implements Report, ItemResourceConstants {
 
@@ -68,54 +70,49 @@
     }
 
     /**
-     * @param resource
-     * @throws IllegalArgumentException if the resource or the session retrieved
-     * from the specified resource is <code>null</code>
-     * @see org.apache.jackrabbit.webdav.version.report.Report#setResource(org.apache.jackrabbit.webdav.version.DeltaVResource)
+     * Always returns <code>false</code>.
+     *
+     * @return false
+     * @see org.apache.jackrabbit.webdav.version.report.Report#isMultiStatusReport()
+     */
+    public boolean isMultiStatusReport() {
+        return false;
+    }
+
+    /**
+     * @see Report#init(org.apache.jackrabbit.webdav.version.DeltaVResource, org.apache.jackrabbit.webdav.version.report.ReportInfo) 
      */
-    public void setResource(DeltaVResource resource) {
+    public void init(DeltaVResource resource, ReportInfo info) throws DavException {
         if (resource == null) {
-            throw new IllegalArgumentException("Resource must not be null.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Resource must not be null.");
+        }
+        if (!getType().isRequestedReportType(info)) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "repositorydescriptors element expected.");
         }
         DavSession session = resource.getSession();
         if (session == null || session.getRepositorySession() == null) {
-            throw new IllegalArgumentException("The resource must provide a non-null session object in order to create the repositorydescriptors report.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "The resource must provide a non-null session object in order to create the repositorydescriptors report.");
         }
         repository = session.getRepositorySession().getRepository();
     }
 
     /**
-     * @param info
-     * @throws IllegalArgumentException if the specified info does not contain
-     * a {@link ItemResourceConstants#NAMESPACE dcr}:repositorydescriptors element.
-     * @see org.apache.jackrabbit.webdav.version.report.Report#setInfo(org.apache.jackrabbit.webdav.version.report.ReportInfo)
-     */
-    public void setInfo(ReportInfo info) {
-        if (info == null || !"repositorydescriptors".equals(info.getReportElement().getName())) {
-            throw new IllegalArgumentException("repositorydescriptors element expected.");
-        }
-    }
-
-    /**
-     * Returns a Xml representation of the node type definition(s) according
+     * Returns a Xml representation of the repository descriptors according
      * to the info object.
      *
-     * @return Xml representation of the node type definition(s)
-     * @throws org.apache.jackrabbit.webdav.DavException if the specified nodetypes are not known or if another
-     * error occurs while retrieving the nodetype definitions.
-     * @see org.apache.jackrabbit.webdav.version.report.Report#toXml()
+     * @return Xml representation of the repository descriptors
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     * @param document
      */
-    public Document toXml() throws DavException {
+    public Element toXml(Document document) {
+        Element report = DomUtil.createElement(document, "repositorydescriptors-report", NAMESPACE);
         String[] keys = repository.getDescriptorKeys();
-        List descList = new ArrayList();
         for (int i = 0; i < keys.length; i++) {
-            Element elem = new Element(XML_DESCRIPTOR, NAMESPACE);
-            elem.addContent(new Element(XML_DESCRIPTORKEY, NAMESPACE).setText(keys[i]));
-            elem.addContent(new Element(XML_DESCRIPTORVALUE, NAMESPACE).setText(repository.getDescriptor(keys[i])));
-            descList.add(elem);
+            Element elem = DomUtil.addChildElement(report, XML_DESCRIPTOR, NAMESPACE);
+            DomUtil.addChildElement(elem, XML_DESCRIPTORKEY, NAMESPACE, keys[i]);
+            DomUtil.addChildElement(elem, XML_DESCRIPTORVALUE, NAMESPACE, repository.getDescriptor(keys[i]));
         }
-        Element report = new Element("repositorydescriptors-report", NAMESPACE).addContent(descList);
-        Document reportDoc = new Document(report);
-        return reportDoc;
+        return report;
     }
+
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java Fri Jan 13 03:11:35 2006
@@ -15,33 +15,67 @@
  */
 package org.apache.jackrabbit.webdav.simple;
 
-import javax.jcr.*;
-import javax.jcr.nodetype.PropertyDefinition;
-import javax.jcr.lock.Lock;
-import java.util.*;
-import java.io.*;
-
-import org.apache.jackrabbit.webdav.*;
-import org.apache.jackrabbit.server.io.IOUtil;
-import org.apache.jackrabbit.webdav.transaction.TransactionConstants;
-import org.apache.jackrabbit.webdav.observation.ObservationConstants;
-import org.apache.jackrabbit.webdav.jcr.lock.JcrActiveLock;
-import org.apache.jackrabbit.webdav.jcr.JcrDavException;
-import org.apache.jackrabbit.webdav.lock.*;
-import org.apache.jackrabbit.webdav.property.*;
 import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.server.io.IOManager;
+import org.apache.jackrabbit.server.io.AbstractExportContext;
 import org.apache.jackrabbit.server.io.ExportContext;
-import org.apache.jackrabbit.webdav.io.InputContext;
-import org.apache.jackrabbit.webdav.io.OutputContext;
-import org.apache.jackrabbit.server.io.ImportContext;
 import org.apache.jackrabbit.server.io.ExportContextImpl;
+import org.apache.jackrabbit.server.io.IOManager;
+import org.apache.jackrabbit.server.io.IOUtil;
+import org.apache.jackrabbit.server.io.ImportContext;
 import org.apache.jackrabbit.server.io.ImportContextImpl;
-import org.apache.jackrabbit.server.io.AbstractExportContext;
-import org.apache.jackrabbit.util.Text;
 import org.apache.jackrabbit.util.ISO9075;
+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.observation.ObservationConstants;
+import org.apache.jackrabbit.webdav.io.InputContext;
+import org.apache.jackrabbit.webdav.io.OutputContext;
+import org.apache.jackrabbit.webdav.jcr.JcrDavException;
+import org.apache.jackrabbit.webdav.jcr.lock.JcrActiveLock;
+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.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.ResourceType;
+import org.apache.jackrabbit.webdav.xml.Namespace;
 import org.apache.log4j.Logger;
-import org.jdom.Namespace;
+
+import javax.jcr.Item;
+import javax.jcr.NamespaceException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.lock.Lock;
+import javax.jcr.nodetype.PropertyDefinition;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
 
 /**
  * DavResourceImpl implements a DavResource.
@@ -58,7 +92,6 @@
     static {
         reservedNamespaces.put(DavConstants.NAMESPACE.getPrefix(), DavConstants.NAMESPACE.getURI());
         reservedNamespaces.put(ObservationConstants.NAMESPACE.getPrefix(), ObservationConstants.NAMESPACE.getURI());
-        reservedNamespaces.put(TransactionConstants.NAMESPACE.getPrefix(), TransactionConstants.NAMESPACE.getURI());
     }
 
     private DavResourceFactory factory;
@@ -359,7 +392,7 @@
             throw new DavException(DavServletResponse.SC_NOT_FOUND);
         }
 
-        MultiStatusResponse msr = new MultiStatusResponse(getHref());
+        MultiStatusResponse msr = new MultiStatusResponse(getHref(), null);
         boolean success = true;
 
         // loop over set and remove Sets and remember all properties and propertyNames
@@ -489,7 +522,8 @@
             throw new DavException(DavServletResponse.SC_FORBIDDEN);
         }
         try {
-            ImportContext ctx = getImportContext(inputContext, Text.getName(member.getLocator().getJcrPath()));
+            String memberName = Text.getName(member.getLocator().getJcrPath());
+            ImportContext ctx = getImportContext(inputContext, memberName);
             if (!ioManager.importContent(ctx, member)) {
                 // any changes should have been reverted in the importer
                 throw new DavException(DavServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionImpl.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionImpl.java Fri Jan 13 03:11:35 2006
@@ -15,10 +15,9 @@
  */
 package org.apache.jackrabbit.webdav.simple;
 
-import javax.jcr.Session;
-
 import org.apache.jackrabbit.webdav.DavSession;
 
+import javax.jcr.Session;
 import java.util.HashSet;
 
 /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionProviderImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionProviderImpl.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionProviderImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionProviderImpl.java Fri Jan 13 03:11:35 2006
@@ -15,20 +15,27 @@
  */
 package org.apache.jackrabbit.webdav.simple;
 
-import javax.jcr.*;
-import javax.servlet.ServletException;
-
-import org.apache.jackrabbit.webdav.*;
-import org.apache.jackrabbit.webdav.jcr.JcrDavException;
 import org.apache.jackrabbit.server.CredentialsProvider;
 import org.apache.jackrabbit.server.SessionProvider;
+import org.apache.jackrabbit.webdav.DavException;
+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.NoSuchWorkspaceException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.servlet.ServletException;
+
 /**
- * Simple implementation of the {@link DavSessionProvider}
+ * Simple implementation of the {@link org.apache.jackrabbit.webdav.DavSessionProvider}
  * interface that uses a {@link CredentialsProvider} to locate
  * credentials in the request, log into the respository, and provide
- * a {@link DavSession} to the request.
+ * a {@link org.apache.jackrabbit.webdav.DavSession} to the request.
  */
 public class DavSessionProviderImpl implements DavSessionProvider {
 
@@ -61,7 +68,7 @@
      * A session will not be available if an exception is thrown.
      *
      * @param request
-     * @throws DavException if a problem occurred while obtaining the session
+     * @throws org.apache.jackrabbit.webdav.DavException if a problem occurred while obtaining the session
      * @see DavSessionProvider#attachSession(org.apache.jackrabbit.webdav.WebdavRequest)
      */
     public boolean attachSession(WebdavRequest request) throws DavException {

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImpl.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImpl.java Fri Jan 13 03:11:35 2006
@@ -16,8 +16,9 @@
 
 package org.apache.jackrabbit.webdav.simple;
 
-import org.apache.jackrabbit.webdav.*;
 import org.apache.jackrabbit.util.Text;
+import org.apache.jackrabbit.webdav.DavLocatorFactory;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
 import org.apache.log4j.Logger;
 
 /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java Fri Jan 13 03:11:35 2006
@@ -18,18 +18,23 @@
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.server.io.IOManager;
 import org.apache.jackrabbit.server.io.DefaultIOManager;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.input.SAXBuilder;
+import org.apache.jackrabbit.webdav.xml.ElementIterator;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
 
 import javax.jcr.Item;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
 import java.net.URL;
 import java.util.List;
-import java.util.Iterator;
+import java.util.ArrayList;
 import java.io.IOException;
+import java.io.InputStream;
 
 /**
  * <code>ResourceConfig</code>...
@@ -66,13 +71,22 @@
      * @param configURL
      */
     public void parse(URL configURL) {
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setNamespaceAware(true);
         try {
-            Document doc = new SAXBuilder().build(configURL);
-            Element root = doc.getRootElement();
+            InputStream in = configURL.openStream();
+            DocumentBuilder builder = factory.newDocumentBuilder();
+            Document document = builder.parse(in);
+            Element config = document.getDocumentElement();
 
-            Element ioElem = root.getChild("iomanager");
-            if (ioElem != null) {
-                Object inst = buildClassFromConfig(ioElem.getChild("class"));
+            if (config == null) {
+                log.error("Resource configuration: mandatory 'iomanager' element is missing.");
+                return;
+            }
+
+            Element el = DomUtil.getChildElement(config, "iomanager", null);
+            if (el != null) {
+                Object inst = buildClassFromConfig(el);
                 if (inst != null && inst instanceof IOManager) {
                    ioManager = (IOManager)inst;
                 }
@@ -80,50 +94,45 @@
                 log.error("Resource configuration: mandatory 'iomanager' element is missing.");
             }
 
-            Element collection = root.getChild("collection");
-            Element noncollection = root.getChild("noncollection");
-            if (collection != null && noncollection != null) {
-                log.warn("Resource configuration may only contain a collection OR a noncollection element -> entries are ignored");
-            } else {
-                if (collection != null) {
-                    Element nts = collection.getChild("nodetypes");
-                    nodetypeNames = parseNodeTypesEntry(nts);
+            el = DomUtil.getChildElement(config, "collection", null);
+            if (el != null) {
+                nodetypeNames = parseNodeTypesEntry(el);
                     collectionNames = true;
-                } else if (noncollection != null) {
-                    Element nts = noncollection.getChild("nodetypes");
-                    nodetypeNames = parseNodeTypesEntry(nts);
+            } else if ((el = DomUtil.getChildElement(config, "noncollection", null)) != null) {
+                nodetypeNames = parseNodeTypesEntry(el);
                     collectionNames = false;
                 }
-            }
+            // todo: should check if both 'noncollection' and 'collection' are present and write a warning
 
-            Element filter = root.getChild("filter");
-            if (filter != null) {
-                Object inst = buildClassFromConfig(filter.getChild("class"));
+            el = DomUtil.getChildElement(config, "filter", null);
+            if (el != null) {
+                Object inst = buildClassFromConfig(el);
                 if (inst != null && inst instanceof ItemFilter) {
                     itemFilter = (ItemFilter)inst;
                 }
                 if (itemFilter != null) {
-                    Element nts = filter.getChild("nodetypes");
-                    itemFilter.setFilteredNodetypes(parseNodeTypesEntry(nts));
-                    parseNamespacesEntry(filter.getChild("namespaces"), itemFilter);
+                    itemFilter.setFilteredNodetypes(parseNodeTypesEntry(el));
+                    parseNamespacesEntry(el);
                 }
             } else {
                 log.debug("Resource configuration: no 'filter' element specified.");
             }
         } catch (IOException e) {
-            log.error("Invalid resource configuration: " + e.getMessage());
-        } catch (JDOMException e) {
-            log.error("Invalid resource configuration: " + e.getMessage());
+            log.debug("Invalid resource configuration: " + e.getMessage());
+        } catch (ParserConfigurationException e) {
+            log.warn("Failed to parse resource configuration: " + e.getMessage());
+        } catch (SAXException e) {
+            log.warn("Failed to parse resource configuration: " + e.getMessage());
         }
     }
 
-    private Object buildClassFromConfig(Element classElement) {
+    private Object buildClassFromConfig(Element parent) {
         Object instance = null;
-        if (classElement == null) {
-            return instance;
-        }
+        Element classElem = DomUtil.getChildElement(parent, "class", null);
+        if (classElem != null) {
+            // contains a 'class' child node
         try {
-            String className = classElement.getAttributeValue("name");
+                String className = DomUtil.getAttribute(classElem, "name", null);
             if (className != null) {
                 Class c = Class.forName(className);
                 instance = c.newInstance();
@@ -133,43 +142,47 @@
         } catch (Exception e) {
             log.error("Error while create class instance: " + e.getMessage());
         }
+        }
         return instance;
     }
 
-    private void parseNamespacesEntry(Element child, ItemFilter filter) {
-        if (child == null) {
-            return;
-        }
-        List l = child.getChildren("prefix");
-        Iterator it = l.iterator();
-        String[] prefixes = new String[l.size()];
-        int i = 0;
-        while(it.hasNext()) {
-            prefixes[i++] = ((Element) it.next()).getText();
-        }
-
-        l = child.getChildren("uri");
-        it = l.iterator();
-        String[] uris = new String[l.size()];
-        i = 0;
-        while(it.hasNext()) {
-            uris[i++] = ((Element) it.next()).getText();
+    private void parseNamespacesEntry(Element parent) {
+        Element namespaces = DomUtil.getChildElement(parent, "namespaces", null);
+        if (namespaces != null) {
+            List l = new ArrayList();
+            // retrieve prefix child elements
+            ElementIterator it = DomUtil.getChildren(namespaces, "prefix", null);
+            while (it.hasNext()) {
+                Element e = it.nextElement();
+                l.add(DomUtil.getText(e));
+            }
+            String[] prefixes = (String[])l.toArray(new String[l.size()]);
+            l.clear();
+            // retrieve uri child elements
+            it = DomUtil.getChildren(namespaces, "uri", null);
+            while (it.hasNext()) {
+                Element e = it.nextElement();
+                l.add(DomUtil.getText(e));
+            }
+            String[] uris = (String[])l.toArray(new String[l.size()]);
+            itemFilter.setFilteredPrefixes(prefixes);
+            itemFilter.setFilteredURIs(uris);
         }
-
-        filter.setFilteredPrefixes(prefixes);
-        filter.setFilteredURIs(uris);
     }
 
-    private String[] parseNodeTypesEntry(Element child) {
-        if (child == null) {
-            return new String[0];
-        }
-        List l = child.getChildren("nodetype");
-        Iterator it = l.iterator();
-        String[] ntNames = new String[l.size()];
-        int i = 0;
-        while(it.hasNext()) {
-            ntNames[i++] = ((Element) it.next()).getText();
+    private String[] parseNodeTypesEntry(Element parent) {
+        String[] ntNames;
+        Element nodetypes = DomUtil.getChildElement(parent, "nodetypes", null);
+        if (nodetypes != null) {
+            List l = new ArrayList();
+            ElementIterator it = DomUtil.getChildren(nodetypes, "nodetype", null);
+            while (it.hasNext()) {
+                Element e = it.nextElement();
+                l.add(DomUtil.getText(e));
+        }
+            ntNames = (String[])l.toArray(new String[l.size()]);
+        } else {
+            ntNames = new String[0];
         }
         return ntNames;
     }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/project.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/project.xml?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/project.xml (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/project.xml Fri Jan 13 03:11:35 2006
@@ -90,14 +90,6 @@
         
         <!-- non-jackrabbit dependencies -->
         <dependency>
-            <groupId>jdom</groupId>
-            <artifactId>jdom</artifactId>
-            <version>1.0</version>
-            <properties>
-                <war.bundle>true</war.bundle>
-            </properties>
-        </dependency>
-        <dependency>
             <groupId>log4j</groupId>
             <artifactId>log4j</artifactId>
             <version>1.2.8</version>

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/SimpleWebdavServlet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/SimpleWebdavServlet.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/SimpleWebdavServlet.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/SimpleWebdavServlet.java Fri Jan 13 03:11:35 2006
@@ -15,22 +15,29 @@
  */
 package org.apache.jackrabbit.j2ee;
 
-import org.apache.jackrabbit.server.SessionProvider;
-import org.apache.jackrabbit.server.SessionProviderImpl;
 import org.apache.jackrabbit.server.AbstractWebdavServlet;
 import org.apache.jackrabbit.server.BasicCredentialsProvider;
+import org.apache.jackrabbit.server.SessionProvider;
+import org.apache.jackrabbit.server.SessionProviderImpl;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavLocatorFactory;
+import org.apache.jackrabbit.webdav.DavMethods;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavSessionProvider;
+import org.apache.jackrabbit.webdav.WebdavRequest;
+import org.apache.jackrabbit.webdav.WebdavResponse;
 import org.apache.jackrabbit.webdav.jcr.DavLocatorFactoryImpl;
 import org.apache.jackrabbit.webdav.lock.LockManager;
 import org.apache.jackrabbit.webdav.lock.SimpleLockManager;
 import org.apache.jackrabbit.webdav.simple.DavSessionProviderImpl;
-import org.apache.jackrabbit.webdav.simple.ResourceFactoryImpl;
 import org.apache.jackrabbit.webdav.simple.ResourceConfig;
-import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.simple.ResourceFactoryImpl;
 import org.apache.log4j.Logger;
 
 import javax.jcr.Repository;
-import javax.servlet.ServletException;
 import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
 import java.io.IOException;
 import java.net.MalformedURLException;
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/project.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/project.xml?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/project.xml (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/project.xml Fri Jan 13 03:11:35 2006
@@ -40,11 +40,6 @@
         
         <!-- non-jackrabbit dependencies -->
         <dependency>
-            <groupId>jdom</groupId>
-            <artifactId>jdom</artifactId>
-            <version>1.0</version>
-        </dependency>
-        <dependency>
             <groupId>log4j</groupId>
             <artifactId>log4j</artifactId>
             <version>1.2.8</version>

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavConstants.java?rev=368683&r1=368682&r2=368683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavConstants.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavConstants.java Fri Jan 13 03:11:35 2006
@@ -15,7 +15,7 @@
  */
 package org.apache.jackrabbit.webdav;
 
-import org.jdom.Namespace;
+import org.apache.jackrabbit.webdav.xml.Namespace;
 import org.apache.jackrabbit.webdav.util.HttpDateFormat;
 
 import java.text.DateFormat;
@@ -55,7 +55,6 @@
     
     //----------------------------------------------------- Overwrite header ---
     public static final String HEADER_OVERWRITE = "Overwrite";
-    public static final String NO_OVERWRITE = "T";
 
     //--------------------------------------------------------- Depth header ---
     public static final String HEADER_DEPTH = "Depth";



Mime
View raw message