Package org.apache.jackrabbit.vfs.ext.fs
Class VFSFileSystem
- java.lang.Object
-
- org.apache.jackrabbit.vfs.ext.fs.VFSFileSystem
-
- All Implemented Interfaces:
FileSystem
public class VFSFileSystem extends Object implements FileSystem
VFS (Commons-VFS) basedFileSystem
implementation.
-
-
Field Summary
-
Fields inherited from interface org.apache.jackrabbit.core.fs.FileSystem
SEPARATOR, SEPARATOR_CHAR
-
-
Constructor Summary
Constructors Constructor Description VFSFileSystem()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the file system.protected org.apache.commons.vfs2.FileSystemManager
createFileSystemManager()
Creates aFileSystemManager
instance.protected org.apache.commons.vfs2.FileSystemOptions
createFileSystemOptions()
Builds and returnsFileSystemOptions
instance which is used when resolving thebaseFolder
during the initialization.void
createFolder(String folderPath)
Creates the folder named by this path, including any necessary but nonexistent parent folders.void
deleteFile(String filePath)
Deletes the file denoted by this path.void
deleteFolder(String folderPath)
Deletes the folder denoted by this path.boolean
equals(Object obj)
boolean
exists(String path)
Tests whether the file system entry denoted by this path exists.String
getConfig()
Return path of configuration properties.org.apache.commons.vfs2.FileSystemManager
getFileSystemManager()
Returns the VFSFileSystemManager
instance used in this VFS file system.String
getFileSystemManagerClassName()
Returns the class name of the VFSFileSystemManager
instance used in this VFS file system.org.apache.commons.vfs2.FileSystemOptions
getFileSystemOptions()
ReturnsFileSystemOptions
instance used when resolving thebaseFolder
.protected Properties
getFileSystemOptionsProperties()
Returns properties used when building aFileSystemOptions
instance by the properties during the initialization.InputStream
getInputStream(String filePath)
Returns an input stream of the contents of the file denoted by this path.OutputStream
getOutputStream(String filePath)
Returns an output stream for writing bytes to the file denoted by this path.boolean
hasChildren(String path)
Tests whether the file system entry denoted by this path has child entries.int
hashCode()
Returns zero to satisfy the Object equals/hashCode contract.void
init()
Initialize the file systemboolean
isFile(String path)
Tests whether the file system entry denoted by this path exists and is a file.boolean
isFolder(String path)
Tests whether the file system entry denoted by this path exists and is a folder.long
lastModified(String path)
Returns the time that the file system entry denoted by this path was last modified.long
length(String filePath)
Returns the length of the file denoted by this path.String[]
list(String folderPath)
Returns an array of strings naming the files and folders in the folder denoted by this path.String[]
listFiles(String folderPath)
Returns an array of strings naming the files in the folder denoted by this path.String[]
listFolders(String folderPath)
Returns an array of strings naming the folders in the folder denoted by this path.void
setBaseFolderUri(String baseFolderUri)
Sets the base VFS folder URI.void
setConfig(String config)
Set the configuration properties path.void
setFileSystemManagerClassName(String fileSystemManagerClassName)
Sets the class name of the VFSFileSystemManager
instance used in this VFS file system.void
setFileSystemOptions(org.apache.commons.vfs2.FileSystemOptions fileSystemOptions)
Sets theFileSystemOptions
instance used when resolving thebaseFolder
.void
setFileSystemOptionsProperties(Properties fileSystemOptionsProperties)
Sets the properties used when building aFileSystemOptions
, usingDelegatingFileSystemOptionsBuilder
.void
setFileSystemOptionsPropertiesInString(String fileSystemOptionsPropertiesInString)
Sets the properties in a semi-colon delimited string used when building aFileSystemOptions
, usingDelegatingFileSystemOptionsBuilder
.
-
-
-
Method Detail
-
getConfig
public String getConfig()
Return path of configuration properties.- Returns:
- path of configuration properties.
-
setConfig
public void setConfig(String config)
Set the configuration properties path.- Parameters:
config
- path of configuration properties.
-
getFileSystemManagerClassName
public String getFileSystemManagerClassName()
Returns the class name of the VFSFileSystemManager
instance used in this VFS file system.- Returns:
-
setFileSystemManagerClassName
public void setFileSystemManagerClassName(String fileSystemManagerClassName)
Sets the class name of the VFSFileSystemManager
instance used in this VFS file system. If this is not set, thenStandardFileSystemManager
is used by default.- Parameters:
fileSystemManagerClassName
-
-
getFileSystemManager
public org.apache.commons.vfs2.FileSystemManager getFileSystemManager()
Returns the VFSFileSystemManager
instance used in this VFS file system.- Returns:
- the VFS
FileSystemManager
instance used in this VFS file system
-
getFileSystemOptions
public org.apache.commons.vfs2.FileSystemOptions getFileSystemOptions() throws FileSystemException
ReturnsFileSystemOptions
instance used when resolving thebaseFolder
. This may return null ifFileSystemOptions
instance was not injected or afileSystemOptionsProperties
instance cannot be injected or created. Therefore, the caller should check whether or not this returns null. When returning null, the caller may not use aFileSystemOptions
instance.- Returns:
FileSystemOptions
instance used when resolving thebaseFolder
- Throws:
FileSystemException
-
setFileSystemOptions
public void setFileSystemOptions(org.apache.commons.vfs2.FileSystemOptions fileSystemOptions)
Sets theFileSystemOptions
instance used when resolving thebaseFolder
.- Parameters:
fileSystemOptions
-FileSystemOptions
instance used when resolving thebaseFolder
-
setFileSystemOptionsProperties
public void setFileSystemOptionsProperties(Properties fileSystemOptionsProperties)
Sets the properties used when building aFileSystemOptions
, usingDelegatingFileSystemOptionsBuilder
.- Parameters:
fileSystemOptionsProperties
- properties used when building aFileSystemOptions
-
setFileSystemOptionsPropertiesInString
public void setFileSystemOptionsPropertiesInString(String fileSystemOptionsPropertiesInString)
Sets the properties in a semi-colon delimited string used when building aFileSystemOptions
, usingDelegatingFileSystemOptionsBuilder
.- Parameters:
fileSystemOptionsPropertiesInString
- properties in String
-
setBaseFolderUri
public void setBaseFolderUri(String baseFolderUri)
Sets the base VFS folder URI.- Parameters:
baseFolderUri
- base VFS folder URI
-
hashCode
public int hashCode()
Returns zero to satisfy the Object equals/hashCode contract. This class is mutable and not meant to be used as a hash key.- Overrides:
hashCode
in classObject
- Returns:
- always zero
- See Also:
Object.hashCode()
-
init
public void init() throws FileSystemException
Description copied from interface:FileSystem
Initialize the file system- Specified by:
init
in interfaceFileSystem
- Throws:
FileSystemException
- if the file system initialization fails
-
close
public void close() throws FileSystemException
Description copied from interface:FileSystem
Close the file system. After calling this method, the file system is no longer accessible.- Specified by:
close
in interfaceFileSystem
- Throws:
FileSystemException
-
createFolder
public void createFolder(String folderPath) throws FileSystemException
Description copied from interface:FileSystem
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.- Specified by:
createFolder
in interfaceFileSystem
- Parameters:
folderPath
- the path of the folder to be created.- Throws:
FileSystemException
- if a file system entry denoted by path already exists or if another error occurs.
-
deleteFile
public void deleteFile(String filePath) throws FileSystemException
Description copied from interface:FileSystem
Deletes the file denoted by this path.- Specified by:
deleteFile
in interfaceFileSystem
- Parameters:
filePath
- the path of the file to be deleted.- Throws:
FileSystemException
- if this path does not denote a file or if another error occurs.
-
deleteFolder
public void deleteFolder(String folderPath) throws FileSystemException
Description copied from interface:FileSystem
Deletes the folder denoted by this path. Any contents of this folder (folders and files) will be deleted recursively.- Specified by:
deleteFolder
in interfaceFileSystem
- Parameters:
folderPath
- the path of the folder to be deleted.- Throws:
FileSystemException
- if this path does not denote a folder or if another error occurs.
-
exists
public boolean exists(String path) throws FileSystemException
Description copied from interface:FileSystem
Tests whether the file system entry denoted by this path exists.- Specified by:
exists
in interfaceFileSystem
- Parameters:
path
- the path of a file system entry.- Returns:
- true if the file system entry at path exists; false otherwise.
- Throws:
FileSystemException
-
getInputStream
public InputStream getInputStream(String filePath) throws FileSystemException
Description copied from interface:FileSystem
Returns an input stream of the contents of the file denoted by this path.- Specified by:
getInputStream
in interfaceFileSystem
- Parameters:
filePath
- the path of the file.- Returns:
- an input stream of the contents of the file.
- Throws:
FileSystemException
- if the file does not exist or if it cannot be read from
-
getOutputStream
public OutputStream getOutputStream(String filePath) throws FileSystemException
Description copied from interface:FileSystem
Returns an output stream for writing bytes to the file denoted by this path. The file will be created if it doesn't exist. If the file exists, its contents will be overwritten.- Specified by:
getOutputStream
in interfaceFileSystem
- Parameters:
filePath
- the path of the file.- Returns:
- an output stream for writing bytes to the file.
- Throws:
FileSystemException
- if the file cannot be written to or created
-
hasChildren
public boolean hasChildren(String path) throws FileSystemException
Description copied from interface:FileSystem
Tests whether the file system entry denoted by this path has child entries.- Specified by:
hasChildren
in interfaceFileSystem
- Parameters:
path
- the path of a file system entry.- Returns:
- true if the file system entry at path has child entries; false otherwise.
- Throws:
FileSystemException
-
isFile
public boolean isFile(String path) throws FileSystemException
Description copied from interface:FileSystem
Tests whether the file system entry denoted by this path exists and is a file.- Specified by:
isFile
in interfaceFileSystem
- Parameters:
path
- the path of a file system entry.- Returns:
- true if the file system entry at path is a file; false otherwise.
- Throws:
FileSystemException
-
isFolder
public boolean isFolder(String path) throws FileSystemException
Description copied from interface:FileSystem
Tests whether the file system entry denoted by this path exists and is a folder.- Specified by:
isFolder
in interfaceFileSystem
- Parameters:
path
- the path of a file system entry.- Returns:
- true if the file system entry at path is a folder; false otherwise.
- Throws:
FileSystemException
-
lastModified
public long lastModified(String path) throws FileSystemException
Description copied from interface:FileSystem
Returns the time that the file system entry denoted by this path was last modified.- Specified by:
lastModified
in interfaceFileSystem
- Parameters:
path
- the path of a file system entry.- Returns:
- A long value representing the time the file system entry was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or 0L if the modification time can't be determined.
- Throws:
FileSystemException
- if the file system entry does not exist.
-
length
public long length(String filePath) throws FileSystemException
Description copied from interface:FileSystem
Returns the length of the file denoted by this path.- Specified by:
length
in interfaceFileSystem
- Parameters:
filePath
- the path of the file.- Returns:
- The length, in bytes, of the file denoted by this path, or -1L if the length can't be determined.
- Throws:
FileSystemException
- if the path does not denote an existing file.
-
list
public String[] list(String folderPath) throws FileSystemException
Description copied from interface:FileSystem
Returns an array of strings naming the files and folders in the folder denoted by this path.- Specified by:
list
in interfaceFileSystem
- Parameters:
folderPath
- the path of the folder whose contents is to be listed.- Returns:
- an array of strings naming the files and folders in the folder denoted by this path.
- Throws:
FileSystemException
- if this path does not denote a folder or if another error occurs.
-
listFiles
public String[] listFiles(String folderPath) throws FileSystemException
Description copied from interface:FileSystem
Returns an array of strings naming the files in the folder denoted by this path.- Specified by:
listFiles
in interfaceFileSystem
- Parameters:
folderPath
- the path of the folder whose contents is to be listed.- Returns:
- an array of strings naming the files in the folder denoted by this path.
- Throws:
FileSystemException
- if this path does not denote a folder or if another error occurs.
-
listFolders
public String[] listFolders(String folderPath) throws FileSystemException
Description copied from interface:FileSystem
Returns an array of strings naming the folders in the folder denoted by this path.- Specified by:
listFolders
in interfaceFileSystem
- Parameters:
folderPath
- the path of the folder whose contents is to be listed.- Returns:
- an array of strings naming the folders in the folder denoted by this path.
- Throws:
FileSystemException
- if this path does not denote a folder or if another error occurs.
-
createFileSystemManager
protected org.apache.commons.vfs2.FileSystemManager createFileSystemManager() throws FileSystemException
Creates aFileSystemManager
instance.- Returns:
- a
FileSystemManager
instance. - Throws:
FileSystemException
- if an error occurs creating the manager.
-
createFileSystemOptions
protected org.apache.commons.vfs2.FileSystemOptions createFileSystemOptions() throws FileSystemException
Builds and returnsFileSystemOptions
instance which is used when resolving thebaseFolder
during the initialization. IffileSystemOptionsProperties
is available, this scans all the property key names starting withFILE_SYSTEM_OPTIONS_PROP_PREFIX
and uses the rest of the key name after theFILE_SYSTEM_OPTIONS_PROP_PREFIX
as the combination of scheme and property name when building aFileSystemOptions
usingDelegatingFileSystemOptionsBuilder
.- Returns:
FileSystemOptions
instance which is used when resolving thebaseFolder
during the initialization- Throws:
FileSystemException
- if any file system exception occurs
-
getFileSystemOptionsProperties
protected Properties getFileSystemOptionsProperties()
Returns properties used when building aFileSystemOptions
instance by the properties during the initialization.- Returns:
- properties used when building a
FileSystemOptions
instance by the properties during the initialization
-
-