Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

cannot set security level of cloned+linked issue

Brian Bishop
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 Leaders.
July 24, 2015

Please help... I am trying to add a security level to an issue cloned and linked by the Script Runner's built in script.  Post function, on transition, using built in clone/link - and then the code below is running.

 

It seems that the error is due to the fact that the issue is not really created yet, so i can't set the security level, here's the error.  The builtin script is configured to create the cloned issue in the same project as the source issue, by leaving off the 

 

"Target project. Leave blank for the same project as the source issue."

 


2015-07-24 10:44:29,903 http-bio-8080-exec-13 WARN vendor3 644x44262x1 gmwl4q 0:0:0:0:0:0:0:1 /secure/WorkflowUIDispatcher.jspa [jira.workflow.postfunctions.CloneIssue] Could not set security level, as the schemes between the two projects are different.
2015-07-24 10:44:30,345 http-bio-8080-exec-13 ERROR vendor3 644x44262x1 gmwl4q 0:0:0:0:0:0:0:1 /secure/WorkflowUIDispatcher.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] *************************************************************************************
2015-07-24 10:44:30,346 http-bio-8080-exec-13 ERROR vendor3 644x44262x1 gmwl4q 0:0:0:0:0:0:0:1 /secure/WorkflowUIDispatcher.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: ECSP16-82, actionId: 21, file: null
groovy.lang.MissingPropertyException: No such property: issueSecurityLevelManager for class: Script44

 

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.security.Permissions
import com.atlassian.jira.issue.security.IssueSecurityLevelManager
import com.atlassian.jira.issue.security.IssueSecuritySchemeManager
import com.atlassian.jira.ManagerFactory
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.user.ApplicationUsers
import org.apache.log4j.Category
import org.ofbiz.core.entity.GenericValue
log.setLevel(org.apache.log4j.Level.DEBUG)
def componentManager = ComponentManager.getInstance()
def currentUser = componentManager.jiraAuthenticationContext?.user
def permissionManager = componentManager.getPermissionManager()

if (permissionManager.hasPermission(Permissions.ASSIGNABLE_USER, issue, currentUser))
{
issue.assigneeId = currentUser.name
}
checkLink = {link -> false};
issue.summary = 'QUOTE in response to ' + sourceIssue.summary;
log = Category.getInstance("DBG:com.onresolve.jira.groovy.PostFunction")
log.debug ("DBG: PostFunction function running")
def secLevelString = currentUser.name + "_allowed"
log.debug ("DBG: Security Level is " + secLevelString)
GenericValue srcProjectGV = sourceIssue.getProject() 
def issueSecurityScheme = issueSecuritySchemeManager.getSchemes(srcProjectGV).size() == 0 ? null : issueSecuritySchemeManager.getSchemes(srcProjectGV)[0]
def secLevelGv = null

if (issueSecurityScheme != null)
{
secLevelGv = issueSecurityLevelManager.getSecurityLevelsByName(secLevelString).iterator().next();
log.debug ("DBG: Security is not null")
//now set the SecLev
if (secLevelGv)
{
issue.setSecurityLevel(secLevelGv)
issue.store()
log.debug ("DBG: Set security level")
}
}

 

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Robert Dzido
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 Leaders.
July 24, 2015

add following lines before line:

GenericValue srcProjectGV = sourceIssue.getProject() 

 

IssueSecuritySchemeManager issueSecuritySchemeManager = ManagerFactory.getIssueSecuritySchemeManager()
IssueSecurityLevelManager issueSecurityLevelManager = ManagerFactory.getIssueSecurityLevelManager()

 

 

TAGS
AUG Leaders

Atlassian Community Events