jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r802677 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/fs/ main/java/org/apache/jackrabbit/core/fs/db/ main/java/org/apache/jackrabbit/core/fs/local/ main/java/org/apache/jackrabbit/core/fs/mem/ test/java/o...
Date Mon, 10 Aug 2009 07:40:01 GMT
Author: thomasm
Date: Mon Aug 10 07:40:01 2009
New Revision: 802677

URL: http://svn.apache.org/viewvc?rev=802677&view=rev
Log:
JCR-2246 Deprecate/remove unused FileSystem features

Removed:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/RAFOutputStream.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/BasedFileSystem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystemResource.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/RandomAccessOutputStream.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystemEntry.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/AbstractFileSystemTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/BasedFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/BasedFileSystem.java?rev=802677&r1=802676&r2=802677&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/BasedFileSystem.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/BasedFileSystem.java
Mon Aug 10 07:40:01 2009
@@ -89,13 +89,6 @@
     /**
      * {@inheritDoc}
      */
-    public void copy(String srcPath, String destPath) throws FileSystemException {
-        fsBase.copy(buildBasePath(srcPath), buildBasePath(destPath));
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public void createFolder(String folderPath) throws FileSystemException {
         fsBase.createFolder(buildBasePath(folderPath));
     }
@@ -138,14 +131,6 @@
     /**
      * {@inheritDoc}
      */
-    public RandomAccessOutputStream getRandomAccessOutputStream(String filePath)
-            throws FileSystemException {
-        return fsBase.getRandomAccessOutputStream(buildBasePath(filePath));
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public boolean hasChildren(String path) throws FileSystemException {
         return fsBase.hasChildren(buildBasePath(path));
     }
@@ -181,13 +166,6 @@
     /**
      * {@inheritDoc}
      */
-    public void touch(String filePath) throws FileSystemException {
-        fsBase.touch(buildBasePath(filePath));
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public String[] list(String folderPath) throws FileSystemException {
         return fsBase.list(buildBasePath(folderPath));
     }
@@ -205,11 +183,4 @@
     public String[] listFolders(String folderPath) throws FileSystemException {
         return fsBase.listFolders(buildBasePath(folderPath));
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void move(String srcPath, String destPath) throws FileSystemException {
-        fsBase.move(buildBasePath(srcPath), buildBasePath(destPath));
-    }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystem.java?rev=802677&r1=802676&r2=802677&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystem.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystem.java
Mon Aug 10 07:40:01 2009
@@ -77,23 +77,6 @@
     OutputStream getOutputStream(String filePath) throws FileSystemException;
 
     /**
-     * Returns an output stream for writing bytes to the file denoted by this path.
-     * The file will be created if it doesn't exist. The current position of the
-     * file pointer is set to <code>0</code>. See also
-     * {@link RandomAccessOutputStream#seek(long)};
-     *
-     * @param filePath the path of the file.
-     * @return an random access output stream for writing bytes to the file.
-     * @throws FileSystemException           if the file could not be created or
-     *                                       if the output stream cannot be obtained.
-     * @throws UnsupportedOperationException if the implementation does
-     *                                       not support file access through a
-     *                                      {@link RandomAccessOutputStream}.
-     */
-    RandomAccessOutputStream getRandomAccessOutputStream(String filePath)
-            throws FileSystemException, UnsupportedOperationException;
-
-    /**
      * Creates the folder named by this path, including any necessary but
      * nonexistent parent folders. Note that if this operation fails it
      * may have succeeded in creating some of the necessary parent folders.
@@ -166,14 +149,6 @@
     long lastModified(String path) throws FileSystemException;
 
     /**
-     * Set the modified time of an existing file to now.
-     *
-     * @param filePath the path of the file.
-     * @throws FileSystemException if the path does not denote an existing file.
-     */
-    void touch(String filePath) throws FileSystemException;
-
-    /**
      * Returns an array of strings naming the files and folders
      * in the folder denoted by this path.
      *
@@ -228,22 +203,4 @@
      */
     void deleteFolder(String folderPath) throws FileSystemException;
 
-    /**
-     * Moves a file or folder to a new location.
-     *
-     * @param srcPath  the path of the file or folder to be moved.
-     * @param destPath the destination path to which the file or folder is to be moved.
-     * @throws FileSystemException if the move fails
-     */
-    void move(String srcPath, String destPath) throws FileSystemException;
-
-    /**
-     * Copies a file or folder to a new location.
-     *
-     * @param srcPath  the path of the file or folder to be copied.
-     * @param destPath the destination path to which the file or folder is to be copied.
-     * @throws FileSystemException if the copy fails
-     */
-    void copy(String srcPath, String destPath) throws FileSystemException;
-
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystemResource.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystemResource.java?rev=802677&r1=802676&r2=802677&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystemResource.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystemResource.java
Mon Aug 10 07:40:01 2009
@@ -175,14 +175,6 @@
     }
 
     /**
-     * @see FileSystem#getRandomAccessOutputStream
-     */
-    public RandomAccessOutputStream getRandomAccessOutputStream()
-            throws FileSystemException {
-        return fs.getRandomAccessOutputStream(path);
-    }
-
-    /**
      * @see FileSystem#lastModified
      */
     public long lastModified() throws FileSystemException {
@@ -196,20 +188,6 @@
         return fs.length(path);
     }
 
-    /**
-     * @see FileSystem#touch
-     */
-    public void touch() throws FileSystemException {
-        fs.touch(path);
-    }
-
-    /**
-     * @see FileSystem#move
-     */
-    public void move(String destPath) throws FileSystemException {
-        fs.move(path, destPath);
-    }
-
     //-------------------------------------------< java.lang.Object overrides >
     /**
      * Returns the path string of this resource. This is just the

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/RandomAccessOutputStream.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/RandomAccessOutputStream.java?rev=802677&r1=802676&r2=802677&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/RandomAccessOutputStream.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/RandomAccessOutputStream.java
Mon Aug 10 07:40:01 2009
@@ -23,6 +23,8 @@
  * Extends the regular <code>java.io.OutputStream</code> with a random
  * access facility. Multiple <code>write()</code> operations can be
  * positioned off sequence with the {@link #seek} method.
+ *
+ * @deprecated this class should no longer be used
  */
 public abstract class RandomAccessOutputStream extends OutputStream {
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java?rev=802677&r1=802676&r2=802677&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
Mon Aug 10 07:40:01 2009
@@ -20,7 +20,6 @@
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.FileSystemPathUtil;
-import org.apache.jackrabbit.core.fs.RandomAccessOutputStream;
 import org.apache.jackrabbit.util.Text;
 import org.apache.jackrabbit.util.TransientFileFactory;
 import org.slf4j.Logger;
@@ -37,7 +36,6 @@
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.FileInputStream;
-import java.io.RandomAccessFile;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
 import java.sql.PreparedStatement;
@@ -569,7 +567,7 @@
                     }
                     names.add(name);
                 }
-                return (String[]) names.toArray(new String[names.size()]);
+                return names.toArray(new String[names.size()]);
             } catch (SQLException e) {
                 String msg = "failed to list child entries of folder: " + folderPath;
                 log.error(msg, e);
@@ -604,7 +602,7 @@
                 while (rs.next()) {
                     names.add(rs.getString(1));
                 }
-                return (String[]) names.toArray(new String[names.size()]);
+                return names.toArray(new String[names.size()]);
             } catch (SQLException e) {
                 String msg = "failed to list file entries of folder: " + folderPath;
                 log.error(msg, e);
@@ -645,7 +643,7 @@
                     }
                     names.add(name);
                 }
