ch.sbb.polarion.extension.api.extender.util.RolesUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ch.sbb.polarion.extension.api-extender Show documentation
Show all versions of ch.sbb.polarion.extension.api-extender Show documentation
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());
}
}