All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ch.sbb.polarion.extension.api.extender.util.RolesUtils Maven / Gradle / Ivy

Go to download

This Polarion extension provides additional functionality which is not implemented in standard Polarion API for some reason

The newest version!
package ch.sbb.polarion.extension.api.extender.util;

import ch.sbb.polarion.extension.generic.util.ScopeUtils;
import com.polarion.alm.projects.IProjectService;
import com.polarion.alm.projects.model.IProject;
import com.polarion.platform.core.PlatformContext;
import com.polarion.platform.security.ISecurityService;
import lombok.experimental.UtilityClass;

import java.util.Collection;
import java.util.Set;

@UtilityClass
public class RolesUtils {

    private static final ISecurityService securityService = PlatformContext.getPlatform().lookupService(ISecurityService.class);
    private static final IProjectService projectService = PlatformContext.getPlatform().lookupService(IProjectService.class);

    public static Collection getGlobalRoles() {
        return securityService.getGlobalRoles();
    }

    public static Collection getProjectRoles(String scope) {
        String projectId = ScopeUtils.getProjectFromScope(scope);
        if (projectId == null) {
            return Set.of();
        }
        IProject project = projectService.getProject(projectId);
        return securityService.getContextRoles(project.getContextId());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy