Class ResultFactory

java.lang.Object
com.atlassian.greenhopper.api.ResultFactory

@Service public class ResultFactory extends Object
Factory for constructing service results in our API.
Since:
v5.8.1
Author:
mtokar
  • Constructor Details

    • ResultFactory

      public ResultFactory()
  • Method Details

    • makeOkOrNotFoundResult

      public <T> com.atlassian.jira.bc.ServiceOutcome<T> makeOkOrNotFoundResult(@Nullable T payload, String notFoundErrorMessageKey)
      Constructs a ServiceOutcome result from a payload and a error message. The error message together with a NOT_FOUND reason is returned in case the payload is null, otherwise a successfuly outcome is returned.
      Type Parameters:
      T - the type of the payload
      Parameters:
      payload - the payload from the service operation
      Returns:
      a result which either contains errors or the payload.
    • makeJiraOutcome

      public <T> com.atlassian.jira.bc.ServiceOutcome<T> makeJiraOutcome(ServiceOutcome<T> serviceOutcome, com.atlassian.jira.user.ApplicationUser user)
      Constructs a ServiceOutcome from a ServiceOutcome.

      The messages of the error collection are translated into the specified user's locale.

      Type Parameters:
      T - the type of the payload
      Parameters:
      serviceOutcome - the outcome from greenhopper service
      user - the user who performed the service operation
      Returns:
      a result which either contains errors or the payload
    • makeJiraErrorOutcome

      public <T, S> com.atlassian.jira.bc.ServiceOutcome<T> makeJiraErrorOutcome(ServiceOutcome<S> serviceOutcome, com.atlassian.jira.user.ApplicationUser user)
      Constructs an invalid ServiceOutcome from a invalid ServiceOutcome. Because they both have only errors, the returned outcome can have different type.
      Type Parameters:
      T - the type of the returned ServiceOutcome
      S - the type of the invalid ServiceOutcome
      Parameters:
      serviceOutcome - an invalid service outcome
      user - the user who performed the service operation, need for needed for internationalisation
      Returns:
      an invalid ServiceOutcome