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?

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

You can get the current project with UserProjectHistoryManager:

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

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

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 =

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 Apr 03, 2019 in Marketplace Apps

How to estimate projects more accurately?

Gaining insight into your team’s effectiveness and choosing the right estimation technique.   Estimating projects is hard. It is because people have the tendency to underestimate the time thin...

276 views 2 8
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you