com.japisoft.filebrowser
Class FileResourceManager

java.lang.Object
  |
  +--com.japisoft.filebrowser.FileResourceManager
All Implemented Interfaces:
ResourceManager

public class FileResourceManager
extends java.lang.Object
implements ResourceManager

Version:
1.0
Author:
(c) 2004 JAPISoft / http://www.japisoft.com

Constructor Summary
FileResourceManager()
           
FileResourceManager(java.io.File rootPath)
           
 
Method Summary
 void deleteFile(ResourceItem path)
          Delete a file or an empty directory for this path
 byte[] getContent(ResourceItem path)
           
 boolean isConnectionSupported()
           
 boolean isLockSupported()
           
 ResourceItemModel list(ResourceItem item)
          List a directory
 void lock(ResourceItem path, boolean locked)
          Lock this resource located at the path.
 void renameFile(ResourceItem path, java.lang.String newPathName)
          Rename a file name to another one.
 void setContent(ResourceItem path, byte[] content)
          Reset a content located at this path
 java.lang.String start(java.lang.String host, java.lang.String user, java.lang.String password)
          Open a connection to a server or a specific resource.
 void stop()
          Close the current connection
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileResourceManager

public FileResourceManager()

FileResourceManager

public FileResourceManager(java.io.File rootPath)
Method Detail

start

public java.lang.String start(java.lang.String host,
                              java.lang.String user,
                              java.lang.String password)
                       throws ResourceException
Description copied from interface: ResourceManager
Open a connection to a server or a specific resource.

Specified by:
start in interface ResourceManager
Parameters:
host - The Remote server IP location
user - The user account name
password - The user password name
Returns:
The root directory for sample '/'
Throws:
ResourceException - If the connection cannot be opened

deleteFile

public void deleteFile(ResourceItem path)
                throws ResourceException
Description copied from interface: ResourceManager
Delete a file or an empty directory for this path

Specified by:
deleteFile in interface ResourceManager
Parameters:
path - A file or an empty directory location
Throws:
ResourceException - If the file cannot be deleted

getContent

public byte[] getContent(ResourceItem path)
                  throws ResourceException
Specified by:
getContent in interface ResourceManager
Parameters:
path - A location for a file
Returns:
The content of the file located at the path. You may have to specify an encoding like UTF8 for converting it to a java.lang.String
Throws:
ResourceException - If the file cannot be downloaded

stop

public void stop()
Description copied from interface: ResourceManager
Close the current connection

Specified by:
stop in interface ResourceManager

isConnectionSupported

public boolean isConnectionSupported()
Specified by:
isConnectionSupported in interface ResourceManager
Returns:
if an host, user and password is required before browing a content

isLockSupported

public boolean isLockSupported()
Specified by:
isLockSupported in interface ResourceManager
Returns:
true if the file lock if supported

list

public ResourceItemModel list(ResourceItem item)
                       throws ResourceException
Description copied from interface: ResourceManager
List a directory

Specified by:
list in interface ResourceManager
Parameters:
item - A directory
Returns:
a set of ResourceItem inside the ResourceModel
Throws:
ResourceException - If the listing is not possible

lock

public void lock(ResourceItem path,
                 boolean locked)
          throws ResourceException
Description copied from interface: ResourceManager
Lock this resource located at the path. This method will have only effect if the isLockSupported method returns true

Specified by:
lock in interface ResourceManager
Parameters:
path - A file or a directory
locked - true for locking the resource path
Throws:
ResourceException - If the file cannot be locked

renameFile

public void renameFile(ResourceItem path,
                       java.lang.String newPathName)
                throws ResourceException
Description copied from interface: ResourceManager
Rename a file name to another one. Note you must use the specific name syntax

Specified by:
renameFile in interface ResourceManager
Parameters:
path - A file or a directory
newPathName - A new name
Throws:
ResourceException - If the file or the directory cannot be renammed

setContent

public void setContent(ResourceItem path,
                       byte[] content)
                throws ResourceException
Description copied from interface: ResourceManager
Reset a content located at this path

Specified by:
setContent in interface ResourceManager
Parameters:
path - A file location
content - A new content
Throws:
ResourceException - If the file cannot be updated