Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

ContentPermissionEvent: Telling add/remove events apart

I'd like to record permission changes on pages. I already found this https://jira.atlassian.com/browse/CONFSERVER-19721 but figured I might be able to implement something myself with the help of the Scriptrunner Addon.

I created a custom Event which listens to the ContentPermissionEvent being fired. Generally speaking it would be enough to log something to console stating how a permission was changed. I also found out that the confluence database keeps the set of page permissions, whereas no entry means "full permissions and EDIT/VIEW are written according to what I configured.

The following shows the script that I got so far.

import com.atlassian.confluence.event.events.security.ContentPermissionEvent
import com.atlassian.confluence.core.ContentEntityObject
import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.user.User


// create Loglistener
def log = Logger.getLogger("com.company.CustomContentPermissionEventListener")
log.setLevel(Level.INFO)

 

def event = event as ContentPermissionEvent
def contentid = event.content.idAsString
def contentPermission = event.contentPermission

def permissionString

//group our user
if(contentPermission.groupPermission){
permissionString = "Group: " + contentPermission.groupName
}else{
permissionString = "User: " + contentPermission.userName
}

//type
permissionString = permissionString + ", Type: " + contentPermission.type


// Log data from Event
log.info("PermissionEvent registered for PageId " + contentid + ", details: " + permissionString)

 

Apparently the event seems to be not smart enough to tell adding and removing permissions apart. In both cases the log entry is the same. Is there a way to tell them apart?

Thanks allot for any pointers.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

97 views 0 5
Read article

Community Events

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

Events near you