[Jira] retrieving the current project key for project sidebar

I am trying to create a page displaying data about the current jira project. It should be accessible through the sidebar (project-centric-view).

The page has been made accessibel through a WebItem (link in the sidebar). The page itself is rendered as a WebPanel. I have provided the Panel with a contextrenderer (extends AbstractJiraContextProvider) which allows me to override the getContextMap(ApplicationUser, JiraHelper) method. 
I would need the projectId of the current project to retrieve the data I want to display, however the JiraHelper object returns null on the getProject() call.

So how do I get a hold of the projectId?

I suspect that I would need to pass it as a parameter, possibly form the WebItem, but how would I do this?

Any help would be appreciated.




<web-item key="overview-menu-item" name="Upsource Overview Link" 
              weigth="30" application="jira">
        <desctiption>Link to the upsource connectivity overview page for this project</desctiption>
        <label key="upsource-connectivity.overview.label"/>
        <link linkId="upsource-connectivity-overview-link">/projects/$pathEncodedProjectKey?selectedItem=com.atlassian.jira.jira-projects-plugin:upsource-overview-page</link>
        <param name="iconClass" value="aui-icon-large icon-sidebar-issues"/>
    <web-panel key="upsource-overview-panel" location="com.atlassian.jira.jira-projects-plugin:upsource-overview-page">
        <description>Project overview of open upsource reviews</description>
        <resource name="view" type="velocity" location="templates/OverviewPanel.vsl"/>
        <context-provider class="com.nikon.developmenttools.impl.OverviewContextProvider"/>

ContextProvider class



public class OverviewContextProvider extends AbstractJiraContextProvider {

    private UpsourceConnectivityExtentionMethods methodContainer;
    public OverviewContextProvider(){}

    public UpsourceConnectivityExtentionMethods getMethodContainer() {
        return methodContainer;

    public void setMethodContainer(UpsourceConnectivityExtentionMethods methodContainer) {
        this.methodContainer = methodContainer;
    public Map getContextMap(ApplicationUser au, JiraHelper jh) {
        Map contextMap = new HashMap();
        List<String> exceptionMessages = new ArrayList<String>();
            Project currentProject = (Project) (jh.getProject());
            if(currentProject == null){
                String message = "it's the currentproject"
                        + "\nqs: " + jh.getQueryString()
                        + "\ncontextparam: "+ jh.getContextParams().toString();
                throw new Exception(message);
            UpsourceConfig uc = this.methodContainer.loadConfig(currentProject.getKey());
            HashMap<String, String> ucProperties = new HashMap<String, String>();
            ucProperties.put("host", uc.getHost());
            ucProperties.put("user", uc.getUsername());
            ucProperties.put("upsourceId", uc.getUpsourceProjectId());
            contextMap.put("config", ucProperties);
            ResultDTO result = this.methodContainer.getReviews(currentProject);
            if(result == null || result.getResult() == null){
                throw new Exception("its the result");
            ReviewsDTO response = (ReviewsDTO) result.getResult();
            contextMap.put("reviewsDTO", response);
        }catch (UpsourceConnectionFailureException ucfe) {
            System.err.println("UPSOURCE CONNECTION EXCEPTION: " + ucfe.getMessage());
            if (ucfe.getCause() != null && ucfe.getCause().getCause() instanceof java.net.UnknownHostException) {
                exceptionMessages.add("Error resolving host, please check the Upsource Connectivity Settings for this project and your network settings.");
            } else {
        } catch (UpsourceUnsetConfigException uuce) {
            System.err.println("UPSOURCE CONFIGRATION EXCEPTION: " + uuce.getMessage());
        } catch (UpsourceConnectivityException uce) {
            System.err.println("UPSOURCE EXCEPTION: " + uce.getMessage());
            if (uce.getCause() != null) {
            } else {
        } catch (Exception ex) {
            System.err.println("EXCEPTION: " + ex.toString());
        contextMap.put("exceptionList", exceptionMessages);
        return contextMap;


Overview Page


<div class="mod-header">
    <h2>Code Reviews</h2>
    #if( !$exceptionList.isEmpty() )
        #foreach( $exception in $exceptionList )
        <p>No reviews available.</p>
    #foreach( $review in $reviewsDTO.reviews )
        <td>State: #if($review.state == 1)
        <td><a href="${review.additionalProperties.get("link")}">Go to review ${review.reviewId.reviewId}</a></td>


2 answers

This widget could not be displayed.
Sam Hall Community Champion Apr 05, 2017

Hi Robrecht - since this is development related, you might want to try asking this over at: https://community.developer.atlassian.com as well (if you haven't already).

There's a lot of helpful and experienced people over there. You might well get a quicker answer in there than on here.

This widget could not be displayed.

Hi Robrecht,

I have same requirement and even me too facing the same issue in getting the projectId from the sidebar (project-centric-view).

Hope you might have got the solution for this. Could you please provide any link with the solution?

Thanks in advance!


Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

92 views 1 0
Join discussion

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