org.globus.cog.abstraction.impl.file.ftp
Class FileResourceImpl

java.lang.Object
  extended byorg.globus.cog.abstraction.impl.file.ftp.FileResourceImpl
All Implemented Interfaces:
FileResource, GridResource

public class FileResourceImpl
extends Object
implements FileResource

File resource interface implementation for FTP Servers. Supports relative and absolute path names.


Field Summary
 
Fields inherited from interface org.globus.cog.abstraction.interfaces.FileResource
FTP, GridFTP, Local, WebDAV
 
Fields inherited from interface org.globus.cog.abstraction.interfaces.GridResource
EXECUTION, FILE, INFORMATION
 
Constructor Summary
FileResourceImpl()
          throws invalidprovider exception
FileResourceImpl(String name, ServiceContact serviceContact, SecurityContext securityContext)
          the constructor to be used normally
 
Method Summary
 void changeMode(GridFile newGridFile)
          change mode for the file if authorized to do so
 void changeMode(String filename, int mode)
          Changes the permissions on the file if authorized to do so
 void createDirectory(String directory)
          Equivalent to mkdir
 void deleteDirectory(String directory, boolean force)
          Remove directory and its files if force = true.
 void deleteFile(String file)
          Equivalent to rm command on a file
 boolean exists(String filename)
          returns true if the file exists
 Enumeration getAllAttributes()
           
 Object getAttribute(String name)
          get attribute
 String getCurrentDirectory()
          Return Current path
 void getDirectory(String remoteDirName, String localDirName)
          Equivalent to the cp -r command for copying directories
 void getFile(String remoteFilename, String localFileName)
          Equivalent to cp/copy command
 GridFile getGridFile(String fileName)
          get file information
 Identity getIdentity()
          return identity of the resource
 void getMultipleFiles(String[] remoteFileNames, String localDirName)
          mget - Obtain multiple files from the ftp server
 void getMultipleFiles(String[] remoteFileNames, String[] localFileNames)
          mget - Obtain multiple files from the remote server
 String getName()
          Return name of the resource
 String getProtocol()
          return protocol ="ftp"
 SecurityContext getSecurityContext()
          Get the securityContext for the remote resource
 ServiceContact getServiceContact()
          return service contact
 int getType()
          return type = FILE which is defined in GridResource
 boolean isDirectory(String dirName)
          return true if the input is a directory in the ftp resource.
 boolean isStarted()
           
 Collection list()
          Equivalent to ls command in the current directory
 Collection list(String directory)
          Equivalent to ls command on the given directory
 void putDirectory(String localDirName, String remoteDirName)
          Equivalent to cp -r command for copying directories
 void putFile(String localFileName, String remoteFileName)
          Copy a local file to a remote file.
 void putMultipleFiles(String[] localFileNames, String remoteDirName)
          mput - copy multiple files to the ftp server
 void putMultipleFiles(String[] localFileNames, String[] remoteFileNames)
          mput - copy multiple files into the ftp server
 void rename(String remoteFileName1, String remoteFileName2)
          rename a remote file.
 void setAttribute(String name, Object value)
          set attribute for ftp resource
 void setCurrentDirectory(String directory)
          Equivalent to cd command
 void setIdentity(Identity identity)
          Set identity of the resource
 void setName(String name)
          Set the name of the resource
 void setSecurityContext(SecurityContext securityContext)
          Set the appropriate SecurityContext for the FileResource
 void setServiceContact(ServiceContact serviceContact)
          set service contact
 void start()
          Create the ftpClient and authenticate with the resource.
 void stop()
          Stop the ftpClient from connecting to the server
 void submit(ExecutableObject commandWorkflow)
          execute workflow in ftp resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileResourceImpl

public FileResourceImpl()
                 throws Exception
throws invalidprovider exception


FileResourceImpl

public FileResourceImpl(String name,
                        ServiceContact serviceContact,
                        SecurityContext securityContext)