-                return (String[]) names.toArray(new String[names.size()]);
+                return names.toArray(new String[names.size()]);
             } catch (SQLException e) {
                 String msg = "failed to list folder entries of folder: " + folderPath;
                 log.error(msg, e);
@@ -659,39 +657,6 @@
     /**
      * {@inheritDoc}
      */
-    public void touch(String filePath) throws FileSystemException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        FileSystemPathUtil.checkFormat(filePath);
-
-        String parentDir = FileSystemPathUtil.getParentDir(filePath);
-        String name = FileSystemPathUtil.getName(filePath);
-
-        int count = 0;
-        synchronized (updateLastModifiedSQL) {
-            try {
-                Statement stmt = executeStmt(updateLastModifiedSQL, new Object[]{
-                        new Long(System.currentTimeMillis()),
-                        parentDir,
-                        name});
-                count = stmt.getUpdateCount();
-            } catch (SQLException e) {
-                String msg = "failed to touch file: " + filePath;
-                log.error(msg, e);
-                throw new FileSystemException(msg, e);
-            }
-        }
-
-        if (count == 0) {
-            throw new FileSystemException("no such file: " + filePath);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public InputStream getInputStream(String filePath) throws FileSystemException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
@@ -818,163 +783,6 @@
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public RandomAccessOutputStream getRandomAccessOutputStream(final String filePath)
-            throws FileSystemException, UnsupportedOperationException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        FileSystemPathUtil.checkFormat(filePath);
-
-        final String parentDir = FileSystemPathUtil.getParentDir(filePath);
-        final String name = FileSystemPathUtil.getName(filePath);
-
-        if (!isFolder(parentDir)) {
-            throw new FileSystemException("path not found: " + parentDir);
-        }
-
-        if (isFolder(filePath)) {
-            throw new FileSystemException("path denotes folder: " + filePath);
-        }
-
-        try {
-            TransientFileFactory fileFactory = TransientFileFactory.getInstance();
-            final File tmpFile = fileFactory.createTransientFile("bin", null, null);
-
-            // @todo FIXME use java.sql.Blob
-
-            if (isFile(filePath)) {
-                // file entry exists, spool contents to temp file first
-                InputStream in = getInputStream(filePath);
-                OutputStream out = new FileOutputStream(tmpFile);
-                try {
-                    IOUtils.copy(in, out);
-                } finally {
-                    out.close();
-                    in.close();
-                }
-            }
-
-            return new RandomAccessOutputStream() {
-                private final RandomAccessFile raf =
-                    new RandomAccessFile(tmpFile, "rw");
-
-                public void close() throws IOException {
-                    raf.close();
-
-                    InputStream in = null;
-                    try {
-                        if (isFile(filePath)) {
-                            synchronized (updateDataSQL) {
-                                long length = tmpFile.length();
-                                in = new FileInputStream(tmpFile);
-                                executeStmt(updateDataSQL,
-                                        new Object[]{
-                                            new SizedInputStream(in, length),
-                                            new Long(System.currentTimeMillis()),
-                                            new Long(length),
-                                            parentDir,
-                                            name
-                                        });
-                            }
-                        } else {
-                            synchronized (insertFileSQL) {
-                                long length = tmpFile.length();
-                                in = new FileInputStream(tmpFile);
-                                executeStmt(insertFileSQL,
-                                        new Object[]{
-                                            parentDir,
-                                            name,
-                                            new SizedInputStream(in, length),
-                                            new Long(System.currentTimeMillis()),
-                                            new Long(length)
-                                        });
-                            }
-                        }
-
-                    } catch (Exception e) {
-                        IOException ioe = new IOException(e.getMessage());
-                        ioe.initCause(e);
-                        throw ioe;
-                    } finally {
-                        if (in != null) {
-                            in.close();
-                        }
-                        // temp file can now safely be removed
-                        tmpFile.delete();
-                    }
-                }
-
-                public void seek(long position) throws IOException {
-                    raf.seek(position);
-                }
-
-                public void write(int b) throws IOException {
-                    raf.write(b);
-                }
-
-                public void flush() /*throws IOException*/ {
-                    // nop
-                }
-
-                public void write(byte[] b) throws IOException {
-                    raf.write(b);
-                }
-
-                public void write(byte[] b, int off, int len) throws IOException {
-                    raf.write(b, off, len);
-                }
-            };
-        } catch (Exception e) {
-            String msg = "failed to open output stream to file: " + filePath;
-            log.error(msg, e);
-            throw new FileSystemException(msg, e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void copy(String srcPath, String destPath) throws FileSystemException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        FileSystemPathUtil.checkFormat(srcPath);
-        FileSystemPathUtil.checkFormat(destPath);
-
-        if (isFolder(srcPath)) {
-            // src is a folder
-            copyDeepFolder(srcPath, destPath);
-        } else {
-            // src is a file
-            copyFile(srcPath, destPath);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void move(String srcPath, String destPath) throws FileSystemException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        FileSystemPathUtil.checkFormat(srcPath);
-        FileSystemPathUtil.checkFormat(destPath);
-
-        // @todo optimize move (use sql update stmts)
-        copy(srcPath, destPath);
-        if (isFile(srcPath)) {
-            deleteFile(srcPath);
-        } else {
-            deleteFolder(srcPath);
-        }
-    }
-
     //----------------------------------< misc. helper methods & overridables >
 
     /**
@@ -1085,7 +893,7 @@
             throws SQLException {
         int trials = 2;
         while (true) {
-            PreparedStatement stmt = (PreparedStatement) preparedStatements.get(sql);
+            PreparedStatement stmt = preparedStatements.get(sql);
             try {
                 for (int i = 0; i < params.length; i++) {
                     if (params[i] instanceof SizedInputStream) {
@@ -1426,90 +1234,6 @@
     }
 
     /**
-     * Recursively copies the given folder to the given destination.
-     *
-     * @param srcPath folder to be copied
-     * @param destPath destination path to which the folder is to be copied
-     * @throws FileSystemException if an error occurs
-     */
-    protected void copyDeepFolder(String srcPath, String destPath)
-            throws FileSystemException {
-
-        if (!exists(destPath)) {
-            createDeepFolder(destPath);
-        }
-
-        String[] names = listFolders(srcPath);
-
-        for (int i = 0; i < names.length; i++) {
-            String src = (FileSystemPathUtil.denotesRoot(srcPath)
-                    ? srcPath + names[i] : srcPath + FileSystem.SEPARATOR + names[i]);
-            String dest = (FileSystemPathUtil.denotesRoot(destPath)
-                    ? destPath + names[i] : destPath + FileSystem.SEPARATOR + names[i]);
-            copyDeepFolder(src, dest);
-        }
-
-        synchronized (copyFilesSQL) {
-            try {
-                executeStmt(copyFilesSQL, new Object[]{destPath, srcPath});
-            } catch (SQLException e) {
-                String msg = "failed to copy file entries from " + srcPath + " to " + destPath;
-                log.error(msg, e);
-                throw new FileSystemException(msg, e);
-            }
-        }
-    }
-
-    /**
-     * Copies the given file entry to the given destination path. The parent
-     * folder of the destination path will be created if it doesn't exist
-     * already. If the destination path refers to an existing file, the file
-     * will be overwritten.
-     *
-     * @param srcPath file to be copied
-     * @param destPath destination path to which the file is to be copied
-     * @throws FileSystemException if an error occurs
-     */
-    protected void copyFile(String srcPath, String destPath)
-            throws FileSystemException {
-
-        final String srcParentDir = FileSystemPathUtil.getParentDir(srcPath);
-        final String srcName = FileSystemPathUtil.getName(srcPath);
-
-        final String destParentDir = FileSystemPathUtil.getParentDir(destPath);
-        final String destName = FileSystemPathUtil.getName(destPath);
-
-        if (!exists(destParentDir)) {
-            createDeepFolder(destParentDir);
-        }
-        if (isFile(destPath)) {
-            deleteFile(destPath);
-        }
-
-        int count = 0;
-        synchronized (copyFileSQL) {
-            try {
-                Statement stmt = executeStmt(
-                        copyFileSQL,
-                        new Object[]{
-                                destParentDir,
-                                destName,
-                                srcParentDir,
-                                srcName});
-                count = stmt.getUpdateCount();
-            } catch (SQLException e) {
-                String msg = "failed to copy file from " + srcPath + " to " + destPath;
-                log.error(msg, e);
-                throw new FileSystemException(msg, e);
-            }
-        }
-
-        if (count == 0) {
-            throw new FileSystemException("no such file: " + srcPath);
-        }
-    }
-
-    /**
      * Resets the given <code>PreparedStatement</code> by clearing the parameters
      * and warnings contained.
      * <p/>

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java?rev=802677&r1=802676&r2=802677&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java
Mon Aug 10 07:40:01 2009
@@ -21,7 +21,6 @@
 import org.apache.jackrabbit.util.TransientFileFactory;
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.FileSystemPathUtil;
-import org.apache.jackrabbit.core.fs.RandomAccessOutputStream;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -40,7 +39,6 @@
 import java.io.FilterOutputStream;
 import java.io.FileOutputStream;
 import java.io.FileInputStream;
-import java.io.RandomAccessFile;
 import java.lang.reflect.Method;
 
 /**
@@ -426,130 +424,6 @@
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public RandomAccessOutputStream getRandomAccessOutputStream(
-            final String filePath)
-            throws FileSystemException, UnsupportedOperationException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        FileSystemPathUtil.checkFormat(filePath);
-
-        final String parentDir = FileSystemPathUtil.getParentDir(filePath);
-        final String name = FileSystemPathUtil.getName(filePath);
-
-        if (!isFolder(parentDir)) {
-            throw new FileSystemException("path not found: " + parentDir);
-        }
-
-        if (isFolder(filePath)) {
-            throw new FileSystemException("path denotes folder: " + filePath);
-        }
-
-        try {
-            TransientFileFactory fileFactory = TransientFileFactory.getInstance();
-            final File tmpFile = fileFactory.createTransientFile("bin", null, null);
-
-            // @todo FIXME use java.sql.Blob
-
-            if (isFile(filePath)) {
-                // file entry exists, spool contents to temp file first
-                InputStream in = getInputStream(filePath);
-                OutputStream out = new FileOutputStream(tmpFile);
-                try {
-                    IOUtils.copy(in, out);
-                } finally {
-                    out.close();
-                    in.close();
-                }
-            }
-
-            return new RandomAccessOutputStream() {
-                private final RandomAccessFile raf =
-                    new RandomAccessFile(tmpFile, "rw");
-
-                public void close() throws IOException {
-                    raf.close();
-
-                    InputStream in = null;
-                    Blob blob = null;
-                    try {
-                        if (isFile(filePath)) {
-                            synchronized (updateDataSQL) {
-                                long length = tmpFile.length();
-                                in = new FileInputStream(tmpFile);
-                                blob = createTemporaryBlob(in);
-                                executeStmt(updateDataSQL,
-                                        new Object[]{
-                                            blob,
-                                            new Long(System.currentTimeMillis()),
-                                            new Long(length),
-                                            parentDir,
-                                            name
-                                        });
-                            }
-                        } else {
-                            synchronized (insertFileSQL) {
-                                long length = tmpFile.length();
-                                in = new FileInputStream(tmpFile);
-                                blob = createTemporaryBlob(in);
-                                executeStmt(insertFileSQL,
-                                        new Object[]{
-                                            parentDir,
-                                            name,
-                                            blob,
-                                            new Long(System.currentTimeMillis()),
-                                            new Long(length)
-                                        });
-                            }
-                        }
-                    } catch (Exception e) {
-                        IOException ioe = new IOException(e.getMessage());
-                        ioe.initCause(e);
-                        throw ioe;
-                    } finally {
-                        if (blob != null) {
-                            try {
-                                freeTemporaryBlob(blob);
-                            } catch (Exception e1) {
-                            }
-                        }
-                        IOUtils.closeQuietly(in);
-                        // temp file can now safely be removed
-                        tmpFile.delete();
-                    }
-                }
-
-                public void seek(long position) throws IOException {
-                    raf.seek(position);
-                }
-
-                public void write(int b) throws IOException {
-                    raf.write(b);
-                }
-
-                public void flush() /*throws IOException*/ {
-                    // nop
-                }
-
-                public void write(byte[] b) throws IOException {
-                    raf.write(b);
-                }
-
-                public void write(byte[] b, int off, int len) throws IOException {
-                    raf.write(b, off, len);
-                }
-            };
-        } catch (Exception e) {
-            String msg = "failed to open output stream to file: " + filePath;
-            log.error(msg, e);
-            throw new FileSystemException(msg, e);
-        }
-    }
-
     //----------------------------------------< oracle-specific blob handling >
     /**
      * Creates a temporary oracle.sql.BLOB instance via reflection and spools

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java?rev=802677&r1=802676&r2=802677&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java
Mon Aug 10 07:40:01 2009
@@ -18,7 +18,6 @@
 
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
-import org.apache.jackrabbit.core.fs.RandomAccessOutputStream;
 import org.apache.jackrabbit.util.LazyFileInputStream;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -30,7 +29,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.RandomAccessFile;
 
 /**
  * A <code>LocalFileSystem</code> ...
@@ -179,23 +177,6 @@
     /**
      * {@inheritDoc}
      */
-    public void copy(String srcPath, String destPath)
-            throws FileSystemException {
-        File src = new File(root, osPath(srcPath));
-        File dest = new File(root, osPath(destPath));
-        try {
-            FileUtil.copy(src, dest);
-        } catch (IOException ioe) {
-            String msg = "copying " + src.getPath() + " to "
-                    + dest.getPath() + " failed";
-            log.debug(msg);
-            throw new FileSystemException(msg, ioe);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public void createFolder(String folderPath) throws FileSystemException {
         File f = new File(root, osPath(folderPath));
         if (f.exists()) {
@@ -296,21 +277,6 @@
     /**
      * {@inheritDoc}
      */
-    public RandomAccessOutputStream getRandomAccessOutputStream(String filePath)
-            throws FileSystemException {
-        File f = new File(root, osPath(filePath));
-        try {
-            return new RAFOutputStream(new RandomAccessFile(f, "rw"));
-        } catch (IOException e) {
-            String msg = "failed to get output stream for " + f.getPath();
-            log.debug(msg);
-            throw new FileSystemException(msg, e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public boolean hasChildren(String path) throws FileSystemException {
         File f = new File(root, osPath(path));
         if (!f.exists()) {
@@ -362,14 +328,6 @@
     /**
      * {@inheritDoc}
      */
-    public void touch(String filePath) throws FileSystemException {
-        File f = new File(root, osPath(filePath));
-        f.setLastModified(System.currentTimeMillis());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public String[] list(String folderPath) throws FileSystemException {
         File f = new File(root, osPath(folderPath));
         String[] entries = f.list();
@@ -425,42 +383,4 @@
         return entries;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void move(String srcPath, String destPath)
-            throws FileSystemException {
-        File src = new File(root, osPath(srcPath));
-        File dest = new File(root, osPath(destPath));
-
-        if (dest.exists()) {
-            // we need to move the existing file/folder out of the way first
-            try {
-                FileUtil.delete(dest);
-            } catch (IOException ioe) {
-                String msg = "moving " + src.getPath() + " to "
-                        + dest.getPath() + " failed";
-                log.debug(msg);
-                throw new FileSystemException(msg, ioe);
-            }
-        }
-        File destParent = dest.getParentFile();
-        if (!destParent.exists()) {
-            // create destination parent folder first
-            if (!destParent.mkdirs()) {
-                String msg = "moving " + src.getPath() + " to "
-                        + dest.getPath() + " failed";
-                log.debug(msg);
-                throw new FileSystemException(msg);
-            }
-        }
-
-        // now we're ready to move/rename the file/folder
-        if (!src.renameTo(dest)) {
-            String msg = "moving " + src.getPath() + " to "
-                    + dest.getPath() + " failed";
-            log.debug(msg);
-            throw new FileSystemException(msg);
-        }
-    }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java?rev=802677&r1=802676&r2=802677&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
Mon Aug 10 07:40:01 2009
@@ -31,7 +31,6 @@
 import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
-import org.apache.jackrabbit.core.fs.RandomAccessOutputStream;
 
 public class MemoryFileSystem implements FileSystem {
 
@@ -40,20 +39,6 @@
     public void close() {
     }
 
-    public void copy(String srcPath, String destPath)
-            throws FileSystemException {
-        assertExistence(srcPath);
-        MemoryFile srcFile = getFile(srcPath);
-        OutputStream destinationOutputStream = getOutputStream(destPath);
-        try {
-            destinationOutputStream.write(srcFile.getData());
-        } catch (IOException e) {
-            throw new FileSystemException(e.getMessage(), e);
-        } finally {
-            IOUtils.closeQuietly(destinationOutputStream);
-        }
-    }
-
     private MemoryFile getFile(String filePath) throws FileSystemException {
         MemoryFileSystemEntry entry = getEntry(filePath);
         assertIsFile(filePath);
@@ -159,12 +144,6 @@
         };
     }
 
-    public RandomAccessOutputStream getRandomAccessOutputStream(String filePath)
-            throws UnsupportedOperationException {
-        throw new UnsupportedOperationException(
-                "Random access is not implemented for the memory file system");
-    }
-
     public boolean hasChildren(String path) throws FileSystemException {
         assertIsFolder(path);
         return list(path).length > 0;
@@ -243,48 +222,4 @@
         return (String[]) result.toArray(new String[result.size()]);
     }
 
-    public void move(String srcPath, String destPath)
-            throws FileSystemException {
-        assertExistence(srcPath);
-        if (exists(destPath)) {
-            throw new FileSystemException("Destination exists: " + destPath);
-        }
-
-        // Create destination folder if it does not yet exist
-        String[] path = destPath.split(SEPARATOR);
-        String folder = "";
-        for (int i = 1; i < path.length; i++) {
-            folder += SEPARATOR + path[i];
-            if (!exists(folder)) {
-                createFolder(folder);
-            }
-        }
-        
-        Map moves = new HashMap();
-        moves.put(srcPath, destPath);
-        if (getEntry(srcPath).isFolder()) {
-            srcPath = srcPath + "/";
-            Iterator iterator = entries.keySet().iterator();
-            while (iterator.hasNext()) {
-                String name = (String) iterator.next();
-                if (name.startsWith(srcPath)) {
-                    moves.put(
-                            name,
-                            destPath + "/" + name.substring(srcPath.length()));
-                }
-            }
-        }
-
-        Iterator iterator = moves.entrySet().iterator();
-        while (iterator.hasNext()) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            entries.put(entry.getValue(), entries.remove(entry.getKey()));
-        }
-    }
-
-    public void touch(String filePath) throws FileSystemException {
-        assertIsFile(filePath);
-        getEntry(filePath).touch();
-    }
-
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystemEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystemEntry.java?rev=802677&r1=802676&r2=802677&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystemEntry.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystemEntry.java
Mon Aug 10 07:40:01 2009
@@ -30,8 +30,4 @@
         return lastModified;
     }
 
-    public void touch() {
-        this.lastModified = System.currentTimeMillis();
-    }
-
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/AbstractFileSystemTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/AbstractFileSystemTest.java?rev=802677&r1=802676&r2=802677&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/AbstractFileSystemTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/AbstractFileSystemTest.java
Mon Aug 10 07:40:01 2009
@@ -23,6 +23,9 @@
 
 import junit.framework.TestCase;
 
+/**
+ * Tests a file system implementation.
+ */
 public abstract class AbstractFileSystemTest extends TestCase {
 
     private FileSystem fs;
@@ -69,68 +72,6 @@
         assertEquals(3, fs.length("/folder/file"));
         verifyStreamInput(fs.getInputStream("/folder/file"), sampleBytes);
 
-        // Copy the file
-        fs.copy("/folder/file", "/folder/file2");
-        assertTrue(fs.exists("/folder/file"));
-        assertFalse(fs.isFolder("/folder/file"));
-        assertTrue(fs.isFile("/folder/file"));
-        assertTrue(fs.exists("/folder/file2"));
-        assertFalse(fs.isFolder("/folder/file2"));
-        assertTrue(fs.isFile("/folder/file2"));
-        list = fs.list("/folder");
-        Arrays.sort(list);
-        assertEquals(2, list.length);
-        assertEquals("file", list[0]);
-        assertEquals("file2", list[1]);
-        assertEquals(3, fs.length("/folder/file2"));
-        verifyStreamInput(fs.getInputStream("/folder/file2"), sampleBytes);
-
-        // Delete the copy
-        fs.deleteFile("/folder/file2");
-        assertFalse(fs.exists("/folder/file2"));
-        assertFalse(fs.isFolder("/folder/file2"));
-        assertFalse(fs.isFile("/folder/file2"));
-        list = fs.list("/folder");
-        assertEquals(1, list.length);
-        assertEquals("file", list[0]);
-
-        // Move the file
-        fs.move("/folder/file", "/folder/file2");
-        assertFalse(fs.exists("/folder/file"));
-        assertFalse(fs.isFolder("/folder/file"));
-        assertFalse(fs.isFile("/folder/file"));
-        assertTrue(fs.exists("/folder/file2"));
-        assertFalse(fs.isFolder("/folder/file2"));
-        assertTrue(fs.isFile("/folder/file2"));
-        list = fs.list("/folder");
-        assertEquals(1, list.length);
-        assertEquals("file2", list[0]);
-        assertEquals(3, fs.length("/folder/file2"));
-        verifyStreamInput(fs.getInputStream("/folder/file2"), sampleBytes);
-
-        // Move the folder
-        fs.move("/folder", "/folder2");
-        assertFalse(fs.exists("/folder"));
-        assertFalse(fs.isFolder("/folder"));
-        assertFalse(fs.isFile("/folder"));
-        assertTrue(fs.exists("/folder2"));
-        assertTrue(fs.isFolder("/folder2"));
-        assertFalse(fs.isFile("/folder2"));
-        assertFalse(fs.exists("/folder/file2"));
-        assertFalse(fs.isFolder("/folder/file2"));
-        assertFalse(fs.isFile("/folder/file2"));
-        assertTrue(fs.exists("/folder2/file2"));
-        assertFalse(fs.isFolder("/folder2/file2"));
-        assertTrue(fs.isFile("/folder2/file2"));
-        list = fs.list("/");
-        assertEquals(1, list.length);
-        assertEquals("folder2", list[0]);
-        list = fs.list("/folder2");
-        assertEquals(1, list.length);
-        assertEquals("file2", list[0]);
-        assertEquals(3, fs.length("/folder2/file2"));
-        verifyStreamInput(fs.getInputStream("/folder2/file2"), sampleBytes);
-
         // Create a subfolder
         fs.createFolder("/folder2/subfolder");
         assertTrue(fs.exists("/folder2/subfolder"));
@@ -149,7 +90,7 @@
         assertEquals(1, list.length);
         assertEquals("subfolder", list[0]);
 
-        // Try to create a file coliding with an exisiting folder
+        // Try to create a file colliding with an existing folder
         try {
             createFile("/folder2/subfolder", sampleBytes);
             fail("FileSystemException expected");
@@ -185,9 +126,6 @@
         Thread.sleep(100);
         createFile("/file2", sampleBytes);
         assertTrue(fs.lastModified("/file1") <= fs.lastModified("/file2"));
-        Thread.sleep(100);
-        fs.touch("/file1");
-        assertTrue(fs.lastModified("/file1") >= fs.lastModified("/file2"));
 
         // Try to create a file inside a nonexistent folder
         try {
@@ -211,61 +149,6 @@
         assertEquals("subfolder", list[0]);
     }
 
-    public void testMoveFile_destFolderDoesNotExist() throws Exception {
-        // Create a folder with a file
-        fs.createFolder("/folder");
-        createFile("/folder/file", sampleBytes);
-
-        // Check that the destination folder and file do not exist
-        assertFalse(fs.exists("/folder2"));
-        assertFalse(fs.exists("/folder2/file"));
-
-        // Move the file into a non-existent directory
-        fs.move("/folder/file", "/folder2/file");
-
-        // Check that the file has been moved
-        assertFalse(fs.exists("/folder/file"));
-        assertFalse(fs.isFolder("/folder/file"));
-        assertFalse(fs.isFile("/folder/file"));
-        assertTrue(fs.exists("/folder2/file"));
-        assertFalse(fs.isFolder("/folder2/file"));
-        assertTrue(fs.isFile("/folder2/file"));
-
-        // Check that folder2 has been silently created
-        assertTrue(fs.exists("/folder2"));
-        assertTrue(fs.isFolder("/folder2"));
-        assertFalse(fs.isFile("/folder2"));
-    }
-    
-    public void testMoveFolder_destFolderDoesNotExist() throws Exception {
-        // Create a folder with a file
-        fs.createFolder("/folder");
-        createFile("/folder/file", sampleBytes);
-        // Check that the destination folder and file do not exist
-        assertFalse(fs.exists("/folder2"));
-        assertFalse(fs.exists("/folder2/folder3"));
-        assertFalse(fs.exists("/folder2/folder3/file"));
-
-        // Move the folder into a non-existent directory
-        fs.move("/folder", "/folder2/folder3");
-
-        // Assert
-        assertFalse(fs.exists("/folder"));
-        assertFalse(fs.exists("/folder/file"));
-        
-        assertTrue(fs.exists("/folder2"));
-        assertTrue(fs.isFolder("/folder2"));
-        assertFalse(fs.isFile("/folder2"));
-
-        assertTrue(fs.exists("/folder2/folder3"));
-        assertTrue(fs.isFolder("/folder2/folder3"));
-        assertFalse(fs.isFile("/folder2/folder3"));
-
-        assertTrue(fs.exists("/folder2/folder3/file"));
-        assertFalse(fs.isFolder("/folder2/folder3/file"));
-        assertTrue(fs.isFile("/folder2/folder3/file"));
-    }
-
     private void verifyStreamInput(
             InputStream inputStream, byte[] expectedBytes) throws IOException {
         byte[] resultBytes = new byte[3];



Mime
View raw message