org.opentox.toxotis.client
Interface IPostClient

All Superinterfaces:
Closeable, IClient
All Known Implementing Classes:
PostHttpClient, PostHttpsClient

public interface IPostClient
extends IClient

Interface for clients that perform POST requests.

Author:
Pantelis Sopasakis, Charalampos Chomenides

Field Summary
static String METHOD
          The method that this client applies
 
Fields inherited from interface org.opentox.toxotis.client.IClient
httpProtocol, httpSecureProtocol, URL_ENCODING
 
Method Summary
 IPostClient addPostParameter(String paramName, String paramValue)
          Add a parameter which will be posted to the target URI.
 String getContentType()
           
 ReentrantReadWriteLock.WriteLock getPostLock()
           
 void post()
          According to the the configuration of the PostHttpClient, permorms a remote POST request to the server identified by the URI provided in the contructor.
 IPostClient setContentType(Media media)
          Specify the Content-type header value that is the MIME of the POSTed entity.
 IPostClient setContentType(String contentType)
          Specify the Content-type header value that is the MIME of the POSTed entity.
 IPostClient setPostable(File objectToPost)
          Set a file whose contents are to be posted to the remote server specified in the constructor of this class.
 IPostClient setPostable(InputStream inputStream)
           
 IPostClient setPostable(IStAXWritable staxWritable)
          Set a StAX-writeable component to be posted to the remote location
 IPostClient setPostable(com.hp.hpl.jena.ontology.OntModel model)
          Set an ontological data model which is to be posted to the remote location as application/rdf+xml.
 IPostClient setPostable(String string, boolean binary)
          Provide a POSTable object as a string.
 
Methods inherited from interface org.opentox.toxotis.client.IClient
addHeaderParameter, authorize, close, getConnectionLock, getMediaType, getReadLock, getRemoteStream, getResponseCode, getResponseContentType, getResponseHeader, getResponseOntModel, getResponseOntModel, getResponseText, getResponseUriList, getUri, setMediaType, setMediaType, setUri, setUri
 

Field Detail

METHOD

static final String METHOD
The method that this client applies

See Also:
Constant Field Values
Method Detail

getContentType

String getContentType()

post

void post()
          throws ServiceInvocationException
According to the the configuration of the PostHttpClient, permorms a remote POST request to the server identified by the URI provided in the contructor. First, the protected method initializeConnection(URI) is invoked and then a DataOutputStream opens to tranfer the data to the server.

Throws:
ToxOtisException - Encapsulates an IOException which might be thrown due to I/O errors during the data transaction.
ServiceInvocationException

setContentType

IPostClient setContentType(String contentType)
Specify the Content-type header value that is the MIME of the POSTed entity. Alternatively users can invoke IClient.addHeaderParameter(java.lang.String, java.lang.String) using the Header RequestHeaders.CONTENT_TYPE.

Parameters:
contentType - The MIME type corresponding to the Content-type value for the underlying request as a String.
Returns:
The current updated modifiable POST client.

setContentType

IPostClient setContentType(Media media)
Specify the Content-type header value that is the MIME of the POSTed entity. Alternatively users can invoke IClient.addHeaderParameter(java.lang.String, java.lang.String) using the Header RequestHeaders.CONTENT_TYPE.

Parameters:
media - The MIME type corresponding to the Content-type value for the underlying request as an instance of Media.
Returns:
The current updated modifiable POST client.

setPostable

IPostClient setPostable(com.hp.hpl.jena.ontology.OntModel model)
Set an ontological data model which is to be posted to the remote location as application/rdf+xml. Invokations of this method set automatically the content-type to application/rdf+xml though it can be overriden afterwards.

Parameters:
model - Ontological Model to be posted
Returns:
The PostHttpClient with the updated Ontological Model.

setPostable

IPostClient setPostable(InputStream inputStream)

setPostable

IPostClient setPostable(IStAXWritable staxWritable)
Set a StAX-writeable component to be posted to the remote location

Parameters:
staxWritable - A StAX component that implements the interface IStAXWritable that will be posted to the remote server via the method write(OutputStream) that writes the component to an outputstream pointing to the remote stream
Returns:
The PostHttpClient with the updated writeable component.

setPostable

IPostClient setPostable(File objectToPost)
Set a file whose contents are to be posted to the remote server specified in the constructor of this class. If the file is not found under the specified path, an IllegalArgumentException is thrown. Because the type of the file is in general unknown and it is not considered to be a good practise to deduce the file type from the file extension, it is up to the user to specify the content type of the posted object using the method setContentType. Since it is not possible to POST entities of different content types to an HTTP server, any invokation to this method will override any previous invokation of setPostable(OntModel) and setPostable(String).

Parameters:
objectToPost - File whose contents are to be posted.
Returns:
This post client
Throws:
IllegalArgumentException - In case the provided file does not exist

setPostable

IPostClient setPostable(String string,
                        boolean binary)
Provide a POSTable object as a string. Keep in mind that the this string will not be URL-Encoded or by any means modified prior to the POST operation. It is also up to the user to specify a proper Content-type.

Parameters:
string - String representation of an entity to be posted to a remote server.
binary - Specifies whether the data should be posted in binary format, i.e. as a sequence of bytes or as a character sequence.
Returns:
This post client with an updated value of the postable object.
See Also:
Collection of Media Types

addPostParameter

IPostClient addPostParameter(String paramName,
                             String paramValue)
                             throws NullPointerException
Add a parameter which will be posted to the target URI. Once the parameter is submitted to the PostHttpClient, it is stored as URL-encoded using the UTF-8 encoding.

Parameters:
paramName - Parameter name
paramValue - Parameter value
Returns:
This object
Throws:
NullPointerException - If paramName is null.

getPostLock

ReentrantReadWriteLock.WriteLock getPostLock()


Copyright © 2011-2012 OpenTox. All Rights Reserved.