CMJ Integrity Check reports errors in a dashboard, but it's not accessible to the CMJ user
Symptoms:
The dashboard “dashboard” for active user <user> does not exist. For the solution presented, I cannot modify the dashboard to clear the error as it does not exist
Cause:
The CMJ user does not have share permissions to access this dashboard.
Resolution 1:
Use the following Groovy script to make only a dashboard with specified ID on the system be accessible to the "jira-administrators" group:
Make dashboards accessible to admin
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.portal.PortalPage import com.atlassian.jira.portal.PortalPageManager import com.atlassian.jira.sharing.SharePermission import com.atlassian.jira.sharing.SharePermissionImpl import com.atlassian.jira.sharing.SharedEntity.SharePermissions import com.atlassian.jira.sharing.type.ShareType.Name import com.atlassian.jira.util.collect.EnclosedIterable.Functions; def makeDashboardAccessibleToAdmin(long dashboardId) { PortalPageManager ppm = ComponentAccessor.getComponent(PortalPageManager.class); PortalPage portalPage = ppm.getPortalPageById(dashboardId); Set<SharePermission> permissionsSet = new HashSet<SharePermission>( portalPage.getPermissions().getPermissionSet() ); permissionsSet.add(new SharePermissionImpl(null, Name.GROUP, "jira-administrators", null)); ppm.update(PortalPage.portalPage(portalPage).permissions(new SharePermissions(permissionsSet)).build()); } makeDashboardAccessibleToAdmin(DASHBOARDIDHERE);
Resolution 2:
You can use this groovy script to make all dashboards global.
NB! makeAllDashboardsGlobal returns the ids of all changed dashboards. This list can be used to revert the changes, so save it!
Make all dashboards global
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.portal.PortalPage import com.atlassian.jira.portal.PortalPageManager import com.atlassian.jira.sharing.SharePermission import com.atlassian.jira.sharing.SharePermissionImpl import com.atlassian.jira.sharing.SharedEntity.SharePermissions import com.atlassian.jira.sharing.type.ShareType.Name import com.atlassian.jira.util.collect.EnclosedIterable.Functions; def makeAllDashboardsGlobal() { def changedIds = []; PortalPageManager ppm = ComponentAccessor.getComponent(PortalPageManager.class); for(PortalPage portalPage in Functions.toList(ppm.getAll())) { Set<SharePermission> permissionsSet = new HashSet<SharePermission>( portalPage.getPermissions().getPermissionSet() ); // check if already global if (!permissionsSet.any { it.getType() == Name.GLOBAL } ) { changedIds.add(portalPage.getId()); permissionsSet.add(new SharePermissionImpl(Name.GLOBAL, null, null)); ppm.update(PortalPage.portalPage(portalPage).permissions(new SharePermissions(permissionsSet)).build()); } } return changedIds; } makeAllDashboardsGlobal();
You can revert the changes and remove the global permissions with this script.
Remove global share permission from dashboards
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.portal.PortalPage import com.atlassian.jira.portal.PortalPageManager import com.atlassian.jira.sharing.SharePermission import com.atlassian.jira.sharing.SharePermissionImpl import com.atlassian.jira.sharing.SharedEntity.SharePermissions import com.atlassian.jira.sharing.type.ShareType.Name import com.atlassian.jira.util.collect.EnclosedIterable.Functions; def removeDashboardGlobalPermission(long dashboardId) { PortalPageManager ppm = ComponentAccessor.getComponent(PortalPageManager.class); PortalPage portalPage = ppm.getPortalPageById(dashboardId); Set<SharePermission> permissionsSet = new HashSet<SharePermission>( portalPage.getPermissions().getPermissionSet()); permissionsSet.removeAll { it.getType() == Name.GLOBAL }; ppm.update(PortalPage.portalPage(portalPage).permissions(new SharePermissions(permissionsSet)).build()); } def removeDashboardGlobalPermission(List ids) { for (id in ids) { removeDashboardGlobalPermission((long)id); } } // Insert actual dashboard ids here! def ids = [10100, 10101]; removeDashboardGlobalPermission(ids);