com.atlassian.greenhopper.web
Class AbstractResource

java.lang.Object
  extended by com.atlassian.greenhopper.global.AbstractLoggable
      extended by com.atlassian.greenhopper.web.AbstractResource
Direct Known Subclasses:
AttachmentsResource, CacheControlResource, CardColorResource, CommentResource, CompleteSprintResource, CreateSprintResource, DetailViewFieldResource, EpicResource, FeaturesResource, IssueResource, JiraTaskResource, PlanningModeResource, ProjectResource, QuickFilterResource, RankResource, RankResource, RapidBoardResource, RapidChartResource, RapidViewEditResource, RapidViewListResource, RapidViewResource, ReleaseResource, SavedFilterResource, SprintIssuesResource, SprintMarkerResource, SprintsResource, SubqueryResource, SwimlaneResource, TeamCalendarsResource, UserDataResource, WelcomeResource, WorkflowResource, WorkResource

public abstract class AbstractResource
extends AbstractLoggable

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


Field Summary
static java.lang.String HTTP_HEADER_GREENHOPPER_GADGET
           
 
Fields inherited from class com.atlassian.greenhopper.global.AbstractLoggable
logger
 
Constructor Summary
AbstractResource()
           
 
Method Summary
 void check(ServiceOutcome<?> 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.
 
Methods inherited from class com.atlassian.greenhopper.global.AbstractLoggable
logDebug, logError, logException, logInfo, logTrace, logWarn, setInfoLogLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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

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 void check(ServiceOutcome<?> 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-2012 Atlassian. All Rights Reserved.