Class TransferState

    • Constructor Detail

      • TransferState

        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
        State of the current file transfer.
        Parameters:
        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.
        Throws:
        java.io.IOException - I/O exception
        ServerError - server error
    • Method Detail

      • getBuffer

        public byte[] getBuffer()
        (Not thread safe) Get a moderately large buffer for use in reading/writing data. To prevent the creation of many MB-sized byte arrays, this value can be re-used but requires external synchronization.
        Returns:
        the buffer
      • getChecksum

        public java.lang.String getChecksum()
        Get the digest string for the local file. This will only be available, i.e. non-null, after save() has been called.
        Returns:
        the checksum
      • getChecksumProvider

        public ome.util.checksum.ChecksumProvider getChecksumProvider()
        Get the 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.
        Returns:
        the checksum provider used for calculating the checksum
      • getFile

        public java.io.File getFile()
        Return the target file passed to the constructor.
        Returns:
        the source file
      • getLength

        public long getLength()
        Return the length of the target file.
        Returns:
        the length of the source file
      • getOriginalFile

        public OriginalFile getOriginalFile()
                                     throws ServerError
        Find original file as defined by the ID in the RawFileStorePrx regardless of group.
        Returns:
        the original file from the upload process
        Throws:
        ServerError - server error
      • getRootFile

        public OriginalFile getRootFile()
                                 throws ServerError
        Find original file represented by the managed repository that import is taking place to.
        Returns:
        the original file at the root of the repository targeted by the upload process
        Throws:
        ServerError - server error
      • closeUploader

        public void closeUploader()
        Call 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.
      • uploadBytes

        public void uploadBytes​(long offset)
        Raise the ImportEvent.FILE_UPLOAD_BYTES event to all observers.
        Parameters:
        offset - how many bytes are uploaded
      • uploadComplete

        public void uploadComplete​(long offset)
        Raise the ImportEvent.FILE_UPLOAD_COMPLETE event to all observers.
        Parameters:
        offset - how many bytes are uploaded
      • stop

        public void stop()
        Description copied from interface: TimeEstimator
        Stops the time counting and updates the internal time counter.
        Specified by:
        stop in interface TimeEstimator
      • stop

        public void stop​(long uploadedBytes)
        Description copied from interface: TimeEstimator
        Stops the time counting and updates the internal updates the internal time counter and counter of total number of transmitted bytes.
        Specified by:
        stop in interface TimeEstimator
        Parameters:
        uploadedBytes - Number of bytes uploaded in a single time frame that is being sampled.
      • getUploadTimeLeft

        public long getUploadTimeLeft()
        Description copied from interface: TimeEstimator
        Return the estimated time left in milliseconds based on the calls to start and stop methods.
        Specified by:
        getUploadTimeLeft in interface TimeEstimator
        Returns:
        The estimated time remaining. The value 0 is returned if stop hasn't been called at least once before calling this method.