Hi,
I created a confluence space for a empolyee blog. Every employee shall be able to write a blog post, but only the author and a moderator group should be able to edit these posts.
This doesn't seem possible without scriptrunner.
So I think a custom event listener for the "BlogPostCreateEvent" would be the right way to trigger a script, that will set the restrictions to these values:
- view everyone
- edit author user
- edit moderator group
Do you think this is the right way?
Is there an example for setting page restrictions through scriptrunner?
There is a built-in script to set page restrictions, but I can't see the source code of it.
Thank you
Hi Alexander!
This script should be pretty close to what you're looking for when creating your custom event listener:
import com.atlassian.confluence.core.ContentPermissionManager
import com.atlassian.confluence.pages.AbstractPage
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.security.ContentPermission
import com.atlassian.confluence.user.ConfluenceUser
import static com.atlassian.confluence.security.ContentPermission.EDIT_PERMISSION
import static com.atlassian.confluence.security.ContentPermission.VIEW_PERMISSION
def contentPermissionManager = ComponentLocator.getComponent(ContentPermissionManager)
def blogPost = event.blogPost
def author = blogPost.creator
def everyonePermission = ContentPermission.createGroupPermission(VIEW_PERMISSION, "confluence-users")
def authorPermission = ContentPermission.createUserPermission(EDIT_PERMISSION, author)
def moderatorPermission = ContentPermission.createGroupPermission(EDIT_PERMISSION, "confluence-administrators")
contentPermissionManager.setContentPermissions(
[
(VIEW_PERMISSION): [everyonePermission],
(EDIT_PERMISSION): [authorPermission, moderatorPermission]
], blogPost
)
Hello!
I believe that if you want to use a listener to do this you'll need to take a look at the ContentPermissionManager and PagePermissionManager classes in order to set the permissions. I don't believe there's an example, but if you have trouble getting something to work feel free to post your code up here and I'll give you some pointers. :)
Jenna Davis
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.