Hi guys
I've been doing a bit of a tidy up after exposing parts of our JIRA instance to customers, and Iv'e found about 1800 filters and dashboards that have been shared either globally or with jira-users.
I can tweak most of those in SQL to change the group visibility, but is there an easier way to do with with JIRA CLI or with Scriptrunner that anyone knows of?
One thing that I've just found to be a potentially major issue is working out which filters and dashboards belong to inactive users - those ones I'd like to just delete!
Community moderators have prevented the ability to post new answers.
Here is a code exsample to get all filters:
import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.issue.search.SearchRequest; import com.atlassian.jira.issue.search.SearchRequestManager; import com.atlassian.jira.sharing.SharePermission import com.atlassian.jira.sharing.SharedEntity; import com.atlassian.jira.user.ApplicationUser; import com.atlassian.jira.user.util.UserUtil; List<String> Filters = new ArrayList<String>(); UserUtil userUtil = ComponentAccessor.getUserUtil(); SearchRequestManager searchRequestManager = ComponentAccessor.getComponent(SearchRequestManager.class); String CurFilter; boolean HasGlobal; for(ApplicationUser CurUser: (ArrayList<ApplicationUser>) userUtil.getAllApplicationUsers()){ for (SearchRequest searchRequest: searchRequestManager.getAllOwnedSearchRequests(CurUser)){ CurFilter = searchRequest.getName() + "#" + searchRequest.getQuery() + "/" + searchRequest.getOwnerUserName() + "#"; HasGlobal = false; for (SharePermission Perm: searchRequest.getPermissions().getPermissionSet()) { CurFilter += Perm.getType().get() + "/" + Perm.getParam1() + "/" + Perm.getParam2() + "#"; //It should delete a filter //searchRequestManager.delete(searchRequest.getId()) } } StringBuilder Result = new StringBuilder(); for (String Filter: Filters){ Result.append(Filter + "\n@"); } return Result
There is a method searchRequestManager.delete(searchRequest.getId()) which should to delete specifie filter. I have never used it but you could try to use it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.