}
}
- private EventDto insertDbEvent(DbSession dbSession, CreateEventRequest request, SnapshotDto analysis) {
+ private EventDto insertDbEvent(DbSession dbSession, CreateEventRequest request, SnapshotDto analysis) {
EventDto dbEvent = dbClient.eventDao().insert(dbSession, toDbEvent(request, analysis));
if (VERSION.equals(request.getCategory())) {
analysis.setVersion(request.getName());
import org.sonarqube.ws.client.projectlinks.DeleteWsRequest;
import static org.sonar.db.component.ComponentLinkDto.PROVIDED_TYPES;
-import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException;
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.ACTION_DELETE;
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_ID;
ComponentLinkDto link = dbClient.componentLinkDao().selectById(dbSession, id);
link = WsUtils.checkFound(link, "Link with id '%s' not found", id);
- checkPermissions(link.getComponentUuid());
+ checkProjectAdminPermission(link);
checkNotProvided(link);
dbClient.componentLinkDao().delete(dbSession, link.getId());
WsUtils.checkRequest(!isProvided, "Provided link cannot be deleted.");
}
- private void checkPermissions(String projectUuid) {
- if (!userSession.hasComponentUuidPermission(UserRole.ADMIN, projectUuid)) {
- throw insufficientPrivilegesException();
- }
+ private void checkProjectAdminPermission(ComponentLinkDto link) {
+ userSession.checkComponentUuidPermission(UserRole.ADMIN, link.getComponentUuid());
}
}