Class AbstractResource

java.lang.Object
com.atlassian.greenhopper.web.AbstractResource
Direct Known Subclasses:
AbstractGadgetResource, AssigneeUserPickerResource, AttachmentsResource, BoardSidebarResource, CacheControlResource, CardColorResource, CardLayoutResource, CompleteSprintResource, DetailViewFieldResource, EpicPropertiesResource, EpicResource, FeaturesResource, FlagResource, IncompleteIssuesDestinationSuggestionsResource, IssueResource, JiraTaskResource, KanbanPlanModeResource, LexoRankResource, ManagedCustomFieldsResource, ManagedIssueLinkTypesResource, ManagedIssueTypesResource, PlanningModeResource, ProjectResource, QuickFilterResource, RankResource, RankResource, RapidBoardResource, RapidChartResource, RapidViewEditResource, RapidViewListResource, RapidViewResource, ReleaseResource, RemoteEpicLinkResource, RemoteIssueLinkResource, RemoteLinkConversationResource, RemoteSprintLinkResource, ReopenSprintResource, SavedFilterResource, SearchConfluencePagesResource, SplitIssueResource, SprintGoalOnboardingResource, SprintHealthResource, SprintPagesResource, SprintQueryResource, SprintRankResource, SprintRemainingDaysResource, SprintResource, StartSprintResource, SubqueryResource, SwimlaneResource, TeamCalendarsResource, UserDataResource, VersionResource, WelcomeResource, WizardConfigResource, WorkflowResource, WorkingDaysResource, WorkResource

public abstract class AbstractResource extends Object
To be extended by all GreenHopper rest resources. Provides no-cache logic.
  • Field Details

    • log

      protected final LoggerWrapper log
    • authenticationContext

      @Inject protected com.atlassian.jira.security.JiraAuthenticationContext authenticationContext
  • Constructor Details

    • AbstractResource

      public AbstractResource()
  • Method Details

    • response

      protected javax.ws.rs.core.Response response(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

      Will perform the access check before invoking the passed in callable.

      Parameters:
      responseCallable - a callable block of code
      Returns:
      the REST response from that callable block of code 403 if the current user is not a software user
    • responseWithoutAccessCheck

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

      Does not perform the access check before invoking the passed in callable.

      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()
    • check

      public <T> T check(ServiceOutcome<T> outcome)
      Check this outcome for errors. If found, will implement ErrorCollections.checkErrors(ErrorCollection, I18n2), which will throw some REST exceptions.
      Parameters:
      outcome - the outcome to check
    • checkResult

      public void checkResult(ServiceResult result)
      Check this result for errors. If found, will implement ErrorCollections.checkErrors(ErrorCollection, I18n2), which will throw some REST exceptions.
      Parameters:
      result - the result to check
    • nullSafe

      protected <T> Set<T> nullSafe(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.jira.user.ApplicationUser 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