Hello,
I have the following script which should create map of dashboards of all jira users with owner of this dashboard.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.portal.PortletConfigurationManager
import com.atlassian.jira.bc.portal.PortalPageService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.user.search.UserSearchParams
import com.atlassian.jira.bc.user.search.UserSearchService
PortalPageService portalPageService = ComponentAccessor.getComponent(PortalPageService)
UserSearchService userSearchService = ComponentAccessor.getComponent(UserSearchService.class)
UserSearchParams userSearchParams = (new UserSearchParams
.Builder())
.allowEmptyQuery(true)
.includeActive(true)
.includeInactive(true)
.maxResults(20000).build()
def users = userSearchService.findUsers("", userSearchParams)
def dash = [:]
def dash2 =[:]
users.each{user ->
def privdashboards = portalPageService.getOwnedPortalPages(user)
privdashboards.each{dashboard ->
dash.put(dashboard.getName(),user)
dash2.put(user,dashboard.getName())
log.error "1111--${dash}"
log.error "2222--${dash2}"
}}
log.error "1111--${dash}"
log.error "22222--${dash2}"
return null
The problem is that dash collect what I expect so the list of all dashboards for all users but dash2 for each user only collect last dashboard so it overwrite value in smaller loop (privdashboards.each) and I don't get why. for me dash should be equal to dash 2 but it is not:
here is output from logs:
1111--[test111:admin(JIRAUSER10000)]
2222--[admin(JIRAUSER10000):test111]
1111--[test111:admin(JIRAUSER10000), test222:admin(JIRAUSER10000)]
2222--[admin(JIRAUSER10000):test222]
1111--[test111:admin(JIRAUSER10000), test222:admin(JIRAUSER10000), LStest111:lukasz(JIRAUSER10200)]
2222--[admin(JIRAUSER10000):test222, lukasz(JIRAUSER10200):LStest111]
1111--[test111:admin(JIRAUSER10000), test222:admin(JIRAUSER10000), LStest111:lukasz(JIRAUSER10200), LStest2222:lukasz(JIRAUSER10200)]
2222--[admin(JIRAUSER10000):test222, lukasz(JIRAUSER10200):LStest2222]
1111--[test111:admin(JIRAUSER10000), test222:admin(JIRAUSER10000), LStest111:lukasz(JIRAUSER10200), LStest2222:lukasz(JIRAUSER10200)]
22222--[admin(JIRAUSER10000):test222, lukasz(JIRAUSER10200):LStest2222]