com.atlassian.jira.plugin.link.applinks
Class RemoteResponse<T>

java.lang.Object
  extended by com.atlassian.jira.plugin.link.applinks.RemoteResponse<T>
Type Parameters:
T - the type of entity stored in the response

public class RemoteResponse<T>
extends Object

Represents a response from a remote resource, e.g. REST, XMLRPC.


Constructor Summary
RemoteResponse(T entity, ErrorCollection errors, com.atlassian.sal.api.net.Response response)
           
RemoteResponse(T entity, com.atlassian.sal.api.net.Response response)
           
 
Method Summary
 boolean containsErrorWithText(String... text)
          Checks if any of the error messages contain all of the elements in the text list.
static
<E> RemoteResponse<E>
credentialsRequired(com.atlassian.sal.api.net.Response response)
          Creates a RemoteResponse for when the endpoint requires authentication, but no credentials are available.
 T getEntity()
           
 ErrorCollection getErrors()
          Returns the ErrorCollection from the response entity.
 int getStatusCode()
           
 String getStatusText()
           
 boolean hasErrors()
          Returns true if the response entity was a non-empty ErrorCollection, false if otherwise.
 boolean isSuccessful()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteResponse

public RemoteResponse(@Nullable
                      T entity,
                      @Nullable
                      ErrorCollection errors,
                      com.atlassian.sal.api.net.Response response)

RemoteResponse

public RemoteResponse(@Nullable
                      T entity,
                      com.atlassian.sal.api.net.Response response)
Method Detail

getEntity

public T getEntity()

hasErrors

public boolean hasErrors()
Returns true if the response entity was a non-empty ErrorCollection, false if otherwise.

Returns:
true if the response entity was a non-empty ErrorCollection, false if otherwise

getErrors

public ErrorCollection getErrors()
Returns the ErrorCollection from the response entity. If the response was successful, this will generally be null.

Returns:
the ErrorCollection from the response entity

containsErrorWithText

public boolean containsErrorWithText(String... text)
Checks if any of the error messages contain all of the elements in the text list.

Parameters:
text - an array of snippets to check for in the error message
Returns:
true if an error message contains all of the elements in the text list, false if otherwise

getStatusCode

public int getStatusCode()

getStatusText

public String getStatusText()

isSuccessful

public boolean isSuccessful()

credentialsRequired

public static <E> RemoteResponse<E> credentialsRequired(com.atlassian.sal.api.net.Response response)
Creates a RemoteResponse for when the endpoint requires authentication, but no credentials are available.

Parameters:
response - response requiring authentication
Returns:
RemoteResponse that requires credentials


Copyright © 2002-2012 Atlassian. All Rights Reserved.