}
String effectiveKey = ComponentKeys.createKey(projectKey, branch);
- PermissionTemplateDto template = findTemplate(dbSession, organizationUuid, new ComponentDto().setOrganizationUuid(organizationUuid).setKey(effectiveKey).setQualifier(qualifier));
+ ComponentDto dto = new ComponentDto().setOrganizationUuid(organizationUuid).setKey(effectiveKey).setQualifier(qualifier);
+ PermissionTemplateDto template = findTemplate(dbSession, organizationUuid, dto);
if (template == null) {
return false;
}
import org.sonar.db.property.PropertyQuery;
import org.sonar.db.qualitygate.QualityGateDto;
import org.sonar.server.component.ComponentFinder;
-import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.qualitygate.QualityGateFinder;
import org.sonar.server.qualityprofile.QPMeasureData;
import org.sonar.server.qualityprofile.QualityProfile;
import static org.sonar.api.web.UserRole.ADMIN;
import static org.sonar.api.web.UserRole.USER;
import static org.sonar.core.permission.GlobalPermissions.QUALITY_PROFILE_ADMIN;
+import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
public class ComponentAction implements NavigationWsAction {
try (DbSession session = dbClient.openSession(false)) {
ComponentDto component = componentFinder.getByKey(session, componentKey);
if (!(userSession.hasComponentPermission(USER, component) || userSession.hasComponentPermission(ADMIN, component))) {
- throw new ForbiddenException("Insufficient privileges");
+ throw insufficientPrivilegesException();
}
OrganizationDto org = componentFinder.getOrganization(session, component);
Optional<SnapshotDto> analysis = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(session, component.projectUuid());
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.ComponentDto;
-import org.sonar.db.component.ResourceDao;
import org.sonar.db.user.GroupDto;
import org.sonar.db.user.UserDto;
@CheckForNull
private final UserDto userDto;
private final DbClient dbClient;
- private final ResourceDao resourceDao;
private final Supplier<List<GroupDto>> groups;
private List<String> globalPermissions = null;
- private SetMultimap<String, String> projectKeyByPermission = HashMultimap.create();
private SetMultimap<String, String> projectUuidByPermission = HashMultimap.create();
private SetMultimap<String, String> permissionsByOrganizationUuid;
private Map<String, String> projectUuidByComponentUuid = newHashMap();
private ServerUserSession(DbClient dbClient, @Nullable UserDto userDto) {
this.userDto = userDto;
this.dbClient = dbClient;
- this.resourceDao = dbClient.resourceDao();
this.groups = Suppliers.memoize(this::loadGroups);
}
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
-import org.sonar.core.permission.GlobalPermissions;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.user.UserDto;