org.globus.cog.abstraction.impl.file.gridftp.old
Class FileResourceImpl

java.lang.Object
  extended byorg.globus.cog.abstraction.impl.file.gridftp.old.FileResourceImpl
All Implemented Interfaces:
FileResource, GridResource
Direct Known Subclasses:
FileResourceImpl

public class FileResourceImpl
extends Object
implements FileResource

Implements FileResource API for accessing gridftp server 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 InvalidProviderException
FileResourceImpl(String name, ServiceContact serviceContact, SecurityContext securityContext)
          constructor be used normally
 
Method Summary
 void changeMode(GridFile newGridFile)
          change permissions to a remote file
 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 file command
 boolean exists(String filename)
          Returns true if the file exists
 void get(String remoteFileName, DataSink sink, MarkerListener mListener)
          get a remote file to the local stream
 void get(String remoteFileName, File localFile)
          get a remote file
 Enumeration getAllAttributes()
           
 Object getAttribute(String name)
          Get an attribute *
 String getCurrentDirectory()
          Return Current Directory's name
 void getDirectory(String remoteDirName, String localDirName)
          Equivalent to the cp -r command
 void getFile(String remoteFileName, String localFileName)
          Equivalent to cp/copy command
 GridFile getGridFile(String fileName)
          get remote file information
protected  GridFTPClient getGridFTPClient()
           
 Identity getIdentity()
          Return identity of the resource
 void getMultipleFiles(String[] remoteFileNames, String localDirName)
          mget - copy multiple files from remote server to local dir
 void getMultipleFiles(String[] remoteFileNames, String[] localFileNames)
          mget - copy multiple files from remote server
 String getName()
          Return name of the resource
 String getProtocol()
          return protocol ="gridftp"
 SecurityContext getSecurityContext()
          Get the securityContext for the remote resource
 ServiceContact getServiceContact()
          get service contact
 int getType()
          Return type = FILE which is defined in GridResource
 boolean isDirectory(String dirName)
          Is this filename a directory.
 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 put(DataSource source, String remoteFileName, MarkerListener mListener)
          put the input from a stream into a remote resource.
 void put(File localFile, String remoteFileName, boolean append)
          put a local file into remote resource
 void putDirectory(String localDirName, String remoteDirName)
          Equivalent to cp -r command
 void putFile(String localFileName, String remoteFileName)
          Copy a local file to a remote file.
 void putMultipleFiles(String[] localFileNames, String remoteDirName)
          mput - copy multiple files from local machines to remote directory
 void putMultipleFiles(String[] localFileNames, String[] remoteFileNames)
          mput - copy multiple files from local machine to remote destinations
 void rename(String remoteFileName1, String remoteFileName2)
          Rename a remote file.
 void setAttribute(String name, Object value)
          Set an attribute *
 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 gridFTPClient and authenticate with the resource.
 void stop()
          Stop the gridFTPClient from connecting to the server
 void submit(ExecutableObject commandWorkflow)
          Not implemented in GridFTP *
 
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 InvalidProviderException


FileResourceImpl

public FileResourceImpl(String name,
                        ServiceContact serviceContact,
                        SecurityContext securityContext)
constructor 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

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 ="gridftp"

Specified by:
getProtocol in interface FileResource

setServiceContact

public void setServiceContact(ServiceContact serviceContact)
set service contact

Specified by:
setServiceContact in interface FileResource

getServiceContact

public ServiceContact getServiceContact()
get service contact

Specified by:
getServiceContact 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 gridFTPClient and authenticate with the resource.

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

stop

public void stop()
          throws GeneralException
Stop the gridFTPClient 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 Directory's name

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 file command

Specified by:
deleteFile in interface FileResource
Throws:
FileNotFoundException
GeneralException

get

public void get(String remoteFileName,
                DataSink sink,
                MarkerListener mListener)
         throws FileNotFoundException,
                GeneralException
get a remote file to the local stream

Throws:
FileNotFoundException
GeneralException

get

public void get(String remoteFileName,
                File localFile)
         throws FileNotFoundException,
                GeneralException
get a remote file

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

put

public void put(File localFile,
                String remoteFileName,
                boolean append)
         throws FileNotFoundException,
                GeneralException
put a local file into remote resource

Throws:
FileNotFoundException
GeneralException

put

public void put(DataSource source,
                String remoteFileName,
                MarkerListener mListener)
         throws FileNotFoundException,
                GeneralException
put the input from a stream into a remote resource. unique to gridftp file resource.

Throws:
FileNotFoundException
GeneralException

getDirectory

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

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

Specified by:
putDirectory in interface FileResource
Throws:
DirectoryNotFoundException
GeneralException

getMultipleFiles

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

Specified by:
getMultipleFiles in interface FileResource
Throws:
FileNotFoundException
GeneralException

getMultipleFiles

public void getMultipleFiles(String[] remoteFileNames,
                             String localDirName)
                      throws FileNotFoundException,
                             DirectoryNotFoundException,
                             GeneralException
mget - copy multiple files from remote server to local dir

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 from local machine to remote destinations

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 from local machines to remote directory

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

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
Is this filename a directory. works if user has permissions to change to the given directory

Specified by:
isDirectory in interface FileResource
Throws:
GeneralException

getGridFile

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

Specified by:
getGridFile in interface FileResource
Throws:
FileNotFoundException
GeneralException

changeMode

public void changeMode(GridFile newGridFile)
                throws FileNotFoundException,
                       GeneralException
change permissions to a remote file

Specified by:
changeMode in interface FileResource
Throws:
FileNotFoundException
GeneralException

submit

public void submit(ExecutableObject commandWorkflow)
            throws IllegalSpecException,
                   TaskSubmissionException
Not implemented in GridFTP *

Specified by:
submit in interface FileResource
Throws:
IllegalSpecException
TaskSubmissionException

setAttribute

public void setAttribute(String name,
                         Object value)
Set an attribute *

Specified by:
setAttribute in interface FileResource

getAllAttributes

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

getAttribute

public Object getAttribute(String name)
Get an attribute *

Specified by:
getAttribute in interface FileResource

getGridFTPClient

protected GridFTPClient getGridFTPClient()