jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r331281 [2/3] - in /incubator/jackrabbit/trunk/contrib/jcr-server: ./ client/ server/ server/src/java/org/apache/jackrabbit/server/ server/src/java/org/apache/jackrabbit/server/io/ server/src/java/org/apache/jackrabbit/server/jcr/ server/sr...
Date Mon, 07 Nov 2005 15:28:23 GMT
Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOHandler.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOHandler.java?rev=331281&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOHandler.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOHandler.java Mon Nov  7 07:26:33 2005
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.jackrabbit.webdav.DavResource;
+
+import java.io.IOException;
+
+/**
+ * <code>IOHandler</code>...
+ */
+public interface IOHandler {
+
+    /**
+     * Returns the <code>IOManager</code> that called this handler or <code>null</code>.
+     *
+     * @return
+     */
+    public IOManager getIOManager();
+
+    /**
+     * Returns a human readable name for this <code>IOHandler</code>
+     *
+     * @return
+     */
+    public String getName();
+
+    /**
+     * Returns true, if this handler can run a successful import based on the
+     * specified context.
+     *
+     * @param context
+     * @param isCollection
+     * @return
+     */
+    public boolean canImport(ImportContext context, boolean isCollection);
+
+    /**
+     * Returns true, if this handler can run a successful import based on
+     * the specified context and resource. A simple implementation may choose
+     * to return the same as {@link #canImport(ImportContext, boolean)} where
+     * the isCollection flag is determined by {@link DavResource#isCollection()}.
+     *
+     * @param context
+     * @param resource
+     * @return
+     */
+    public boolean canImport(ImportContext context, DavResource resource);
+
+    /**
+     * Runs the import for the given context and indicates by a boolean return
+     * value, if the import could be completed successfully. If the specified
+     * <code>ImportContext</code> does not provide a {@link ImportContext#hasStream() stream}
+     * the implementation is free, to only import properties of to refuse the
+     * import.<br>
+     *
+     * Please note, that it is the responsibility of the specified
+     * <code>ImportContext</code> to assert, that its stream is not consumed
+     * multiple times when being passed to a chain of <code>IOHandler</code>s.
+     *
+     * @param context
+     * @param isCollection
+     * @return true if the import was successful.
+     * @throws IOException if an unexpected error occurs or if this method has
+     * been called although {@link #canImport(ImportContext, boolean)} returns
+     * false.
+     */
+    public boolean importContent(ImportContext context, boolean isCollection) throws IOException;
+
+    /**
+     * Runs the import for the given context and resource. It indicates by a boolean return
+     * value, if the import could be completed successfully. If the specified
+     * <code>ImportContext</code> does not provide a {@link ImportContext#hasStream() stream}
+     * the implementation is free, to only import properties of to refuse the
+     * import. A simple implementation may return the same as
+     * {@link #importContent(ImportContext, boolean)} where the isCollection flag
+     * is determined by {@link DavResource#isCollection()}<br>
+     *
+     * Please note, that it is the responsibility of the specified
+     * <code>ImportContext</code> to assert, that its stream is not consumed
+     * multiple times when being passed to a chain of <code>IOHandler</code>s.
+     *
+     * @param context
+     * @param resource
+     * @return
+     * @throws IOException if an unexpected error occurs or if this method has
+     * been called although {@link #canImport(ImportContext, DavResource)} returns
+     * false.
+     * @see #importContent(ImportContext, boolean)
+     */
+    public boolean importContent(ImportContext context, DavResource resource) throws IOException;
+
+    /**
+     * Returns true, if this handler can run a successful export based on the
+     * specified context.
+     *
+     * @param context
+     * @param isCollection
+     * @return
+     */
+    public boolean canExport(ExportContext context, boolean isCollection);
+
+    /**
+     * Returns true, if this handler can run a successful export based on
+     * the specified context and resource. A simple implementation may choose
+     * to return the same as {@link #canExport(ExportContext, boolean)} where
+     * the isCollection flag is determined by {@link DavResource#isCollection()}.
+     *
+     * @param context
+     * @param resource
+     * @return
+     */
+    public boolean canExport(ExportContext context, DavResource resource);
+
+    /**
+     * Runs the export for the given context. It indicates by a boolean return
+     * value, if the export could be completed successfully. If the specified
+     * <code>ExportContext</code> does not provide a {@link ExportContext#hasStream() stream}
+     * the implementation should set the properties only and ignore the content to
+     * be exported. A simple implementation may return the same as
+     * {@link #exportContent(ExportContext, boolean)} where the isCollection flag
+     * is determined by {@link DavResource#isCollection()}<br>
+     *
+     * Please note, that it is the responsibility of the specified
+     * <code>ExportContext</code> to assert, that its stream is not written
+     * multiple times when being passed to a chain of <code>IOHandler</code>s.
+     *
+     * @param context
+     * @param isCollection
+     * @return
+     * @throws IOException if an unexpected error occurs or if this method has
+     * been called although {@link #canExport(ExportContext, boolean)} returns
+     * false.
+     */
+    public boolean exportContent(ExportContext context, boolean isCollection) throws IOException;
+
+    /**
+     * Runs the export for the given context and resource. It indicates by a boolean return
+     * value, if the export could be completed successfully. If the specified
+     * <code>ExportContext</code> does not provide a {@link ExportContext#hasStream() stream}
+     * the implementation should set the properties only and ignore the content to
+     * be exported. A simple implementation may return the same as
+     * {@link #exportContent(ExportContext, boolean)} where the isCollection flag
+     * is determined by {@link DavResource#isCollection()}<br>
+     *
+     * Please note, that it is the responsibility of the specified
+     * <code>ExportContext</code> to assert, that its stream is not written
+     * multiple times when being passed to a chain of <code>IOHandler</code>s.
+     *
+     * @param context
+     * @param resource
+     * @return
+     * @throws IOException if an unexpected error occurs or if this method has
+     * been called although {@link #canExport(ExportContext, DavResource)} returns
+     * false.
+     */
+    public boolean exportContent(ExportContext context, DavResource resource) throws IOException;
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOListener.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOListener.java?rev=331281&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOListener.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOListener.java Mon Nov  7 07:26:33 2005
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+/**
+ * <code>IOListener</code> defines an import/export listener.
+ */
+public interface IOListener {
+
+    /**
+     * The import/export context has been passed to the given <code>IOHandler</code>
+     *
+     * @param handler
+     * @param context
+     */
+    public void onBegin(IOHandler handler, IOContext context);
+
+    /**
+     * The specified <code>IOHandler</code> finished. A boolean flag indicates
+     * whether the handler was able to run the import/export.
+     *
+     * @param handler
+     * @param context
+     * @param success
+     */
+    public void onEnd(IOHandler handler, IOContext context, boolean success);
+
+    /**
+     * An expection occured during import/export within the specified
+     * <code>IOHandler</code>.
+     *
+     * @param ioHandler
+     * @param context
+     * @param e
+     */
+    public void onError(IOHandler ioHandler, IOContext context, Exception e);
+}

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOManager.java?rev=331281&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOManager.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOManager.java Mon Nov  7 07:26:33 2005
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.jackrabbit.webdav.DavResource;
+
+import java.io.IOException;
+
+/**
+ * <code>IOManager</code> interface provides the means to define a list of
+ * <code>IOHandlers</code> that should be asked to perform an import or export.
+ */
+public interface IOManager {
+
+    /**
+     * Adds the specified handler to the list of handlers.
+     *
+     * @param ioHandler to be added
+     */
+    public void addIOHandler(IOHandler ioHandler);
+
+    /**
+     * Returns all handlers that have been added to this manager.
+     *
+     * @return Array of all handlers
+     */
+    public IOHandler[] getIOHandlers();
+
+    /**
+     * Passes the specified context and boolean value to the IOHandlers present
+     * on this manager.
+     * As soon as the first handler incidates success the import should be
+     * considered completed. If none of the handlers can deal with the given
+     * information this method must return false.
+     *
+     * @param context
+     * @param isCollection
+     * @return true if any of the handlers import the given context.
+     * False otherwise.
+     * @throws IOException
+     * @see IOHandler#importContent(ImportContext, boolean)
+     */
+    public boolean importContent(ImportContext context, boolean isCollection) throws IOException;
+
+    /**
+     * Passes the specified information to the IOHandlers present on this manager.
+     * As soon as the first handler incidates success the import should be
+     * considered completed. If none of the handlers can deal with the given
+     * information this method must return false.
+     *
+     * @param context
+     * @param resource
+     * @return true if any of the handlers import the information present on the
+     * specified context.
+     * @throws IOException
+     * @see IOHandler#importContent(ImportContext, DavResource)
+     */
+    public boolean importContent(ImportContext context, DavResource resource) throws IOException;
+
+    /**
+     * Passes the specified information to the IOHandlers present on this manager.
+     * As soon as the first handler incidates success the export should be
+     * considered completed. If none of the handlers can deal with the given
+     * information this method must return false.
+     *
+     * @param context
+     * @param isCollection
+     * @return true if any of the handlers could run the export successfully,
+     * false otherwise.
+     * @throws IOException
+     * @see IOHandler#exportContent(ExportContext, boolean)
+     */
+    public boolean exportContent(ExportContext context, boolean isCollection) throws IOException;
+
+    /**
+     * Passes the specified information to the IOHandlers present on this manager.
+     * As soon as the first handler incidates success the export should be
+     * considered completed. If none of the handlers can deal with the given
+     * information this method must return false.
+     *
+     * @param context
+     * @param resource
+     * @return true if any of the handlers could run the export successfully,
+     * false otherwise.
+     * @throws IOException
+     * @see IOHandler#exportContent(ExportContext, DavResource)
+     */
+    public boolean exportContent(ExportContext context, DavResource resource) throws IOException;
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOUtil.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOUtil.java?rev=331281&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOUtil.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/IOUtil.java Mon Nov  7 07:26:33 2005
@@ -0,0 +1,210 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.util.Text;
+import org.apache.jackrabbit.webdav.DavConstants;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.Date;
+
+/**
+ * <code>IOUtil</code> provides utitily methods used for import and export
+ * operations.
+ */
+public class IOUtil {
+
+    private static Logger log = Logger.getLogger(IOUtil.class);
+
+    /**
+     * Constant for undefined modification/creation time
+     */
+    public static final long UNDEFINED_TIME = -1;
+
+    /**
+     * Constant for undefined content length
+     */
+    public static final long UNDEFINED_LENGTH = -1;
+
+    /**
+     * MimeType resolver used to retrieve the mimetype if no content type is
+     * available during import.
+     */
+    public static final MimeResolver MIME_RESOLVER = new MimeResolver();
+
+    /**
+     * Return the last modification time as formatted string.
+     *
+     * @return last modification time as string.
+     * @see DavConstants#modificationDateFormat
+     */
+    public static String getLastModified(long modificationTime) {
+        if (modificationTime <= IOUtil.UNDEFINED_TIME) {
+            modificationTime = new Date().getTime();
+        }
+        return DavConstants.modificationDateFormat.format(new Date(modificationTime));
+    }
+
+    /**
+     * Return the creation time as formatted string.
+     *
+     * @return creation time as string.
+     * @see DavConstants#creationDateFormat
+     */
+    public static String getCreated(long createdTime) {
+        if (createdTime <= IOUtil.UNDEFINED_TIME) {
+            createdTime = 0;
+        }
+        return DavConstants.creationDateFormat.format(new Date(createdTime));
+    }
+
+    /**
+     *
+     * @param in
+     * @param out
+     * @throws IOException
+     */
+    public static void spool(InputStream in, OutputStream out) throws IOException {
+        try {
+            byte[] buffer = new byte[8192];
+            int read;
+            while ((read = in.read(buffer)) >= 0) {
+                out.write(buffer, 0, read);
+            }
+        } finally {
+            in.close();
+        }
+    }
+
+    /**
+     * Build a valid content type string from the given mimeType and encoding:
+     * <pre>
+     * &lt;mimeType&gt;; charset="&lt;encoding&gt;"
+     * </pre>
+     * If the specified mimeType is <code>null</code>, <code>null</code> is returned.
+     *
+     * @param mimeType
+     * @param encoding
+     * @return contentType or <code>null</code> if the specified mimeType is
+     * <code>null</code>
+     */
+    public static String buildContentType(String mimeType, String encoding) {
+        String contentType = mimeType;
+        if (encoding != null) {
+            contentType += "; charset=\"" + encoding + "\"";
+        }
+        return contentType;
+    }
+
+    /**
+     * Retrieve the mimeType from the specified contentType.
+     *
+     * @param contentType
+     * @return mimeType or <code>null</code>
+     */
+    public static String getMimeType(String contentType) {
+        String mimeType = contentType;
+        if (mimeType == null) {
+            // property will be removed.
+            // Note however, that jcr:mimetype is a mandatory property with the
+            // built-in nt:file nodetype.
+            return mimeType;
+        }
+        // strip any parameters
+        int semi = mimeType.indexOf(";");
+        return (semi > 0) ? mimeType.substring(0, semi) : mimeType;
+    }
+
+    /**
+     * Retrieve the encoding from the specified contentType.
+     *
+     * @param contentType
+     * @return encoding or <code>null</code> if the specified contentType is
+     * <code>null</code> or does not define a charset.
+     */
+    public static String getEncoding(String contentType) {
+        // find the charset parameter
+        int equal;
+        if (contentType == null || (equal = contentType.indexOf("charset=")) == -1) {
+            // jcr:encoding property will be removed
+            return null;
+        }
+        String encoding = contentType.substring(equal + 8);
+        // get rid of any other parameters that might be specified after the charset
+        int semi = encoding.indexOf(";");
+        if (semi != -1) {
+            encoding = encoding.substring(0, semi);
+        }
+        // strip off enclosing quotes
+        if (encoding.startsWith("\"") || encoding.startsWith("'")) {
+            encoding = encoding.substring(1, encoding.length() - 1);
+        }
+        return encoding;
+    }
+
+    /**
+     * Builds a new temp. file from the given input stream.<br>
+     * It is left to the user to remove the file as soon as it is not used
+     * any more.
+     *
+     * @param inputStream the input stream
+     * @return temp. file or <code>null</code> if the specified input is
+     * <code>null</code>.
+     */
+    public static File getTempFile(InputStream inputStream) throws IOException {
+        if (inputStream == null) {
+            return null;
+        }
+        // we need a tmp file, since the import could fail
+        File tmpFile = File.createTempFile("__importcontext", "tmp");
+        FileOutputStream out = new FileOutputStream(tmpFile);
+        byte[] buffer = new byte[8192];
+        int read;
+        while ((read=inputStream.read(buffer))>0) {
+            out.write(buffer, 0, read);
+        }
+        out.close();
+        inputStream.close();
+        return tmpFile;
+    }
+
+    /**
+     * Recursively creates nodes below the specified root node.
+     *
+     * @param root
+     * @param relPath
+     * @return the node corresponding to the last segment of the specified
+     * relative path.
+     * @throws RepositoryException
+     */
+    public static Node mkDirs(Node root, String relPath, String dirNodeType) throws RepositoryException {
+        String[] seg = Text.explode(relPath, '/');
+        for (int i=0; i< seg.length; i++) {
+            if (!root.hasNode(seg[i])) {
+                root.addNode(seg[i], dirNodeType);
+            }
+            root = root.getNode(seg[i]);
+        }
+        return root;
+    }
+}
\ No newline at end of file

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

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

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContext.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContext.java?rev=331281&r1=331280&r2=331281&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContext.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContext.java Mon Nov  7 07:26:33 2005
@@ -16,139 +16,21 @@
  */
 package org.apache.jackrabbit.server.io;
 
-import javax.jcr.Node;
+import javax.jcr.Item;
 import java.io.InputStream;
 
 /**
- * This Class implements an import context which is passed to the respective
- * import commands. An import command can alter the current node for creating
- * a recursive structure, thus is can lead to errors, if the configuration
- * is not done properly. A import command should clear the input stream,
- * after having processed it.
- * </p>
- * Please note, that this import context lacks an explicit
- * {@link org.apache.jackrabbit.webdav.DavResource} member. Currently, this
- * information is not needed in any of the known import commands but leaves this
- * I/O framework more generic.
+ * <code>ImportContext</code>...
  */
-public class ImportContext extends AbstractContext {
+public interface ImportContext extends IOContext {
 
     /**
-     * The import root node, i.e. the parent node of the new content.
-     */
-    private final Node importRoot;
-
-    /**
-     * The 'current' node.
-     */
-    private Node node = null;
-
-    /**
-     * The input stream of the resource data
-     */
-    private InputStream inputStream;
-
-    /**
-     * The systemid of the resource, eg. the display name of a dav resource,
-     * the filename of a file, etc.
-     */
-    private String systemId;
-
-    /**
-     * The content type of the resource to be imported.
-     */
-    private String contentType;
-
-    /**
-     * The content language of the resource to be imported.
-     */
-    private String contentLanguage;
-
-    /**
-     * The modification time of the resource, if known
-     */
-    private long modificationTime;
-
-    /**
-     * Creates a new import context with the given root node
-     *
-     * @param importRoot the import root node
-     */
-    public ImportContext(Node importRoot) {
-        this(null, importRoot);
-    }
-
-    /**
-     * Creats a new import context with the given root node and property defaults.
-     *
-     * @param base
-     * @param importRoot
-     */
-    public ImportContext(ImportContext base, Node importRoot) {
-        super(base);
-        if (importRoot == null) {
-            throw new IllegalArgumentException("importRoot can not be null.");
-        }
-        this.importRoot = importRoot;
-    }
-
-    /**
-     * Creates a new sub context which bases on this contexts properties
-     *
-     * @param importRoot
-     * @return
-     */
-    public ImportContext createSubContext(Node importRoot) {
-        return new ImportContext(this, importRoot);
-    }
-
-    /**
-     * Retruns the input stream of the resource to import.
-     *
-     * @return the input stream.
-     */
-    public InputStream getInputStream() {
-        return inputStream;
-    }
-
-    /**
-     * Sets the inpurt stream of the resource to import. A import command that
-     * consumed the input stream should set this member to <code>null</code>.
-     *
-     * @param inputStream the input stream
-     */
-    public void setInputStream(InputStream inputStream) {
-        this.inputStream = inputStream;
-    }
-
-    /**
-     * Returns the import root of the resource to import.
+     * Returns the import root of the resource to import, i.e. the parent node
+     * of the new content to be created.
      *
      * @return the import root of the resource to import.
      */
-    public Node getImportRoot() {
-        return importRoot;
-    }
-
-    /**
-     * Returns the current parent node of the resource to import. If no current
-     * parent node is defined, the import root is returned.
-     *
-     * @return the parent node.
-     */
-    public Node getNode() {
-        return node == null ? importRoot : node;
-    }
-
-    /**
-     * Sets the current parent node of the resource to import. A command can
-     * set this member in order to generate recursive structured.
-     *
-     * @param node
-     */
-    public void setNode(Node node) {
-        this.node = node;
-    }
+    public Item getImportRoot();
 
     /**
      * Returns the system id of the resource to be imported. This id depends on
@@ -157,71 +39,61 @@
      *
      * @return the system id of the resource to import
      */
-    public String getSystemId() {
-        return systemId;
-    }
+    public String getSystemId();
 
     /**
-     * sets the system id of this resource.
+     * Returns the input stream of the data to import or <code>null</code> if
+     * there are none.
      *
-     * @param systemId
+     * @return the input stream.
+     * @see #hasStream()
      */
-    public void setSystemId(String systemId) {
-        this.systemId = systemId;
-    }
+    public InputStream getInputStream();
 
     /**
-     * Returns the content type of the resource to be imported or null, if
-     * no contenttype was defined.
+     * Returns the modification time of the resource or the current time if
+     * the modification time has not been set.
      *
-     * @return the content type of the resource
+     * @return the modification time.
      */
-    public String getContentType() {
-        return contentType;
-    }
+    public long getModificationTime();
 
     /**
-     * Sets the content type of the resource.
+     * Returns the content language or <code>null</code>
      *
-     * @param contentType the content type.
+     * @return contentLanguage
      */
-    public void setContentType(String contentType) {
-        this.contentType = contentType;
-    }
+    public String getContentLanguage();
 
     /**
-     * Returns the content language or <code>null</code>
+     * Returns the length of the data or {@link IOUtil#UNDEFINED_LENGTH -1} if
+     * the content length could not be determined.
      *
-     * @return contentLanguage
+     * @return the content length
      */
-    public String getContentLanguage() {
-        return contentLanguage;
-    }
+    public long getContentLength();
 
     /**
-     * Sets the content language.
+     * Returns the main media type. It should be retrieved from a content type
+     * (as present in a http request) or from the systemId. If either value
+     * is indefined <code>null</code> should be returned.
      *
-     * @param contentLanguage
+     * @return the mimetype of the resource to be imported
      */
-    public void setContentLanguage(String contentLanguage) {
-        this.contentLanguage = contentLanguage;
-    }
+    public String getMimeType();
 
     /**
-     * Returns the modification time of the resource
+     * Returns the encoding extracted from a content type as present in a
+     * request header or <code>null</code>
      *
-     * @return the modification time.
+     * @return the encoding to be used for importing
      */
-    public long getModificationTime() {
-        return modificationTime;
-    }
+    public String getEncoding();
 
     /**
-     * Sets the modification time of the resource
      *
-     * @param modificationTime the modification time
+     * @param propertyName
+     * @return
      */
-    public void setModificationTime(long modificationTime) {
-        this.modificationTime = modificationTime;
-    }
+    public Object getProperty(Object propertyName);
 }

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContextImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContextImpl.java?rev=331281&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContextImpl.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ImportContextImpl.java Mon Nov  7 07:26:33 2005
@@ -0,0 +1,216 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.io.InputContext;
+
+import javax.jcr.Item;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.File;
+import java.util.Date;
+
+/**
+ * <code>ImportContextImpl</code>...
+ */
+public class ImportContextImpl implements ImportContext {
+
+    private static Logger log = Logger.getLogger(ImportContextImpl.class);
+
+    private final IOListener ioListener;
+    private final Item importRoot;
+    private final String systemId;
+    private final File inputFile;
+
+    private InputContext inputCtx;
+    private boolean completed;
+
+    /**
+     * Creates a new item import context with the given root item and the
+     * specified <code>InputContext</code>. If the input context provides an
+     * input stream, the stream is written to a temporary file in order to avoid
+     * problems with multiple IOHandlers that try to run the import but fail.
+     * The temporary file is deleted as soon as this context is informed that
+     * the import has been completed and it will not be used any more.
+     *
+     * @param importRoot the import root node
+     * @param inputCtx wrapped by this <code>ImportContext</code>
+     */
+    public ImportContextImpl(Item importRoot, String systemId, InputContext inputCtx) throws IOException {
+        this(importRoot, systemId, (inputCtx != null) ? inputCtx.getInputStream() : null, null);
+        this.inputCtx = inputCtx;
+    }
+
+    /**
+     * Creates a new item import context. The specified InputStream is written
+     * to a temporary file in order to avoid problems with multiple IOHandlers
+     * that try to run the import but fail. The temporary file is deleted as soon
+     * as this context is informed that the import has been completed and it
+     * will not be used any more.
+     *
+     * @param importRoot
+     * @param systemId
+     * @param in
+     * @param ioListener
+     * @throws IOException
+     * @see ImportContext#informCompleted(boolean)
+     */
+    public ImportContextImpl(Item importRoot, String systemId, InputStream in, IOListener ioListener) throws IOException {
+        this.importRoot = importRoot;
+        this.systemId = systemId;
+        this.inputFile = IOUtil.getTempFile(in);
+        this.ioListener = (ioListener != null) ? ioListener : new DefaultIOListener(log);
+    }
+
+    /**
+     * @see ImportContext#getIOListener()
+     */
+    public IOListener getIOListener() {
+        return ioListener;
+    }
+
+    /**
+     * @see ImportContext#getImportRoot()
+     */
+    public Item getImportRoot() {
+        return importRoot;
+    }
+
+    /**
+     * @see ImportContext#hasStream()
+     */
+    public boolean hasStream() {
+        return inputFile != null;
+    }
+
+    /**
+     * Returns a new <code>InputStream</code> to the temporary file created
+     * during instanciation or <code>null</code>, if this context does not
+     * provide a stream.
+     *
+     * @see ImportContext#getInputStream()
+     * @see #hasStream()
+     */
+    public InputStream getInputStream() {
+        checkCompleted();
+        InputStream in = null;
+        if (inputFile != null) {
+            try {
+                in = new FileInputStream(inputFile);
+            } catch (IOException e) {
+                // unexpected error... ignore and return null
+            }
+        }
+        return in;
+    }
+
+    /**
+     * @see ImportContext#getSystemId()
+     */
+    public String getSystemId() {
+        return systemId;
+    }
+
+    /**
+     * @see ImportContext#getModificationTime()
+     */
+    public long getModificationTime() {
+        return (inputCtx != null) ? inputCtx.getModificationTime() : new Date().getTime();
+    }
+
+    /**
+     * @see ImportContext#getContentLanguage()
+     */
+    public String getContentLanguage() {
+        return (inputCtx != null) ? inputCtx.getContentLanguage() : null;
+    }
+
+    /**
+     * @see ImportContext#getContentLength()
+     */
+    public long getContentLength() {
+        return (inputCtx != null) ? inputCtx.getContentLength() : IOUtil.UNDEFINED_LENGTH;
+    }
+
+    /**
+     * @return the content type present on the <code>InputContext</code> or
+     * <code>null</code>
+     * @see InputContext#getContentType()
+     */
+    private String getContentType() {
+        return (inputCtx != null) ? inputCtx.getContentType() : null;
+    }
+
+    /**
+     * @see ImportContext#getMimeType()
+     */
+    public String getMimeType() {
+        String contentType = getContentType();
+        String mimeType = null;
+        if (contentType != null) {
+            mimeType = IOUtil.getMimeType(contentType);
+        } else if (getSystemId() != null) {
+            mimeType = IOUtil.MIME_RESOLVER.getMimeType(getSystemId());
+        }
+        return mimeType;
+    }
+
+    /**
+     * @see ImportContext#getEncoding()
+     */
+    public String getEncoding() {
+        String contentType = getContentType();
+        return (contentType != null) ? IOUtil.getEncoding(contentType) : null;
+    }
+
+    /**
+     * @see ImportContext#getProperty(Object)
+     */
+    public Object getProperty(Object propertyName) {
+        return (inputCtx != null) ? inputCtx.getProperty(propertyName.toString()) : null;
+    }
+
+    /**
+     * @see ImportContext#informCompleted(boolean)
+     */
+    public void informCompleted(boolean success) {
+        checkCompleted();
+        completed = true;
+        if (inputFile != null) {
+            inputFile.delete();
+        }
+    }
+
+    /**
+     * @see ImportContext#isCompleted()
+     */
+    public boolean isCompleted() {
+        return completed;
+    }
+
+    /**
+     * @throws IllegalStateException if the context is already completed.
+     * @see #isCompleted()
+     * @see #informCompleted(boolean)
+     */
+    private void checkCompleted() {
+        if (completed) {
+            throw new IllegalStateException("ImportContext has already been consumed.");
+        }
+    }
+}

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XmlHandler.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XmlHandler.java?rev=331281&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XmlHandler.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XmlHandler.java Mon Nov  7 07:26:33 2005
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.log4j.Logger;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.ImportUUIDBehavior;
+import javax.jcr.Session;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.jackrabbit.JcrConstants;
+
+/**
+ * <code>XmlHandler</code> imports xml files and exports nodes that have
+ * the proper {@link #XML_MIMETYPE} defined with their content. The export is
+ * performed by running a {@link Session#exportDocumentView(String, OutputStream, boolean, boolean)
+ * document view export} for the content of the export root defined with the
+ * specified {@link ExportContext}.<br>
+ * Please note that this handler is not suited for a generic system or document
+ * view import/export of {@link Node}s because an extra root node is always
+ * created during import and expected during export, respectively.
+ */
+public class XmlHandler extends DefaultHandler {
+
+    private static Logger log = Logger.getLogger(XmlHandler.class);
+
+    /**
+     * the xml mimetype
+     */
+    public static final String XML_MIMETYPE = "text/xml";
+
+    /**
+     * Creates a new <code>XmlHandler</code> with default nodetype definitions:<br>
+     * <ul>
+     * <li>Nodetype for Collection: {@link JcrConstants#NT_UNSTRUCTURED nt:unstructured}</li>
+     * <li>Nodetype for Non-Collection: {@link JcrConstants#NT_FILE nt:file}</li>
+     * <li>Nodetype for Non-Collection content: {@link JcrConstants#NT_UNSTRUCTURED nt:unstructured}</li>
+     * </ul>
+     *
+     * @param ioManager
+     */
+    public XmlHandler(IOManager ioManager) {
+        super(ioManager, JcrConstants.NT_UNSTRUCTURED, JcrConstants.NT_FILE, JcrConstants.NT_UNSTRUCTURED);
+    }
+
+    /**
+     * Creates a new <code>XmlHandler</code>
+     *
+     * @param ioManager
+     * @param collectionNodetype
+     * @param defaultNodetype
+     * @param contentNodetype
+     */
+    public XmlHandler(IOManager ioManager, String collectionNodetype, String defaultNodetype, String contentNodetype) {
+        super(ioManager, collectionNodetype, defaultNodetype, contentNodetype);
+    }
+
+    /**
+     * @see IOHandler#canImport(ImportContext, boolean)
+     */
+    public boolean canImport(ImportContext context, boolean isCollection) {
+        if (context == null || context.isCompleted()) {
+            return false;
+        }
+        boolean isXmlMimeType = XML_MIMETYPE.equals(context.getMimeType());
+        return isXmlMimeType && context.hasStream() && super.canImport(context, isCollection);
+    }
+
+    /**
+     * @see DefaultHandler#importData(ImportContext, boolean, Node)
+     */
+    protected boolean importData(ImportContext context, boolean isCollection, Node contentNode) throws IOException, RepositoryException {
+        InputStream in = context.getInputStream();
+        int uuidBehavior = (isCollection)
+            ? ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING
+            : ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW;
+        try {
+            contentNode.getSession().importXML(contentNode.getPath(), in, uuidBehavior);
+        } finally {
+            in.close();
+        }
+        return true;
+    }
+
+    /**
+     * @see DefaultHandler#importProperties(ImportContext, boolean, Node)
+     */
+    protected boolean importProperties(ImportContext context, boolean isCollection, Node contentNode) {
+        boolean success = super.importProperties(context, isCollection, contentNode);
+        if (success) {
+            // encoding: always UTF-8 for the xml import
+            try {
+                contentNode.setProperty(JcrConstants.JCR_ENCODING, "UTF-8");
+            } catch (RepositoryException e) {
+                // ignore, since given nodetype could not allow encoding
+                // deliberately not rethrowing an IOException.
+            }
+        }
+        return success;
+    }
+
+    /**
+     * @see IOHandler#canExport(ExportContext, boolean)
+     */
+    public boolean canExport(ExportContext context, boolean isCollection) {
+        if (super.canExport(context, isCollection)) {
+            String mimeType = null;
+            try {
+                Node contentNode = getContentNode(context, isCollection);
+                if (contentNode.hasProperty(JcrConstants.JCR_MIMETYPE)) {
+                    mimeType = contentNode.getProperty(JcrConstants.JCR_MIMETYPE).getString();
+                } else {
+                    mimeType = IOUtil.MIME_RESOLVER.getMimeType(context.getExportRoot().getName());
+                }
+            } catch (RepositoryException e) {
+                // ignore and return false
+            }
+            return XML_MIMETYPE.equals(mimeType);
+        }
+        return false;
+    }
+
+    /**
+     * @see DefaultHandler#exportProperties(ExportContext, boolean, Node)
+     */
+    protected void exportData(ExportContext context, boolean isCollection, Node contentNode) throws IOException, RepositoryException {
+        // first child of content is XML document root
+        if (contentNode.getNodes().hasNext()) {
+            contentNode = contentNode.getNodes().nextNode();
+        }
+        OutputStream out = context.getOutputStream();
+        contentNode.getSession().exportDocumentView(contentNode.getPath(), out, true, false);
+    }
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ZipHandler.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ZipHandler.java?rev=331281&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ZipHandler.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/ZipHandler.java Mon Nov  7 07:26:33 2005
@@ -0,0 +1,356 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.server.io;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.util.Text;
+import org.apache.jackrabbit.JcrConstants;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.NodeIterator;
+import javax.jcr.Item;
+import javax.jcr.Property;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * <code>ZipHandler</code> imports and extracts Zip files and exported nodes
+ * (an their subnodes) to a Zip file. Please not that for the export the selected
+ * export root must have the property {@link #ZIP_MIMETYPE} defined with its
+ * content. Furthermore the content must not represent a zip-file that has
+ * been imported to a binary {@link Property property}, which is properly
+ * handled by the {@link DefaultHandler}.
+ */
+public class ZipHandler extends DefaultHandler {
+
+    private static Logger log = Logger.getLogger(ZipHandler.class);
+
+    /**
+     * the zip mimetype
+     */
+    public static final String ZIP_MIMETYPE = "application/zip";
+
+    private boolean intermediateSave;
+
+    /**
+     * Creates a new <code>ZipHandler</code> with default nodetype definitions:<br>
+     * <ul>
+     * <li>Nodetype for Collection: {@link JcrConstants#NT_UNSTRUCTURED nt:unstructured}</li>
+     * <li>Nodetype for Non-Collection: {@link JcrConstants#NT_FILE nt:file}</li>
+     * <li>Nodetype for Non-Collection content: {@link JcrConstants#NT_UNSTRUCTURED nt:unstructured}</li>
+     * </ul>
+     *
+     * @param ioManager
+     * @throws IllegalArgumentException if the specified <code>IOManager</code>
+     * is <code>null</code>
+     */
+    public ZipHandler(IOManager ioManager) {
+        this(ioManager, JcrConstants.NT_UNSTRUCTURED, JcrConstants.NT_FILE, JcrConstants.NT_UNSTRUCTURED);
+    }
+
+    /**
+     * Creates a new <code>ZipHandler</code>
+     *
+     * @param ioManager
+     * @param collectionNodetype
+     * @param defaultNodetype
+     * @param contentNodetype
+     * @throws IllegalArgumentException if the specified <code>IOManager</code>
+     * is <code>null</code>
+     */
+    public ZipHandler(IOManager ioManager, String collectionNodetype, String defaultNodetype, String contentNodetype) {
+        super(ioManager, collectionNodetype, defaultNodetype, contentNodetype);
+        if (ioManager == null) {
+            throw new IllegalArgumentException("The IOManager must not be null.");
+        }
+    }
+
+    /**
+     * If set to <code>true</code> the import root will be {@link Item#save() saved}
+     * after every imported zip entry. Note however, that this removes the possibility
+     * to revert all modifications if the import cannot be completed successfully.
+     * By default the intermediate save is disabled.
+     *
+     * @param intermediateSave
+     */
+    public void setIntermediateSave(boolean intermediateSave) {
+        this.intermediateSave = intermediateSave;
+    }
+
+    /**
+     * @see IOHandler#canImport(ImportContext, boolean)
+     */
+    public boolean canImport(ImportContext context, boolean isCollection) {
+        if (context == null || context.isCompleted()) {
+            return false;
+        }
+        boolean isZip = ZIP_MIMETYPE.equals(context.getMimeType());
+        return isZip && context.hasStream() && super.canImport(context, isCollection);
+    }
+
+    /**
+     * @see DefaultHandler#importData(ImportContext, boolean, Node)
+     */
+    protected boolean importData(ImportContext context, boolean isCollection, Node contentNode) throws IOException, RepositoryException {
+        boolean success = true;
+        InputStream in = context.getInputStream();
+        ZipInputStream zin = new ZipInputStream(in);
+        try {
+            ZipEntry entry;
+            while ((entry=zin.getNextEntry())!=null && success) {
+                importZipEntry(zin, entry, context, contentNode);
+                zin.closeEntry();
+            }
+        } finally {
+            zin.close();
+            in.close();
+        }
+        return success;
+    }
+
+    /**
+     * @see IOHandler#canExport(ExportContext, boolean)
+     */
+    public boolean canExport(ExportContext context, boolean isCollection) {
+        if (super.canExport(context, isCollection)) {
+            // mimetype must be application/zip
+            String mimeType = null;
+            // if zip-content has not been extracted -> delegate to some other handler
+            boolean hasDataProperty = false;
+            try {
+                Node contentNode = getContentNode(context, isCollection);
+                // jcr:data property indicates that the zip-file has been imported as binary (not extracted)
+                hasDataProperty = contentNode.hasProperty(JcrConstants.JCR_DATA);
+                if (contentNode.hasProperty(JcrConstants.JCR_MIMETYPE)) {
+                    mimeType  = contentNode.getProperty(JcrConstants.JCR_MIMETYPE).getString();
+                } else {
+                    mimeType = IOUtil.MIME_RESOLVER.getMimeType(context.getExportRoot().getName());
+                }
+            } catch (RepositoryException e) {
+                // ignore and return false
+            }
+            return ZIP_MIMETYPE.equals(mimeType) && !hasDataProperty;
+        }
+        return false;
+    }
+
+    /**
+     * @see DefaultHandler#exportData(ExportContext,boolean,Node)
+     */
+    protected void exportData(ExportContext context, boolean isCollection, Node contentNode) throws IOException, RepositoryException {
+        ZipOutputStream zout = new ZipOutputStream(context.getOutputStream());
+        zout.setMethod(ZipOutputStream.DEFLATED);
+        try {
+            exportZipEntry(context, zout, contentNode, contentNode.getPath().length()+1);
+        } finally {
+            zout.finish();
+        }
+    }
+
+    /**
+     * If the specified node is the defined non-collection nodetype a new
+     * Zip entry is created and the exportContent is called on the IOManager
+     * defined with this handler. If in contrast the specified node does not
+     * represent a non-collection this method is called recursively for all
+     * child nodes.
+     *
+     * @param context
+     * @param zout
+     * @param node
+     * @param pos
+     * @throws IOException
+     */
+    private void exportZipEntry(ExportContext context, ZipOutputStream zout, Node node, int pos) throws IOException{
+        try {
+            if (node.isNodeType(getNodeType())) {
+                ZipEntryExportContext subctx = new ZipEntryExportContext(node, zout, context, pos);
+                // try if iomanager can treat node as zip entry otherwise recurse.
+                zout.putNextEntry(subctx.entry);
+                getIOManager().exportContent(subctx, false);
+            } else {
+                // recurse
+                NodeIterator niter = node.getNodes();
+                while (niter.hasNext()) {
+                    exportZipEntry(context, zout, niter.nextNode(), pos);
+                }
+            }
+        } catch (RepositoryException e) {
+            log.fatal(e.getMessage());
+            // should never occur
+        }
+    }
+
+    /**
+     * Creates a new sub context for the specified Zip entry and passes it to
+     * the IOManager defined with this handler.
+     *
+     * @param zin
+     * @param entry
+     * @param context
+     * @param node
+     * @return
+     * @throws RepositoryException
+     * @throws IOException
+     */
+    private boolean importZipEntry(ZipInputStream zin, ZipEntry entry, ImportContext context, Node node) throws RepositoryException, IOException {
+        boolean success = false;
+        log.debug("entry: " + entry.getName() + " size: " + entry.getSize());
+        if (entry.isDirectory()) {
+            IOUtil.mkDirs(node, makeValidJCRPath(entry.getName(), false), getCollectionNodeType());
+        } else {
+            // import zip entry as file
+            BoundedInputStream bin = new BoundedInputStream(zin);
+            bin.setPropagateClose(false);
+            ImportContext entryContext = new ZipEntryImportContext(context, entry, bin, node);
+
+            // let the iomanager deal with the individual entries.
+            IOManager ioManager = getIOManager();
+            success = (ioManager != null) ? ioManager.importContent(entryContext, false) : false;
+
+            // intermediate save in order to avoid problems with large zip files
+            if (intermediateSave) {
+                context.getImportRoot().save();
+            }
+        }
+        return success;
+    }
+
+    /**
+     * Creates a valid jcr label from the given one
+     *
+     * @param label
+     * @return
+     */
+    private static String makeValidJCRPath(String label, boolean appendLeadingSlash) {
+        if (appendLeadingSlash && !label.startsWith("/")) {
+            label = "/" + label;
+        }
+        StringBuffer ret = new StringBuffer(label.length());
+        for (int i=0; i<label.length(); i++) {
+            char c = label.charAt(i);
+            if (c=='*' || c=='\'' || c=='\"') {
+                c='_';
+            /* not quite correct: [] may be the index of a previously exported item. */
+            } else if (c=='[') {
+                c='(';
+            } else if (c==']') {
+                c=')';
+            }
+            ret.append(c);
+        }
+        return ret.toString();
+    }
+
+    //--------------------------------------------------------< inner class >---
+    /**
+     * Inner class used to create subcontexts for the import of the individual
+     * zip file entries.
+     */
+    private class ZipEntryImportContext extends ImportContextImpl {
+
+        private final Item importRoot;
+        private final ZipEntry entry;
+
+        private ZipEntryImportContext(ImportContext context, ZipEntry entry, BoundedInputStream bin, Node contentNode) throws IOException, RepositoryException {
+            super(contentNode, Text.getName(makeValidJCRPath(entry.getName(), true)), bin, context.getIOListener());
+            this.entry = entry;
+            String path = makeValidJCRPath(entry.getName(), true);
+            importRoot = IOUtil.mkDirs(contentNode, Text.getRelativeParent(path, 1), getCollectionNodeType());
+        }
+
+        public Item getImportRoot() {
+            return importRoot;
+        }
+
+        public long getModificationTime() {
+            return entry.getTime();
+        }
+
+        public long getContentLength() {
+            return entry.getSize();
+        }
+    }
+
+    /**
+     * Inner class used to create subcontexts for the export of the individual
+     * zip file entries.
+     */
+    private class ZipEntryExportContext extends AbstractExportContext {
+
+        private ZipEntry entry;
+        private OutputStream out;
+
+        private ZipEntryExportContext(Item exportRoot, OutputStream out, ExportContext context, int pos) {
+            super(exportRoot, out != null, context.getIOListener());
+            this.out = out;
+            try {
+                String entryPath = (exportRoot.getPath().length() > pos) ? exportRoot.getPath().substring(pos) : "";
+                entry = new ZipEntry(entryPath);
+            } catch (RepositoryException e) {
+                // should never occur
+            }
+        }
+
+        /**
+         * Returns the Zip output stream. Note, that this context does not
+         * deal properly with multiple IOHandlers writing to the stream.
+         *
+         * @return
+         */
+        public OutputStream getOutputStream() {
+            return out;
+        }
+
+        public void setContentType(String mimeType, String encoding) {
+            if (entry != null) {
+                entry.setComment(mimeType);
+            }
+        }
+
+        public void setContentLanguage(String contentLanguage) {
+            // ignore
+        }
+
+        public void setContentLength(long contentLength) {
+            if (entry != null) {
+                entry.setSize(contentLength);
+            }
+        }
+
+        public void setCreationTime(long creationTime) {
+            // ignore
+        }
+
+        public void setModificationTime(long modificationTime) {
+            if (entry != null) {
+                entry.setTime(modificationTime);
+            }
+        }
+
+        public void setETag(String etag) {
+            // ignore
+        }
+
+        public void setProperty(Object propertyName, Object propertyValue) {
+            // ignore
+        }
+    }
+}
\ No newline at end of file

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

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

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/package.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/package.html?rev=331281&r1=331280&r2=331281&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/package.html (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/package.html Mon Nov  7 07:26:33 2005
@@ -1,39 +1,3 @@
-The jackrabbit webdav server, makes use of the <a href="http://jakarta.apache.org/commons/chain/">commons-chain</a>
-framekwork in order to perform inport and export operations.
-</p>
-the i/o catalog consists of 4 commands chains:
-<ul>
-<li><b>import-collection</b><br>
-    commands that import a collection, eg. create a folder node in the
-    repository.
-<li><b>import-resource</b><br>
-    commands that import a non-collection resource, eg. importing a file, deserializing
-    an xml document. etc.
-<li><b>export-collection</b><br>
-    commands that export a collection, eg. create a dir-listing
-<li><b>export-resource</b><br>
-    commands that export a non-collection resource, eg. spool a file, generate a docview response
-</ul>
-
-an example catalog.xml:<br>
-<xmp>
-<?xml version="1.0" ?>
-<catalog>
-    <chain name="import-collection">
-        <command id="add-node" className="org.apache.jackrabbit.server.io.AddNodeCommand" nodeType="nt:folder" />
-    </chain>
-
-    <chain name="import-resource">
-        <command id="add-node"  className="org.apache.jackrabbit.server.io.AddNodeCommand" nodeType="nt:file" />
-        <command id="add-mixin" className="org.apache.jackrabbit.server.io.AddMixinCommand" nodeType="mix:versionable"/>
-        <command id="import-file" className="org.apache.jackrabbit.server.io.FileImportCommand" />
-    </chain>
-
-    <chain name="export-collection">
-        <command id="export-dirlisting" className="org.apache.jackrabbit.server.io.DirListingExportCommand"  collectionNodeType="nt:folder"/>
-    </chain>
-    <chain name="export-resource">
-        <command id="export-file" className="org.apache.jackrabbit.server.io.FileExportCommand" />
-    </chain>
-</catalog>
-</xmp>
\ No newline at end of file
+The jackrabbit webdav server uses the classes defined in this package in order
+to perform import and export operations in order to respond to PUT and MKCOL and
+PROPFIND, GET, HEAD request, respectively.
\ No newline at end of file

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java?rev=331281&r1=331280&r2=331281&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java Mon Nov  7 07:26:33 2005
@@ -92,7 +92,7 @@
      */
     private class DavSessionImpl implements DavSession {
 
-        /** the underlaying jcr session */
+        /** the underlying jcr session */
         private final Session session;
 
         /**
@@ -128,8 +128,8 @@
         /**
          * Removes the reference from this <code>DavSession</code>. If no
          * more references are present, this <code>DavSession</code> is removed
-         * from the internal cache and the underlaying session is released by calling
-         * {@link javax.jcr.Session#logout()}.
+         * from the internal cache and the underlying session is released by
+         * calling {@link SessionProvider#releaseSession(javax.jcr.Session)} 
          *
          * @see DavSession#removeReference(Object)
          */
@@ -248,8 +248,8 @@
                 if (referenceSet.isEmpty()) {
                     log.info("No more references present on webdav session -> clean up.");
                     sessionMap.remove(session);
+                    sessionProvider.releaseSession(session.getRepositorySession());
                     log.info("Login: User '" + session.getRepositorySession().getUserID() + "' logged out");
-                    session.getRepositorySession().logout();
                 } else {
                     log.debug(referenceSet.size() + " references remaining on webdav session " + session);
                 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java?rev=331281&r1=331280&r2=331281&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java Mon Nov  7 07:26:33 2005
@@ -122,7 +122,7 @@
     }
 
     /**
-     * Moves the underlaying repository item to the indicated destination.
+     * Moves the underlying repository item to the indicated destination.
      *
      * @param destination
      * @throws DavException
@@ -158,7 +158,7 @@
     }
 
     /**
-     * Copies the underlaying repository item to the indicated destination. If
+     * Copies the underlying repository item to the indicated destination. If
      * the locator of the specified destination resource indicates a different
      * workspace, {@link Workspace#copy(String, String, String)} is used to perform
      * the copy operation, {@link Workspace#copy(String, String)} otherwise.
@@ -282,7 +282,7 @@
 
     /**
      * If this resource exists but does not contain a transaction id, complete
-     * will try to persist any modifications present on the underlaying
+     * will try to persist any modifications present on the underlying
      * repository item.
      *
      * @throws DavException if calling {@link Item#save()} fails

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java?rev=331281&r1=331280&r2=331281&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java Mon Nov  7 07:26:33 2005
@@ -17,6 +17,8 @@
 
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.server.io.IOUtil;
+import org.apache.jackrabbit.webdav.io.OutputContext;
 import org.apache.jackrabbit.webdav.search.SearchResource;
 import org.apache.jackrabbit.webdav.search.QueryGrammerSet;
 import org.apache.jackrabbit.webdav.search.SearchInfo;
@@ -40,6 +42,8 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Item;
 import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
 import java.util.*;
 
 /**
@@ -59,7 +63,7 @@
     private TxLockManagerImpl txMgr;
     private String transactionId;
 
-    private long modificationTime = DavResource.UNDEFINED_MODIFICATIONTIME;
+    private long modificationTime = new Date().getTime();
 
     protected boolean initedProps;
     protected DavPropertySet properties = new DavPropertySet();
@@ -90,11 +94,11 @@
     }
 
     /**
-     * Returns the path of the underlaying repository item or the item to
+     * Returns the path of the underlying repository item or the item to
      * be created (PUT/MKCOL). If the resource exists but does not represent
      * a repository item <code>null</code> is returned.
      *
-     * @return path of the underlaying repository item.
+     * @return path of the underlying repository item.
      * @see DavResource#getResourcePath()
      * @see org.apache.jackrabbit.webdav.DavResourceLocator#getResourcePath()
      */
@@ -134,10 +138,60 @@
      * Returns <code>null</code>
      *
      * @return Always returns <code>null</code>
-     * @see org.apache.jackrabbit.webdav.DavResource#getStream()
      */
-    public InputStream getStream() {
+    InputStream getStream() {
         return null;
+    }
+
+    /**
+     * @see DavResource#spool(OutputContext)
+     */
+    public void spool(OutputContext outputContext) throws IOException {
+        if (!initedProps) {
+            initProperties();
+        }
+
+        // export properties
+        outputContext.setModificationTime(getModificationTime());
+        DavProperty etag = getProperty(DavPropertyName.GETETAG);
+        if (etag != null) {
+            outputContext.setETag(String.valueOf(etag.getValue()));
+        }
+        DavProperty contentType = getProperty(DavPropertyName.GETCONTENTTYPE);
+        if (contentType != null) {
+            outputContext.setContentType(String.valueOf(contentType.getValue()));
+        }
+        DavProperty contentLength = getProperty(DavPropertyName.GETCONTENTLENGTH);
+        if (contentLength != null) {
+            try {
+                long length = Long.parseLong(contentLength.getValue() + "");
+                if (length > 0) {
+                    outputContext.setContentLength(length);
+                }
+            } catch (NumberFormatException e) {
+                log.error("Could not build content length from property value '" + contentLength.getValue() + "'");
+            }
+        }
+        DavProperty contentLanguage = getProperty(DavPropertyName.GETCONTENTLANGUAGE);
+        if (contentLanguage != null) {
+            outputContext.setContentLanguage(contentLanguage.getValue().toString());
+        }
+
+        // spool content
+        InputStream in = getStream();
+        OutputStream out = outputContext.getOutputStream();
+        if (in != null && out != null) {
+            try {
+                IOUtil.spool(in, out);
+            } finally {
+                // also close stream if not sending content
+                try {
+                    in.close();
+                } catch (IOException e) {
+                    // ignore
+                }
+            }
+        }
     }
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java?rev=331281&r1=331280&r2=331281&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java Mon Nov  7 07:26:33 2005
@@ -42,7 +42,7 @@
 
     private static Logger log = Logger.getLogger(DefaultItemCollection.class);
 
-    private InputStream in;
+    private File content;
 
     /**
      * Create a new <code>DefaultItemCollection</code>.
@@ -93,20 +93,27 @@
 
     /**
      * Returns an {@link java.io.InputStream} to the content of this collection.
-     *
-     * @return
-     * @see org.apache.jackrabbit.webdav.DavResource#getStream()
      */
     public InputStream getStream() {
+        if (!initedProps)  {
         initProperties();
-        return in;
+        }
+        if (content != null) {
+            try {
+                return new FileInputStream(content);
+            } catch (FileNotFoundException e) {
+                // should not occur
+                log.error(e.getMessage());
+            }
+        }
+        return null;
     }
 
     /**
      * This implementation of the <code>DavResource</code> does only allow
      * to set the mixinnodetypes property. Please note that the existing list of
      * mixin nodetypes will be completely replaced.<br>
-     * In order to add / set any other repository property on the underlaying
+     * In order to add / set any other repository property on the underlying
      * {@link javax.jcr.Node} use <code>addMember(DavResource)</code> or
      * <code>addMember(DavResource, InputStream)</code> or modify the value
      * of the corresponding resource.
@@ -263,13 +270,13 @@
      * changed/set to type {@link PropertyType#BINARY binary}.
      *
      * @param resource
-     * @param inputCxt
+     * @param inputContext
      * @throws org.apache.jackrabbit.webdav.DavException
      * @see org.apache.jackrabbit.webdav.DavResource#addMember(org.apache.jackrabbit.webdav.DavResource, InputContext)
      * @see Node#addNode(String)
      * @see Node#setProperty(String, java.io.InputStream)
      */
-    public void addMember(DavResource resource, InputContext inputCxt)
+    public void addMember(DavResource resource, InputContext inputContext)
             throws DavException {
 
         /* RFC 2815 states that all 'parents' must exist in order all addition of members */
@@ -279,12 +286,13 @@
 
         try {
             Node n = (Node) item;
-            InputStream in = (inputCxt != null) ? inputCxt.getInputStream() : null;
+            InputStream in = (inputContext != null) ? inputContext.getInputStream() : null;
             String itemPath = getLocator().getJcrPath();
+            String memberName = getItemName(resource.getLocator().getJcrPath());
             if (resource.isCollection()) {
                 if (in == null) {
                     // MKCOL without a request body, try if a default-primary-type is defined.
-                    n.addNode(getItemName(itemPath));
+                    n.addNode(memberName);
                 } else {
                     // MKCOL, which is not allowed for existing resources
                     if (getTransactionId() == null) {
@@ -305,7 +313,7 @@
                     // TODO: find a way to create non-binary and multivalue properties
                     // PUT : create new or overwrite existing property.
                     // NOTE: will fail for multivalue properties.
-                    n.setProperty(getItemName(itemPath), in);
+                    n.setProperty(memberName, in);
                 }
             }
             complete();
@@ -320,15 +328,6 @@
     }
 
     /**
-     * @see org.apache.jackrabbit.webdav.DavResource#addMember(org.apache.jackrabbit.webdav.DavResource)
-     */
-    public void addMember(DavResource resource) throws DavException {
-        InputContext ctx = new InputContext();
-        ctx.setInputStream(resource.getStream());
-        addMember(resource, ctx);
-    }
-
-    /**
      * @see org.apache.jackrabbit.webdav.DavResource#getMembers()
      */
     public DavResourceIterator getMembers() {
@@ -366,7 +365,7 @@
      * resource.
      *
      * @throws DavException if this resource does not exist or if an error occurs
-     * while deleting the underlaying item.
+     * while deleting the underlying item.
      * @see DavResource#removeMember(DavResource)
      * @see javax.jcr.Item#remove()
      */
@@ -418,7 +417,7 @@
      * @param scope
      * @return lock with the specified type and scope is present on this
      * resource or <code>null</code>. NOTE: If retrieving the write lock present
-     * on the underlaying repository item fails, <code>null</code> is return.
+     * on the underlying repository item fails, <code>null</code> is return.
      * @see org.apache.jackrabbit.webdav.DavResource#getLock(org.apache.jackrabbit.webdav.lock.Type, org.apache.jackrabbit.webdav.lock.Scope)
      * @see javax.jcr.Node#getLock() for the write locks.
      */
@@ -449,7 +448,7 @@
     }
 
     /**
-     * Creates a lock on this resource by locking the underlaying
+     * Creates a lock on this resource by locking the underlying
      * {@link javax.jcr.Node node}. Except for the {@link org.apache.jackrabbit.webdav.lock.LockInfo#isDeep()} }
      * all information included in the <code>LockInfo</code> object is ignored.
      * Lock timeout is defined by JCR implementation.
@@ -487,7 +486,7 @@
 
     /**
      * Refreshes the lock on this resource. With this implementation the
-     * {@link javax.jcr.lock lock} present on the underlaying {@link javax.jcr.Node node}
+     * {@link javax.jcr.lock lock} present on the underlying {@link javax.jcr.Node node}
      * is refreshed. The timeout indicated by the <code>LockInfo</code>
      * object is ignored.
      *
@@ -530,7 +529,7 @@
     }
 
     /**
-     * Remove the write lock from this resource by unlocking the underlaying
+     * Remove the write lock from this resource by unlocking the underlying
      * {@link javax.jcr.Node node}.
      *
      * @param lockToken
@@ -573,7 +572,7 @@
     //-----------------------------------------< OrderingResource interface >---
     /**
      * Returns true if this resource exists and the nodetype defining the
-     * underlaying repository node allow to reorder this nodes children.
+     * underlying repository node allow to reorder this nodes children.
      *
      * @return true if {@link #orderMembers(OrderPatch)} can be called on this
      * resource.
@@ -673,7 +672,7 @@
     //--------------------------------------------------------------------------
     /**
      * Extend the general {@link #supportedLock} field by lock entries specific for this
-     * resource: write locks (exclusive or exclusive session-scoped) in case the underlaying
+     * resource: write locks (exclusive or exclusive session-scoped) in case the underlying
      * node has the node type mix:lockable.
      *
      * @see org.apache.jackrabbit.JcrConstants#MIX_LOCKABLE
@@ -719,14 +718,12 @@
             try {
                 String prefix = "_tmp_" + item.getName();
                 // create tmpFile in default system-tmp directory
-                File tmpfile = File.createTempFile(prefix, null, null);
-                tmpfile.deleteOnExit();
-                FileOutputStream out = new FileOutputStream(tmpfile);
+                content = File.createTempFile(prefix, null, null);
+                content.deleteOnExit();
+                FileOutputStream out = new FileOutputStream(content);
                 getSession().getRepositorySession().exportSystemView(item.getPath(), out, false, true);
                 out.close();
-                in = new FileInputStream(tmpfile);
-
-                properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTLENGTH, new Long(tmpfile.length())));
+                properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTLENGTH, new Long(content.length())));
                 properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTTYPE, "text/xml"));
 
             } catch (IOException e) {

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java?rev=331281&r1=331280&r2=331281&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java Mon Nov  7 07:26:33 2005
@@ -60,7 +60,7 @@
     }
 
     /**
-     * In case an underlaying repository {@link Property property} exists the following
+     * In case an underlying repository {@link Property property} exists the following
      * logic is applyed to obtain the stream:<ul>
      * <li>Property is not multivalue: Return the {@link javax.jcr.Value#getStream()
      * stream representation} of the property value.</li>
@@ -69,9 +69,8 @@
      * </ul>
      *
      * @return
-     * @see DavResource#getStream()
      */
-    public InputStream getStream() {
+    InputStream getStream() {
         InputStream in = null;
         if (exists()) {
             try {
@@ -190,16 +189,7 @@
      *
      * @see org.apache.jackrabbit.webdav.DavResource#addMember(org.apache.jackrabbit.webdav.DavResource, InputContext)
      */
-    public void addMember(DavResource resource, InputContext inputCxt) throws DavException {
-        throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED, "Cannot add members to a non-collection resource");
-    }
-
-    /**
-     * Method is not allowed.
-     *
-     * @see DavResource#addMember(DavResource)
-     */
-    public void addMember(DavResource resource) throws DavException {
+    public void addMember(DavResource resource, InputContext inputContext) throws DavException {
         throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED, "Cannot add members to a non-collection resource");
     }
 
@@ -282,7 +272,7 @@
      * value property. Note: if this resource does not exist or if the definition
      * could not be retrieved false is returned.
      *
-     * @return true if the underlaying resource is a multi value property.
+     * @return true if the underlying resource is a multi value property.
      */
     private boolean isMultiple() {
         try {

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java?rev=331281&r1=331280&r2=331281&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java Mon Nov  7 07:26:33 2005
@@ -121,15 +121,7 @@
      * Throws exception: 403 Forbidden.
      * @see DavResource#addMember(DavResource, InputContext)
      */
-    public void addMember(DavResource resource, InputContext inputCxt) throws DavException {
-        throw new DavException(DavServletResponse.SC_FORBIDDEN);
-    }
-
-    /**
-     * Throws exception: 403 Forbidden.
-     * @see DavResource#addMember(org.apache.jackrabbit.webdav.DavResource)
-     */
-    public void addMember(DavResource resource) throws DavException {
+    public void addMember(DavResource resource, InputContext inputContext) throws DavException {
         throw new DavException(DavServletResponse.SC_FORBIDDEN);
     }
 
@@ -189,7 +181,7 @@
     /**
      * Since the root resource does not represent a repository item and therefore
      * is not member of a workspace resource, the workspace href is calculated
-     * from the workspace name retrieved from the underlaying repository session.
+     * from the workspace name retrieved from the underlying repository session.
      *
      * @return workspace href build from workspace name.
      * @see AbstractResource#getWorkspaceHref()

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java?rev=331281&r1=331280&r2=331281&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java Mon Nov  7 07:26:33 2005
@@ -26,7 +26,7 @@
 import java.util.*;
 
 /**
- * <code>RootItemCollection</code> represents the root node of the underlaying
+ * <code>RootItemCollection</code> represents the root node of the underlying
  * repository. However, the display name the name of the workspace is returned
  * the root node is located.
  *
@@ -49,7 +49,7 @@
 
     //----------------------------------------------< DavResource interface >---
     /**
-     * Returns the name of the workspace the underlaying root item forms part of.
+     * Returns the name of the workspace the underlying root item forms part of.
      *
      * @return The workspace name
      * @see org.apache.jackrabbit.webdav.DavResource#getDisplayName()

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java?rev=331281&r1=331280&r2=331281&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java Mon Nov  7 07:26:33 2005
@@ -192,7 +192,7 @@
      * version control, this method has no effect.
      *
      * @throws org.apache.jackrabbit.webdav.DavException if this resource does not
-     * exist yet or if an error occurs while making the underlaying node versionable.
+     * exist yet or if an error occurs while making the underlying node versionable.
      * @see org.apache.jackrabbit.webdav.version.VersionableResource#addVersionControl()
      */
     public void addVersionControl() throws DavException {
@@ -210,7 +210,7 @@
     }
 
     /**
-     * Calls {@link javax.jcr.Node#checkin()} on the underlaying repository node.
+     * Calls {@link javax.jcr.Node#checkin()} on the underlying repository node.
      *
      * @throws org.apache.jackrabbit.webdav.DavException
      * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#checkin()
@@ -233,7 +233,7 @@
     }
 
     /**
-     * Calls {@link javax.jcr.Node#checkout()} on the underlaying repository node.
+     * Calls {@link javax.jcr.Node#checkout()} on the underlying repository node.
      *
      * @throws org.apache.jackrabbit.webdav.DavException
      * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#checkout()



Mime
View raw message