]> source.dussan.org Git - sonarqube.git/commitdiff
Fix Quality flaws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Sun, 29 Jan 2017 20:11:28 +0000 (21:11 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 1 Feb 2017 16:11:52 +0000 (17:11 +0100)
server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/CreateEventAction.java
server/sonar-server/src/main/java/org/sonar/server/projectlink/ws/DeleteAction.java

index fbe5927ba402bdaf3a891b63809ba88213ead0b7..b2978637482d5767798c123605ece04863b9e8d8 100644 (file)
@@ -119,7 +119,7 @@ public class CreateEventAction implements ProjectAnalysesWsAction {
     }
   }
 
-    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());
index 2adce3cfd8385b63c4f6592d171da54b617f452f..607b27fb79916376154ebc940d6f135d3b99da08 100644 (file)
@@ -31,7 +31,6 @@ import org.sonar.server.ws.WsUtils;
 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;
 
@@ -79,7 +78,7 @@ public class DeleteAction implements ProjectLinksWsAction {
       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());
@@ -95,9 +94,7 @@ public class DeleteAction implements ProjectLinksWsAction {
     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());
   }
 }