com.atlassian.jira.rest.v2.entity
Class AbstractRemoteEntityLinkResource<S,T extends RemoteEntityLink<S>>

java.lang.Object
  extended by com.atlassian.jira.rest.v2.entity.AbstractRemoteEntityLinkResource<S,T>
Type Parameters:
S - the target entity (like Version)
T - the entity link type (like RemoteVersionLink)
Direct Known Subclasses:
RemoteVersionLinkResource

public abstract class AbstractRemoteEntityLinkResource<S,T extends RemoteEntityLink<S>>
extends Object

Common toolkit for implementing remote entity link services.

Since:
JIRA REST v6.5.1 (in JIRA 6.1.1)

Field Summary
protected  ContextUriInfo contextUriInfo
           
protected  I18nHelper i18n
           
protected  JiraAuthenticationContext jiraAuthenticationContext
           
protected  JsonEntityPropertyManager jsonEntityPropertyManager
           
 
Constructor Summary
protected AbstractRemoteEntityLinkResource(I18nHelper i18n, JiraAuthenticationContext jiraAuthenticationContext, JsonEntityPropertyManager jsonEntityPropertyManager, ContextUriInfo contextUriInfo)
           
 
Method Summary
protected abstract  URI createSelfLink(T link)
          Forms the self URI for a link.
protected  ApplicationUser getUser()
          Returns the currently logged in user.
protected  RemoteEntityLinksJsonBean toBean(Collection<? extends T> links)
          Creates a list of JSON beans for the provided remote entity links.
protected  RemoteEntityLinkJsonBean toBean(T link)
          Creates a JSON bean for the provided remote entity link.
protected  javax.ws.rs.core.Response toResponse(Collection<? extends T> links)
          Responds with a list of remote entity links.
protected  javax.ws.rs.core.Response toResponse(Object entity)
          Turns a bean into an normal response object.
protected  javax.ws.rs.core.Response toResponse(T link)
          Responds with a single remote entity link.
protected  javax.ws.rs.core.Response toSuccessfulDeleteResponse()
          Forms a 204 response with no content to acknowledge the successful deletion.
protected  javax.ws.rs.core.Response toSuccessfulPostResponse(T link)
          Forms a 201 response with a Location: header pointing to link's self URI.
protected
<T extends ServiceResult>
T
valid(T result)
          Verifies that the provided service result is error-free.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

i18n

protected final I18nHelper i18n

jiraAuthenticationContext

protected final JiraAuthenticationContext jiraAuthenticationContext

jsonEntityPropertyManager

protected final JsonEntityPropertyManager jsonEntityPropertyManager

contextUriInfo

protected final ContextUriInfo contextUriInfo
Constructor Detail

AbstractRemoteEntityLinkResource

protected AbstractRemoteEntityLinkResource(I18nHelper i18n,
                                           JiraAuthenticationContext jiraAuthenticationContext,
                                           JsonEntityPropertyManager jsonEntityPropertyManager,
                                           ContextUriInfo contextUriInfo)
Method Detail

toBean

protected RemoteEntityLinkJsonBean toBean(T link)
Creates a JSON bean for the provided remote entity link.

Parameters:
link - the remote entity link to be written out
Returns:
the corresponding bean

toBean

protected RemoteEntityLinksJsonBean toBean(Collection<? extends T> links)
Creates a list of JSON beans for the provided remote entity links.

Parameters:
links - the remote entity links to be written out
Returns:
the corresponding bean

toResponse

protected javax.ws.rs.core.Response toResponse(T link)
Responds with a single remote entity link. This convenience method is equivalent to toResponse(toBean(link)).

Parameters:
link - the remote entity link to write
Returns:
a response containing the link

toResponse

protected javax.ws.rs.core.Response toResponse(Collection<? extends T> links)
Responds with a list of remote entity links. This convenience method is equivalent to toResponse(toBean(links)).

Parameters:
links - the remote entity links to be written out
Returns:
the response containing the links

toResponse

protected javax.ws.rs.core.Response toResponse(Object entity)
Turns a bean into an normal response object.

Parameters:
entity - the object to respond with
Returns:
the response

toSuccessfulPostResponse

protected javax.ws.rs.core.Response toSuccessfulPostResponse(T link)
Forms a 201 response with a Location: header pointing to link's self URI.

Parameters:
link - the newly created link
Returns:
the successful response

toSuccessfulDeleteResponse

protected javax.ws.rs.core.Response toSuccessfulDeleteResponse()
Forms a 204 response with no content to acknowledge the successful deletion.

Returns:
the successful response

createSelfLink

protected abstract URI createSelfLink(T link)
Forms the self URI for a link.

Parameters:
link - the link to be rendered as a URI
Returns:
the self URI for the link

valid

protected <T extends ServiceResult> T valid(T result)
Verifies that the provided service result is error-free. If it is invalid, then we throw the appropriate RESTException containing the error collection instead of returning the result.

Type Parameters:
T - the inferred service result class
Parameters:
result - the service result to validate
Returns:
result itself

getUser

protected ApplicationUser getUser()
Returns the currently logged in user.

Returns:
the currently logged in user.


Copyright © 2002-2014 Atlassian. All Rights Reserved.