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.
This script should be pretty close to what you're looking for when creating your custom event listener:
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")
(EDIT_PERMISSION): [authorPermission, moderatorPermission]
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. :)
Hi, Confluence collaborators! As part of #Confluence-Collaboratory month, we’ve created a very special Mythsbusters segment, where we're dive into an interesting myth and uncover the truth behind i...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events