Class ProjectsAndProjectCategoriesResource

java.lang.Object
com.atlassian.jira.gadgets.system.ProjectsAndProjectCategoriesResource

@Path("/projectsAndProjectCategories") @Produces("application/json") public class ProjectsAndProjectCategoriesResource extends Object
This REST resource is used to generate an option list that is closely mapped to the option elements of a HTML select element, so that the returned JSON object can replace the option elements of a HTML select element, without further manipulation. However, this also tightly couples this resource to HTML structure. Future improvement of decoupling is recommended.
Since:
v4.0
  • Field Details

  • Constructor Details

  • Method Details

    • generate

      @GET public javax.ws.rs.core.Response generate()
      Generates an option list of all projects and categories.

      This is the only REST endpoint, accessed via a GET method to the path annotating the class.

      Currently, there is no parameter required.

      The returned option list will always contain an option group for "Projects", which will always contain an option "All Projects" as the first element, even if there is no project at all.

      The result may also contain a "Project Categories" option group, if any project is assigned a category. It should be noted that in this implementation, any existing project category is not included if there is no project is listed under that category. This is consistent with the implementation of the road map portlet.

      There are some noticeable differences between this implementation of that of road map gadget:

      • The option group name is now always shown even if there is only one group.
      • There is no enterprise edition check when handling project categories, as this will be available in all versions soon.
      Returns:
      an OK response with an ProjectsAndProjectCategoriesResource.ProjectAndCategories object.
    • filterProjectIds

      public static Set<Long> filterProjectIds(Collection<String> projectOrCategoryIds)
      Filter project ids from the given collection. Returns a set of project ids as Long objects. Value is a valid project id if it is a long number.
      Parameters:
      projectOrCategoryIds - collection of project or category ids
      Returns:
      set of project ids, never null
    • filterProjectCategoryIds

      public static Set<Long> filterProjectCategoryIds(Collection<String> projectOrCategoryIds)
      Filter project category ids from the given collection. Returns a set of project category ids as Long objects. Value is a valid category if it takes form "catXYZ" where "cat" is the prefix (CATEGORY) and XYZ is a long number.
      Parameters:
      projectOrCategoryIds - collection of project or category ids
      Returns:
      set of project category ids, never null