the constructor to be used normally

Method Detail

setName

public void setName(String name)
Set the name of the resource

Specified by:
setName in interface GridResource

getName

public String getName()
Return name of the resource

Specified by:
getName in interface GridResource

setServiceContact

public void setServiceContact(ServiceContact serviceContact)
set service contact

Specified by:
setServiceContact in interface FileResource

getServiceContact

public ServiceContact getServiceContact()
return service contact

Specified by:
getServiceContact in interface FileResource

setIdentity

public void setIdentity(Identity identity)
Set identity of the resource

Specified by:
setIdentity in interface GridResource

getIdentity

public Identity getIdentity()
return identity of the resource

Specified by:
getIdentity in interface GridResource

getType

public int getType()
return type = FILE which is defined in GridResource

Specified by:
getType in interface GridResource

getProtocol

public String getProtocol()
return protocol ="ftp"

Specified by:
getProtocol in interface FileResource

setSecurityContext

public void setSecurityContext(SecurityContext securityContext)
Set the appropriate SecurityContext for the FileResource

Specified by:
setSecurityContext in interface FileResource

getSecurityContext

public SecurityContext getSecurityContext()
Get the securityContext for the remote resource

Specified by:
getSecurityContext in interface FileResource

start

public void start()
           throws IllegalHostException,
                  InvalidSecurityContextException,
                  GeneralException
Create the ftpClient and authenticate with the resource.

Specified by:
start in interface FileResource
Throws:
IllegalHostException
InvalidSecurityContextException
GeneralException

stop

public void stop()
          throws GeneralException
Stop the ftpClient from connecting to the server

Specified by:
stop in interface FileResource
Throws:
GeneralException

isStarted

public boolean isStarted()
Specified by:
isStarted in interface FileResource

setCurrentDirectory

public void setCurrentDirectory(String directory)
                         throws DirectoryNotFoundException,
                                GeneralException
Equivalent to cd command

Specified by:
setCurrentDirectory in interface FileResource
Throws:
DirectoryNotFoundException
GeneralException

getCurrentDirectory

public String getCurrentDirectory()
                           throws GeneralException
Return Current path

Specified by:
getCurrentDirectory in interface FileResource
Throws:
GeneralException

list

public Collection list()
                throws GeneralException
Equivalent to ls command in the current directory

Specified by:
list in interface FileResource
Throws:
GeneralException

list

public Collection list(String directory)
                throws DirectoryNotFoundException,
                       GeneralException
Equivalent to ls command on the given directory

Specified by:
list in interface FileResource
Throws:
DirectoryNotFoundException
GeneralException

createDirectory

public void createDirectory(String directory)
                     throws GeneralException
Equivalent to mkdir

Specified by:
createDirectory in interface FileResource
Throws:
GeneralException

deleteDirectory

public void deleteDirectory(String directory,
                            boolean force)
                     throws DirectoryNotFoundException,
                            GeneralException
Remove directory and its files if force = true. Else remove directory only if empty

Specified by:
deleteDirectory in interface FileResource
Throws:
DirectoryNotFoundException
GeneralException

deleteFile

public void deleteFile(String file)
                throws FileNotFoundException,
                       GeneralException
Equivalent to rm command on a file

Specified by:
deleteFile in interface FileResource
Throws:
FileNotFoundException
GeneralException

getFile

public void getFile(String remoteFilename,
                    String localFileName)
             throws FileNotFoundException,
                    GeneralException
Equivalent to cp/copy command

Specified by:
getFile in interface FileResource
Throws:
FileNotFoundException
GeneralException

putFile

public void putFile(String localFileName,
                    String remoteFileName)
             throws FileNotFoundException,
                    GeneralException
Copy a local file to a remote file. Default option 'overwrite'

Specified by:
putFile in interface FileResource
Throws:
FileNotFoundException
GeneralException

getDirectory

public void getDirectory(String remoteDirName,
                         String localDirName)
                  throws DirectoryNotFoundException,
                         GeneralException
