|
Seems to me like this should be resolved by updating the Enterprise Jira SOAP API so that users can create an issue with the security level set. This is one of the main Enterprise features we use and I was pretty disappointed to find out the SOAP API doesn't support creating issues with a security level set...
Same to me: importing a lot of issues from our current tracking system requires the possibility to set issue security level during issue creation.
it's only a work around but
you can set security level with a listener like this: SetSecurityLevelListener.java package tr.com.yurticikargo.jira.securitylevel; import com.atlassian.jira.ManagerFactory; import com.atlassian.jira.event.issue.AbstractIssueEventListener; import com.atlassian.jira.event.issue.IssueEvent; import com.atlassian.jira.event.issue.IssueEventListener; import com.atlassian.jira.issue.MutableIssue; import com.atlassian.jira.issue.security.IssueSecurityLevelManager; import com.opensymphony.user.User; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Map; import org.ofbiz.core.entity.GenericValue; public class SetSecurityLevelListener extends AbstractIssueEventListener implements IssueEventListener { private final IssueSecurityLevelManager issueSecurityLevelManager = ManagerFactory.getIssueSecurityLevelManager(); private final String SECURTY_LEVEL_PREFIX = "Securty Level Name Prefix (Default #)"; private final String PROJECTS_TO_SET = "Project Keys (Enter project keys with (;) without space; Null for All Projects)"; private String projectsToSet; private String securtyLevelPrefix; public void init(Map params) { projectsToSet = null; if (params.containsKey(PROJECTS_TO_SET )){ projectsToSet = (String)params.get(PROJECTS_TO_SET)+";"; } securtyLevelPrefix = "#"; if (params.containsKey(SECURTY_LEVEL_PREFIX )){ securtyLevelPrefix= (String)params.get(SECURTY_LEVEL_PREFIX); } } public String[] getAcceptedParams() { return new String[]{PROJECTS_TO_SET, SECURTY_LEVEL_PREFIX}; } public void issueCreated(IssueEvent event) { MutableIssue issue = (MutableIssue)event.getIssue(); if (projectsToSet !=null && projectsToSet.indexOf(issue.getProjectObject().getKey()+";")<0) { return; } User reporter = issue.getReporter(); List reporterGroups = reporter.getGroups(); try { Collection issueSecurityLevels = issueSecurityLevelManager.getUsersSecurityLevels(issue.getGenericValue(), reporter); groups: for (Iterator iterator = reporterGroups.iterator(); iterator.hasNext();) { String groupName = (String) iterator.next(); for (Iterator iterator1 = issueSecurityLevels.iterator(); iterator1.hasNext();) { GenericValue securityLevel = (GenericValue) iterator1.next(); String s = securityLevel.getString("name"); if (s.startsWith(securtyLevelPrefix) && s.subSequence(1, s.length()).equals(groupName)) { issue.setSecurityLevel(securityLevel); issue.store(); break groups; } } } } catch (Exception e) { e.printStackTrace(); } return; } public boolean isInternal() { return false; } public boolean isUnique() { return false; } public String getDescription() { return "It sets the issue security level based on one group the reporter is member of.<br>The group and security level have both the same name and in order to make this work as we expect, the user cannot be member of more than one group that has the same name of a security level."; } } Thanks for this proposal.
Unfortunately this does not work since the limitations listed in the description are not fullfilled. The fix for this issue has not been able to make it into JIRA v3.12. We are hoping to incorporate it into v3.12.1. As of writing however, there are 163 items scheduled as Fix For v3.12.1. We will not be able to include all of them.
While not ideal, I was able to work around this issue by doing HTTP requests.
Here is a php example: curl = curl_init(); $loginUrl = "http://localhost/login.jsp?os_username=" . $soapUsername . "&os _password=" . $soapPassword . "&os_cookie=true";; curl_setopt($curl,CURLOPT_URL, $loginUrl ); curl_setopt($curl,CURLOPT_POST, true ); curl_setopt($curl,CURLOPT_COOKIEFILE, '/tmp/cookie' ); curl_setopt($curl,CURLOPT_COOKIEJAR, '/tmp/cookiejar' ); curl_setopt($curl,CURLOPT_RETURNTRANSFER, true ); curl_setopt($curl,CURLOPT_FOLLOWLOCATION, false ); curl_setopt($curl,CURLOPT_NOBODY, true ); curl_setopt($curl,CURLOPT_MUTE,true ); curl_exec( $curl ); curl_setopt($curl,CURLOPT_RETURNTRANSFER, false ); curl_setopt($curl,CURLOPT_URL, "http://localhost/secure/CreateIssueDetails.j spa?pid=12345&issuetype=1&summary=foo&assignee=" . $project->lead . "&reporter=" . $soapUsername . "&security=10003" ); curl_exec( $curl ); curl_close( $curl ); Please fix this at the earliest opportunity. We really need it (and we are getting ready to decide if we want to renew JIRA).
At the very least do this:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Thanks!
Igor