com.lightdev.app.filemanager.io
Class HttpFileSystem

java.lang.Object
  extended by com.lightdev.app.filemanager.io.HttpFileSystem
All Implemented Interfaces:
FileSystem

public class HttpFileSystem
extends Object
implements FileSystem

A class that implements the Light Development File System as a client to the Light Development HTTP File Server.

Version:
1, 09.09.2008
Author:
Ulrich Hilger, Light Development, http://www.lightdev.com, info@lightdev.com, published under the terms and conditions of the BSD License, for details see file license.txt in the distribution package of this software

Field Summary
static String SERVER_SIDE_FILE_MANAGEMENT_HANDLER_NAME
          the name of the XML-RPC handler on the server side which is to be used for all XML-RPC requests from this class
 
Fields inherited from interface com.lightdev.lib.filesystem.FileSystem
LOCAL_FILE_SYSTEM
 
Constructor Summary
HttpFileSystem(Session session)
          create a new instance of class HttpFileSystem for an existing http connection
 
Method Summary
 void addFileSystemListener(FileSystemListener listener)
           
 boolean copy(FileRef[] filesToCopy, FileRef toFolder)
          copy files to a given folder.
 boolean createFolder(FileRef folder)
          create a new folder
 boolean delete(FileRef[] filesToDelete)
          delete one or more files
 void exportFiles(FileRef[] exportFiles, FileRef targetFolder, FileSystem targetFs)
           
 boolean extract(FileRef archive, FileRef toFolder)
          extract a given ZIP archive to a given folder
 boolean fileExists(FileRef file)
          determine whether or not a given file exists in this instance of file system
protected  void fireContentChanged(FileSystemEvent event)
           
 String getFileSeparator()
          get the string that is used to separate file and folder names in path expressions for the machine this file system refers to
 double getFolderSize(FileRef folder)
          determine the size of a folder in bytes
 FileRef getParentFile(FileRef file)
          get the file that is directly on top of a given file in the file hierarchy of this file system
 FileRef[] getRoots()
          get the root directories of this file system
 String getSessionId()
           
 double getSize(FileRef[] files)
           
 String getUrl()
          get the url string of the machine this file system is located
 void importFiles(FileRef[] sourceFiles, FileRef importFolder, FileSystem sourceFs)
          import from a given file system to this file system
 FileRef[] list(FileRef folder)
          get the files that are contained in a given folder
 boolean move(FileRef[] filesToMove, FileRef toFolder)
          move one or more files to a given folder.
 boolean pack(FileRef folder, FileRef archive)
          pack the contents of a given folder into a new ZIP compressed archive
 byte[] read(FileRef file)
          read contents of a file
 void removeFileSystemListener(FileSystemListener listener)
           
 FileRef rename(FileRef file, String newName)
          rename a file, i.e. change the name of a file but not its location
 boolean write(FileRef file, byte[] contents)
          write contents of a file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVER_SIDE_FILE_MANAGEMENT_HANDLER_NAME

public static String SERVER_SIDE_FILE_MANAGEMENT_HANDLER_NAME
the name of the XML-RPC handler on the server side which is to be used for all XML-RPC requests from this class

Constructor Detail

HttpFileSystem

public HttpFileSystem(Session session)
create a new instance of class HttpFileSystem for an existing http connection

Parameters:
session - the session to use for remote communication
Method Detail

list

public FileRef[] list(FileRef folder)
               throws Exception
get the files that are contained in a given folder

Specified by:
list in interface FileSystem
Parameters:
folder - the directory to get the files for
Returns:
the list of files contained in the given directory
Throws:
Throwable
Exception

getFileSeparator

public String getFileSeparator()
                        throws Exception
get the string that is used to separate file and folder names in path expressions for the machine this file system refers to

Specified by:
getFileSeparator in interface FileSystem
Returns:
the separator string
Throws:
Throwable
Exception

getParentFile

public FileRef getParentFile(FileRef file)
                      throws Exception
get the file that is directly on top of a given file in the file hierarchy of this file system

Specified by:
getParentFile in interface FileSystem
Parameters:
file - the file to get the parent file for
Returns:
the parent file
Throws:
Throwable
Exception

getRoots

public FileRef[] getRoots()
                   throws Exception
get the root directories of this file system

Specified by:
getRoots in interface FileSystem
Returns:
the root directories of this file system
Throws:
Throwable
Exception

