public class HttpGDataRequest extends java.lang.Object implements Service.GDataRequest
GDataRequest interface over HTTP.Service.GDataRequest| Modifier and Type | Class and Description |
|---|---|
static class |
HttpGDataRequest.Factory
The HttpGDataRequest.Factory class is a factory class for constructing
new HttpGDataRequest instances.
|
Service.GDataRequest.RequestType| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
METHOD_OVERRIDE_HEADER
Deprecated.
Use
GDataProtocol.Header#METHOD_OVERRIDE instead |
static java.lang.String |
METHOD_OVERRIDE_PROPERTY
If this system property is set to
true, the GData HTTP
client library will use POST to send data to the associated GData service
and will specify the actual method using the METHOD_OVERRIDE_HEADER
HTTP header. |
| Modifier and Type | Method and Description |
|---|---|
void |
end()
Ends all processing associated with this request and releases any
transient resources (such as open data streams) required for execution.
|
void |
execute()
Executes the GData service request.
|
java.net.HttpURLConnection |
getConnection()
Returns the URLConnection instance that represents the underlying
connection to the GData service that will be used by this request.
|
ParseSource |
getParseSource()
Returns a parse source that can be used to read response data from the
GData service.
|
ContentType |
getRequestContentType()
Returns the
ContentType of the data that will be written to the
service by this request or null if no data is written to the
server by the request. |
java.io.OutputStream |
getRequestStream()
Returns a stream that can be used to write request data to the GData
service.
|
java.net.URL |
getRequestUrl()
Returns the
URL that is the target of the GData request |
XmlWriter |
getRequestWriter() |
ContentType |
getResponseContentType()
Returns the content type of the GData response.
|
DateTime |
getResponseDateHeader(java.lang.String headerName)
Returns the value of a header containing a header or
null if no
response header of this type exists or it could not be parsed as a valid
date. |
java.lang.String |
getResponseHeader(java.lang.String headerName)
Returns the value of the specified response header name or
null
if no response header of this type exists. |
java.io.InputStream |
getResponseStream()
Returns an input stream that can be used to read response data from the
GData service.
|
void |
setConnectTimeout(int timeout)
Sets the number of milliseconds to wait for a connection to the remote
GData service before timing out.
|
void |
setEtag(java.lang.String etag)
Sets the entity tag value that will be used to conditionalize the request
if not
null. |
void |
setHeader(java.lang.String name,
java.lang.String value)
Sets a request header (and logs it, if logging is enabled)
|
void |
setIfModifiedSince(DateTime conditionDate)
Sets the If-Modified-Since date precondition to be applied to the
request.
|
void |
setMethod(java.lang.String method) |
void |
setPrivateHeader(java.lang.String name,
java.lang.String value)
Sets request header (and log just the name but not the value, if logging
is enabled)
|
void |
setReadTimeout(int timeout)
Sets the number of milliseconds to wait for a response from the remote
GData service before timing out.
|
public static final java.lang.String METHOD_OVERRIDE_PROPERTY
true, the GData HTTP
client library will use POST to send data to the associated GData service
and will specify the actual method using the METHOD_OVERRIDE_HEADER
HTTP header. This can be used as a workaround for HTTP proxies or gateways
that do not handle PUT or DELETE HTTP methods properly. If the system
property is false, the regular PUT and DELETE HTTP verbs
will be used.@Deprecated public static final java.lang.String METHOD_OVERRIDE_HEADER
GDataProtocol.Header#METHOD_OVERRIDE insteadpublic java.net.URL getRequestUrl()
Service.GDataRequestURL that is the target of the GData requestgetRequestUrl in interface Service.GDataRequestpublic ContentType getRequestContentType()
Service.GDataRequestContentType of the data that will be written to the
service by this request or null if no data is written to the
server by the request.getRequestContentType in interface Service.GDataRequestpublic void setConnectTimeout(int timeout)
Service.GDataRequestsetConnectTimeout in interface Service.GDataRequesttimeout - the read timeout. A value of zero indicates an infinite
timeout.URLConnection.setConnectTimeout(int)public void setReadTimeout(int timeout)
Service.GDataRequestsetReadTimeout in interface Service.GDataRequesttimeout - the read timeout. A value of zero indicates an infinite
timeout.URLConnection.setReadTimeout(int)public void setIfModifiedSince(DateTime conditionDate)
Service.GDataRequestNotModifiedException will be thrown. The default
value is null, indicating no precondition.setIfModifiedSince in interface Service.GDataRequestconditionDate - the date that should be used to limit the operation
on the target resource. The operation will only be performed if
the resource has been modified later than the specified date.public void setEtag(java.lang.String etag)
Service.GDataRequestnull. For a query requests, the tag will cause the target
resource to be returned if the resource entity tag does not match
the specified value (i.e. if the resource has not changed). For update or
delete request types, the entity tag value is used to indicate that the
requested operation should occur only if the specified etag value does
match the specified value (i.e. if the resource has changed). A
request entity tag value may not be associated with other request types.setEtag in interface Service.GDataRequestpublic java.io.OutputStream getRequestStream()
throws java.io.IOException
Service.GDataRequestgetRequestStream in interface Service.GDataRequestjava.io.IOException - error obtaining the request output stream.public XmlWriter getRequestWriter() throws java.io.IOException
java.io.IOExceptionpublic void setMethod(java.lang.String method)
throws java.net.ProtocolException
java.net.ProtocolExceptionpublic void setHeader(java.lang.String name,
java.lang.String value)
Service.GDataRequestsetHeader in interface Service.GDataRequestname - the header namevalue - the header valuepublic void setPrivateHeader(java.lang.String name,
java.lang.String value)
Service.GDataRequestsetPrivateHeader in interface Service.GDataRequestname - the header namevalue - the header valuepublic void execute()
throws java.io.IOException,
ServiceException
Service.GDataRequestexecute in interface Service.GDataRequestjava.io.IOException - error writing to or reading from GData service.ResourceNotFoundException - invalid request
target resource.ServiceException - system error executing request.public ContentType getResponseContentType()
Service.GDataRequestgetResponseContentType in interface Service.GDataRequestnull if no
response content.public java.lang.String getResponseHeader(java.lang.String headerName)
Service.GDataRequestnull
if no response header of this type exists.getResponseHeader in interface Service.GDataRequestheaderName - name of headerpublic DateTime getResponseDateHeader(java.lang.String headerName)
Service.GDataRequestnull if no
response header of this type exists or it could not be parsed as a valid
date.getResponseDateHeader in interface Service.GDataRequestheaderName - name of headerpublic java.io.InputStream getResponseStream()
throws java.io.IOException
Service.GDataRequestService.GDataRequest.getParseSource() instead.
The caller is responsible for ensuring that the input stream is properly closed after the response has been read.
getResponseStream in interface Service.GDataRequestjava.io.IOException - error obtaining the response input stream.public ParseSource getParseSource() throws java.io.IOException
Service.GDataRequestThe caller is responsible for ensuring that input streams and readers contained in the parse source are properly closed after the response has been read.
getParseSource in interface Service.GDataRequestjava.io.IOException - error obtaining the response data.public java.net.HttpURLConnection getConnection()
public void end()
Service.GDataRequestend in interface Service.GDataRequest