Equivalent to the cp -r command for copying directories

Specified by:
getDirectory in interface FileResource
Throws:
DirectoryNotFoundException
GeneralException

putDirectory

public void putDirectory(String localDirName,
                         String remoteDirName)
                  throws DirectoryNotFoundException,
                         GeneralException
Equivalent to cp -r command for copying directories

Specified by:
putDirectory in interface FileResource
Throws:
DirectoryNotFoundException
GeneralException

getMultipleFiles

public void getMultipleFiles(String[] remoteFileNames,
                             String[] localFileNames)
                      throws FileNotFoundException,
                             GeneralException
mget - Obtain multiple files from the remote server

Specified by:
getMultipleFiles in interface FileResource
Throws:
FileNotFoundException
GeneralException

getMultipleFiles

public void getMultipleFiles(String[] remoteFileNames,
                             String localDirName)
                      throws FileNotFoundException,
                             DirectoryNotFoundException,
                             GeneralException
mget - Obtain multiple files from the ftp server

Specified by:
getMultipleFiles in interface FileResource
Throws:
FileNotFoundException
DirectoryNotFoundException
GeneralException

putMultipleFiles

public void putMultipleFiles(String[] localFileNames,
                             String[] remoteFileNames)
                      throws FileNotFoundException,
                             GeneralException
mput - copy multiple files into the ftp server

Specified by:
putMultipleFiles in interface FileResource
Throws:
FileNotFoundException
GeneralException

putMultipleFiles

public void putMultipleFiles(String[] localFileNames,
                             String remoteDirName)
                      throws FileNotFoundException,
                             DirectoryNotFoundException,
                             GeneralException
mput - copy multiple files to the ftp server

Specified by:
putMultipleFiles in interface FileResource
Throws:
FileNotFoundException
DirectoryNotFoundException
GeneralException

rename

public void rename(String remoteFileName1,
                   String remoteFileName2)
            throws FileNotFoundException,
                   GeneralException
rename a remote file.

Specified by:
rename in interface FileResource
Throws:
FileNotFoundException
GeneralException

changeMode

public void changeMode(String filename,
                       int mode)
                throws FileNotFoundException,
                       GeneralException
Changes the permissions on the file if authorized to do so

Specified by:
changeMode in interface FileResource
Throws:
FileNotFoundException
GeneralException

getGridFile

public GridFile getGridFile(String fileName)
                     throws FileNotFoundException,
                            GeneralException
get file information

Specified by:
getGridFile in interface FileResource
Throws:
FileNotFoundException
GeneralException

changeMode

public void changeMode(GridFile newGridFile)
                throws FileNotFoundException,
                       GeneralException
change mode for the file if authorized to do so

Specified by:
changeMode in interface FileResource
Throws:
FileNotFoundException
GeneralException

exists

public boolean exists(String filename)
               throws FileNotFoundException,
                      GeneralException
returns true if the file exists

Specified by:
exists in interface FileResource
Throws:
FileNotFoundException
GeneralException

isDirectory

public boolean isDirectory(String dirName)
                    throws GeneralException
return true if the input is a directory in the ftp resource. works only if you have permissions to change to the specified directory.

Specified by:
isDirectory in interface FileResource
Throws:
GeneralException

submit

public void submit(ExecutableObject commandWorkflow)
            throws IllegalSpecException,
                   TaskSubmissionException
execute workflow in ftp resource. not implemented

Specified by:
submit in interface FileResource
Throws:
IllegalSpecException
TaskSubmissionException

setAttribute

public void setAttribute(String name,
                         Object value)
set attribute for ftp resource

Specified by:
setAttribute in interface FileResource

getAllAttributes

public Enumeration getAllAttributes()
Specified by:
getAllAttributes in interface FileResource

getAttribute

public Object getAttribute(String name)
get attribute

Specified by:
getAttribute in interface FileResource