copy

public boolean copy(FileRef[] filesToCopy,
                    FileRef toFolder)
             throws Exception
copy files to a given folder.

Specified by:
copy in interface FileSystem
Parameters:
filesToCopy - the files to copy
toFolder - the directory to copy to
Throws:
Throwable
Exception

importFiles

public void importFiles(FileRef[] sourceFiles,
                        FileRef importFolder,
                        FileSystem sourceFs)
                 throws Throwable
import from a given file system to this file system

Specified by:
importFiles in interface FileSystem
Parameters:
sourceFiles - references to the files in the source file system that are to be imported
importFolder - folder of this file system to import to
sourceFs - the file system to import from
Throws:
Throwable

exportFiles

public void exportFiles(FileRef[] exportFiles,
                        FileRef targetFolder,
                        FileSystem targetFs)
                 throws Throwable
Specified by:
exportFiles in interface FileSystem
Throws:
Throwable

rename

public FileRef rename(FileRef file,
                      String newName)
               throws Exception
rename a file, i.e. change the name of a file but not its location

Specified by:
rename in interface FileSystem
Parameters:
file - the file to rename
newName - the new name; just the name, no path
Throws:
Throwable
Exception

delete

public boolean delete(FileRef[] filesToDelete)
               throws Exception
delete one or more files

Specified by:
delete in interface FileSystem
Parameters:
filesToDelete - the list of files to delete
Throws:
Throwable
Exception

extract

public boolean extract(FileRef archive,
                       FileRef toFolder)
                throws Exception
extract a given ZIP archive to a given folder

Specified by:
extract in interface FileSystem
Parameters:
archive - the archive to extract
toFolder - the folder to extract the contents of the archive to
Throws:
Throwable
Exception

move

public boolean move(FileRef[] filesToMove,
                    FileRef toFolder)
             throws Exception
move one or more files to a given folder.

Specified by:
move in interface FileSystem
Parameters:
filesToMove - the files to move
toFolder - the folder to move to
Throws:
Throwable
Exception

pack

public boolean pack(FileRef folder,
                    FileRef archive)
             throws Exception
pack the contents of a given folder into a new ZIP compressed archive

Specified by:
pack in interface FileSystem
Parameters:
folder - the folder to pack
archive - the archive to create from the given files
Throws:
Throwable
Exception

createFolder

public boolean createFolder(FileRef folder)
                     throws Exception
create a new folder

Specified by:
createFolder in interface FileSystem
Parameters:
folder - the folder to create
Throws:
Throwable
Exception

fileExists

public boolean fileExists(FileRef file)
                   throws Exception
determine whether or not a given file exists in this instance of file system

Specified by:
fileExists in interface FileSystem
Parameters:
file - the file to determine existence for
Returns:
true if the given files exists in this instance of file system, false if not
Throws:
Throwable
Exception

getSize

public double getSize(FileRef[] files)
               throws Throwable
Specified by:
getSize in interface FileSystem
Throws:
Throwable

getFolderSize

public double getFolderSize(FileRef folder)
                     throws Exception
determine the size of a folder in bytes

Specified by:
getFolderSize in interface FileSystem
Parameters:
folder - the folder to determine the size for
Returns:
the size of the folder in bytes
Throws:
Exception

getUrl

public String getUrl()
              throws Exception
get the url string of the machine this file system is located

Specified by:
getUrl in interface FileSystem
Returns:
url string of machine this file system is located
Throws:
Exception

getSessionId

public String getSessionId()

read

public byte[] read(FileRef file)
            throws Exception
read contents of a file

Specified by:
read in interface FileSystem
Parameters:
file - reference to the file to read
Returns:
the file contents
Throws:
Exception

write

public boolean write(FileRef file,
                     byte[] contents)
              throws Exception
write contents of a file

Specified by:
write in interface FileSystem
Parameters:
file - reference to the file to write
contents - the contents to write to the referenced file
Throws:
Exception

addFileSystemListener

public void addFileSystemListener(FileSystemListener listener)
                           throws Throwable
Specified by:
addFileSystemListener in interface FileSystem
Throws:
Throwable

removeFileSystemListener

public void removeFileSystemListener(FileSystemListener listener)
                              throws Throwable
Specified by:
removeFileSystemListener in interface FileSystem
Throws:
Throwable

fireContentChanged

protected void fireContentChanged(FileSystemEvent event)