@Component public class ResponseFactoryImpl extends Object implements ResponseFactory
Constructor and Description |
---|
ResponseFactoryImpl(I18nHelper i18nBean) |
Modifier and Type | Method and Description |
---|---|
javax.ws.rs.core.Response |
badRequest(String i18nKey,
String... args)
Constructs a "bad request" (400) HTTP reposne without caching.
|
javax.ws.rs.core.Response |
created(URI self,
Object entity)
Constructs CREATED response with cache control set to never
|
javax.ws.rs.core.Response |
errorResponse(ErrorCollection errorCollection)
Creates an appropriate REST error response out of error collection.
|
javax.ws.rs.core.Response |
forbidden(String i18nKey,
String... args)
Constructs "forbidden" (403) HTTP response without caching.
|
javax.ws.rs.core.Response |
generateErrorResponse(ErrorCollection errors)
Given a list of errors generate a http response
|
javax.ws.rs.core.Response |
generateFieldErrorResponse(ErrorCollection errors)
Given a list of errors generate a http response
|
javax.ws.rs.core.Response |
noContent()
Constructs "no content" (204) HTTP response with cache control set to never
|
javax.ws.rs.core.Response |
notFound(String i18nKey,
String... args)
Constructs "not found" (404) HTTP response without caching.
|
javax.ws.rs.core.Response |
notLoggedInResponse()
Creates a response that tells the user they can't use a feature when they are not logged in
|
javax.ws.rs.core.Response |
okNoCache(Object entity)
Constructs OK response with cache control set to never
|
javax.ws.rs.core.Response |
serviceResultToNoContentResponse(ServiceResult serviceResult)
Transforms a service result to "no content" (204) HTTP response with cache control set to never
if the result is valid, or error response is invalid.
|
<T> io.atlassian.fugue.Either<javax.ws.rs.core.Response,T> |
toResponse(io.atlassian.fugue.Either<ErrorCollection,T> either)
Maps
ErrorCollection in an Either to a Response . |
<T> io.atlassian.fugue.Either<javax.ws.rs.core.Response,T> |
validateOutcome(ServiceOutcome<T> outcome)
Returns a proper error response if the outcome is invalid, or the outcome value otherwise.
|
@Autowired public ResponseFactoryImpl(I18nHelper i18nBean)
public javax.ws.rs.core.Response notLoggedInResponse()
ResponseFactory
notLoggedInResponse
in interface ResponseFactory
public javax.ws.rs.core.Response errorResponse(ErrorCollection errorCollection)
ResponseFactory
errorResponse
in interface ResponseFactory
errorCollection
- errors that will be sent back to the user and from which the HTTP response status will be
figured outpublic javax.ws.rs.core.Response okNoCache(Object entity)
ResponseFactory
okNoCache
in interface ResponseFactory
entity
- object that will be sent in the responseentity
public javax.ws.rs.core.Response created(URI self, Object entity)
ResponseFactory
created
in interface ResponseFactory
self
- URI to the newly created entityentity
- object that will be sent in the responseentity
public javax.ws.rs.core.Response noContent()
ResponseFactory
noContent
in interface ResponseFactory
public javax.ws.rs.core.Response badRequest(String i18nKey, String... args)
ResponseFactory
badRequest
in interface ResponseFactory
i18nKey
- key of the i18n message which is included in the response.args
- arguments to be added to the internationalised message.public javax.ws.rs.core.Response forbidden(String i18nKey, String... args)
ResponseFactory
forbidden
in interface ResponseFactory
i18nKey
- key of the i18n message which is included in the response.public javax.ws.rs.core.Response notFound(String i18nKey, String... args)
ResponseFactory
notFound
in interface ResponseFactory
i18nKey
- key of the i18n message which is included in the response.public javax.ws.rs.core.Response generateFieldErrorResponse(ErrorCollection errors)
generateFieldErrorResponse
in interface ResponseFactory
errors
- generatedpublic javax.ws.rs.core.Response generateErrorResponse(ErrorCollection errors)
ResponseFactory
generateErrorResponse
in interface ResponseFactory
errors
- generatedpublic <T> io.atlassian.fugue.Either<javax.ws.rs.core.Response,T> validateOutcome(ServiceOutcome<T> outcome)
ResponseFactory
validateOutcome
in interface ResponseFactory
T
- service outcome value typeoutcome
- service outcomepublic javax.ws.rs.core.Response serviceResultToNoContentResponse(ServiceResult serviceResult)
ResponseFactory
serviceResultToNoContentResponse
in interface ResponseFactory
serviceResult
- service result to validatepublic <T> io.atlassian.fugue.Either<javax.ws.rs.core.Response,T> toResponse(io.atlassian.fugue.Either<ErrorCollection,T> either)
ResponseFactory
ErrorCollection
in an Either
to a Response
.toResponse
in interface ResponseFactory
T
- type of right valueeither
- either to map the left value inCopyright © 2002-2019 Atlassian. All Rights Reserved.