I'm trying to programatically create some issue security levels with my Java plugin, and it's working well by using the IssueSecurityLevelManager's createIssueSecurityLevel method. However, it would be even better if I could populate that level with actual permissions, be it with groups, roles or user fields. Is there any practical way to do that using the same API?
Community moderators have prevented the ability to post new answers.
If you have a valid JIRA license, then I suggest you take a look at the JIRA sources and how it is done there in com.atlassian.jira.web.action.admin.issuesecurity.AddIssueSecurity#doExecute
, i.e.:
IssueSecuritySchemeManager issueSecuritySchemeManager; Long mySchemeId; Long myLevelId; String type; // see SecurityTypeManager#getSecurityTypes and permission-types.xml String parameter; // type-specific, e.g. the group name if type=="group" issueSecuritySchemeManager.createSchemeEntity( issueSecuritySchemeManager.getScheme(mySchemeId), new SchemeEntity(type, parameter, myLevelId) );
That worked like a charm, thank you very much! However, is there a way to fetch the IssueSecuritySchemeManager without using the deprecated ManagerFactory class? It still works, but I don't think it's recommended.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, as the class javadoc of ManagerFactory[1] states, you should use ComponentAccessor instead. Or even better, use Constructor Injection[2] (if applicable): Simple place the manager/service as a parameter in the constructor of your class. [1] https://docs.atlassian.com/jira/latest/com/atlassian/jira/ManagerFactory.html [2] http://en.wikipedia.org/wiki/Dependency_injection#Constructor_injection
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.