Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Delete filters and dashboards of inactive users

Scott Harman
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 15, 2016

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!

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Vasiliy Zverev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 20, 2016

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.

TAGS
AUG Leaders

Atlassian Community Events