com.zipxap.vfs
Class VFSRepository

java.lang.Object
  extended by com.zipxap.vfs.VFSRepository

public class VFSRepository
extends java.lang.Object

This class represents the Virtual-File-System equivalent of a java.io.File being used as a directory. The virtual file system is different from the underlying java API in that a java.io.File can represent both a file and a directory. In the VFS, a VFSFile can only represent a file, and a VFSRepository can only represent a directory. The VFSRepository is analogous to a java.io.File being used as a directory.

MilestoneWhoDate, Time
Initial VersionK PenroseJune 2009

** Note that this table is not intended as an exhaustive list of subtle changes. It is intended to list changes that break the compatibility of older code, or major enhancements/rewrites


Method Summary
 java.util.List<java.lang.String> addRecursive(java.io.File file, boolean overwriteExisting)
          This method adds the file/directory (recursively) to the Document Manager, creating Documents/Repositories as appropriate.
 boolean containsFile(java.lang.String filePath)
          Determine if this repository contains a document with the specified path.
 VFSRepository createRepository(java.lang.String repositoryName)
          Create a repository with the specified name
 VFSRepository createRepository(java.lang.String repositoryName, boolean createRecursive)
          Create a repository with the specified name or (if createRecursive is true), path.
 void delete()
          Delete this repository.
 void deleteAll()
          Deletes this repository and all documents and repositories it contains, recursively, including deletion of all associated history items.
 void deleteFile(java.lang.String fileName)
          Deletes the file with the specified name.
 void deleteFile(VFSFile file)
          Delete the specified file from the repository.
 ValuePair<java.lang.Integer,java.lang.Integer> extractToFileSystemInternal(java.io.File outputDirectory, boolean recursive)
          Be careful because this method overwrites existing files if they are there.
 long getCreated()
           
 java.lang.String getCreatedId()
           
 VFSFile getFile(java.lang.String filePath)
          Retrieve the file with the specified name.
 int getFileCount()
           
 VFSFile[] getFiles()
           
 long getLastModified()
           
 java.lang.String getLastModifiedId()
           
 java.lang.String getName()
           
 java.io.OutputStream getOutputStream(java.lang.String fileName)
          Retrieve the OutputStream of the VFSFile associated with the specified fileName.
 java.io.OutputStream getOutputStream(java.lang.String fileName, boolean overwriteExisting)
          Retrieve the OutputStream of the VFSFile associated with the specified fileName.
 java.lang.String getOwnerId()
           
 VFSRepository getParent()
           
 java.lang.String getPath()
           
 VFSRepository[] getRepositories()
           
 VFSRepository getRepository(int repositoryIdx)
           
 VFSRepository getRepository(java.lang.String repositoryPath)
          Get the VFSRepository at the specified path.
 int getRepositoryCount()
           
 Entry getUnderlyingEntry()
           
 VirtualFileSystem getVirtualFileSystem()
           
 boolean isFileCollisionUponExtract(java.io.File outputDirectory, boolean recursive)
          Determine if performing an extractToFileSystem() will cause files to be overwritten in the specified output directory.
 void move(VFSRepository newParent)
          Move this repository to the specified parent repository.
 void moveFile(VFSFile file, VFSRepository newParent)
          Move this repository to the specified parent repository.
 void registerChildFile(VFSFile file)
          This should not be called by users of this API.
 void registerChildRepository(VFSRepository rep)
          This should not be called by users of this API.
 void rename(java.lang.String newName)
          Rename this repository to the specified newName.
 VFSFile saveFile(java.lang.String fileName, byte[] content)
          Save a file to this repository.
 VFSFile saveFile(java.lang.String fileName, byte[] content, boolean overwriteExisting)
          Save a file to this repository.
 VFSFile saveFile(java.lang.String fileName, java.io.File fileSystemFile)
          Save the contents of the specified fileSystemFile to this repository using the specified fileName.
 VFSFile saveFile(java.lang.String fileName, java.io.File fileSystemFile, boolean overwriteExisting)
          Save the contents of the specified fileSystemFile to this repository using the specified fileName.
 VFSFile saveFile(java.lang.String fileName, java.io.InputStream inputStream)
          Save the contents of the specified inputStream to this repository using the specified fileName.
 VFSFile saveFile(java.lang.String fileName, java.io.InputStream inputStream, boolean overwriteExisting)
          Save the contents of the specified inputStream to this repository using the specified fileName.
 VFSFile saveFile(java.lang.String filename, java.util.List<java.lang.Object> beansToSerialize)
          This method performs bean serialization using the JavabeanSerializer
 VFSFile saveFile(java.lang.String fileName, java.io.Reader reader)
          Save the contents of the specified Reader to this repository using the specified fileName.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFiles

