com.atlassian.greenhopper.web
Class AbstractResource

java.lang.Object
  extended by com.atlassian.greenhopper.web.AbstractResource
Direct Known Subclasses:
AttachmentsResource, CacheControlResource, CardColorResource, ClassicMigrationResource, CompleteSprintResource, DetailViewFieldResource, EpicResource, FeaturesResource, FixVersionResource, FlagResource, IssueResource, JiraTaskResource, PlanningModeResource, ProjectResource, QuickFilterResource, RankResource, RankResource, RapidBoardResource, RapidChartResource, RapidViewEditResource, RapidViewListResource, RapidViewResource, ReleaseResource, SavedFilterResource, SprintHealthResource, SprintMarkerMigrationResource, SprintMigrationBannerResource, SprintQueryResource, SprintRankResource, SprintRemainingDaysResource, SprintResource, StartSprintResource, SubqueryResource, SwimlaneResource, TeamCalendarsResource, UserDataResource, VersionResource, WelcomeResource, WorkflowResource, WorkingDaysResource, WorkResource

public abstract class AbstractResource
extends java.lang.Object

To be extended by all GreenHopper rest resources. Provides no-cache logic.


Field Summary
static java.lang.String HTTP_HEADER_GREENHOPPER_GADGET
           
protected  LoggerWrapper log
           
 
Constructor Summary
AbstractResource()
           
 
Method Summary
<T> T
check(ServiceOutcome<T> outcome)
          Check this outcome for errors.
 javax.ws.rs.core.Response createErrorResponse(ErrorCollection errors)
          Deprecated. 
 javax.ws.rs.core.Response createFromServiceOutcome(ServiceOutcome<? extends RestTemplate> outcome)
          Deprecated. 
 javax.ws.rs.core.Response createNoContentResponse()
           
 javax.ws.rs.core.Response createOkResponse(RestTemplate entity)
          Returns an ok response with NO_CACHE headers applied to it.
 javax.ws.rs.core.Response createOkResponse(RestTemplate template, javax.ws.rs.core.EntityTag eTag)
          Creates an ok response including an etag.
protected  com.atlassian.crowd.embedded.api.User getUser()
           
protected  boolean isGadgetRequest()
          Is this request for rendering a gadget? GH.Ajax.get() puts in a special header if sending ajax requests for gadgets.
protected
<T> java.util.Set<T>
nullSafe(java.util.Set<T> set)
          Used for converting sets created by Jersey.
protected  javax.ws.rs.core.Response response(java.util.concurrent.Callable<javax.ws.rs.core.Response> responseCallable)
          A standard way to invoke a REST resource and handle errors that might be throw.
 void wireAuthenticationContext(com.atlassian.jira.security.JiraAuthenticationContext authenticationContext)
           
 void wireI18nFactoryService(I18nFactoryService i18nFactoryService)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final LoggerWrapper log

HTTP_HEADER_GREENHOPPER_GADGET

public static final java.lang.String HTTP_HEADER_GREENHOPPER_GADGET
See Also:
Constant Field Values
Constructor Detail

AbstractResource

public AbstractResource()
Method Detail

wireI18nFactoryService

public void wireI18nFactoryService(I18nFactoryService i18nFactoryService)

wireAuthenticationContext

public void wireAuthenticationContext(com.atlassian.jira.security.JiraAuthenticationContext authenticationContext)

response

protected javax.ws.rs.core.Response response(java.util.concurrent.Callable<javax.ws.rs.core.Response> responseCallable)
A standard way to invoke a REST resource and handle errors that might be throw. JIRA as of 5.0 lose stuff when bad errors happen and this way any badness is captured into atlassian-greenhopper.log

Parameters:
responseCallable - a callable block of code
Returns:
the REST response from that callable block of code

createOkResponse

public javax.ws.rs.core.Response createOkResponse(RestTemplate entity)
Returns an ok response with NO_CACHE headers applied to it.

Parameters:
entity - the returned rest template
Returns:
a REST response

createOkResponse

public javax.ws.rs.core.Response createOkResponse(RestTemplate template,
                                                  javax.ws.rs.core.EntityTag eTag)
Creates an ok response including an etag.

Parameters:
template - the template to used
eTag - an entity tag
Returns:
a REST response

createNoContentResponse

public javax.ws.rs.core.Response createNoContentResponse()

createFromServiceOutcome

@Deprecated
public javax.ws.rs.core.Response createFromServiceOutcome(ServiceOutcome<? extends RestTemplate> outcome)
Deprecated. 


createErrorResponse

@Deprecated
public javax.ws.rs.core.Response createErrorResponse(ErrorCollection errors)
Deprecated. 


check

public <T> T check(ServiceOutcome<T> outcome)
Check this outcome for errors. If found, will implement ErrorCollection.checkErrors(com.atlassian.greenhopper.model.I18n2), which will throw some REST exceptions.

Parameters:
outcome - the outcome to check

nullSafe

protected <T> java.util.Set<T> nullSafe(java.util.Set<T> set)
Used for converting sets created by Jersey. They're null if the respective parameter wasn't specified. Null collections are bad. Stupid Jersey.

Parameters:
set - that cant be null
Returns:
a non null set

getUser

protected com.atlassian.crowd.embedded.api.User getUser()

isGadgetRequest

protected boolean isGadgetRequest()
Is this request for rendering a gadget? GH.Ajax.get() puts in a special header if sending ajax requests for gadgets.

Returns:
true or false


Copyright © 2007-2013 Atlassian. All Rights Reserved.