com.japisoft.resourcebrowser
Interface ResourceManager

All Known Implementing Classes:
FTPResourceManager, WEBDAVResourceManager, ZIPResourceManager

public interface ResourceManager

This is a common interface for browsing and managing a kind resource. This interface is used by the ResourceBrowserPanel for letting the final user browses the content and acts on this content. A Resource is any remote contents containing directories and files. For sample, if you need to list an FTP server account, you will have to implement or use an class implementing this interface. By default JResourceBrowser supports ZIP/JAR,FTP,WEBDAV

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

Method Summary
 java.lang.String connect(java.lang.String host, java.lang.String user, java.lang.String password)
          Open a connection to a server or a specific resource.
 void deleteFile(ResourceItem path)
          Delete a file or an empty directory for this path
 void disconnect()
          Close the current connection
 byte[] getContent(ResourceItem path)
           
 boolean isConnectionSupported()
           
 boolean isLockSupported()
           
 ResourceItemModel list(ResourceItem path)
          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
 

Method Detail

connect

public java.lang.String connect(java.lang.String host,
                                java.lang.String user,
                                java.lang.String password)
                         throws ResourceException
Open a connection to a server or a specific resource.

Parameters:
host - The Remove 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

disconnect

public void disconnect()
Close the current connection


list

public ResourceItemModel list(ResourceItem path)
                       throws ResourceException
List a directory

Parameters:
path - A directory
Returns:
a set of ResourceItem inside the ResourceModel
Throws:
ResourceException - If the listing is not possible

getContent

public byte[] getContent(ResourceItem path)
                  throws ResourceException
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

setContent

public void setContent(ResourceItem path,
                       byte[] content)
                throws ResourceException
Reset a content located at this path

Parameters:
path - A file location
content - A new content
Throws:
ResourceException - If the file cannot be updated

deleteFile

public void deleteFile(ResourceItem path)
                throws ResourceException
Delete a file or an empty directory for this path

Parameters:
path - A file or an empty directory location
Throws:
ResourceException - If the file cannot be deleted

renameFile

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

Parameters:
path - A file or a directory
newPathName - A new name
Throws:
ResourceException - If the file or the directory cannot be renammed

lock

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

Parameters:
path - A file or a directory
locked - true for locking the resource path
Throws:
ResourceException - If the file cannot be locked

isLockSupported

public boolean isLockSupported()
Returns:
true if the file lock if supported

isConnectionSupported

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