The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to link a web-item to a servlet rendering soy template to show up in repository settings?

madhu g
October 19, 2017

I am using latest bitbucket server and trying to add some configuration form to repository settings page under add-ons section. This configuration is specific for each repository. I was able to add a web-tem which shows up as a link under add-ons in repository settings. Now i would like link this web-item to a servlet to render the configuration page (built using soy template). when my link is clicked, It shows up a 404. I couldn't find any doc related to this configuration.

1. What is the <link> value that i should be using to invoke my servlet? Here is what i am using.

<web-item name="My Configuration Tab" key="My-configuration-tab" section="bitbucket.repository.settings.panel/repository-settings-addons-section">
<label key="My Configuration">My Configuration</label>
<link linkId="My-configuration-tab-link">/projects/${project.key}/repos/${repository.slug}/settings/configservlet</link>
<tooltip key="My-configuration-tab.tooltip">My Configuration</tooltip>
</web-item>


2. What is the corresponding url-pattern i should be using ? Here's what i have

<servlet name="My Config Servlet Module" i18n-name-key="my-config-servlet.name" key="my-config-servlet" class="com.my.servlet.MyConfigServlet">
<description key="my-config-servlet.description">The My Config Servlet Plugin</description>
<url-pattern>/settings/configservlet</url-pattern>
</servlet>



3. What is the meta tag that i should be using in soy template? Here's what i have

<meta name="decorator" content="bitbucket.repository.settings">


Other than above 3, are there any other things i need to have to get this working?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Daniel Wester
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
October 22, 2017

You’re using a servlet so the path to it rooted at /plugins/servlet

so the link should be:

/plugins/servlet/settings/configservlet

madhu g
October 23, 2017

It is still giving the 404 error. I tried this.

1. Inside web-item i gave this link path

<link linkId="my-configuration-tab-link">/plugins/servlet/settings/configservlet</link>

 

2. Inside the servlet i gave the below path.

<url-pattern>*/settings/configservlet</url-pattern>

 

Did i miss anything? does the above path in <link> links to repository settings? What is the best way to debug this?

Thanks for the help.

Daniel Wester
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
October 23, 2017

Make the url-pattern in the servlet be:

<url-pattern>/settings/configservlet</url-pattern>

 

By specifying

<url-pattern>*/settings/configservlet</url-pattern>

 

-the actual url pattern is /plugins/servlet/*/settings/configservlet

 - which you probably don't want :)

 

The other piece I would suggest is to have your add-on name in the url-pattern somewhere to avoid another add-on collding with your paths ( for example I try to have the Wittified add-ons at /wittified/....). This way likelihood of somebody else having the same path is a lot smaller :)

madhu g
October 24, 2017

Thanks Daniel. that worked. In addition to the above one, i had to make few more changes in my soy template and in the servlet.

- I have added the necessary meta tags required for the repository settings decorater in the soy template.

<meta name="decorator" content="bitbucket.repository.settings">
<meta name="projectKey" content="{$repository.project.key}">
<meta name="repositorySlug" content="{$repository.slug}">

- I have declared the repository param in the soy template.

/**
* @param repository Repository object
*/

- I have passed in the project and repository names as part of the <link> tag and used those inside my servlet to get a repository instance like this and passed it on to the renderer.

<link linkId="my-configuration-tab-link">/plugins/servlet/settings/myconfig/${project.key}/${repository.slug}</link>
String pathInfo = req.getPathInfo();
String[] path = pathInfo.split("/");
String project = path[path.length-2];
String repo = path[path.length-1];
Repository repository = repositoryService.getBySlug(project, repo);

 

Hope this info helps someone with similar needs.

0 votes
Aleksandr Zuevich
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
October 20, 2017

Hi!

Try to use 

<url-pattern>*/settings/configservlet</url-pattern>
madhu g
October 20, 2017

Sorry that didn't wok.  it still gives 404. I was building on top of decorator-plugin example. if i use the <link> , <url-pattern>, <meta> tags from that example it works but opens in user accounts section.  Any other suggestions?

TAGS
AUG Leaders

Atlassian Community Events