Class RemoteResponse<T>

java.lang.Object
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 Details

    • 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 Details

    • 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
    • setStatusCode

      public void setStatusCode(int statusCode)
    • setSuccessful

      public void setSuccessful(boolean success)
    • toString

      public String toString()
      Overrides:
      toString in class Object