Class DefaultSearchRequestService

java.lang.Object
com.atlassian.jira.bc.filter.DefaultSearchRequestService
All Implemented Interfaces:
SearchRequestService

public class DefaultSearchRequestService extends Object implements SearchRequestService
Default implementation of SearchRequestService
Since:
v3.13
  • Constructor Details

  • Method Details

    • getFavouriteFilters

      public Collection<SearchRequest> getFavouriteFilters(ApplicationUser user)
      Description copied from interface: SearchRequestService
      Retrieve all filters a user has favourited. Permission checks are done to ensure the user can see the filter, as visibility may have been removed from underneath them.
      Specified by:
      getFavouriteFilters in interface SearchRequestService
      Parameters:
      user - The user who has favourite filters. Also to test visibility and with
      Returns:
      a Collection of SearchRequest objects that represent filters the user has favourited.
    • getOwnedFilters

      public Collection<SearchRequest> getOwnedFilters(ApplicationUser user)
      Description copied from interface: SearchRequestService
      Retrieve all filters a user owns/has created.
      Specified by:
      getOwnedFilters in interface SearchRequestService
      Parameters:
      user - The user who created the filters.
      Returns:
      a Collection of SearchRequest objects that represent filters the user has created.
    • getNonPrivateFilters

      public Collection<SearchRequest> getNonPrivateFilters(ApplicationUser user)
      Description copied from interface: SearchRequestService
      Get a user's non private filters. I.e. filters that other users can possibly see.
      Specified by:
      getNonPrivateFilters in interface SearchRequestService
      Parameters:
      user - The author of the filters
      Returns:
      Collection of SearchRequest objects that do not have private scope.
    • getFiltersFavouritedByOthers

      public Collection<SearchRequest> getFiltersFavouritedByOthers(ApplicationUser user)
      Description copied from interface: SearchRequestService
      Get filters owned by a given user that have been favourited by at least one other user
      Specified by:
      getFiltersFavouritedByOthers in interface SearchRequestService
      Parameters:
      user - The author of the filters
      Returns:
      Collection of SearchRequest objects owned by the given user and favourited by at least one other user
    • deleteFilter

      public void deleteFilter(JiraServiceContext serviceCtx, Long filterId)
      Description copied from interface: SearchRequestService
      Delete a given filter.
      Specified by:
      deleteFilter in interface SearchRequestService
      Parameters:
      serviceCtx - JIRA Service context containing an error collection and user performing action. User must be owner of filter, else error is passed back through the error collection.
      filterId - The id of the filter to delete. Id must not be null, else error is passed back through the error collection.
    • deleteAllFiltersForUser

      public void deleteAllFiltersForUser(JiraServiceContext serviceCtx, ApplicationUser user)
      Description copied from interface: SearchRequestService
      Delete all filters for a given user
      Specified by:
      deleteAllFiltersForUser in interface SearchRequestService
      Parameters:
      serviceCtx - JIRA Service context containing an error collection and user performing action
      user - The user to remove all filters for
    • getFilter

      public SearchRequest getFilter(JiraServiceContext serviceCtx, Long filterId)
      Description copied from interface: SearchRequestService
      Retrieve a given filter by id.
      Specified by:
      getFilter in interface SearchRequestService
      Parameters:
      serviceCtx - JIRA Service context containing an error collection and user requesting (to run) the filter. The filter must exist and the user must be able to see filter else an error will result.
      filterId - The id of the filter to retrieve. Id must not be null.
      Returns:
      The Filter as specified by the id, or null if none exists for the user.
    • validateFilterForUpdate

      public void validateFilterForUpdate(JiraServiceContext serviceCtx, SearchRequest request)
      Description copied from interface: SearchRequestService
      Validates that a filter is in a correct state to be updated.
      Specified by:
      validateFilterForUpdate in interface SearchRequestService
      Parameters:
      serviceCtx - Context containing user, error collection and i18n bean
      request - the SearchRequest to validate
    • validateUpdateSearchParameters

      public boolean validateUpdateSearchParameters(JiraServiceContext serviceCtx, SearchRequest request)
      Description copied from interface: SearchRequestService
      Validate that the passed SearchRequest's search parameters and search sorts can be persisted. This method does *not* check the validity of the name, description, share permissions or any other fields in the SearchRequest. Any errors will be reported in the passed context.
      Specified by:
      validateUpdateSearchParameters in interface SearchRequestService
      Parameters:
      serviceCtx - Context containing user, error collection and i18n bean
      request - the request to validate.
      Returns:
      true iff the passed request's parameters can be saved.
    • validateFilterForCreate

      public void validateFilterForCreate(JiraServiceContext serviceCtx, SearchRequest request)
      Description copied from interface: SearchRequestService
      Validates that a filter is in a correct state to be created.
      Specified by:
      validateFilterForCreate in interface SearchRequestService
      Parameters:
      serviceCtx - Context containing user, error collection and i18n bean
      request - the SearchRequest to validate
    • validateForDelete

      public void validateForDelete(JiraServiceContext serviceCtx, Long filterId)
      Description copied from interface: SearchRequestService
      Validates that the filter can be deleted successfully.
      Specified by:
      validateForDelete in interface SearchRequestService
      Parameters:
      serviceCtx - context of the calling user.
      filterId - the filter to delete.
    • createFilter

      public SearchRequest createFilter(JiraServiceContext serviceCtx, SearchRequest request)
      Description copied from interface: SearchRequestService
      Persists a SearchRequest to the database.
      Specified by:
      createFilter in interface SearchRequestService
      Parameters:
      serviceCtx - Context containing user, error collection and i18n bean
      request - the request to save
      Returns:
      the SearchRequest that was persisted to the database.
    • createFilter

      public SearchRequest createFilter(JiraServiceContext serviceCtx, SearchRequest request, boolean isFavourite)
      Description copied from interface: SearchRequestService
      Persists a SearchRequest to the database.
      Specified by:
      createFilter in interface SearchRequestService
      Parameters:
      serviceCtx - Context containing user, error collection and i18n bean
      request - the request to save
      isFavourite - saves the SearchRequest as a favourite (or not)
      Returns:
      the SearchRequest that was persisted to the database.
    • updateFilter

      public SearchRequest updateFilter(JiraServiceContext serviceCtx, SearchRequest request)
      Description copied from interface: SearchRequestService
      Persists a SearchRequest to the database.
      Specified by:
      updateFilter in interface SearchRequestService
      Parameters:
      serviceCtx - Context containing user, error collection and i18n bean
      request - the request to update
      Returns:
      the SearchRequest that was persisted to the database.
    • updateFilter

      public SearchRequest updateFilter(JiraServiceContext serviceCtx, SearchRequest request, boolean isFavourite)
      Description copied from interface: SearchRequestService
      Persists a SearchRequest to the database.
      Specified by:
      updateFilter in interface SearchRequestService
      Parameters:
      serviceCtx - Context containing user, error collection and i18n bean
      request - the request to update
      isFavourite - saves the SearchRequest as a favourite (or not)
      Returns:
      the SearchRequest that was persisted to the database.
    • validateFilterForChangeOwner

      public void validateFilterForChangeOwner(JiraServiceContext contextWithNewOwner, SearchRequest requestWithNewOwner)
      Description copied from interface: SearchRequestService
      Validates that the proposed owner can take over the ownership of the filter
      Specified by:
      validateFilterForChangeOwner in interface SearchRequestService
      Parameters:
      contextWithNewOwner - containing proposed owner
      requestWithNewOwner - the SearchRequest that you want to change ownership of
    • updateFilterOwner

      public SearchRequest updateFilterOwner(JiraServiceContext contextWithNewOwner, ApplicationUser loggedInUser, SearchRequest requestWithNewOwner)
      Description copied from interface: SearchRequestService
      Persists a SearchRequest to the database - only available to administrators.
      Specified by:
      updateFilterOwner in interface SearchRequestService
      Parameters:
      contextWithNewOwner - Context containing the new owner, error collection and i18n bean
      loggedInUser - the user requesting the update, must have Permissions.ADMINISTER permissions
      requestWithNewOwner - the request to update
      Returns:
      the SearchRequest that was persisted to the database
    • updateFilterOwner

      public SearchRequest updateFilterOwner(JiraServiceContext serviceCtx, Long filterId, ApplicationUser newOwner)
      Description copied from interface: SearchRequestService
      Changes the owner of the portal page. User performing this operation must be an administrator.

      You should call SearchRequestService.validateFilterForChangeOwner(JiraServiceContext, SearchRequest) prior to calling this method.

      Specified by:
      updateFilterOwner in interface SearchRequestService
      Parameters:
      serviceCtx - the context of the service call
      filterId - the id of the filter to update
      newOwner - the new owner
      Returns:
      a newly updated SearchRequest, or null if user is not an admin
    • updateSearchParameters

      public SearchRequest updateSearchParameters(JiraServiceContext serviceCtx, SearchRequest request)
      Description copied from interface: SearchRequestService
      Persists changes to passed SearchRequest's search parameters and search sorts. Changes to the SearchRequest's other fields (name, description, share permissions, ...) are not saved. Any errors will be reported in the passed context.

      This method does not check the validity of the SearchRequest's share permissions when saving. This is to allow JIRA to save search parameter changes even when the SearchRequest's permissions are invalid.

      Specified by:
      updateSearchParameters in interface SearchRequestService
      Parameters:
      serviceCtx - Context containing user, error collection and i18n bean
      request - the request to update.
      Returns:
      the SearchRequest that was persisted to the database. May return null if an error occurs. The passed service context will have details of any errors.
    • validateForSearch

      public void validateForSearch(JiraServiceContext serviceCtx, SharedEntitySearchParameters searchParameters)
      Description copied from interface: SearchRequestService
      This will validate that the input parameters are valid for a search that encompasses ANY share entity type.
      Specified by:
      validateForSearch in interface SearchRequestService
      Parameters:
      serviceCtx - Context containing user, error collection and i18n bean
      searchParameters - the SharedEntitySearchParameters to validate
    • search

      public SharedEntitySearchResult<SearchRequest> search(JiraServiceContext serviceCtx, SharedEntitySearchParameters searchParameters, int pagePosition, int pageWidth)
      Description copied from interface: SearchRequestService
      Search for the SearchRequests that match the passed searchParameters. The result can be paged so that a subset of the results can be returned.
      Specified by:
      search in interface SearchRequestService
      Parameters:
      serviceCtx - Context containing user, error collection and i18n bean
      searchParameters - the searchParameters to query.
      pagePosition - the page to return.
      pageWidth - the number of results per page.
      Returns:
      the result of the search.
    • hasShareRights

      public boolean hasShareRights(@Nullable ApplicationUser user, @Nonnull SearchRequest searchRequest, @Nonnull ShareRight shareRight)
      Description copied from interface: SearchRequestService
      Checks if provided user has share rights for given search request.
      Specified by:
      hasShareRights in interface SearchRequestService
      Parameters:
      user - user which wants for example view or edit the entity
      searchRequest - search request which permissions and ownership are going to be checked
      shareRight - share rights which will be checked if user has it
      Returns:
      true in case provided user has specified rights for the search request, false otherwise