Hi,
I'd like to bulk edit filter/board/structure owner from a specific user into a group due to the fact when the filter is not available when a owner is on inactive state.
However, I didn't managed to do so via:
1.Filter bulk
2.Update filter share permission by API.
Ver: DC 8.22.16
Kindly,
Gilad
Hi @Gilad Shtern ,
You can change owner of the filters and Dashboard one by one from Administration settings --> System --> SHARED ITEMS.
One by one, is not an option when we need to change lot of filter or boards.
Kindly,
Gilad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you have a scripting app like scriptrunner to perform this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tom,
You probably want to use: Change dashboard ownership build in script.
However, this option allow you to switch into another user.
I'd like to switch from a user into a group otherwise its meaningles as the 2nd will become inactive.
Kindly,
Gilad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gilad
i have some scripts for changing ownership somewhere.
I’ll try and locate them tomorrow.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gilad
Try this for as a template ( added to my Github server-dc/Scriptrunner/Admin/permChanges.groovy)
import com.atlassian.jira.sharing.type.ShareType
import com.atlassian.jira.sharing.SharedEntity
import com.atlassian.jira.issue.search.SearchRequestManager
import com.atlassian.jira.sharing.SharePermissionImpl
import com.atlassian.jira.sharing.SharePermission
import com.atlassian.jira.bc.filter.SearchRequestService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.issue.search.SearchRequest
import com.atlassian.jira.bc.JiraServiceContextImpl
import com.atlassian.jira.sharing.rights.ShareRights
def userManager = ComponentAccessor.getUserManager()
try {
def ownerUser = userManager.getUserByName("listertuk-admin")
log.warn("LOGGER decomUser " + ownerUser)
def user2 = userManager.getUserByName("listertuk-user2")
log.warn("LOGGER decomUser " +user2)
def loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def groupName = "Group1"
SearchRequestService searchRequestService = ComponentAccessor.getComponent(SearchRequestService.class)
SearchRequestManager searchRequestManager = ComponentAccessor.getComponent(SearchRequestManager.class)
def contextImpl = new JiraServiceContextImpl(ownerUser)
Collection<SearchRequest> searchRequests = searchRequestManager.getAllOwnedSearchRequests(ownerUser)
//Collection<SearchRequest> searchRequests = searchRequestService.getOwnedFilters(ownerUser)
if(searchRequests.size() > 0) {
searchRequests.each { s ->
log.warn s
//set owner
//s.setOwner(user2)
Set<SharePermission> permissionsSet = new HashSet<SharePermission>(
s.getPermissions().getPermissionSet()
)
log.warn permissionsSet
permissionsSet.add(new SharePermissionImpl( ShareType.Name.GROUP, groupName, ShareRights.VIEW_EDIT.toString()))
s.setPermissions(new SharedEntity.SharePermissions(permissionsSet))
searchRequestManager.update(loggedInUser, s)
}
} else {
log.warn "LOGGER ${ownerUser.getName()} no filters found."
}
} catch(Exception e) {
log.warn e.getMessage()
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tom,
When I execute your script, I get an error message: "Permission type 'loggedin' must not be included with other permissions" & all viewer/editors deleted.
In addition, I wasn't able to change owner into a group, only for a specific user.
The highlight is to add:
1)A specific group into owner
2)Add group into the editors, as well.
Kindly,
Gilad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The downside of directly updating Jira via code is that you can bypass some of the checks in the GUI and create unworkable configs.
This works in my server because I rarely add 'Any logged in user' as a permission. When re-test with that set I can recreate your error.
It will be necessary to remove that permission before adding a new View permission. I will update and test my code and repost shortly. Whether this is needed to be removed depends on each case but I'll assume any additions will need to remove type "loggedin" before adding any new perms.
Ownership of the the filter can only be set to a user. VIEW and VIEW_EDIT can be set to groups.
Could you post your amended code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This version will remove the loggedin permission before updating.
Will add the group to edit permission - I had used the wrong SharePermissionImpl constructor. Also defined groupName specifically as String as that prevented the constructor error being warned.
import com.atlassian.jira.sharing.type.ShareType
import com.atlassian.jira.sharing.SharedEntity
import com.atlassian.jira.issue.search.SearchRequestManager
import com.atlassian.jira.sharing.SharePermissionImpl
import com.atlassian.jira.sharing.SharePermission
import com.atlassian.jira.bc.filter.SearchRequestService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.issue.search.SearchRequest
import com.atlassian.jira.bc.JiraServiceContextImpl
import com.atlassian.jira.sharing.rights.ShareRights
def userManager = ComponentAccessor.getUserManager()
try {
def ownerUser = userManager.getUserByName('listertuk-admin')
log.warn('LOGGER decomUser ' + ownerUser)
def user2 = userManager.getUserByName('listertuk-user2')
log.warn('LOGGER decomUser ' + user2)
def loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
String groupName = 'Group1'
SearchRequestService searchRequestService = ComponentAccessor.getComponent(SearchRequestService.class)
SearchRequestManager searchRequestManager = ComponentAccessor.getComponent(SearchRequestManager.class)
def contextImpl = new JiraServiceContextImpl(ownerUser)
Collection<SearchRequest> searchRequests = searchRequestManager.getAllOwnedSearchRequests(ownerUser)
if (searchRequests.size() > 0) {
searchRequests.each { s ->
log.warn s
//set owner
//s.setOwner(user2)
Set<SharePermission> permissionsSet = new HashSet<SharePermission>(
s.getPermissions().getPermissionSet()
)
log.warn('start ' + permissionsSet)
try {
def newPerm = new SharePermissionImpl(ShareType.Name.GROUP, groupName, '', ShareRights.VIEW_EDIT)
//log.warn permissionsSet.contains(newPerm)
permissionsSet.add(newPerm)
permissionsSet.forEach() { perm ->
if (perm.type.toString() == 'loggedin') {
//log.warn('loggedin ' + perm.type.toString() == 'loggedin')
//log.warn('before remove ' + permissionsSet.contains(perm))
permissionsSet.remove(perm)
//log.warn('after remove ' + ' ' + perm + permissionsSet)
}
}
} catch (Exception e) {
log.warn('ERROR1 ' + e.getMessage())
}
//log.warn('*(*(' + permissionsSet)
s.setPermissions(new SharedEntity.SharePermissions(permissionsSet))
searchRequestManager.update(loggedInUser, s)
}
} else {
log.warn "LOGGER ${ownerUser.getName()} no filters found."
}
} catch (Exception e) {
log.warn('ERROR2 ' + e.getMessage())
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In the end, I switched all into applicable user by using build-in scrpit.
It took some time.
Kindly,
Gilad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Gilad Shtern ,
For updating the run as users for your Structure Generators, you can use the script found here.
Hope it helps!
Best,
David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you need to just bulk change owners the you could uncomment the lines in my script
//set owner
//s.setOwner(user2)
and remove the section on getting an updating permissions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.