com.atlassian.confluence.it
Class RestHelper

java.lang.Object
  extended by com.atlassian.confluence.it.RestHelper

public class RestHelper
extends java.lang.Object

Provides methods for creating REST WebResource objects and processing REST calls.


Field Summary
static java.lang.String BASE_URL
          Deprecated. since 5.6 Use BaseUrlSelector.getBaseUrl()
static java.lang.String PROTOTYPE_REST_PATH
           
static java.lang.String REST_PATH
          Deprecated. since 5.6 Use PROTOTYPE_REST_PATH
 
Constructor Summary
RestHelper()
           
 
Method Summary
static void doDeleteJson(java.lang.String url, User user)
           
static
<T> T
doGet(com.sun.jersey.api.client.WebResource resource, java.lang.Class<T> entityClass)
           
static
<T> T
doGet(com.sun.jersey.api.client.WebResource resource, java.lang.Class<T> entityClass, java.lang.String requestType)
           
static com.sun.jersey.api.client.ClientResponse doGetRequest(com.sun.jersey.api.client.WebResource resource, java.lang.String requestType)
           
static java.net.URI doPost(com.sun.jersey.api.client.WebResource resource, java.lang.Object entity)
           
static
<T> T
doPut(com.sun.jersey.api.client.WebResource resource, T entity)
           
static
<T> T
doPut(com.sun.jersey.api.client.WebResource resource, T entity, java.lang.String requestType)
           
static
<T> T
doRawGet(com.sun.jersey.api.client.WebResource resource, java.lang.Class<T> entityClass)
          Do a get without asserting success
static
<T> T
doRawGet(com.sun.jersey.api.client.WebResource resource, java.lang.Class<T> entityClass, java.lang.String requestType)
          Do a get without asserting success, specifying the request type.
static com.sun.jersey.api.client.WebResource expand(com.sun.jersey.api.client.WebResource webResource, java.lang.String... values)
           
static com.sun.jersey.api.client.WebResource expandWithIndexes(com.sun.jersey.api.client.WebResource webResource, java.lang.String value, int start, int end)
           
static org.codehaus.jackson.JsonNode fetchJsonResponse(com.sun.jersey.api.client.WebResource resource)
          Send a GET request to the provided WebResource and return the response as a JSON object.
static com.sun.jersey.api.client.Client getClient()
          Return a jersey client configured for Jackson annotations.
static com.sun.jersey.api.client.Client getClient(org.codehaus.jackson.map.Module jacksonModule)
          Returns a Client configured with the provided jackson module for custom deserialization.
static java.lang.String getFullRestPath()
          Deprecated. since 5.6. Use getPrototypeRestBaseUrl(String) or getPrototypeRestBaseUrl(BaseUrlSelector)
static com.sun.jersey.api.client.ClientResponse getGETResponse(java.lang.String relativePath, User user, java.util.Map<java.lang.String,java.lang.String> params)
          Deprecated. 
static JSONObject getJsonResponse(com.sun.jersey.api.client.WebResource resource)
          Deprecated. Since 5.4 Use fetchJsonResponse(com.sun.jersey.api.client.WebResource)
static java.lang.String getJsonResponseString(com.sun.jersey.api.client.WebResource resource)
          Send a GET request to the provided WebResource and return the response as a JSON string.
static java.lang.String getPrototypeRestBaseUrl(BaseUrlSelector baseUrlSelector)
           
static java.lang.String getPrototypeRestBaseUrl(java.lang.String baseUrl)
           
static com.sun.jersey.api.client.WebResource getRootResource(User user)
          Deprecated. since 5.6 Use newResource(String, User)
static com.sun.jersey.api.client.Client newClient()
          Create a new Jersey client configured for Jackson annotations.
static com.sun.jersey.api.client.Client newClient(org.codehaus.jackson.map.Module jacksonModule)
          Creates a new client configured with the provided jackson module for custom deserialization
static com.sun.jersey.api.client.WebResource.Builder newJsonResource(java.lang.String url, User user)
          Returns a new web resource accepting JSON, with OS credentials for the passed user.
static com.sun.jersey.api.client.WebResource newResource(java.lang.String url, User user)
          Returns a new web resource with OS credentials for the passed user.
static com.sun.jersey.api.client.WebResource newResource(User user)
          Deprecated. since 5.6 Use newResource(String, User)
static org.codehaus.jackson.JsonNode postJson(java.lang.String url, java.lang.String jsonPayload, User user)
           
static void postJsonWithNoResponse(java.lang.String url, java.lang.String jsonPayload, User user)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASE_URL

@Deprecated
public static final java.lang.String BASE_URL
Deprecated. since 5.6 Use BaseUrlSelector.getBaseUrl()

PROTOTYPE_REST_PATH

public static final java.lang.String PROTOTYPE_REST_PATH
See Also:
Constant Field Values

REST_PATH

@Deprecated
public static final java.lang.String REST_PATH
Deprecated. since 5.6 Use PROTOTYPE_REST_PATH
See Also:
Constant Field Values
Constructor Detail

RestHelper

public RestHelper()
Method Detail

newResource

