public abstract class

AbstractResource

extends Object
java.lang.Object
   ↳ com.atlassian.jira.gadgets.system.AbstractResource
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Lightweight optional convenience base class for REST end points with commonly used methods.

Summary

Public Constructors
AbstractResource()
Protected Methods
Response createErrorResponse(Collection<ValidationError> errors)
Creates an error response using the given errors.
Response createIndexingUnavailableResponse(String message)
Response createValidationResponse(Collection<ValidationError> errors)
Creates a response based on the given errors.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public AbstractResource ()

Protected Methods

protected Response createErrorResponse (Collection<ValidationError> errors)

Creates an error response using the given errors.

Parameters
errors the errors to use for the error response. Should not be empty.
Returns
  • the error response.

protected Response createIndexingUnavailableResponse (String message)

protected Response createValidationResponse (Collection<ValidationError> errors)

Creates a response based on the given errors. If there are no errors, the response will be NO_CONTENT (204). If there are errors, these will be used to return an error response. Many REST validate methods need to first build up a possibly empty collection of ValidationError and then just return the result of calling this method.

Parameters
errors the possibly empty collection of errors.
Returns
  • a success response if the errors are empty, otherwise an error response based on these errors.