Search in sources :

Example 6 with UserPermissionDto

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

the class UserDbTester method insertProjectPermissionOnUser.

/**
   * Grant permission on given project
   */
public UserPermissionDto insertProjectPermissionOnUser(UserDto user, String permission, ComponentDto project) {
    UserPermissionDto dto = new UserPermissionDto(project.getOrganizationUuid(), permission, user.getId(), project.getId());
    db.getDbClient().userPermissionDao().insert(db.getSession(), dto);
    db.commit();
    return dto;
}
Also used : UserPermissionDto(org.sonar.db.permission.UserPermissionDto)

Example 7 with UserPermissionDto

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

the class UserDbTester method insertPermissionOnUser.

/**
   * Grant global permission
   * @deprecated use {@link #insertPermissionOnUser(OrganizationDto, UserDto, OrganizationPermission)}
   */
@Deprecated
public UserPermissionDto insertPermissionOnUser(OrganizationDto org, UserDto user, String permission) {
    UserPermissionDto dto = new UserPermissionDto(org.getUuid(), permission, user.getId(), null);
    db.getDbClient().userPermissionDao().insert(db.getSession(), dto);
    db.commit();
    return dto;
}
Also used : UserPermissionDto(org.sonar.db.permission.UserPermissionDto)

Example 8 with UserPermissionDto

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

the class ListActionTest method addComponent.

private ComponentDto addComponent(ComponentDto component) {
    db.components().insertComponent(component);
    dbClient.userPermissionDao().insert(dbSession, new UserPermissionDto(component.getOrganizationUuid(), UserRole.USER, userSession.getUserId(), component.getId()));
    db.commit();
    return component;
}
Also used : UserPermissionDto(org.sonar.db.permission.UserPermissionDto)

Aggregations

UserPermissionDto (org.sonar.db.permission.UserPermissionDto)8 DbSession (org.sonar.db.DbSession)2 ComponentDto (org.sonar.db.component.ComponentDto)2 OrganizationDto (org.sonar.db.organization.OrganizationDto)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 String.format (java.lang.String.format)1 MessageFormat (java.text.MessageFormat)1 ArrayList (java.util.ArrayList)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