com.atlassian.jira.gadgets.system
Class ProjectsAndProjectCategoriesResource

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

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

Nested Class Summary
static class ProjectsAndProjectCategoriesResource.Option
           
static class ProjectsAndProjectCategoriesResource.ProjectAndCategories
           
 
Field Summary
static String ALL_CATEGORIES
           
static String ALL_PROJECTS
           
 
Constructor Summary
ProjectsAndProjectCategoriesResource(JiraAuthenticationContext authenticationContext, PermissionManager permissionManager)
           
 
Method Summary
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.
 javax.ws.rs.core.Response generate()
          Generates an option list of all projects and categories.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_PROJECTS

public static final String ALL_PROJECTS
See Also:
Constant Field Values

ALL_CATEGORIES

public static final String ALL_CATEGORIES
See Also:
Constant Field Values
Constructor Detail

ProjectsAndProjectCategoriesResource

public ProjectsAndProjectCategoriesResource(JiraAuthenticationContext authenticationContext,
                                            PermissionManager permissionManager)
Method Detail

generate

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:

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


Copyright © 2002-2012 Atlassian. All Rights Reserved.