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.GDataRequest
URL
that is the target of the GData requestgetRequestUrl
in interface Service.GDataRequest
public ContentType getRequestContentType()
Service.GDataRequest
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.getRequestContentType
in interface Service.GDataRequest
public void setConnectTimeout(int timeout)
Service.GDataRequest
setConnectTimeout
in interface Service.GDataRequest
timeout
- the read timeout. A value of zero indicates an infinite
timeout.URLConnection.setConnectTimeout(int)
public void setReadTimeout(int timeout)
Service.GDataRequest
setReadTimeout
in interface Service.GDataRequest
timeout
- the read timeout. A value of zero indicates an infinite
timeout.URLConnection.setReadTimeout(int)
public void setIfModifiedSince(DateTime conditionDate)
Service.GDataRequest
NotModifiedException
will be thrown. The default
value is null
, indicating no precondition.setIfModifiedSince
in interface Service.GDataRequest
conditionDate
- 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.GDataRequest
null
. 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.GDataRequest
public java.io.OutputStream getRequestStream() throws java.io.IOException
Service.GDataRequest
getRequestStream
in interface Service.GDataRequest
java.io.IOException
- error obtaining the request output stream.public XmlWriter getRequestWriter() throws java.io.IOException
java.io.IOException
public void setMethod(java.lang.String method) throws java.net.ProtocolException
java.net.ProtocolException
public void setHeader(java.lang.String name, java.lang.String value)
Service.GDataRequest
setHeader
in interface Service.GDataRequest
name
- the header namevalue
- the header valuepublic void setPrivateHeader(java.lang.String name, java.lang.String value)
Service.GDataRequest
setPrivateHeader
in interface Service.GDataRequest
name
- the header namevalue
- the header valuepublic void execute() throws java.io.IOException, ServiceException
Service.GDataRequest
execute
in interface Service.GDataRequest
java.io.IOException
- error writing to or reading from GData service.ResourceNotFoundException
- invalid request
target resource.ServiceException
- system error executing request.public ContentType getResponseContentType()
Service.GDataRequest
getResponseContentType
in interface Service.GDataRequest
null
if no
response content.public java.lang.String getResponseHeader(java.lang.String headerName)
Service.GDataRequest
null
if no response header of this type exists.getResponseHeader
in interface Service.GDataRequest
headerName
- name of headerpublic DateTime getResponseDateHeader(java.lang.String headerName)
Service.GDataRequest
null
if no
response header of this type exists or it could not be parsed as a valid
date.getResponseDateHeader
in interface Service.GDataRequest
headerName
- name of headerpublic java.io.InputStream getResponseStream() throws java.io.IOException
Service.GDataRequest
Service.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.GDataRequest
java.io.IOException
- error obtaining the response input stream.public ParseSource getParseSource() throws java.io.IOException
Service.GDataRequest
The 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.GDataRequest
java.io.IOException
- error obtaining the response data.public java.net.HttpURLConnection getConnection()
public void end()
Service.GDataRequest
end
in interface Service.GDataRequest