Keel 2.1RC2

org.apache.excalibur.source.impl
Class HTTPClientSource.WrappedFileOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byjava.io.FileOutputStream
          extended byorg.apache.excalibur.source.impl.HTTPClientSource.WrappedFileOutputStream
Enclosing class:
HTTPClientSource

private class HTTPClientSource.WrappedFileOutputStream
extends java.io.FileOutputStream

Internal class which extends FileOutputStream to automatically upload the data written to it, upon a close() operation.


Field Summary
private  java.io.File m_file
          Reference to the File being written itself.
private  Logger m_logger
          Reference to a Logger.
 
Fields inherited from class java.io.FileOutputStream
 
Constructor Summary
HTTPClientSource.WrappedFileOutputStream(java.io.File file, Logger logger)
          Constructor, creates a new WrappedFileOutputStream instance.
 
Method Summary
 boolean canCancel()
          Method to test whether this stream can be closed.
 void cancel()
          Cancels this stream.
 void close()
          Closes the stream, and uploads the file written to the server.
private  boolean successfulUpload(int response)
          According to RFC2616 (HTTP 1.1) valid responses for a HTTP PUT are 201 (Created), 200 (OK), and 204 (No Content).
private  void upload()
          Helper method to attempt uploading of the local data file to the remove server via a HTTP PUT.
 
Methods inherited from class java.io.FileOutputStream
finalize, getChannel, getFD, write, write, write
 
Methods inherited from class java.io.OutputStream
flush
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_file

private java.io.File m_file
Reference to the File being written itself.


m_logger

private final Logger m_logger
Reference to a Logger.

Constructor Detail

HTTPClientSource.WrappedFileOutputStream

public HTTPClientSource.WrappedFileOutputStream(java.io.File file,
                                                Logger logger)
                                         throws java.io.IOException
Constructor, creates a new WrappedFileOutputStream instance.

Parameters:
file - File to write to.
logger - Logger reference.
Throws:
java.io.IOException - if an error occurs
Method Detail

close

public void close()
           throws java.io.IOException
Closes the stream, and uploads the file written to the server.

Throws:
java.io.IOException - if an error occurs

canCancel

public boolean canCancel()
Method to test whether this stream can be closed.

Returns:
true if possible, false otherwise.

cancel

public void cancel()
            throws java.io.IOException
Cancels this stream.

Throws:
java.io.IOException - if stream is already closed

upload

private void upload()
             throws java.io.IOException
Helper method to attempt uploading of the local data file to the remove server via a HTTP PUT.

Throws:
java.io.IOException - if an error occurs

successfulUpload

private boolean successfulUpload(int response)
According to RFC2616 (HTTP 1.1) valid responses for a HTTP PUT are 201 (Created), 200 (OK), and 204 (No Content).

Parameters:
response - response code from the HTTP PUT
Returns:
true if upload was successful, false otherwise.

Keel 2.1RC2

Please see keelframework.org for information about new Keel releases.