Class AbstractTransporter

    • Method Detail

      • peek

        public void peek​(PeekTask task)
                  throws Exception
        Description copied from interface: Transporter
        Checks the existence of a resource in the repository. If the remote repository can be contacted successfully but indicates the resource specified in the request does not exist, an exception is thrown such that invoking Transporter.classify(Throwable) with that exception yields Transporter.ERROR_NOT_FOUND.
        Specified by:
        peek in interface Transporter
        Parameters:
        task - The existence check to perform, must not be null.
        Throws:
        Exception - If the existence of the specified resource could not be confirmed.
      • implPeek

        protected abstract void implPeek​(PeekTask task)
                                  throws Exception
        Implements peek(PeekTask), gets only called if the transporter has not been closed.
        Parameters:
        task - The existence check to perform, must not be null.
        Throws:
        Exception - If the existence of the specified resource could not be confirmed.
      • get

        public void get​(GetTask task)
                 throws Exception
        Description copied from interface: Transporter
        Downloads a resource from the repository. If the resource is downloaded to a file as given by GetTask.getDataFile() and the operation fails midway, the transporter should not delete the partial file but leave its management to the caller.
        Specified by:
        get in interface Transporter
        Parameters:
        task - The download to perform, must not be null.
        Throws:
        Exception - If the transfer failed.
      • implGet

        protected abstract void implGet​(GetTask task)
                                 throws Exception
        Implements get(GetTask), gets only called if the transporter has not been closed.
        Parameters:
        task - The download to perform, must not be null.
        Throws:
        Exception - If the transfer failed.
      • utilGet

        protected void utilGet​(GetTask task,
                               InputStream is,
                               boolean close,
                               long length,
                               boolean resume)
                        throws IOException,
                               TransferCancelledException
        Performs stream-based I/O for the specified download task and notifies the configured transport listener. Subclasses might want to invoke this utility method from within their implGet(GetTask) to avoid boilerplate I/O code.
        Parameters:
        task - The download to perform, must not be null.
        is - The input stream to download the data from, must not be null.
        close - true if the supplied input stream should be automatically closed, false to leave the stream open.
        length - The size in bytes of the downloaded resource or -1 if unknown, not to be confused with the length of the supplied input stream which might be smaller if the download is resumed.
        resume - true if the download resumes from GetTask.getResumeOffset(), false if the download starts at the first byte of the resource.
        Throws:
        IOException - If the transfer encountered an I/O error.
        TransferCancelledException - If the transfer was cancelled.
      • put

        public void put​(PutTask task)
                 throws Exception
        Description copied from interface: Transporter
        Uploads a resource to the repository.
        Specified by:
        put in interface Transporter
        Parameters:
        task - The upload to perform, must not be null.
        Throws:
        Exception - If the transfer failed.
      • implPut

        protected abstract void implPut​(PutTask task)
                                 throws Exception
        Implements put(PutTask), gets only called if the transporter has not been closed.
        Parameters:
        task - The upload to perform, must not be null.
        Throws:
        Exception - If the transfer failed.
      • utilPut

        protected void utilPut​(PutTask task,
                               OutputStream os,
                               boolean close)
                        throws IOException,
                               TransferCancelledException
        Performs stream-based I/O for the specified upload task and notifies the configured transport listener. Subclasses might want to invoke this utility method from within their implPut(PutTask) to avoid boilerplate I/O code.
        Parameters:
        task - The upload to perform, must not be null.
        os - The output stream to upload the data to, must not be null.
        close - true if the supplied output stream should be automatically closed, false to leave the stream open.
        Throws:
        IOException - If the transfer encountered an I/O error.
        TransferCancelledException - If the transfer was cancelled.
      • close

        public void close()
        Description copied from interface: Transporter
        Closes this transporter and frees any network resources associated with it. Once closed, a transporter must not be used for further transfers, any attempt to do so would yield a IllegalStateException or similar. Closing an already closed transporter is harmless and has no effect.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface Transporter
      • implClose

        protected abstract void implClose()
        Implements close(), gets only called if the transporter has not already been closed.