jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r396565 - in /jackrabbit/trunk/jcr-server: server/src/java/org/apache/jackrabbit/server/io/ server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ server/src/java/org/apache/jackrabbit/webdav/simple/ webapp/src/webapp/WEB-INF/ web...
Date Mon, 24 Apr 2006 14:26:43 GMT
Author: angela
Date: Mon Apr 24 07:26:38 2006
New Revision: 396565

URL: http://svn.apache.org/viewcvs?rev=396565&view=rev
Log:
a) JCR-407: read IOHandlers from the config.xml
b) Add static DocumentBuilderFactory constant to DomUtil 
   and replace existing constants present in various places.



Added:
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOManagerImpl.java
  (with props)
Modified:
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DefaultHandler.java
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DefaultIOManager.java
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportHandler.java
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOHandler.java
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XmlHandler.java
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ZipHandler.java
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java
    jackrabbit/trunk/jcr-server/webapp/src/webapp/WEB-INF/config.xml
    jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
    jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
    jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/xml/DomUtil.java

Modified: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DefaultHandler.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DefaultHandler.java?rev=396565&r1=396564&r2=396565&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DefaultHandler.java
(original)
+++ jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DefaultHandler.java
Mon Apr 24 07:26:38 2006
@@ -63,6 +63,15 @@
     private IOManager ioManager;
 
     /**
+     * Creates a new <code>DefaultHandler</code> with default nodetype definitions
+     * and without setting the IOManager.
+     *
+     * @see IOHandler#setIOManager(IOManager)
+     */
+    public DefaultHandler() {
+    }
+
+    /**
      * Creates a new <code>DefaultHandler</code> with default nodetype definitions:<br>
      * <ul>
      * <li>Nodetype for Collection: {@link JcrConstants#NT_FOLDER nt:folder}</li>
@@ -98,6 +107,13 @@
      */
     public IOManager getIOManager() {
         return ioManager;
+    }
+
+    /**
+     * @see IOHandler#setIOManager(IOManager)
+     */
+    public void setIOManager(IOManager ioManager) {
+        this.ioManager = ioManager;
     }
 
     /**

Modified: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DefaultIOManager.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DefaultIOManager.java?rev=396565&r1=396564&r2=396565&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DefaultIOManager.java
(original)
+++ jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DefaultIOManager.java
Mon Apr 24 07:26:38 2006
@@ -15,133 +15,51 @@
  */
 package org.apache.jackrabbit.server.io;
 
-import org.apache.jackrabbit.webdav.DavResource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
 /**
  * <code>DefaultIOManager</code>...
  */
