public class TransferState extends java.lang.Object implements TimeEstimator
FileTransfer implementations.
 A single instance will be created per invocation of
 FileTransfer.transfer(TransferState). Several instance methods are
 provided for common reporting actions (See usage in existing
 FileTransfer implementations.| Constructor and Description | 
|---|
| TransferState(java.io.File file,
             int index,
             int total,
             ImportProcessPrx proc,
             ImportLibrary library,
             TimeEstimator estimator,
             ome.util.checksum.ChecksumProvider cp,
             byte[] buf)State of the current file transfer. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | closeUploader()Call  StatefulServiceInterfacePrx.close()on the cached uploader
 instance if non-null and null the instance. | 
| byte[] | getBuffer()(Not thread safe) Get a moderately large buffer for use in
 reading/writing data. | 
| java.lang.String | getChecksum()Get the digest string for the local file. | 
| ome.util.checksum.ChecksumProvider | getChecksumProvider()Get the  ChecksumProviderpassed to the constructor. | 
| java.io.File | getFile()Return the target file passed to the constructor. | 
| long | getLength()Return the length of the  target file. | 
| OriginalFile | getOriginalFile()Find original file as defined by the ID in the  RawFileStorePrxregardless of group. | 
| OriginalFile | getRootFile()Find original file represented by the managed repository that
 import is taking place to. | 
| RawFileStorePrx | getUploader() | 
| RawFileStorePrx | getUploader(java.lang.String mode)Return the  RawFileStorePrxinstance for this index setting
 the mode if not null. | 
| long | getUploadTimeLeft() | 
| void | save()Calls  RawFileStorePrx.save()and stores the resultantOriginalFilefor future inspection along with the local
 checksum. | 
| void | start()Starts the time counting. | 
| void | stop()Stops the time counting and updates the internal time counter. | 
| void | stop(long uploadedBytes)Stops the time counting and updates the internal updates the internal
 time counter and counter of total number of transmitted bytes. | 
| void | uploadBytes(long offset)Raise the  ImportEvent.FILE_UPLOAD_BYTESevent to all observers. | 
| void | uploadComplete(long offset)Raise the  ImportEvent.FILE_UPLOAD_COMPLETEevent to all observers. | 
| void | uploadStarted()Raise the  ImportEvent.FILE_UPLOAD_STARTEDevent to all observers. | 
public TransferState(java.io.File file,
                     int index,
                     int total,
                     ImportProcessPrx proc,
                     ImportLibrary library,
                     TimeEstimator estimator,
                     ome.util.checksum.ChecksumProvider cp,
                     byte[] buf)
              throws java.io.IOException,
                     ServerError
file - Source file which is to be transferred.index - Which of the total files to upload this is.total - Total number of files to upload.proc - ImportProcessPrx which is being imported to.library - ImportLibrary to use for notifications.estimator - a time-to-completion estimator.cp - a checksum provider, for calculating file content checksums.buf - optional buffer. Need not be used or updated.java.io.IOException - I/O exceptionServerError - server errorpublic void save()
          throws ServerError
RawFileStorePrx.save() and stores the resultant
 OriginalFile for future inspection along with the local
 checksum. (The remote checksum is available from the
 OriginalFile.ServerError - server errorpublic byte[] getBuffer()
public java.lang.String getChecksum()
save() has been called.public ome.util.checksum.ChecksumProvider getChecksumProvider()
ChecksumProvider passed to the constructor.
 Since the ChecksumProvider has a number of different usage styles,
 TransferState doesn't attempt to delegate but just returns the
 instance.public java.io.File getFile()
public long getLength()
target file.public OriginalFile getOriginalFile() throws ServerError
RawFileStorePrx
 regardless of group.ServerError - server errorpublic OriginalFile getRootFile() throws ServerError
ServerError - server errorpublic RawFileStorePrx getUploader() throws ServerError
RawFileStorePrx instance for this indexServerError - server errorpublic RawFileStorePrx getUploader(java.lang.String mode) throws ServerError
RawFileStorePrx instance for this index setting
 the mode if not null. Valid values include "r" and "rw". If a non-null
 uploader is available, it will be returned instead.
 Every instance which is returned from this method should
 eventually have StatefulServiceInterfacePrx.close() called on it.
 StatefulServiceInterfacePrx.close() can be used to facilitate this.mode - the mode as understood by
 PublicRepositoryI.file(String, String, Ice.Current)RawFileStorePrx instanceServerError - server errorpublic void closeUploader()
StatefulServiceInterfacePrx.close() on the cached uploader
 instance if non-null and null the instance. If
 ObjectNotExistException is thrown, the service is
 assumed closed. All other exceptions will be printed at WARN.public void uploadStarted()
ImportEvent.FILE_UPLOAD_STARTED
 event to all observers.public void uploadBytes(long offset)
ImportEvent.FILE_UPLOAD_BYTES
 event to all observers.offset - how many bytes are uploadedpublic void uploadComplete(long offset)
ImportEvent.FILE_UPLOAD_COMPLETE
 event to all observers.offset - how many bytes are uploadedpublic void start()
TimeEstimatorstart in interface TimeEstimatorpublic void stop()
TimeEstimatorstop in interface TimeEstimatorpublic void stop(long uploadedBytes)
TimeEstimatorstop in interface TimeEstimatoruploadedBytes - Number of bytes uploaded in a single time frame that is being
            sampled.public long getUploadTimeLeft()
TimeEstimatorgetUploadTimeLeft in interface TimeEstimatorstop hasn't been called at least
         once before calling this method.