public class

ProjectsAndProjectCategoriesResource

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

Class Overview

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.

Summary

Nested Classes
class ProjectsAndProjectCategoriesResource.Option  
class ProjectsAndProjectCategoriesResource.ProjectAndCategories  
Constants
String ALL_CATEGORIES
String ALL_PROJECTS
Public Constructors
ProjectsAndProjectCategoriesResource(JiraAuthenticationContext authenticationContext, PermissionManager permissionManager)
Public Methods
static Set<Long> filterProjectCategoryIds(Collection<String> projectOrCategoryIds)
Filter project category ids from the given collection.
static Set<Long> filterProjectIds(Collection<String> projectOrCategoryIds)
Filter project ids from the given collection.
Response generate()
Generates an option list of all projects and categories.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ALL_CATEGORIES

Constant Value: "catallCategories"

public static final String ALL_PROJECTS

Constant Value: "allprojects"

Public Constructors

public ProjectsAndProjectCategoriesResource (JiraAuthenticationContext authenticationContext, PermissionManager permissionManager)

Public Methods

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

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

public 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