When I am trying the below code. In which I am first fetching the list of Board Admins and adding a group say "Test_Group" in that list and updating the same Board admins with the new list. It is throwing an error "Not Implemented". But when I am fetching board admins from 1 board and adding a group and updating some other board with the new list it is updating successfully. But my task is to fetch from first board and update the first board only with the new admin list.
import com.atlassian.greenhopper.service.rapid.view.BoardAdminService
import com.onresolve.scriptrunner.runner.customisers.PluginModuleCompilationCustomiser
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.greenhopper.service.rapid.ProjectRapidViewService
import com.onresolve.scriptrunner.runner.customisers.PluginModuleCompilationCustomiser
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.greenhopper.model.rapid.BoardAdmin
import com.atlassian.greenhopper.model.rapid.RapidView
import com.atlassian.greenhopper.manager.rapidview.RapidViewManager
import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.manager.rapidview.BoardAdminManagerImpl
//import com.atlassian.greenhopper.manager.rapidview.RapidViewManagerImpl
def rapidViewService = PluginModuleCompilationCustomiser.getGreenHopperBean(RapidViewService)
//def rapidViewManager = PluginModuleCompilationCustomiser.getGreenHopperBean(RapidViewManagerImpl)
def groupManager = ComponentAccessor.getGroupManager()
def BoardAdminManager = PluginModuleCompilationCustomiser.getGreenHopperBean(BoardAdminManagerImpl)
def projectRapidViewService = PluginModuleCompilationCustomiser.getGreenHopperBean(ProjectRapidViewService)
/*Fetching Boards using Project Key*/
def boards = projectRapidViewService.findRapidViewsByProject(
ComponentAccessor.jiraAuthenticationContext.loggedInUser,
ComponentAccessor.projectManager.getProjectByCurrentKey("XYZ")
).value
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def boardAdminService = PluginModuleCompilationCustomiser.getGreenHopperBean(BoardAdminService)
def rapidView = boards[0]
def rapidView1 = boards[1]
/*Fetching Board Admins of any particular board*/
def boardAdmins = boardAdminService.getBoardAdmins(rapidView)
def newAdmin = groupManager.getGroupObject("Test_Group")
def boardAdmin = BoardAdmin.builder().type(BoardAdmin.Type.GROUP).key(newAdmin.name).build()
/*Adding the existing list with a new group*/
def boardAdmin1 = boardAdmin1 = boardAdmins + [boardAdmin]
/*Updating the list*/
BoardAdminManager.updateBoardAdmin(rapidView,boardAdmin1)
Please help me asap. Thanks in advance!!
Did you find a way to do this?
I've been searching a ton and haven't been able to get a script that updates the board admins working.
I have a similar issue when trying to do this:
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.greenhopper.manager.rapidview.RapidViewManager
import com.atlassian.greenhopper.model.rapid.BoardAdmin
import com.atlassian.greenhopper.model.rapid.RapidView
@WithPlugin("com.pyxis.greenhopper.jira")
@JiraAgileBean
RapidViewManager rapidViewManager
@JiraAgileBean
BoardAdminService boardAdminService
ArrayList<RapidView>allBoards = rapidViewManager.getAll().value
ArrayList<BoardAdmin> originalPermissions = boardAdminService.getBoardAdmins(allBoards.first())
try {
boardAdminService.updateBoardAdmins(allBoards.first(),userManager.getUserByName("localadmin"),originalPermissions)
}catch(all) {
log.debug(all.message)
}
This prints the error: Not implemented
I obviously want to do more and update with the old permissions but when I try to create new permissions I get the same problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"originalPermissions" has id and other attributes
I think updateBoardAdmins processes these attributes and we have "Not implemented".
If you pass a list to the function without them, then everything will work. As I wrote above, I reload a list and it works for me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well that med a hell of a difference, many thanks @Dmitriy.Khalturin !!
I was just so focused on that I probably needed to generate new ID´s for my new permissions, I didn't think about not being able to reuse the older ID´s.
So in short, if you are keeping any of the older permissions recreate them:
newPermissions.add(BoardAdmin.builder().type(originalPermission.type).key(originalPermission.key).build())
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi !
I use this code:
/*Fetching Board Admins of any particular board*/
def boardAdmins = boardAdminService.getBoardAdmins(rapidView)
/* Reload admins in new list*/
List<BoardAdmin> boardAdmin1 = new ArrayList<BoardAdmin>()
boardAdmins.each(){ admin ->
boardAdmin1.add(BoardAdmin.builder().type(admin.getType()).key(admin.getKey()).build())
}
def newAdmin = groupManager.getGroupObject("Test_Group")
def boardAdmin = BoardAdmin.builder().type(BoardAdmin.Type.GROUP).key(newAdmin.key).build()
/*Adding the existing list with a new group*/
boardAdmin1.add(boardAdmin)
/*Updating the list*/
boardAdminService.updateBoardAdmin(rapidView,user,boardAdmin1)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I belive this wont work as Groups dont have a key property:
newAdmin.key
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, it's a error-typo.
Must be
def boardAdmin = BoardAdmin.builder().type(BoardAdmin.Type.GROUP).key("Test_Group").build()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.