Hello community, I want to bulk add a group-permission to all pages in a space. I already came up with a script, but it does not work as expected yet.
Here is my current (simplified) implementation.
import com.atlassian.confluence.labels.Label
import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.pages.PageManager
import com.atlassian.confluence.spaces.Space
import com.atlassian.confluence.spaces.SpaceManager
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.api.service.content.SpaceService
import com.atlassian.confluence.core.ContentPermissionManager
import com.atlassian.user.GroupManager
import com.atlassian.confluence.security.ContentPermission
import static com.atlassian.confluence.security.ContentPermission.EDIT_PERMISSION
def spaceManager = ComponentLocator.getComponent(SpaceManager)
def pageManager = ComponentLocator.getComponent(PageManager)
def spaceService = ComponentLocator.getComponent(SpaceService)
def contentPermissionManager =ComponentLocator.getComponent(ContentPermissionManager)
Space sourceSpace = spaceManager.getSpace("TEST")
def groupPermission = ContentPermission.createGroupPermission(EDIT_PERMISSION, "editor-group")
for (Page page : pageManager.getPages(sourceSpace, true)) {
def currentPage = page
contentPermissionManager.addContentPermission(groupPermission, currentPage)
}
What is wrong here? Do I miss something along the lines of a commit/save for each and every page?
Thanks, Christoph
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.