com.atlassian.bamboo.rest.util
Class RESTCall<M extends org.apache.commons.httpclient.HttpMethod>
java.lang.Object
com.atlassian.bamboo.rest.util.RESTCall<M>
- Direct Known Subclasses:
- Delete, Get, Post, Put
public abstract class RESTCall<M extends org.apache.commons.httpclient.HttpMethod>
- extends java.lang.Object
Constructor Summary |
protected |
RESTCall(org.apache.commons.httpclient.HttpClient client,
M method)
|
protected |
RESTCall(M method)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RESTCall
protected RESTCall(org.apache.commons.httpclient.HttpClient client,
M method)
RESTCall
protected RESTCall(M method)
setMarshalledClasses
public void setMarshalledClasses(java.lang.Class... classes)
throws javax.xml.bind.JAXBException
- Throws:
javax.xml.bind.JAXBException
marshal
protected void marshal(java.lang.Object obj,
java.io.OutputStream out)
throws javax.xml.bind.JAXBException
- Throws:
javax.xml.bind.JAXBException
unmarshal
protected java.lang.Object unmarshal(java.io.InputStream in)
throws javax.xml.bind.JAXBException
- Throws:
javax.xml.bind.JAXBException
unmarshal
public <T> T unmarshal(java.lang.Class<T> responseType)
throws java.io.IOException,
javax.xml.bind.JAXBException
- Throws:
java.io.IOException
javax.xml.bind.JAXBException
setBasicCredentials
public void setBasicCredentials(java.lang.String username,
java.lang.String password)
- Configured this call to use Basic HTTP Authentication using the specified username and password. This eliminates
the need to manually encode the Basic authentication string in Authorization request header.
- Parameters:
username
- password
-
setClientProxy
public void setClientProxy()
addRequestHeader
public void addRequestHeader(java.lang.String key,
java.lang.String value)
execute
public void execute()
getStatusCode
public int getStatusCode()
getResponseBody
public byte[] getResponseBody()
- Returns the response body as a byte array.
This assertion must be called after the call has been executed sucessfully, or it will fail the test.
- Returns:
- the response body as a byte array.
getResponseAsStream
public java.io.InputStream getResponseAsStream()
throws java.io.IOException
- Throws:
java.io.IOException
getURI
public java.net.URI getURI()
throws org.apache.commons.httpclient.URIException
- Throws:
org.apache.commons.httpclient.URIException
release
public void release()
- Releases the resources held by the underlying HTTP request. Always call this method (e.g. in a finally clause) to
ensure all HTTP connections are properly closed.
assertExecuted
protected void assertExecuted()
assertNotExecuted
protected void assertNotExecuted()
getMethod
public M getMethod()
Copyright © 2013 Atlassian Software Systems Pty Ltd. All Rights Reserved.