1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import com.atlassian.jira.bc.portal.PortalPageService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.portal.PortalPage
import com.atlassian.jira.sharing.SharedEntity
import com.atlassian.jira.sharing.SharePermissionImpl
import com.atlassian.jira.sharing.type.ShareType
import com.atlassian.jira.bc.JiraServiceContextImpl
//def dashboard_ids = [10000,10104,10200,10201,10202,10203,10403,10500,10604,10401,10612,10701,10804,10805,10808,10809,10806,10811,10602,10803,11002,11001,11003,11004,11005,11000,11006,11007,11008,11009,10609,11100,11101,11200,11301,11306,11308,11400,11402,11501,10503,11506,11700,11704,11702,11711,11710,11712,11717,11600,12102,12301,12305,12400,11715,11716,12501,12502,12702,12706,12707,12708,12712,12714,12800,12801,12802,12804,13200,13901,14101,14201,14401,14700,15001,15200,15300,15002,14300,14100,14500,15700,15900,16100,16301,16300,16400,14000,16500,16701,16700,16705,17100,17101,17301,17302,17702,17703,18100,18101,18400,18401,18502,18503,18600,18601,19400,19403,19404,19500,20200,20201,20202,20203,20204,20205,20600,20601]
def dashboard_ids = [21002,21101]
dashboard_ids.each { item ->
def portalPageService = ComponentAccessor.getComponent(PortalPageService)
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def context = new JiraServiceContextImpl(currentUser)
def sharePerm = new SharePermissionImpl(null, ShareType.Name.GROUP, "jira-software-users", null)
def sharePermissions = new SharedEntity.SharePermissions([sharePerm] as Set)
def originDash = portalPageService.getPortalPage(context, item)
def isFavorite = portalPageService.isFavourite(currentUser, originDash)
def portalPageBuilder = new PortalPage.Builder().portalPage(originDash).permissions(sharePermissions)
def updatedDash = portalPageBuilder.build()
portalPageService.updatePortalPage(context, updatedDash, isFavorite)
}
|