how to construct SharePermission?

I have a large number of filters owned by various users that are shared with Everyone, that really should only (at most) be shared with the jira-developers group.

I'm trying to use ScriptRunner to alter the sharing rather than force users to manually unshare hundreds of filters, but I'm running into a syntax problem...

What I have so far:

import com.atlassian.jira.bc.filter.SearchRequestService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.sharing.SharedEntity
import com.atlassian.jira.sharing.type.ShareType
import com.atlassian.jira.sharing.SharePermissionImpl
def searchRequestService = ComponentAccessor.getOSGiComponentInstanceOfType(SearchRequestService.class)
def user = ComponentAccessor.userManager.getUserByName('--omitted--')
def searchRequests = searchRequestService.getOwnedFilters( (com.atlassian.jira.user.ApplicationUser) user)
searchRequests.each {
  def isshared = 0
  it.getPermissions().getPermissionSet().each {
    if( it.getType() == ShareType.Name.GLOBAL ) {
  if ( isshared > 0 ) {
    log.error it.getName()
    log.error it.getPermissions()
			SharePermissionImpl( ShareType.Name.GROUP, "jira-developers", "")


Ignoring the awkward structure because I don't really know Groovy very well yet, I'm erroring out on the SharePermissionImpl constructor, with:


No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.SharePermissionImpl() 
is applicable for argument types: (com.atlassian.jira.sharing.type.ShareType$Name, java.lang.String, 
java.lang.String) values: [group, jira-developers, ]

yet the API docs clearly show SharePermissionImpl taking ShareType.Name, String, String.

Obviously I'm missing something about the syntax, but I can't tell what.

(And, yes, I know I need to do an Update call at the end... I just haven't got there yet.)



2 answers

I think you want something like:

    new SharedEntity.SharePermissions([
        new SharePermissionImpl( ShareType.Name.GROUP, "jira-developers", "")
    ] as Set)

Hi Adam,

Maybe this free plugin would be a nice work around solution for your request?
You will be able to share filter list or single issues to external users, but you see as a system admin or project admin every active share and the availability - control center of all active shares. You can even easily delete and edit the availability of every active share :)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,706 views 3 11
Read article

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