public abstract class TransportProviderBase extends java.lang.Object implements TransportProvider
Constructor and Description |
---|
TransportProviderBase() |
Modifier and Type | Method and Description |
---|---|
abstract void |
close()
Release all resources acquired by this provider
|
protected byte[] |
compress(byte[] source,
int offset,
int size)
Compress the content using GZip compression.
|
protected byte[] |
decompress(byte[] source,
int offset,
int size)
Decompress the GZip-compressed data
|
abstract byte[] |
delete(java.lang.String path,
java.lang.String acceptType)
Send a DELETE request to the server
|
abstract byte[] |
get(java.lang.String path,
java.lang.String acceptType)
Send a GET request to the server
|
protected int |
getDebugLevel() |
protected Credentials |
getProxyCredentials() |
protected java.net.URI |
getProxyLocation() |
protected java.net.ProxySelector |
getProxySelector() |
protected java.lang.String |
getRequestPath(java.lang.String path)
Build a sanitized path relative to the service location.
|
protected Credentials |
getServiceCredentials() |
protected java.net.URI |
getServiceLocation() |
protected java.lang.String |
getUserAgent() |
abstract boolean |
head(java.lang.String path)
Send a HEAD request to the server
|
abstract byte[] |
post(java.lang.String path,
byte[] content,
java.lang.String contentType,
java.lang.String acceptType)
Send a POST request to the server
|
abstract byte[] |
put(java.lang.String path,
byte[] content,
java.lang.String contentType)
Send a PUT request to the server
|
protected byte[] |
readResponseBody(java.io.InputStream inputStream)
Read the stream fully into a byte array.
|
void |
setDebugLevel(int debugLevel)
Set the extent to which debug messages are produced
|
void |
setProxyCredentials(Credentials proxyCredentials)
Set the credentials for a proxy requiring authentication
|
void |
setProxyLocation(java.net.URI proxyLocation)
Route requests through a proxy server.
|
void |
setServiceCredentials(Credentials serviceCredentials)
Set the service credentials
|
void |
setServiceLocation(java.net.URI serviceLocation)
Set the service endpoint location
|
void |
setUserAgent(java.lang.String userAgent)
Set the content of the User-Agent header to be passed to the server.
|
java.lang.String |
toString() |
public java.lang.String toString()
toString
in class java.lang.Object
public void setServiceLocation(java.net.URI serviceLocation) throws AnaplanAPITransportException
setServiceLocation
in interface TransportProvider
serviceLocation
- the service endpoint locationAnaplanAPITransportException
protected java.net.URI getServiceLocation()
public void setServiceCredentials(Credentials serviceCredentials) throws AnaplanAPITransportException
setServiceCredentials
in interface TransportProvider
serviceCredentials
- the service credentialsAnaplanAPITransportException
protected Credentials getServiceCredentials()
public void setProxyLocation(java.net.URI proxyLocation) throws AnaplanAPITransportException
setProxyLocation
in interface TransportProvider
proxyLocation
- the location of the proxy serverAnaplanAPITransportException
protected java.net.URI getProxyLocation()
public void setProxyCredentials(Credentials proxyCredentials) throws AnaplanAPITransportException
setProxyCredentials
in interface TransportProvider
proxyCredentials
- the proxy credentialsAnaplanAPITransportException
protected Credentials getProxyCredentials()
protected java.net.ProxySelector getProxySelector()
public void setUserAgent(java.lang.String userAgent)
setUserAgent
in interface TransportProvider
userAgent
- The User-Agent header valueprotected java.lang.String getUserAgent()
public void setDebugLevel(int debugLevel)
setDebugLevel
in interface TransportProvider
debugLevel
- the debug level; 0 (the default) means no outputprotected int getDebugLevel()
public abstract byte[] get(java.lang.String path, java.lang.String acceptType) throws AnaplanAPITransportException
TransportProvider
get
in interface TransportProvider
path
- The path relative to the service endpoint locationacceptType
- The Accept header to indicate the format of content
expected in the reponse bodyAnaplanAPITransportException
- a communication or protocol error occuredpublic abstract boolean head(java.lang.String path) throws AnaplanAPITransportException
TransportProvider
head
in interface TransportProvider
path
- The path relative to the service endpoint locationAnaplanAPITransportException
- a communication or protocol error occuredpublic abstract byte[] post(java.lang.String path, byte[] content, java.lang.String contentType, java.lang.String acceptType) throws AnaplanAPITransportException
TransportProvider
post
in interface TransportProvider
path
- The path relative to the service endpoint locationcontent
- The content to send in the request bodycontentType
- The value for the Content-Type header to indicate
the format of the content in the request bodyacceptType
- The Accept header to indicate the format of content
expected in the reponse bodyAnaplanAPITransportException
- a communication or protocol error occuredpublic abstract byte[] put(java.lang.String path, byte[] content, java.lang.String contentType) throws AnaplanAPITransportException
TransportProvider
put
in interface TransportProvider
path
- The path relative to the service endpoint locationcontent
- The content to send in the request bodycontentType
- The value for the Content-Type header to indicate
the format of the content in the request bodyAnaplanAPITransportException
- a communication or protocol error occuredpublic abstract byte[] delete(java.lang.String path, java.lang.String acceptType) throws AnaplanAPITransportException
TransportProvider
delete
in interface TransportProvider
path
- The path relative to the service endpoint locationacceptType
- The Accept header to indicate the format of content
expected in the reponse bodyAnaplanAPITransportException
- a communication or protocol error occuredpublic abstract void close()
TransportProvider
close
in interface TransportProvider
protected java.lang.String getRequestPath(java.lang.String path)
path
- The relative path, which should start with a '/'protected byte[] readResponseBody(java.io.InputStream inputStream) throws AnaplanAPITransportException
inputStream
- the stream to readAnaplanAPITransportException
protected byte[] compress(byte[] source, int offset, int size) throws AnaplanAPITransportException
source
- the byte array containing the content to be compressedoffset
- the start offset of the data to be compressedsize
- the length of the data, in bytes, to be compressedAnaplanAPITransportException
protected byte[] decompress(byte[] source, int offset, int size) throws AnaplanAPITransportException
source
- the byte array containing the data to be decompressedoffset
- the start offset of the data to be decompressedsize
- the length of the compressed data, in bytesAnaplanAPITransportException
- if the compressed data is invalid