You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ad...@apache.org on 2002/10/25 13:07:39 UTC
cvs commit: jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl StandardFileSystemManager.java
adammurdoch 2002/10/25 04:07:39
Modified: vfs/src/java/org/apache/commons/vfs Resources.properties
vfs/src/java/org/apache/commons/vfs/provider
AbstractOriginatingFileProvider.java
AbstractFileSystemProvider.java
vfs/src/java/org/apache/commons/vfs/provider/local
LocalFileSystem.java
vfs/src/java/org/apache/commons/vfs/impl
StandardFileSystemManager.java
Added: vfs/src/java/org/apache/commons/vfs/provider/temp
TemporaryFileProvider.java
Log:
Added a provider for temporary files.
Revision Changes Path
1.8 +5 -2 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/Resources.properties
Index: Resources.properties
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/Resources.properties,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Resources.properties 25 Oct 2002 03:59:09 -0000 1.7
+++ Resources.properties 25 Oct 2002 11:07:39 -0000 1.8
@@ -17,8 +17,8 @@
vfs.provider/delete.error=Could not delete "{0}".
vfs.provider/create-mismatched-type.error=Could not create {0} "{1}" because it already exists and is a {2}.
vfs.provider/create-read-only.error=Could not create {0} "{1}" because the file system is read-only.
-vfs.provider/create-folder.error=Could not create folder "{1}".
-vfs.provider/create-file.error=Could not create file "{1}".
+vfs.provider/create-folder.error=Could not create folder "{0}".
+vfs.provider/create-file.error=Could not create file "{0}".
vfs.provider/write-read-only.error=Could not write to "{0}" because it is read-only.
vfs.provider/write-folder.error=Could not write to "{0}" because it is a folder.
vfs.provider/write-in-use.error=Could not write to "{0}" because it is already in use.
@@ -27,6 +27,8 @@
vfs.provider/copy-read-only.error=Could not copy {0} "{1}" to "{2}" because the destination file is read-only.
vfs.provider/copy-missing-file.error=Could not copy "{0}" because it does not exist.
vfs.provider/find-files.error=Could not find files in "{0}".
+vfs.provider/check-is-writeable.error=Could not determine if file "{0}" is writeable.
+vfs.provider/check-is-readable.error=Could not determine if file "{0}" is readable.
# DefaultFileContent
vfs.provider/get-size-folder.error=Could not determine the size of "{0}" because it is a folder.
@@ -64,6 +66,7 @@
vfs.impl/unknown-provider.error=No file system provider is registered for URI scheme "{0}".
vfs.impl/no-local-file-provider.error=Could not find a file system provider which can handle local files.
vfs.impl/no-replicator.error=No file replicator configured.
+vfs.impl/no-temp-file-store.error=No temporary file store configured.
vfs.impl/replicate-file.error=Could not replicate "{0}".
vfs.impl/delete-temp.warn=Could not clean up temporary file "{0}".
vfs.impl/init-replicator.error=Could not initialise file replicator.
1.5 +1 -11 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java
Index: AbstractOriginatingFileProvider.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractOriginatingFileProvider.java 23 Oct 2002 11:59:40 -0000 1.4
+++ AbstractOriginatingFileProvider.java 25 Oct 2002 11:07:39 -0000 1.5
@@ -71,16 +71,6 @@
extends AbstractFileSystemProvider
{
/**
- * Creates a layered file system.
- */
- public FileObject createFileSystem( final String scheme, final FileObject file )
- throws FileSystemException
- {
- // Can't create a layered file system
- throw new FileSystemException( "vfs.provider/not-layered-fs.error", scheme );
- }
-
- /**
* Locates a file object, by absolute URI.
*
* @param uri
1.10 +11 -0 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileSystemProvider.java
Index: AbstractFileSystemProvider.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileSystemProvider.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AbstractFileSystemProvider.java 23 Oct 2002 11:59:40 -0000 1.9
+++ AbstractFileSystemProvider.java 25 Oct 2002 11:07:39 -0000 1.10
@@ -60,6 +60,7 @@
import java.util.Map;
import org.apache.commons.vfs.FileSystem;
import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileObject;
/**
* A partial {@link FileProvider} implementation. Takes care of managing the
@@ -96,6 +97,16 @@
fileSystems.clear();
}
+ /**
+ * Creates a layered file system.
+ */
+ public FileObject createFileSystem( final String scheme, final FileObject file )
+ throws FileSystemException
+ {
+ // Can't create a layered file system
+ throw new FileSystemException( "vfs.provider/not-layered-fs.error", scheme );
+ }
+
/**
* Adds a file system to those cached by this provider.
*/
1.1 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/temp/TemporaryFileProvider.java
Index: TemporaryFileProvider.java
===================================================================
/* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.vfs.provider.temp;
import java.io.File;
import org.apache.commons.vfs.FileName;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystem;
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.provider.AbstractFileSystemProvider;
import org.apache.commons.vfs.provider.DefaultFileName;
import org.apache.commons.vfs.provider.FileProvider;
import org.apache.commons.vfs.provider.ParsedUri;
import org.apache.commons.vfs.provider.UriParser;
import org.apache.commons.vfs.provider.local.LocalFileSystem;
/**
* A provider for temporary files.
*
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/10/25 11:07:39 $
*/
public class TemporaryFileProvider
extends AbstractFileSystemProvider
implements FileProvider
{
private final UriParser parser = new UriParser();
private File rootFile;
public TemporaryFileProvider( final File rootFile )
{
this.rootFile = rootFile;
}
public TemporaryFileProvider()
{
}
/**
* Locates a file object, by absolute URI.
*/
public FileObject findFile( final FileObject baseFile, final String uri )
throws FileSystemException
{
// Parse the name
final ParsedUri parsedUri = parseUri( uri );
// Create the temp file system
FileSystem filesystem = findFileSystem( this );
if ( filesystem == null )
{
if ( rootFile == null )
{
rootFile = getContext().getTemporaryFileStore().allocateFile( "tempfs" );
}
final FileName rootName = new DefaultFileName( parser, parsedUri.getRootUri(), "/" );
filesystem = new LocalFileSystem( rootName, rootFile.getAbsolutePath() );
addFileSystem( this, filesystem );
}
// Find the file
return filesystem.resolveFile( parsedUri.getPath() );
}
/** Parses an absolute URI into its parts. */
private ParsedUri parseUri( final String uri ) throws FileSystemException
{
final StringBuffer buffer = new StringBuffer( uri );
final ParsedUri parsedUri = new ParsedUri();
final String scheme = parser.extractScheme( uri, buffer );
parsedUri.setScheme( scheme );
parser.decode( buffer, 0, buffer.length() );
parser.normalisePath( buffer );
parsedUri.setPath( buffer.toString() );
parsedUri.setRootUri( scheme + ":" );
return parsedUri;
}
}
1.9 +1 -1 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java
Index: LocalFileSystem.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- LocalFileSystem.java 23 Oct 2002 11:59:41 -0000 1.8
+++ LocalFileSystem.java 25 Oct 2002 11:07:39 -0000 1.9
@@ -67,7 +67,7 @@
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
* @version $Revision$ $Date$
*/
-final class LocalFileSystem
+public final class LocalFileSystem
extends AbstractFileSystem
implements FileSystem
{
1.2 +6 -5 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/StandardFileSystemManager.java
Index: StandardFileSystemManager.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/StandardFileSystemManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StandardFileSystemManager.java 23 Oct 2002 13:12:14 -0000 1.1
+++ StandardFileSystemManager.java 25 Oct 2002 11:07:39 -0000 1.2
@@ -75,10 +75,10 @@
*/
public void init() throws FileSystemException
{
- // Set the replicator
- FileReplicator replicator = new DefaultFileReplicator();
- replicator = new PrivilegedFileReplicator( replicator );
- setReplicator( replicator );
+ // Set the replicator and temporary file store (use the same component)
+ DefaultFileReplicator replicator = new DefaultFileReplicator();
+ setReplicator( new PrivilegedFileReplicator( replicator ) );
+ setTemporaryFileStore( replicator );
// Add the standard providers
addProvider( "file", "org.apache.commons.vfs.provider.local.DefaultLocalFileSystemProvider" );
@@ -86,6 +86,7 @@
addProvider( "jar", "org.apache.commons.vfs.provider.jar.JarFileSystemProvider" );
addProvider( "ftp", "org.apache.commons.vfs.provider.ftp.FtpFileSystemProvider" );
addProvider( "smb", "org.apache.commons.vfs.provider.smb.SmbFileSystemProvider" );
+ addProvider( "tmp", "org.apache.commons.vfs.provider.temp.TemporaryFileProvider" );
// Add a default provider
final FileProvider provider = createProvider( "org.apache.commons.vfs.provider.url.UrlFileProvider" );
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>