-public class DefaultIOManager implements IOManager {
+public class DefaultIOManager extends IOManagerImpl {
 
     private static Logger log = LoggerFactory.getLogger(DefaultIOManager.class);
 
-    private final List ioHandlers = new ArrayList();
-
+    /**
+     * Creates a new <code>DefaultIOManager</code> and populates the internal
+     * list of <code>IOHandler</code>s by the defaults.
+     *
+     * @see #init()
+     */
     public DefaultIOManager() {
-        this(true);
+        init();
     }
 
-    protected DefaultIOManager(boolean doInit) {
-        if (doInit) {
+    /**
+     * Creates a new <code>DefaultIOManager</code>. The if the flag is set to
+     * false no <code>IOHandler</code>s are added to the internal list.
+     *
+     * @deprecated Use {@link IOManagerImpl} instead.
+     */
+    protected DefaultIOManager(boolean initDefaults) {
+        if (initDefaults) {
            init();
         }
     }
 
+    /**
+     * Add the predefined <code>IOHandler</code>s to this manager. This includes
+     * <ul>
+     * <li>{@link ZipHandler}</li>
+     * <li>{@link XmlHandler}</li>
+     * <li>{@link DirListingExportHandler}</li>
+     * <li>{@link DefaultHandler}.</li>
+     * </ul>
+     */
     protected void init() {
         addIOHandler(new ZipHandler(this));
         addIOHandler(new XmlHandler(this));
         addIOHandler(new DirListingExportHandler(this));
         addIOHandler(new DefaultHandler(this));
-    }
-
-    public void addIOHandler(IOHandler ioHandler) {
-        ioHandlers.add(ioHandler);
-    }
-
-    public IOHandler[] getIOHandlers() {
-        return (IOHandler[]) ioHandlers.toArray(new IOHandler[ioHandlers.size()]);
-    }
-
-    public boolean importContent(ImportContext context, boolean isCollection) throws IOException
{
-        boolean success = false;
-        if (context != null) {
-            IOListener ioListener = context.getIOListener();
-            if (ioListener == null) {
-                ioListener = new DefaultIOListener(log);
-            }
-
-            Iterator it = ioHandlers.iterator();
-            while (it.hasNext() && !success) {
-                IOHandler ioh = (IOHandler)it.next();
-                if (ioh.canImport(context, isCollection)) {
-                    ioListener.onBegin(ioh, context);
-                    success = ioh.importContent(context, isCollection);
-                    ioListener.onEnd(ioh, context, success);
-                }
-            }
-            context.informCompleted(success);
-        }
-        return success;
-    }
-
-    public boolean importContent(ImportContext context, DavResource resource) throws IOException
{
-        boolean success = false;
-        if (context != null && resource != null) {
-            IOListener ioListener = context.getIOListener();
-            if (ioListener == null) {
-                ioListener = new DefaultIOListener(log);
-            }
-            Iterator it = ioHandlers.iterator();
-            while (it.hasNext() && !success) {
-                IOHandler ioh = (IOHandler)it.next();
-                if (ioh.canImport(context, resource)) {
-                    ioListener.onBegin(ioh, context);
-                    success = ioh.importContent(context, resource);
-                    ioListener.onEnd(ioh, context, success);
-                }
-            }
-            context.informCompleted(success);
-        }
-        return success;
-    }
-
-    public boolean exportContent(ExportContext context, boolean isCollection) throws IOException
{
-        boolean success = false;
-        if (context != null) {
-            IOListener ioListener = context.getIOListener();
-            if (ioListener == null) {
-                ioListener = new DefaultIOListener(log);
-            }
-
-            Iterator it = ioHandlers.iterator();
-            while (it.hasNext() && !success) {
-                IOHandler ioh = (IOHandler)it.next();
-                if (ioh.canExport(context, isCollection)) {
-                    ioListener.onBegin(ioh, context);
-                    success = ioh.exportContent(context, isCollection);
-                    ioListener.onEnd(ioh, context, success);
-                }
-            }
-            context.informCompleted(success);
-        }
-        return success;
-    }
-
-    public boolean exportContent(ExportContext context, DavResource resource) throws IOException
{
-        boolean success = false;
-        if (context != null && resource != null) {
-            IOListener ioListener = context.getIOListener();
-            if (ioListener == null) {
-                ioListener = new DefaultIOListener(log);
-            }
-
-            Iterator it = ioHandlers.iterator();
-            while (it.hasNext() && !success) {
-                IOHandler ioh = (IOHandler)it.next();
-                if (ioh.canExport(context, resource)) {
-                    ioListener.onBegin(ioh, context);
-                    success = ioh.exportContent(context, resource);
-                    ioListener.onEnd(ioh, context, success);
-                }
-            }
-            context.informCompleted(success);
-        }
-        return success;
     }
 }

Modified: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportHandler.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportHandler.java?rev=396565&r1=396564&r2=396565&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportHandler.java
(original)
+++ jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportHandler.java
Mon Apr 24 07:26:38 2006
@@ -245,6 +245,13 @@
     }
 
     /**
+     * @see IOHandler#setIOManager(IOManager)
+     */
+    public void setIOManager(IOManager ioManager) {
+        this.ioManager = ioManager;
+    }
+    
+    /**
      * @see IOHandler#getName()
      */
     public String getName() {

Modified: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOHandler.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOHandler.java?rev=396565&r1=396564&r2=396565&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOHandler.java
(original)
+++ jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOHandler.java
Mon Apr 24 07:26:38 2006
@@ -32,6 +32,11 @@
     public IOManager getIOManager();
 
     /**
+     * Sets the <code>IOManager</code> that called this handler.
+     */
+    public void setIOManager(IOManager ioManager);
+
+    /**
      * Returns a human readable name for this <code>IOHandler</code>
      *
      * @return

Added: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOManagerImpl.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOManagerImpl.java?rev=396565&view=auto
==============================================================================
--- jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOManagerImpl.java
(added)
+++ jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOManagerImpl.java
Mon Apr 24 07:26:38 2006
@@ -0,0 +1,160 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.jackrabbit.server.io;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.webdav.DavResource;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * <code>IOManagerImpl</code> represents the most simple <code>IOManager</code>
+ * implementation that provides a default constructor and does define any
+ * <code>IOHandler</code>s.
+ */
+public class IOManagerImpl implements IOManager {
+
+    private static Logger log = LoggerFactory.getLogger(IOManagerImpl.class);
+
+    private final List ioHandlers = new ArrayList();
+
+    /**
+     * Create a new <code>IOManager</code>.
+     * Note, that this manager does not define any <code>IOHandler</code>s by
+     * default. Use {@link #addIOHandler(IOHandler)} in order to populate the
+     * internal list of handlers that are called for <code>importContent</code>
and
+     * <code>exportContent</code>.
+     */
+    public IOManagerImpl() {
+    }
+
+    /**
+     * @see IOManager#addIOHandler(IOHandler)
+     */
+    public void addIOHandler(IOHandler ioHandler) {
+        if (ioHandler == null) {
+            throw new IllegalArgumentException("'null' is not a valid IOHandler.");
+        }
+        ioHandler.setIOManager(this);
+        ioHandlers.add(ioHandler);
+    }
+
+    /**
+     * @see IOManager#getIOHandlers()
+     */
+    public IOHandler[] getIOHandlers() {
+        return (IOHandler[]) ioHandlers.toArray(new IOHandler[ioHandlers.size()]);
+    }
+
+    /**
+     * @see IOManager#importContent(ImportContext, boolean)
+     */
+    public boolean importContent(ImportContext context, boolean isCollection) throws IOException
{
+        boolean success = false;
+        if (context != null) {
+            IOListener ioListener = context.getIOListener();
+            if (ioListener == null) {
+                ioListener = new DefaultIOListener(log);
+            }
+            IOHandler[] ioHandlers = getIOHandlers();
+            for (int i = 0; i < ioHandlers.length && !success; i++) {
+                IOHandler ioh = ioHandlers[i];
+                if (ioh.canImport(context, isCollection)) {
+                    ioListener.onBegin(ioh, context);
+                    success = ioh.importContent(context, isCollection);
+                    ioListener.onEnd(ioh, context, success);
+                }
+            }
+            context.informCompleted(success);
+        }
+        return success;
+    }
+
+    /**
+     * @see IOManager#importContent(ImportContext, DavResource)
+     */
+    public boolean importContent(ImportContext context, DavResource resource) throws IOException
{
+        boolean success = false;
+        if (context != null && resource != null) {
+            IOListener ioListener = context.getIOListener();
+            if (ioListener == null) {
+                ioListener = new DefaultIOListener(log);
+            }
+            IOHandler[] ioHandlers = getIOHandlers();
+            for (int i = 0; i < ioHandlers.length && !success; i++) {
+                IOHandler ioh = ioHandlers[i];
+                if (ioh.canImport(context, resource)) {
+                    ioListener.onBegin(ioh, context);
+                    success = ioh.importContent(context, resource);
+                    ioListener.onEnd(ioh, context, success);
+                }
+            }
+            context.informCompleted(success);
+        }
+        return success;
+    }
+
+    /**
+     * @see IOManager#exportContent(ExportContext, boolean)
+     */
+    public boolean exportContent(ExportContext context, boolean isCollection) throws IOException
{
+        boolean success = false;
+        if (context != null) {
+            IOListener ioListener = context.getIOListener();
+            if (ioListener == null) {
+                ioListener = new DefaultIOListener(log);
+            }
+            IOHandler[] ioHandlers = getIOHandlers();
+            for (int i = 0; i < ioHandlers.length && !success; i++) {
+                IOHandler ioh = ioHandlers[i];
+                if (ioh.canExport(context, isCollection)) {
+                    ioListener.onBegin(ioh, context);
+                    success = ioh.exportContent(context, isCollection);
+                    ioListener.onEnd(ioh, context, success);
+                }
+            }
+            context.informCompleted(success);
+        }
+        return success;
+    }
+
+    /**
+     * @see IOManager#exportContent(ExportContext, DavResource)
+     */
+    public boolean exportContent(ExportContext context, DavResource resource) throws IOException
{
+        boolean success = false;
+        if (context != null && resource != null) {
+            IOListener ioListener = context.getIOListener();
+            if (ioListener == null) {
+                ioListener = new DefaultIOListener(log);
+            }
+            IOHandler[] ioHandlers = getIOHandlers();
+            for (int i = 0; i < ioHandlers.length && !success; i++) {
+                IOHandler ioh = ioHandlers[i];
+                if (ioh.canExport(context, resource)) {
+                    ioListener.onBegin(ioh, context);
+                    success = ioh.exportContent(context, resource);
+                    ioListener.onEnd(ioh, context, success);
+                }
+            }
+            context.informCompleted(success);
+        }
+        return success;
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOManagerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOManagerImpl.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XmlHandler.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XmlHandler.java?rev=396565&r1=396564&r2=396565&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XmlHandler.java
(original)
+++ jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XmlHandler.java
Mon Apr 24 07:26:38 2006
@@ -47,6 +47,15 @@
     public static final String XML_MIMETYPE = "text/xml";
 
     /**
+     * Creates a new <code>XmlHandler</code> with default nodetype definitions
+     * and without setting the IOManager.
+     *
+     * @see IOHandler#setIOManager(IOManager)
+     */
+    public XmlHandler() {
+    }
+
+    /**
      * Creates a new <code>XmlHandler</code> with default nodetype definitions:<br>
      * <ul>
      * <li>Nodetype for Collection: {@link JcrConstants#NT_UNSTRUCTURED nt:unstructured}</li>

Modified: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ZipHandler.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ZipHandler.java?rev=396565&r1=396564&r2=396565&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ZipHandler.java
(original)
+++ jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ZipHandler.java
Mon Apr 24 07:26:38 2006
@@ -52,6 +52,15 @@
     private boolean intermediateSave;
 
     /**
+     * Creates a new <code>ZipHandler</code> with default nodetype definitions
+     * and without setting the IOManager.
+     *
+     * @see IOHandler#setIOManager(IOManager)
+     */
+    public ZipHandler() {
+    }
+
+    /**
      * Creates a new <code>ZipHandler</code> with default nodetype definitions:<br>
      * <ul>
      * <li>Nodetype for Collection: {@link JcrConstants#NT_UNSTRUCTURED nt:unstructured}</li>

Modified: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java?rev=396565&r1=396564&r2=396565&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java
(original)
+++ jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java
Mon Apr 24 07:26:38 2006
@@ -15,31 +15,31 @@
  */
 package org.apache.jackrabbit.webdav.jcr.version.report;
 
-import org.apache.jackrabbit.util.Text;
-import org.apache.jackrabbit.webdav.DavException;
-import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
 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.ReportInfo;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.util.Text;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
-import javax.jcr.PathNotFoundException;
-import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.xml.parsers.DocumentBuilderFactory;
+import javax.jcr.RepositoryException;
+import javax.jcr.PathNotFoundException;
 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.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 /**
  * <code>ExportViewReport</code> handles REPORT requests for the 'exportview'
@@ -137,7 +137,7 @@
             out.close();
 
             InputStream in = new FileInputStream(tmpfile);
-            Document tmpDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in);
+            Document tmpDoc = DomUtil.BUILDER_FACTORY.newDocumentBuilder().parse(in);
 
             // import the root node of the generated xml to the given document.
             Element rootElem = (Element)document.importNode(tmpDoc.getDocumentElement(),
true);

Modified: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java?rev=396565&r1=396564&r2=396565&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java
(original)
+++ jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java
Mon Apr 24 07:26:38 2006
@@ -15,27 +15,27 @@
  */
 package org.apache.jackrabbit.webdav.simple;
 
-import org.apache.jackrabbit.server.io.DefaultIOManager;
 import org.apache.jackrabbit.server.io.IOManager;
-import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.server.io.DefaultIOManager;
+import org.apache.jackrabbit.server.io.IOHandler;
 import org.apache.jackrabbit.webdav.xml.ElementIterator;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import 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.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
-import java.io.IOException;
-import java.io.InputStream;
 import java.net.URL;
-import java.util.ArrayList;
 import java.util.List;
+import java.util.ArrayList;
+import java.io.IOException;
+import java.io.InputStream;
 
 /**
  * <code>ResourceConfig</code>...
@@ -54,7 +54,8 @@
      * The xml must match the following structure:<br>
      * <pre>
      * &lt;!ELEMENT config (iomanager, (collection | noncollection)?, filter?) &gt;
-     * &lt;!ELEMENT iomanager (class) &gt;
+     * &lt;!ELEMENT iomanager (class, iohandler*) &gt;
+     * &lt;!ELEMENT iohandler (class) &gt;
      * &lt;!ELEMENT collection (nodetypes) &gt;
      * &lt;!ELEMENT noncollection (nodetypes) &gt;
      * &lt;!ELEMENT filter (class, namespaces?, nodetypes?) &gt;
@@ -72,11 +73,9 @@
      * @param configURL
      */
     public void parse(URL configURL) {
-        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-        factory.setNamespaceAware(true);
         try {
             InputStream in = configURL.openStream();
-            DocumentBuilder builder = factory.newDocumentBuilder();
+            DocumentBuilder builder = DomUtil.BUILDER_FACTORY.newDocumentBuilder();
             Document document = builder.parse(in);
             Element config = document.getDocumentElement();
 
@@ -90,6 +89,20 @@
                 Object inst = buildClassFromConfig(el);
                 if (inst != null && inst instanceof IOManager) {
                     ioManager = (IOManager)inst;
+                    // get optional 'iohandler' child elements and populate the
+                    // ioManager with the instances
+                    ElementIterator iohElements = DomUtil.getChildren(el, "iohandler", null);
+                    while (iohElements.hasNext()) {
+                        Element iohEl = iohElements.nextElement();
+                        inst = buildClassFromConfig(iohEl);
+                        if (inst != null && inst instanceof IOHandler) {
+                            this.ioManager.addIOHandler((IOHandler) inst);
+                        } else {
+                            log.error("Resource configuration: the handler is not a valid
IOHandler.");
+                        }
+                    }
+                } else {
+                    log.error("Resource configuration: 'iomanager' does not define a valid
IOManager.");
                 }
             } else {
                 log.error("Resource configuration: mandatory 'iomanager' element is missing.");

Modified: jackrabbit/trunk/jcr-server/webapp/src/webapp/WEB-INF/config.xml
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/webapp/src/webapp/WEB-INF/config.xml?rev=396565&r1=396564&r2=396565&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/webapp/src/webapp/WEB-INF/config.xml (original)
+++ jackrabbit/trunk/jcr-server/webapp/src/webapp/WEB-INF/config.xml Mon Apr 24 07:26:38 2006
@@ -3,7 +3,8 @@
 <!DOCTYPE config [
         <!ELEMENT config (iomanager , (collection | noncollection)? , filter?) >
 
-        <!ELEMENT iomanager (class) >
+        <!ELEMENT iomanager (class, iohandler*) >
+        <!ELEMENT iohandler (class) >
 
         <!ELEMENT collection (nodetypes) >
         <!ELEMENT noncollection (nodetypes) >
@@ -30,9 +31,28 @@
     -->
     <iomanager>
         <!-- class element defines the manager to be used. The specified class
-             must implement the IOManager interface -->
+             must implement the IOManager interface. -->
+        <!-- the DefaultIOManager builds a predefined set of handlers. the
+             optional 'iohandler' elements are therefore left out. -->
         <class name="org.apache.jackrabbit.server.io.DefaultIOManager" />
+        
     </iomanager>
+    <!--
+    Example config for iomanager that defines the set of handlers to be used.
+    Note, that the handlers are being added and called in the order they appear
+    in the configuration.
+    -->
+    <!--
+    <iomanager>
+        <class name="org.apache.jackrabbit.server.io.IOManagerImpl" />
+        <iohandler>
+           <class name="org.apache.jackrabbit.server.io.XmlHandler" />
+        </iohandler>
+        <iohandler>
+           <class name="org.apache.jackrabbit.server.io.DefaultHandler" />
+        </iohandler>
+    </iomanager>
+    -->
     <!--
     Defines nodetypes, that should always be displayed as 'collection'.
     -->

Modified: jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java?rev=396565&r1=396564&r2=396565&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
(original)
+++ jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
Mon Apr 24 07:26:38 2006
@@ -55,7 +55,6 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import java.io.BufferedInputStream;
 import java.io.BufferedReader;
@@ -76,13 +75,7 @@
 public class WebdavRequestImpl implements WebdavRequest, DavConstants {
 
     private static Logger log = LoggerFactory.getLogger(WebdavRequestImpl.class);
-    private static final DocumentBuilderFactory BUILDER_FACTORY = DocumentBuilderFactory.newInstance();
-    static {
-        BUILDER_FACTORY.setNamespaceAware(true);
-        BUILDER_FACTORY.setIgnoringComments(true);
-        BUILDER_FACTORY.setIgnoringElementContentWhitespace(true);
-        BUILDER_FACTORY.setCoalescing(true);
-    }
+
     private final HttpServletRequest httpRequest;
     private final DavLocatorFactory factory;
     private final IfHeader ifHeader;
@@ -265,7 +258,7 @@
                 boolean isEmpty = -1 == bin.read();
                 bin.reset();
                 if (!isEmpty) {
-                    DocumentBuilder docBuilder = BUILDER_FACTORY.newDocumentBuilder();
+                    DocumentBuilder docBuilder = DomUtil.BUILDER_FACTORY.newDocumentBuilder();
                     requestDocument = docBuilder.parse(bin);
                 }
             }
@@ -896,4 +889,4 @@
     public String getRealPath(String s) {
         return httpRequest.getRealPath(s);
     }
-}
+}
\ No newline at end of file

Modified: jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java?rev=396565&r1=396564&r2=396565&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
(original)
+++ jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
Mon Apr 24 07:26:38 2006
@@ -15,27 +15,27 @@
  */
 package org.apache.jackrabbit.webdav;
 
+import org.apache.jackrabbit.webdav.xml.XmlSerializable;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.webdav.property.DavPropertySet;
 import org.apache.jackrabbit.webdav.lock.ActiveLock;
 import org.apache.jackrabbit.webdav.lock.LockDiscovery;
-import org.apache.jackrabbit.webdav.observation.EventDiscovery;
 import org.apache.jackrabbit.webdav.observation.Subscription;
 import org.apache.jackrabbit.webdav.observation.SubscriptionDiscovery;
-import org.apache.jackrabbit.webdav.property.DavPropertySet;
-import org.apache.jackrabbit.webdav.xml.XmlSerializable;
+import org.apache.jackrabbit.webdav.observation.EventDiscovery;
 import org.apache.xml.serialize.OutputFormat;
 import org.apache.xml.serialize.XMLSerializer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletResponse;
-import javax.xml.parsers.DocumentBuilderFactory;
+import javax.servlet.http.Cookie;
+import javax.servlet.ServletOutputStream;
 import javax.xml.parsers.ParserConfigurationException;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.io.ByteArrayOutputStream;
 import java.util.Locale;
 
 /**
@@ -45,8 +45,6 @@
 
     private static Logger log = LoggerFactory.getLogger(WebdavResponseImpl.class);
 
-    private static final DocumentBuilderFactory BUILDER_FACTORY = DocumentBuilderFactory.newInstance();
-
     private HttpServletResponse httpResponse;
 
     /**
@@ -144,10 +142,10 @@
         if (serializable != null) {
             ByteArrayOutputStream out = new ByteArrayOutputStream();
             try {
-                Document doc = BUILDER_FACTORY.newDocumentBuilder().newDocument();
+                Document doc = DomUtil.BUILDER_FACTORY.newDocumentBuilder().newDocument();
                 doc.appendChild(serializable.toXml(doc));
                 
-                OutputFormat format = new OutputFormat("xml", "UTF-8", true);
+                OutputFormat format = new OutputFormat("xml", "UTF-8", false);
                 XMLSerializer serializer = new XMLSerializer(out, format);
                 serializer.setNamespaces(true);
                 serializer.asDOMSerializer().serialize(doc);

Modified: jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/xml/DomUtil.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/xml/DomUtil.java?rev=396565&r1=396564&r2=396565&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/xml/DomUtil.java
(original)
+++ jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/xml/DomUtil.java
Mon Apr 24 07:26:38 2006
@@ -26,6 +26,7 @@
 import org.w3c.dom.NodeList;
 import org.w3c.dom.Text;
 
+import javax.xml.parsers.DocumentBuilderFactory;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -37,6 +38,18 @@
     private static Logger log = LoggerFactory.getLogger(DomUtil.class);
 
     /**
+     * Constant for <code>DocumentBuilderFactory</code> which is used
+     * widely to create new <code>Document</code>s
+     */
+    public static DocumentBuilderFactory BUILDER_FACTORY = DocumentBuilderFactory.newInstance();
+    static {
+        BUILDER_FACTORY.setNamespaceAware(true);
+        BUILDER_FACTORY.setIgnoringComments(true);
+        BUILDER_FACTORY.setIgnoringElementContentWhitespace(true);
+        BUILDER_FACTORY.setCoalescing(true);
+    }
+
+    /**
      * Returns the value of the named attribute of the current element.
      *
      * @param parent
@@ -389,6 +402,25 @@
      */
     public static Element addChildElement(Element parent, String localName, Namespace namespace)
{
         Element elem = createElement(parent.getOwnerDocument(), localName, namespace);
+        parent.appendChild(elem);
+        return elem;
+    }
+
+    /**
+     * Add a new child element with the given local name and namespace to the
+     * specified parent.
+     *
+     * @param parent
+     * @param localName
+     * @param namespace
+     * @return the new element that was attached to the given parent.
+     */
+    public static Element addChildElement(Node parent, String localName, Namespace namespace)
{
+        Document doc = parent.getOwnerDocument();
+        if (parent instanceof Document) {
+            doc = (Document) parent;
+        }
+        Element elem = createElement(doc, localName, namespace);
         parent.appendChild(elem);
         return elem;
     }



Mime
View raw message