@Deprecated
public static com.sun.jersey.api.client.WebResource newResource(User user)
Deprecated. since 5.6 Use newResource(String, User)


getRootResource

@Deprecated
public static com.sun.jersey.api.client.WebResource getRootResource(User user)
Deprecated. since 5.6 Use newResource(String, User)


newClient

public static com.sun.jersey.api.client.Client newClient()
Create a new Jersey client configured for Jackson annotations.


newClient

public static com.sun.jersey.api.client.Client newClient(org.codehaus.jackson.map.Module jacksonModule)
Creates a new client configured with the provided jackson module for custom deserialization

Parameters:
jacksonModule -
Returns:

getClient

public static com.sun.jersey.api.client.Client getClient(org.codehaus.jackson.map.Module jacksonModule)
Returns a Client configured with the provided jackson module for custom deserialization. May return a client previously used, or currently in use, by another test.


getClient

public static com.sun.jersey.api.client.Client getClient()
Return a jersey client configured for Jackson annotations. May return a client previously used, or currently in use, by another test.


newResource

public static com.sun.jersey.api.client.WebResource newResource(java.lang.String url,
                                                                User user)
Returns a new web resource with OS credentials for the passed user.


newJsonResource

public static com.sun.jersey.api.client.WebResource.Builder newJsonResource(java.lang.String url,
                                                                            User user)
Returns a new web resource accepting JSON, with OS credentials for the passed user.


getJsonResponse

@Deprecated
public static JSONObject getJsonResponse(com.sun.jersey.api.client.WebResource resource)
                                  throws JSONException
Deprecated. Since 5.4 Use fetchJsonResponse(com.sun.jersey.api.client.WebResource)

Send a GET request to the provided WebResource and return the response as a JSON object.

Throws:
JSONException

fetchJsonResponse

public static org.codehaus.jackson.JsonNode fetchJsonResponse(com.sun.jersey.api.client.WebResource resource)
                                                       throws java.io.IOException
Send a GET request to the provided WebResource and return the response as a JSON object.

Throws:
java.io.IOException

getJsonResponseString

public static java.lang.String getJsonResponseString(com.sun.jersey.api.client.WebResource resource)
Send a GET request to the provided WebResource and return the response as a JSON string.


postJson

public static org.codehaus.jackson.JsonNode postJson(java.lang.String url,
                                                     java.lang.String jsonPayload,
                                                     User user)
                                              throws java.io.IOException
Throws:
java.io.IOException

postJsonWithNoResponse

public static void postJsonWithNoResponse(java.lang.String url,
                                          java.lang.String jsonPayload,
                                          User user)

doDeleteJson

public static void doDeleteJson(java.lang.String url,
                                User user)

doGet

public static <T> T doGet(com.sun.jersey.api.client.WebResource resource,
                          java.lang.Class<T> entityClass)

doGet

public static <T> T doGet(com.sun.jersey.api.client.WebResource resource,
                          java.lang.Class<T> entityClass,
                          java.lang.String requestType)

getFullRestPath

@Deprecated
public static java.lang.String getFullRestPath()
Deprecated. since 5.6. Use getPrototypeRestBaseUrl(String) or getPrototypeRestBaseUrl(BaseUrlSelector)


getPrototypeRestBaseUrl

public static java.lang.String getPrototypeRestBaseUrl(BaseUrlSelector baseUrlSelector)

getPrototypeRestBaseUrl

public static java.lang.String getPrototypeRestBaseUrl(java.lang.String baseUrl)

getGETResponse

@Deprecated
public static com.sun.jersey.api.client.ClientResponse getGETResponse(java.lang.String relativePath,
                                                                                 User user,
                                                                                 java.util.Map<java.lang.String,java.lang.String> params)
Deprecated. 


doRawGet

public static <T> T doRawGet(com.sun.jersey.api.client.WebResource resource,
                             java.lang.Class<T> entityClass)
Do a get without asserting success


doRawGet

public static <T> T doRawGet(com.sun.jersey.api.client.WebResource resource,
                             java.lang.Class<T> entityClass,
                             java.lang.String requestType)
Do a get without asserting success, specifying the request type.


doGetRequest

public static com.sun.jersey.api.client.ClientResponse doGetRequest(com.sun.jersey.api.client.WebResource resource,
                                                                    java.lang.String requestType)

doPut

public static <T> T doPut(com.sun.jersey.api.client.WebResource resource,
                          T entity)

doPut

public static <T> T doPut(com.sun.jersey.api.client.WebResource resource,
                          T entity,
                          java.lang.String requestType)

doPost

public static java.net.URI doPost(com.sun.jersey.api.client.WebResource resource,
                                  java.lang.Object entity)

expand

public static com.sun.jersey.api.client.WebResource expand(com.sun.jersey.api.client.WebResource webResource,
                                                           java.lang.String... values)

expandWithIndexes

public static com.sun.jersey.api.client.WebResource expandWithIndexes(com.sun.jersey.api.client.WebResource webResource,
                                                                      java.lang.String value,
                                                                      int start,
                                                                      int end)


Copyright © 2003-2014 Atlassian. All Rights Reserved.