[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>


1 answer

0 vote
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.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,203 views 13 19
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot