Search in sources :

Example 6 with GroupPermissionDto

use of org.sonar.db.permission.GroupPermissionDto in project sonarqube by SonarSource.

the class UserDbTester method insertProjectPermissionOnAnyone.

public GroupPermissionDto insertProjectPermissionOnAnyone(String permission, ComponentDto project) {
    GroupPermissionDto dto = new GroupPermissionDto().setOrganizationUuid(project.getOrganizationUuid()).setGroupId(null).setRole(permission).setResourceId(project.getId());
    db.getDbClient().groupPermissionDao().insert(db.getSession(), dto);
    db.commit();
    return dto;
}
Also used : GroupPermissionDto(org.sonar.db.permission.GroupPermissionDto)

Example 7 with GroupPermissionDto

use of org.sonar.db.permission.GroupPermissionDto in project sonarqube by SonarSource.

the class UserDbTester method insertPermissionOnAnyone.

// GROUP PERMISSIONS
public GroupPermissionDto insertPermissionOnAnyone(OrganizationDto org, String permission) {
    GroupPermissionDto dto = new GroupPermissionDto().setOrganizationUuid(org.getUuid()).setGroupId(null).setRole(permission);
    db.getDbClient().groupPermissionDao().insert(db.getSession(), dto);
    db.commit();
    return dto;
}
Also used : GroupPermissionDto(org.sonar.db.permission.GroupPermissionDto)

Example 8 with GroupPermissionDto

use of org.sonar.db.permission.GroupPermissionDto in project sonarqube by SonarSource.

the class GroupsAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    try (DbSession dbSession = dbClient.openSession(false)) {
        OrganizationDto org = support.findOrganization(dbSession, request.param(PARAM_ORGANIZATION));
        Optional<ProjectId> projectId = support.findProjectId(dbSession, request);
        checkProjectAdmin(userSession, org.getUuid(), projectId);
        PermissionQuery query = buildPermissionQuery(request, projectId);
        // TODO validatePermission(groupsRequest.getPermission(), wsProjectRef);
        List<GroupDto> groups = findGroups(dbSession, org, query);
        int total = dbClient.groupPermissionDao().countGroupsByQuery(dbSession, org.getUuid(), query);
        List<GroupPermissionDto> groupsWithPermission = findGroupPermissions(dbSession, org, groups, projectId);
        Paging paging = Paging.forPageIndex(request.mandatoryParamAsInt(Param.PAGE)).withPageSize(query.getPageSize()).andTotal(total);
        WsGroupsResponse groupsResponse = buildResponse(groups, groupsWithPermission, paging);
        writeProtobuf(groupsResponse, request, response);
    }
}
Also used : DbSession(org.sonar.db.DbSession) Paging(org.sonar.api.utils.Paging) ProjectId(org.sonar.server.permission.ProjectId) GroupDto(org.sonar.db.user.GroupDto) WsGroupsResponse(org.sonarqube.ws.WsPermissions.WsGroupsResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) PermissionQuery(org.sonar.db.permission.PermissionQuery) GroupPermissionDto(org.sonar.db.permission.GroupPermissionDto)

Aggregations

GroupPermissionDto (org.sonar.db.permission.GroupPermissionDto)8 ArrayList (java.util.ArrayList)2 DbSession (org.sonar.db.DbSession)2 ComponentDto (org.sonar.db.component.ComponentDto)2 GroupDto (org.sonar.db.user.GroupDto)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 String.format (java.lang.String.format)1 MessageFormat (java.text.MessageFormat)1 Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1 Collections.singletonList (java.util.Collections.singletonList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Set (java.util.Set)1 CheckForNull (javax.annotation.CheckForNull)1 Nullable (javax.annotation.Nullable)1 StringUtils (org.apache.commons.lang.StringUtils)1 Test (org.junit.Test)1 Qualifiers (org.sonar.api.resources.Qualifiers)1 DefaultGroups.isAnyone (org.sonar.api.security.DefaultGroups.isAnyone)1