From 75e064ab588d33eb40445e3c8e118f35579d3132 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Sun, 29 Jan 2017 21:11:28 +0100 Subject: [PATCH] Fix Quality flaws --- .../server/projectanalysis/ws/CreateEventAction.java | 2 +- .../org/sonar/server/projectlink/ws/DeleteAction.java | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/CreateEventAction.java b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/CreateEventAction.java index fbe5927ba40..b2978637482 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/CreateEventAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/CreateEventAction.java @@ -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()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/projectlink/ws/DeleteAction.java b/server/sonar-server/src/main/java/org/sonar/server/projectlink/ws/DeleteAction.java index 2adce3cfd83..607b27fb799 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/projectlink/ws/DeleteAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/projectlink/ws/DeleteAction.java @@ -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()); } } -- 2.39.5