public VFSFile[] getFiles()
Returns:
The files contained by this repository.

getVirtualFileSystem

public VirtualFileSystem getVirtualFileSystem()
Returns:
the underlying virtual file system that owns this repository

getPath

public java.lang.String getPath()
Returns:
the path of this repository, with '/' separators.

getName

public java.lang.String getName()
Returns:
the name of this repository

saveFile

public VFSFile saveFile(java.lang.String fileName,
                        byte[] content)
Save a file to this repository. This method will not overwrite an existing file

Parameters:
fileName - The name of the document, with no path information
Returns:
the newly created file
Throws:
UCException - if the specified fileName contains path information ('/'), or if the fileName does not represent a valid file, or if a file already exists in this repository with the specified fileName.

saveFile

public VFSFile saveFile(java.lang.String fileName,
                        byte[] content,
                        boolean overwriteExisting)
Save a file to this repository.

Parameters:
fileName - The name of the document, with no path information
Returns:
the newly created file (or updated existing file if this is an overwrite)
Throws:
UCException - if the specified fileName contains path information ('/'), or if the fileName does not represent a valid file, or if a file already exists in this repository with the specified fileName and the overwriteExisting argument was set to False.

saveFile

public VFSFile saveFile(java.lang.String fileName,
                        java.io.File fileSystemFile)
Save the contents of the specified fileSystemFile to this repository using the specified fileName. This method will not overwrite an existing file.

Parameters:
fileName - The name of the document, with no path information
Returns:
the newly created file
Throws:
UCException - if the specified fileName contains path information ('/'), or if the fileName does not represent a valid file, or if a file already exists in this repository with the specified fileName.

saveFile

public VFSFile saveFile(java.lang.String fileName,
                        java.io.File fileSystemFile,
                        boolean overwriteExisting)
Save the contents of the specified fileSystemFile to this repository using the specified fileName.

Parameters:
fileName - The name of the document, with no path information
Returns:
the newly created file (or updated existing file if this is an overwrite)
Throws:
UCException - if the specified fileName contains path information ('/'), or if the fileName does not represent a valid file, or if a file already exists in this repository with the specified fileName and the overwriteExisting argument was set to False.

saveFile

public VFSFile saveFile(java.lang.String fileName,
                        java.io.InputStream inputStream)
Save the contents of the specified inputStream to this repository using the specified fileName. This method will not overwrite an existing file.

Parameters:
fileName - The name of the document, with no path information
inputStream -
Returns:
the newly created file
Throws:
UCException - if the specified fileName contains path information ('/'), or if the fileName does not represent a valid file, or if a file already exists in this repository with the specified fileName.

saveFile

public VFSFile saveFile(java.lang.String fileName,
                        java.io.InputStream inputStream,
                        boolean overwriteExisting)
Save the contents of the specified inputStream to this repository using the specified fileName.

Parameters:
fileName - The name of the document, with no path information
inputStream -
Returns:
the newly created file (or updated existing file if this is an overwrite)
Throws:
UCException - if the specified fileName contains path information ('/'), or if the fileName does not represent a valid file, or if a file already exists in this repository with the specified fileName and the overwriteExisting argument was set to False.

getOutputStream

public java.io.OutputStream getOutputStream(java.lang.String fileName)
Retrieve the OutputStream of the VFSFile associated with the specified fileName. This method is used to create a new VFSFile and will not overwrite the content of an existing file.

Parameters:
fileName -
Returns:
the OutputStream of the VFSFile associated with the specified fileName
Throws:
UCException - if the specified fileName contains path information ('/'), or if the fileName does not represent a valid file, or if a file already exists in this repository with the specified fileName and the overwriteExisting argument was set to False.

getOutputStream

public java.io.OutputStream getOutputStream(java.lang.String fileName,
                                            boolean overwriteExisting)
Retrieve the OutputStream of the VFSFile associated with the specified fileName.

Parameters:
fileName -
overwriteExisting -
Returns:
the OutputStream of the VFSFile associated with the specified fileName.
Throws:
UCException - if the specified fileName contains path information ('/'), or if the fileName does not represent a valid file, or if a file already exists in this repository with the specified fileName and the overwriteExisting argument was set to False.

saveFile

public VFSFile saveFile(java.lang.String fileName,
                        java.io.Reader reader)
Save the contents of the specified Reader to this repository using the specified fileName. This method will not overwrite an existing file.

Parameters:
fileName - The name of the document, with no path information
reader -
Returns:
the newly created file
Throws:
UCException - if the specified fileName contains path information ('/'), or if the fileName does not represent a valid file, or if a file already exists in this repository with the specified fileName.

