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.issue.search.SearchRequest
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 ) {
      isshared++
    }
  }
  if ( isshared > 0 ) {
    log.error it.getName()
    log.error it.getPermissions()
    
	it.setPermissions( 
		SharedEntity.SharePermissions( 
			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:

 

Error
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.)

Help?

 

2 answers

This widget could not be displayed.

I think you want something like:

it.setPermissions(
    new SharedEntity.SharePermissions([
        new SharePermissionImpl( ShareType.Name.GROUP, "jira-developers", "")
    ] as Set)
)
This widget could not be displayed.

Hi Adam,

Maybe this free plugin would be a nice work around solution for your request?
https://marketplace.atlassian.com/plugins/aptis.plugins.shareYourJira
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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published yesterday in Marketplace Apps

The 7 hacks of highly successful automation

...there's anything I've learnt from working, it's that people are lazy! No offense to anyone reading this, but it's true and we can all admit it. The easier you make something for someone, the more...

277 views 0 13
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