I have made a new jira plugin which has some links enabled based on the following condition specified in atlassian-plugin.xml
<conditionclass="com.atlassian.jira.plugin.webfragment.conditions.JiraGlobalPermissionCondition">
<paramname="permission"><u>admin</u></param>
</condition>
But the problem here is that all the project leads need to be provided with the Admin access in JIRA.
Is there a way where i can modify the above condition and use the project role instead.
Currently following project roles are defined in projectrole table.
10000 | Users | A project role that represents users in a project |
10001 | Developers | A project role that represents developers in a project |
10002 | Administrators | A project role that represents administrators in a project |
10100 | leads | One who has previlege to create,modify and delete |
10200 | RCCL Scrum Master | RCCL Scrum Master |
10300 | Eventing Shift Leads | Eventing team resource who come in shifts and support, attend incidents, etc |
how can i use this information and enable the link only for role 10100 i.e leads.
regards
Tarun Arora
How about com.atlassian.jira.plugin.webfragment.conditions.HasProjectPermissionCondition ? It allows testing the current user for specific project permission
Here's a sample :
<condition class="com.atlassian.jira.plugin.webfragment.conditions.HasSelectedProjectCondition" /> <conditions type="OR"> <condition class="com.atlassian.jira.plugin.webfragment.conditions.HasProjectPermissionCondition"> <param name="permission">project</param> </condition> </conditions>
This will not be feasible solution in my case.
It is something like this.
There are 4 links for my plugin. Only one of those 4 links is enabled for the developers and the other 3 should be enabled only for the leads and the administrator.
using the solution mentioned above,it will enable all the 4 links for developers,leads and administrator.
Need a solution to clearly distinguish between a developer and a lead.
Regards
Tarun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The solution I offered may be used if the roles can be distinguished by permissions but that's not ideal solution if the permissions change over time. So the best will be if you implement you own condition that checks the role of a user which should be pretty straightforward
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<
condition
class
=
"class name"
>
<
param
name
=
"role"
>lead</
param
>
</
condition
>
Can we have a solution something like the above where class name has a attribute role which maps to the role in the projectrole table.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here's a sample (not tested though):
package com.myplugin.conditions; import java.util.Map; import com.atlassian.jira.plugin.webfragment.conditions.AbstractWebCondition; import com.atlassian.jira.plugin.webfragment.model.JiraHelper; import com.atlassian.jira.project.Project; import com.atlassian.jira.security.roles.ProjectRole; import com.atlassian.jira.security.roles.ProjectRoleManager; import com.atlassian.jira.user.ApplicationUser; import com.atlassian.plugin.PluginParseException; public class HasProjectRoleCondition extends AbstractWebCondition { private ProjectRoleManager roleManager; private ProjectRole projectRole; public HasProjectRoleCondition(ProjectRoleManager roleManager) { this.roleManager = roleManager; } @Override public void init(Map<String, String> params) throws PluginParseException { String roleName = params.get("role"); projectRole = roleManager.getProjectRole(roleName); if (projectRole == null) { throw new PluginParseException("Could not determine role for: " + params.get("role")); } super.init(params); } @Override public boolean shouldDisplay(ApplicationUser user, JiraHelper jiraHelper) { final Project project = jiraHelper.getProjectObject(); return roleManager.isUserInProjectRole(user, projectRole, project); } }
and then in the atlassian-plugin.xml
<condition class="com.atlassian.jira.plugin.webfragment.conditions.HasSelectedProjectCondition" /> <conditions type="OR"> <condition class="com.myplugin.conditions.HasProjectRoleCondition"> <param name="role">leads</param> </condition> </conditions>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.