How to get SpacePermissions using Java Confluence API (> 7.3.0)?

Earlier we used to get Space Permissions using below code

com.atlassian.confluence.spaces.Space space = spaceManager.getSpace(spaceKey);

List spList = space.getPermissions();

But now we are upgrading to Confluence 7.13.4 and spaceManager.getSpace(spaceKey) is deprecated and I can’t find a way to pull com.atlassian.confluence.spaces.Space which has most of the information.

According to Confluence 7.13.4 API ( SpaceManager (Atlassian Confluence 7.13.4 API) ) " since 7.3.0, use SpaceService.find(Expansion...) in plugins and SpaceManagerInternal in core where applicable ", So when I use above method to pull Space it returns a new Space ( com.atlassian.confluence.api.model.content.Space) class instance with minimum details unlike old one.

When I try to use SpacePermissionManager (SpacePermissionManager (Atlassian Confluence 7.13.4 API)) or PermissionManager methods accept only com.atlassian.confluence.spaces.Space but not new Space ( com.atlassian.confluence.api.model.content.Space)

Without the old Space (com.atlassian.confluence.spaces.Space) class I couldn’t find a way to pull SpacePermissions.

Thanks in advance!!

1 Like

Hello @KrishnaGottapu

You should use the com.atlassian.confluence.api.service.permissions.OperationService in combination with the com.atlassian.confluence.api.service.content.SpaceService to look up available operations/permissions on a given space for the logged in user

    private final SpaceService spaceService;
    private final OperationService operationService;
    public OperationResource(
            @ComponentImport final SpaceService spaceService,
            @ComponentImport final OperationService operationService
    ) {
        this.spaceService = spaceService;
        this.operationService = operationService;

    public Response spaceWithKey(@PathParam("spaceKey") final String spaceKey) {
        List<OperationCheckResult> operationCheckResults = spaceService.find().withKeys(spaceKey)
                .map(space -> operationService.getAvailableOperations(Target.forModelObject(space)))
        return Response.ok(operationCheckResults).build();

code example available here welcome space available operations for logged in user · viqueen/atlassian-devbox@a50102d · GitHub

This however will not return a SpacePermission object that has way too many details , but instead it will return a list of possible operations (read, update, create, delete, export) for the user in context.

The reason we deprecated SpaceManager and co was that it doesn’t run in the user context, which is not exactly a good thing.

I hope this helps

Hasnae R.
former Confluence person