org.nees.data.strategies
Interface FileTransferStrategy

All Known Implementing Classes:
HomeDirectoryTransferStrategy, LocalFileTransferStrategy

public interface FileTransferStrategy

File transfer strategies contain the logic for put/getting files from a staging area. Note that it is not up to these handlers to create staging areas. This will probably involve some sort of permission issues that cannot be handled under NFMS, since it is a java application. Part of the contract for this class is to be able to create pairs of URIs that are

Lifecycle

Server only. Handlers are registered with the system and invoked, based on the protocol the user selects.

Usage

For each protocol, a handler and its associated classes are registered. These are automatically invoked by NFMS in repsonse to application requests.

Implementations of this inteface use a specific strategy (such as "move files to user's home directory for upload") for up- and downloading files from the repository. Strategies are kept separate from protocols, as several protocols could use the same basic file-moving strategy, and vice-versa.


Method Summary
 java.net.URI[] createDownloadURI(DownloadRequestRecord drr)
          This moves an existing file from the repository to staging area and creates the corresponding uri.
 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.
 

Method Detail

createUploadURI

public java.net.URI[] createUploadURI(UploadRequestRecord urr)
                               throws NFMSException
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.

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.

createDownloadURI

public java.net.URI[] createDownloadURI(DownloadRequestRecord drr)
                                 throws NFMSException
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.

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.

finishUpload

public java.net.URI finishUpload(UploadRequestRecord urr)
                          throws NFMSException
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.

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
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.

Returns:
TransferCompleteReturnObject
Throws:
NFMSException