Unable to set permission scheme to the project which is created through Jira API

I can able to set permission scheme to the project which is created through UI where as i am not able to set to the project which is created programmatically we can set but if due to some resons not setted and trying to add through UI i am getting Nullpointer exception.

getting following error
java.lang.NullPointerException at com.atlassian.jira.projectconfig.contextproviders.ProjectPermissionContextProvider.getContextMap(ProjectPermissionContextProvider.java:85) at com.atlassian.jira.plugin.webfragment.CacheableContextProviderDecorator.initContextMap(CacheableContextProviderDecorator.java:70) at com.atlassian.jira.plugin.webfragment.CacheableContextProviderDecorator.getContextMap(CacheableContextProviderDecorator.java:46) at com.atlassian.plugin.web.descriptors.DefaultWebPanelModuleDescriptor$ContextAwareWebPanel.getHtml(DefaultWebPanelModuleDescriptor.java:141) at com.atlassian.jira.projectconfig.tab.WebPanelTab.getTab(WebPanelTab.java:75) at com.atlassian.jira.projectconfig.servlet.PanelServlet.outputTab(PanelServlet.java:163) at com.atlassian.jira.projectconfig.servlet.PanelServlet.doGet(PanelServlet.java:136) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at com.atlassian.plugin.servlet.DelegatingPluginServlet.service(DelegatingPluginServlet.java:42) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at com.atlassian.plugin.servlet.ServletModuleContainerServlet.service(ServletModuleContainerServlet.java:52) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.atlassian.jira.web.filters.steps.ChainedFilterStepRunner.doFilter(ChainedFilterStepRunner.java:78) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.atlassian.core.filters.HeaderSanitisingFilter.doFilter(HeaderSanitisingFilter.java:44) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46) at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66) at com.atlassian.labs.botkiller.BotKillerFilter.doFilter(BotKillerFilter.java:36) at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:74) at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42) at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66) at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:25) at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:74) at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42) at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:77) at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:63) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.atlassian.jira.web.filters.accesslog.AccessLogFilter.executeRequest(AccessLogFilter.java:104) at com.atlassian.jira.web.filters.accesslog.AccessLogFilter.doFilter(AccessLogFilter.java:88) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.atlassian.jira.security.xsrf.XsrfTokenAdditionRequestFilter.doFilter(XsrfTokenAdditionRequestFilter.java:54) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129) at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77) at com.atlassian.jira.web.filters.SitemeshPageFilter.doFilter(SitemeshPageFilter.java:124) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46) at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:77) at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:63)

any one have any idea ??

Thanks,

5 answers

1 accepted

This widget could not be displayed.

after creating project, i am using following jelly tag to set permission scheme through jelly script runner

<jira:SelectProjectScheme projectKey="JIRA" permission-scheme="JIRA Permission Scheme"/>

This widget could not be displayed.

any help on this?

This widget could not be displayed.

So, you created a project via Jira API. Obviously something is missing there. Where do you have that NPE ? Can you post the stack trace ? Otherwise, I'm not sure that you will get an answer right away.

This widget could not be displayed.
Pedro Cora Atlassian Team Dec 19, 2012

Hi there,

When creating a project via SOAP, you need to provide a permission scheme and you can't simply send a string. It needs to be a {{remotePermissionScheme}} object because when that gets converted to the SOAP XML format in the request it will look different than just a string and that's what JIRA expects.

For example:

final RemotePermissionScheme permissionScheme = new RemotePermissionScheme();

            permissionScheme.setId(0L);

            final RemoteProject project = soapy.createProject(token, "TESTD", "Test Proj D", "", "", "contour", permissionScheme, null, null);

The above will work while the below wont:

final RemoteProject project = soapy.createProject(token, "TESTD", "Test Proj D", "", "", "contour", null, null, null);

The permissionScheme can't be a string, it needs to be a permissionScheme SOAP object with the id of the permission scheme filled in.

Cheers,

Pedro

Thanks for your response!

Actually i created project through post function not through SOAP

following code i am using to set permission scheme

UpdateProjectSchemesValidationResult schemesResult = projectService.validateUpdateProjectSchemes(loggedInUser,permissionSchemeId,notificationSchemeId,issueSecuritySchemeId);	
errors.addErrorCollection(schemesResult.getErrorCollection());
if (!errors.hasAnyErrors()) { // adding schemes to Project projectService.updateProjectSchemes(schemesResult, newProject); }


Don't mind me saying this, it looks terribly odd trying to create projects in post functions :(

Can you give a bit more details into the usecase (while I accept that I am not solving your problem by asking this)?

@Renjith,

we are getting number of requests to create new projects based on existing project so i created post function to create project and copy all the configurations from the base project. all the configurations are copied as expected and i am facing the problem while copying permission scheme.

some times it is copying from base project and some times it is not and it is setting null, when i am trying to change null value to some other schem getting the NPE

Have you gotten this issue resolved? I am in the same situation.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted yesterday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

79 views 0 1
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