|
Keel 2.1RC2 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.excalibur.source.impl.HTTPClientSource
HTTP URL Source object, based on the Jakarta Commons project.
| Nested Class Summary | |
private class |
HTTPClientSource.WrappedFileOutputStreamInternal class which extends FileOutputStream to automatically upload the data written to it, upon a HTTPClientSource.WrappedFileOutputStream.close() operation. |
| Field Summary | |
static java.lang.String |
CONTENT_LENGTHConstant used when obtaining the Content-Length from HTTP Headers |
static java.lang.String |
CONTENT_TYPEConstant used when obtaining the Content-Type from HTTP Headers |
static java.lang.String |
GETConstant used for identifying GET requests. |
static java.lang.String |
LAST_MODIFIEDConstant used when obtaining the Last-Modified date from HTTP Headers |
private long |
m_cachedLastModificationDateCached last modification date. |
private SourceValidity |
m_cachedValidityStored SourceValidity object. |
private HttpClient |
m_clientThe HttpClient object. |
private long |
m_contentLengthThe content length of the resource on the server. |
private boolean |
m_dataValidWhether the data held within this instance is currently accurate. |
private boolean |
m_existsWhether the resource exists on the server. |
private long |
m_lastModifiedThe last modified date of the resource on the server. |
private java.lang.String |
m_mimeTypeThe mime type of the resource on the server. |
private java.util.Map |
m_parametersContextual parameters passed via the SourceFactory. |
private java.lang.String |
m_proxyHostProxy host if set via configuration. |
private int |
m_proxyPortProxy port if set via configuration. |
private java.lang.String |
m_uriThe URI being accessed. |
static java.lang.String |
POSTConstant used for identifying POST requests. |
static java.lang.String |
PROXY_HOSTConstant used for configuring the proxy hostname. |
static java.lang.String |
PROXY_PORTConstant used for configuring the proxy port number. |
| Fields inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
|
| Constructor Summary | |
HTTPClientSource(java.lang.String uri, java.util.Map parameters)Constructor, creates a new HTTPClientSource instance. |
|
| Method Summary | |
boolean |
canCancel(java.io.OutputStream stream)Method to determine whether writing to the supplied OutputStream (which must be that returned from getOutputStream()) can be cancelled |
void |
cancel(java.io.OutputStream stream)Cancels any data sent to the HTTPClientSource.WrappedFileOutputStream returned by getOutputStream(). |
private DeleteMethod |
createDeleteMethod(java.lang.String uri)Factory method to create a DeleteMethod object. |
private GetMethod |
createGetMethod(java.lang.String uri)Factory method to create a GetMethod object. |
private HeadMethod |
createHeadMethod(java.lang.String uri)Factory method to create a HeadMethod object. |
private PostMethod |
createPostMethod(java.lang.String uri, SourceParameters params)Factory method to create a new PostMethod with the given SourceParameters object. |
private PutMethod |
createPutMethod(java.lang.String uri, java.io.File uploadFile)Factory method to create a PutMethod object. |
void |
delete()Deletes the referenced resource. |
private boolean |
deleteSuccessful(int response)According to RFC2616 (HTTP 1.1) valid responses for a HTTP DELETE are 200 (OK), 202 (Accepted) and 204 (No Content). |
private int |
executeMethod(HttpMethod method)Executes a particular HttpMethod and updates internal data storage. |
boolean |
exists()Method to ascertain whether the given resource actually exists. |
private java.lang.String |
findMethodType()Method to discover what kind of request is being made from the parameters map passed in to this Source's constructor. |
long |
getContentLength()Obtain the content length of the referenced resource. |
java.io.InputStream |
getInputStream()Method to obtain an InputStream to read the response from the server. |
long |
getLastModified()Get the last modification date of this source. |
private HttpMethod |
getMethod()Helper method to create the required HttpMethod object based on parameters passed to this HTTPClientSource object. |
java.lang.String |
getMimeType()Obtain the mime-type for the referenced resource. |
java.io.OutputStream |
getOutputStream()Obtain an HTTPClientSource.WrappedFileOutputStream to write to. |
java.lang.String |
getScheme()Return the URI scheme identifier, ie. |
java.lang.String |
getURI()Obtain the absolute URI this Source object references. |
SourceValidity |
getValidity()Obtain a SourceValidity object. |
void |
initialize()Initializes this HTTPClientSource instance. |
void |
parameterize(Parameters params)Parameterizes this HTTPClientSource instance. |
private void |
recycle()Recycles this HTTPClientSource object so that it may be reused to refresh it's content. |
void |
refresh()Refreshes this Source object. |
private void |
updateContentLength(HttpMethod method)Method to update the content length of a resource after executing a particular HttpMethod. |
private void |
updateData()Method to make response data available if possible without actually making an actual request (ie. |
private void |
updateExists(HttpMethod method)Method to update whether a referenced resource exists, after executing a particular HttpMethod. |
private void |
updateLastModified(HttpMethod method)Method to update the last modified date of a resource after executing a particular HttpMethod. |
private void |
updateMimeType(HttpMethod method)Method to update the mime type of a resource after executing a particular HttpMethod. |
| Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String POST
public static final java.lang.String GET
public static final java.lang.String PROXY_HOST
public static final java.lang.String PROXY_PORT
public static final java.lang.String CONTENT_TYPE
public static final java.lang.String CONTENT_LENGTH
public static final java.lang.String LAST_MODIFIED
private final java.lang.String m_uri
private final java.util.Map m_parameters
SourceFactory.
private HttpClient m_client
HttpClient object.
private int m_proxyPort
private java.lang.String m_proxyHost
private boolean m_dataValid
private boolean m_exists
private java.lang.String m_mimeType
private long m_contentLength
private long m_lastModified
private SourceValidity m_cachedValidity
SourceValidity object.
private long m_cachedLastModificationDate
| Constructor Detail |
public HTTPClientSource(java.lang.String uri,
java.util.Map parameters)
throws java.lang.Exception
HTTPClientSource instance.
uri - URIparameters - contextual parameters passed to this instancejava.lang.Exception - if an error occurs| Method Detail |
public void parameterize(Parameters params)
throws ParameterException
HTTPClientSource instance.
parameterize in interface Parameterizableparams - a Parameters instance.ParameterException - if an error occurs
public void initialize()
throws java.lang.Exception
HTTPClientSource instance.
initialize in interface Initializablejava.lang.Exception - if an error occursprivate java.lang.String findMethodType()
private HttpMethod getMethod()
HttpMethod object based on parameters passed to this HTTPClientSource object.
HttpMethod object.
private PostMethod createPostMethod(java.lang.String uri,
SourceParameters params)
PostMethod with the given SourceParameters object.
uri - URIparams - SourceParametersPostMethod instanceprivate GetMethod createGetMethod(java.lang.String uri)
GetMethod object.
uri - URIGetMethod instanceprivate HeadMethod createHeadMethod(java.lang.String uri)
HeadMethod object.
uri - URIHeadMethod instance
private PutMethod createPutMethod(java.lang.String uri,
java.io.File uploadFile)
throws java.io.IOException
PutMethod object.
uri - URI to upload uploadFile touploadFile - File to be uploadedPutMethod instancejava.io.IOException - if an error occursprivate DeleteMethod createDeleteMethod(java.lang.String uri)
DeleteMethod object.
uri - URI to deleteDeleteMethod instance.private void updateData()
private int executeMethod(HttpMethod method)
throws java.io.IOException
HttpMethod and updates internal data storage.
method - HttpMethod to executejava.io.IOException - if an error occursprivate void updateExists(HttpMethod method)
HttpMethod.
REVISIT: exists() would be better called canRead() or similar, as a resource can exist but not be readable.
method - HttpMethod executed.public boolean exists()
exists in interface Sourcetrue if the resource pointed to by the URI during construction exists, false otherwise.
public java.io.InputStream getInputStream()
throws java.io.IOException,
SourceNotFoundException
InputStream to read the response from the server.
getInputStream in interface SourceInputStream containing data sent from the server.java.io.IOException - if some I/O problem occurs.SourceNotFoundException - if the source doesn't exist.public java.lang.String getURI()
Source object references.
getURI in interface SourceString object references.public java.lang.String getScheme()
getScheme in interface Sourcepublic SourceValidity getValidity()
SourceValidity object.
getValidity in interface SourceSourceValidity object, or null if this is not possible.public void refresh()
Source object.
refresh in interface Sourceprivate void updateMimeType(HttpMethod method)
HttpMethod.
method - HttpMethod executedpublic java.lang.String getMimeType()
getMimeType in interface Sourceprivate void updateContentLength(HttpMethod method)
HttpMethod.
method - HttpMethod executedpublic long getContentLength()
getContentLength in interface Sourceprivate void updateLastModified(HttpMethod method)
HttpMethod.
method - HttpMethod executedpublic long getLastModified()
getLastModified in interface Source0 if unknown.private void recycle()
HTTPClientSource object so that it may be reused to refresh it's content.
public java.io.OutputStream getOutputStream()
throws java.io.IOException
HTTPClientSource.WrappedFileOutputStream to write to. The HTTPClientSource.WrappedFileOutputStream returned actually references a temporary local file, which will be written to the server upon closing.
getOutputStream in interface ModifiableSourceHTTPClientSource.WrappedFileOutputStream instancejava.io.IOException - if an error occurs
public void delete()
throws SourceException
delete in interface ModifiableSourceSourceException - if an error occursprivate boolean deleteSuccessful(int response)
response - response code from the HTTP PUTpublic boolean canCancel(java.io.OutputStream stream)
getOutputStream()) can be cancelled
canCancel in interface ModifiableSource
public void cancel(java.io.OutputStream stream)
throws java.io.IOException
HTTPClientSource.WrappedFileOutputStream returned by getOutputStream(). After calling this method, the supplied HTTPClientSource.WrappedFileOutputStream should no longer be used.
cancel in interface ModifiableSourcejava.io.IOException
|
Keel 2.1RC2 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||