How to revoke some permission from user in a space through java

neetubhatt July 21, 2021

I want to revoke some permission from a user in a space but not able to find a way that works .

1. when iam trying with removeallpermission then all the access of user is revoked , sometime the user is deleted from his own space .

2)I have tried 

SpacePermission spacePermission = SpacePermission.createUserSpacePermission(SpacePermission.EXPORT_SPACE_PERMISSION,space,user);
spacePermissionManager.removePermission(spacePermission); 

but this is also not working and making no change in permissions.

2 answers

1 accepted

1 vote
Answer accepted
neetubhatt August 9, 2021

List<SpacePermission>permissionsVal= space.getPermissions();
for(SpacePermission permission:permissionsVal){
if( permission.isUserPermission()){
User user= permission.getUserSubject();
if(permission.getType()=="EXPORTSPACE")
{
permissionsToRemove.add(permission);
}}}

I have tried it this way and its working fine to remove permission for user from a space .

Kishan Sharma
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 9, 2021

Great, thanks for sharing!

Like neetubhatt likes this
0 votes
Kishan Sharma
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 8, 2021

Hi @neetubhatt Have you tried below interface?

void removeAllUserPermissions(ConfluenceUser user)

Link here.

neetubhatt August 9, 2021

yes I have tried with removeAllUserPermissions but it deletes user from space which i dont want .

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events