Hey guys,
I want to restrict a page via java to only a amount of users. How can I restrict a page with Java - couldnt find it with google..
Thank You!
Community moderators have prevented the ability to post new answers.
I usually do something like that:
/** * remove edit permissions from old page * @param page */ public static void removeEditPermissions(AbstractPage page , ContentPermissionManager contentPermissionManager) { //remove old edit permissions List<ContentPermission> toDelete = new ArrayList<ContentPermission>(); if (page.getContentPermissionSet(ContentPermission.EDIT_PERMISSION) != null) { for (ContentPermission cp : page.getContentPermissionSet(ContentPermission.EDIT_PERMISSION)) { toDelete.add(cp); } for (ContentPermission cp : toDelete) { contentPermissionManager.removeContentPermission(cp); } } }
This removes all edit permissions. I did not find any better way yet.
Thank you for your fast and good answers! But I've to say I still get a nullpointer: [com.atlassian.hibernate.HibernateObjectDao] remove remove error! org.springframework.orm.hibernate.HibernateSystemException: not-null property references a null or transient value: com.atlassian.confluence.security.ContentPermission.owningSet; nested exception is net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: com.atlassian.confluence.security.ContentPermission.owningSet
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's strange. In which context are you executing this? I am doing this in a servlet and it works just fine. (confluence 5.7.4) But it might be that this is because i never leave the permissions completely empty? Not sure. Consider asking a new question for this issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm using this with a normal class which is used in a Event Listener and a Action. I'm using 5.8.4 - and 5.8.4 does many strange stuff.. Thank you! I'll ask a new question! Best regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, you can use the following code:
page.addPermission(ContentPermission.createUserPermission(ContentPermission.VIEW_PERMISSION, confluenceUser));
for a view permission for example.
Best regards,
Lukas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thank you! But does this mean, that all other users cant view or should i remove all permissions to this page and add all user permissions of the users which should have the permission? Thanks, Best regards, Fabian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Those are basically the restrictions on the page. If no restriction is applied, every one who can see the space can see the page. (same with edit.) If view is restricted to a specific user, only the restricted user can view the page only if he has permission to view the space only if he is allowed to vie the parent page. Similar with edit, but you have to have permission to view the page in order to be able to edit it. https://confluence.atlassian.com/display/DOC/Page+Restrictions Best regards
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.
Ok thanks, but if i want to remove the permission set ill get a nullpointer.. Can you tell me why @lukas.knoch
page.removeContentPermissionSet(page.getContentPermissionSet(ContentPermission.EDIT_PERMISSION)); page.removeContentPermissionSet(page.getContentPermissionSet(ContentPermission.VIEW_PERMISSION));
Thanks!
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.