org.nees.data.strategies
Class HomeDirectoryTransferStrategy

java.lang.Object
  extended byorg.nees.data.strategies.HomeDirectoryTransferStrategy
All Implemented Interfaces:
FileTransferStrategy

public class HomeDirectoryTransferStrategy
extends java.lang.Object
implements FileTransferStrategy

This strategy moves files to and from a user's home directory when uploading and downloading files from the repository.

Lifecycle

Server only This is used by the file location manager. The NFMS instantiates this in repsonse to the specific protocol request.

Usage

The file location manager passes through most of its requests directly to the strategy.


Field Summary
static java.lang.String FTP_PORT_DEFAULT
           
static java.lang.String FTP_PORT_KEY
           
static java.lang.String GRID_FTP_PORT_DEFAULT
           
static java.lang.String GRID_FTP_PORT_KEY
           
 
Constructor Summary
HomeDirectoryTransferStrategy(NMDSAdapter nmds, PermanentStorageInterface pStore, java.lang.String protocol, int port, java.lang.String secretStagingDirectory, java.lang.String repositoryRootDirectory)
          The only constructor for this class.
 
Method Summary
 java.net.URI[] createDownloadURI(DownloadRequestRecord drr)
          This moves an existing file from the repository to staging area and creates the corresponding uri.
protected  java.net.URI[] createTransferURI(TransferRequestRecord trr)
           
 java.net.URI[] createUploadURI(UploadRequestRecord urr)
          This creates the uri that the user can upload a file to.
 void finishDownload(DownloadRequestRecord drr)
          When a download from the server is complete, a notification is sent to NFMS which in turn calls this method.
 java.net.URI finishUpload(UploadRequestRecord urr)
          Once NFMS receives notification that the upload is done, this method is invoked.
protected  org.apache.log4j.Logger getLogger()
           
protected  NMDSAdapter getNMDS()
           
protected  int getPort()
           
 java.lang.String getProtocol()
           
 PermanentStorageInterface getPStore()
           
protected  java.lang.String getRepoDirectory()
           
protected  java.net.URI getServiceURI()
           
protected  java.net.URI getUserDirURI(java.lang.String userID)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GRID_FTP_PORT_KEY

public static java.lang.String GRID_FTP_PORT_KEY

FTP_PORT_KEY

public static java.lang.String FTP_PORT_KEY

GRID_FTP_PORT_DEFAULT

public static java.lang.String GRID_FTP_PORT_DEFAULT

FTP_PORT_DEFAULT

public static java.lang.String FTP_PORT_DEFAULT
Constructor Detail

HomeDirectoryTransferStrategy

public HomeDirectoryTransferStrategy(NMDSAdapter nmds,
                                     PermanentStorageInterface pStore,
                                     java.lang.String protocol,
                                     int port,
                                     java.lang.String secretStagingDirectory,
                                     java.lang.String repositoryRootDirectory)
                              throws NFMSException
The only constructor for this class.

Method Detail

getNMDS

protected NMDSAdapter getNMDS()

getProtocol

public java.lang.String getProtocol()

getRepoDirectory

protected java.lang.String getRepoDirectory()

getPort

protected int getPort()

createUploadURI

public java.net.URI[] createUploadURI(UploadRequestRecord urr)
                               throws NFMSException
Description copied from interface: FileTransferStrategy
This creates the uri that the user can upload a file to. It should check that the uri created has not been used and issue an exception if it exists.

Specified by:
createUploadURI in interface FileTransferStrategy
Parameters:
urr - the record of this request.
Returns:
TransferRequestReturnObject
Throws:
NFMSException - thrown if the file already exists, or if the staging area cannot be accessed or found.

finishUpload

public java.net.URI finishUpload(UploadRequestRecord urr)
                          throws NFMSException
Description copied from interface: FileTransferStrategy
Once NFMS receives notification that the upload is done, this method is invoked. It should move the file to its permanent location and delete the file from the staging area.

Specified by:
finishUpload in interface FileTransferStrategy
Returns:
TransferCompleteReturnObject
Throws:
NFMSException - is thrown if the file fails to exist in the staging area or cannot be moved to its permanent location

finishDownload

public void finishDownload(DownloadRequestRecord drr)
                    throws NFMSException
Description copied from interface: FileTransferStrategy
When a download from the server is complete, a notification is sent to NFMS which in turn calls this method. This should clean up, i.e., remove any temporary file from the storage area. If the file is not found there, no exception need be thrown, unless it indicates some bona fide error.

Specified by:
finishDownload in interface FileTransferStrategy
Returns:
TransferCompleteReturnObject
Throws:
NFMSException

createTransferURI

protected java.net.URI[] createTransferURI(TransferRequestRecord trr)
                                    throws NFMSException
Throws:
NFMSException

createDownloadURI

public java.net.URI[] createDownloadURI(DownloadRequestRecord drr)
                                 throws NFMSException
Description copied from interface: FileTransferStrategy
This moves an existing file from the repository to staging area and creates the corresponding uri. It should check that the uri created has not been used and issue an exception if it exists. Moreover, if the file cannot be found an exception should be thrown.

Specified by:
createDownloadURI in interface FileTransferStrategy
Parameters:
drr - the record of this request.
Returns:
TransferRequestReturnObject
Throws:
NFMSException - thrown if the staging area cannot be accessed or found, or if the file does not exist in the repository.

getServiceURI

protected java.net.URI getServiceURI()
                              throws NFMSException
Throws:
NFMSException

getUserDirURI

protected java.net.URI getUserDirURI(java.lang.String userID)
                              throws NFMSException
Throws:
NFMSException

getLogger

protected org.apache.log4j.Logger getLogger()

getPStore

public PermanentStorageInterface getPStore()
                                    throws NFMSException
Throws:
NFMSException