Permission issues while migrating a private dashboard

 

Symptoms

When migrating the dashboards, the Project Configurator for Jira app throws errors, if any private dashboards are part of the export and the user who is importing does not have permission to access these dashboards.

Cause

The user does not have share permissions to access this dashboard.

Resolution 1

Use the following groovy script to make only a dashboard with a 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.

Make all dashboards global - makeAllDashboardsGlobal returns the IDs of all changed dashboards. This list can be used to revert the changes, so save it!

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);

Â