saveFile

public VFSFile saveFile(java.lang.String filename,
                        java.util.List<java.lang.Object> beansToSerialize)
This method performs bean serialization using the JavabeanSerializer

Parameters:
filename -
beans -
Returns:
the newly created file

addRecursive

public java.util.List<java.lang.String> addRecursive(java.io.File file,
                                                     boolean overwriteExisting)
This method adds the file/directory (recursively) to the Document Manager, creating Documents/Repositories as appropriate. If the document already exists, this method compares the content of the Document to the content of the file, and creates a new version if necessary, or ignores if the content are the same.

Parameters:
file -
Returns:
User Messages

containsFile

public boolean containsFile(java.lang.String filePath)
Determine if this repository contains a document with the specified path.

Parameters:
filePath - The name of the document, with or without relative or absolute path information.
Returns:
true if this repository contains a document with the specified path

createRepository

public VFSRepository createRepository(java.lang.String repositoryName)
Create a repository with the specified name

Parameters:
repositoryName -
Returns:
The newly created repository.

createRepository

public VFSRepository createRepository(java.lang.String repositoryName,
                                      boolean createRecursive)
Create a repository with the specified name or (if createRecursive is true), path.

Parameters:
repositoryName -
createRecursive - If set to true, then path separator ('/') is valid, and will be used to create sub-repositories.
Returns:
the newly created repository

delete

public void delete()
Delete this repository.

Throws:
UCException - if this repository contains any files or sub-repositories.

deleteAll

public void deleteAll()
Deletes this repository and all documents and repositories it contains, recursively, including deletion of all associated history items.


deleteFile

public void deleteFile(java.lang.String fileName)
Deletes the file with the specified name.

Parameters:
fileName -

deleteFile

public void deleteFile(VFSFile file)
Delete the specified file from the repository. This method does nothing if the repository does not contain the specified file.

Parameters:
file -

extractToFileSystemInternal

public ValuePair<java.lang.Integer,java.lang.Integer> extractToFileSystemInternal(java.io.File outputDirectory,
                                                                                  boolean recursive)
Be careful because this method overwrites existing files if they are there.

Parameters:
outputDirectory -
recursive - Specifies whether or not to extract repositories recursively.
Returns:
A value pair containing the number of files and directories extracted, respectively

getFile

public VFSFile getFile(java.lang.String filePath)
Retrieve the file with the specified name.

Parameters:
filePath - The name of the document, with or without relative or absolute path information. Example: /myrepository/mysubrepository/mydocument.txt
Returns:
The Document for the specified filePath, or null if no file exists at that path.

getFileCount

public int getFileCount()
Returns:
the number of files contained by this repository

getRepositories

public VFSRepository[] getRepositories()
Returns:
the child repositories (sub-repositories)

getRepository

public VFSRepository getRepository(java.lang.String repositoryPath)
Get the VFSRepository at the specified path.

Parameters:
repositoryPath -
Returns:
The VFSRepository for the specified repositoryPath, or null if it could not be found.

getRepositoryCount

public int getRepositoryCount()
Returns:
the number of sub-repositories contained by this repository

isFileCollisionUponExtract

public boolean isFileCollisionUponExtract(java.io.File outputDirectory,
                                          boolean recursive)
Determine if performing an extractToFileSystem() will cause files to be overwritten in the specified output directory.

Parameters:
outputDirectory -
Returns:
true if performing an extractToFileSystem() will cause files to be overwritten in the specified output directory, else false

move

public void move(VFSRepository newParent)
Move this repository to the specified parent repository.

Parameters:
newParent -

moveFile

public void moveFile(VFSFile file,
                     VFSRepository newParent)
Move this repository to the specified parent repository.

Parameters:
newParent -

rename

public void rename(java.lang.String newName)
Rename this repository to the specified newName.

Parameters:
newName -

getUnderlyingEntry

public Entry getUnderlyingEntry()
Returns:
the underlying entry which represents this repository

getOwnerId

public java.lang.String getOwnerId()

getCreated

public long getCreated()

getCreatedId

public java.lang.String getCreatedId()

getLastModified

public long getLastModified()

getLastModifiedId

public java.lang.String getLastModifiedId()

getRepository

public VFSRepository getRepository(int repositoryIdx)

registerChildRepository

public void registerChildRepository(VFSRepository rep)
This should not be called by users of this API. It is called by the VFS when the entries are indexed.

Parameters:
rep -

registerChildFile

public void registerChildFile(VFSFile file)
This should not be called by users of this API. It is called by the VFS when the entries are indexed.

Parameters:
file -

getParent

public VFSRepository getParent()
Returns:
the parent repository, if one exists, else null.