It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to restrict custom report visibility?

hunsen lu Jan 05, 2013

hi, here's the thing.

We have a couple of projects created in JIRA. Let's say they are proj1 and proj2.

Now we developed a plugin with a couple of report modules in it. Let's say they are rpt1 and rpt2.

After installed the plugin to JIRA, both rpt1 and rpt2 show in the report menu of proj1 and proj2.

But what we want is that only rpt1 appears in the report menu of proj1 and only rpt2 appears in the report menu in proj2.

For now I already know that there's a method showReport() in AbstractReport class returing true or false to control report to show or not. My idea is to get the current projectId to determine whether the report should show or not. The problem is that I don't know how to get the current project id in my extended report class.

Is there anyone can help? Thanks in advance.

Here's my custom report code:

public class TurnaroundTimeReport extends AbstractReport {
    public String generateReportHtml(ProjectActionSupport projectActionSupport, Map map) throws Exception {
        return descriptor.getHtml("view", getVelocityParams(projectActionSupport, map));
    private Map<String, ?> getVelocityParams(ProjectActionSupport action, Map map) {
        final List<Map> turnaroud = getTurnaroundTimeFromProject(yearmonth, customer);
        final Map<String, Object> velocityParams = new HashMap<String, Object>();
        velocityParams.put("report", this);
        velocityParams.put("action", action);       
        velocityParams.put("turnaround", turnaroud);        
        return velocityParams;
    public boolean showReport() {
    // I want to get the current project id here to determine whether the report should show or not.    
    return true
    public boolean isExcelViewSupported() {
        return true;
    public String generateReportExcel(ProjectActionSupport action, Map params) {
        final StringBuilder builder = new StringBuilder(50);
        HttpServletResponse response = ActionContext.getResponse();
        response.addHeader("content-disposition", builder.toString());
        return descriptor.getHtml("excel", getVelocityParams(action, params));
    private List<Map> getTurnaroundTimeFromProject(int yearmonth, String customer) {
        return turnaround;


2 answers

1 accepted

2 votes
Answer accepted
ConradR Jan 27, 2013

You can get the current project with UserProjectHistoryManager:

UserProjectHistoryManager userProjectHistoryManager =  ComponentAccessor.getOSGiComponentInstanceOfType(UserProjectHistoryManager.class);

Project project = userProjectHistoryManager.getCurrentProject(Permissions.BROWSE, ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser());

hunsen lu Jan 29, 2013

Thank you very much, Conrad Rolack. It works.

But i'm using atlassian-plugin-sdk-3.7.2, so i made a little change.

UserProjectHistoryManager userProjectHistoryManager =

0 votes
Daniel Leng Jan 06, 2013

Hello, can you at least show abit of code so that we will know what are the classes that you actually need to use? Its hard to provide help without seeing some code.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Marketplace Apps & Integrations

Webinar invitation: Generate custom Jira Cloud PDF reports and exports

Jira may be a staple part of your workday, but your colleagues, customers, business partners or an auditor might need information presented in a different format, that is easy to access and read. And...

60 views 0 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you