I have a large set of filters that have been created by users within my project and I was just asked if it's possible to make all of these viewable by everyone logged in. Is this possible? I know ScriptRunner has the built-in function to bulk change ownership, but I want to leave to filter owner as the user.
Any suggestions to point me in the right direction?
Yes, that's possible with scriptrunner.
Here is a short script I've prepared.
import com.atlassian.jira.bc.JiraServiceContextImpl
import com.atlassian.jira.bc.filter.SearchRequestService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.sharing.SharePermissionImpl
import com.atlassian.jira.sharing.SharedEntity
import com.atlassian.jira.sharing.rights.ShareRights
import com.atlassian.jira.sharing.type.ShareType
import com.atlassian.jira.user.ApplicationUser
//you need to find and update the filters user an system admin priviledged user in case the current user doesn't have permission to adjust a filter
ApplicationUser adminUser = ComponentAccessor.userManager.getUserByName('admin')
JiraServiceContextImpl serviceContext = new JiraServiceContextImpl(adminUser)
SearchRequestService searchRequestService = ComponentAccessor.getComponent(SearchRequestService)
def filtersToChange= [12345, 23456] //list all the filters you want to change
filtersToChange.each{filterId ->
def filter = searchRequestService.getFilter(serviceContext, filterId)
//get all the current permission (but no the view permission, this will be replaced by the Authenticated one)
def perms = filter.permissions.permissionSet.collect().findAll{it.rights != ShareRights.VIEW}
//the new permission we will be adding
def authenticatedPerm = new SharePermissionImpl(null, ShareType.Name.AUTHENTICATED,null,null, ShareRights.VIEW)
perms.add( authenticatedPerm)
filter.setPermissions(new SharedEntity.SharePermissions(perms.toSet()))
searchRequestService.updateFilter(serviceContext, filter)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.