]> source.dussan.org Git - sonarqube.git/commitdiff
Fix Quality flaws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 8 Feb 2017 20:29:37 +0000 (21:29 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 8 Feb 2017 20:29:37 +0000 (21:29 +0100)
server/sonar-server/src/main/java/org/sonar/server/ce/ws/TaskAction.java
server/sonar-server/src/main/java/org/sonar/server/user/UserSession.java
sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java

index 4318f5910bf08d0ccc033a66ace7841454763cef..48d3b44c1ce040f2487824525a3f6a4de7720467 100644 (file)
@@ -31,7 +31,6 @@ import javax.annotation.Nullable;
 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.core.util.Uuids;
 import org.sonar.core.util.stream.Collectors;
 import org.sonar.db.DbClient;
@@ -44,6 +43,7 @@ import org.sonar.server.user.UserSession;
 import org.sonarqube.ws.WsCe;
 
 import static org.sonar.core.permission.GlobalPermissions.SCAN_EXECUTION;
+import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN;
 import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException;
 import static org.sonar.server.ws.WsUtils.writeProtobuf;
 
@@ -122,8 +122,9 @@ public class TaskAction implements CeWsAction {
 
   private void checkPermission(Optional<ComponentDto> component) {
     if (component.isPresent()) {
-      if (!userSession.hasOrganizationPermission(component.get().getOrganizationUuid(), GlobalPermissions.SYSTEM_ADMIN) &&
-        !userSession.hasOrganizationPermission(component.get().getOrganizationUuid(), GlobalPermissions.SCAN_EXECUTION) &&
+      String orgUuid = component.get().getOrganizationUuid();
+      if (!userSession.hasOrganizationPermission(orgUuid, SYSTEM_ADMIN) &&
+        !userSession.hasOrganizationPermission(orgUuid, SCAN_EXECUTION) &&
         !userSession.hasComponentPermission(SCAN_EXECUTION, component.get())) {
         throw insufficientPrivilegesException();
       }
index 4198fe6cd15ade4534844df526e43cbfb5fd4449..c95449fb063df697f828ff75fd21e88164887b2c 100644 (file)
@@ -34,7 +34,7 @@ public interface UserSession {
   String getLogin();
 
   /**
-   * NAme of the authenticated user. Returns {@code null}
+   * Name of the authenticated user. Returns {@code null}
    * if {@link #isLoggedIn()} is {@code false}.
    */
   @CheckForNull
index 23f0afc361d96702b1e59c6c0abdefbd8a001c18..93f36f1e21b5dbd16cd1ad7793118d9d2f910749 100644 (file)
@@ -541,8 +541,7 @@ public class ComponentDaoTest {
   public void select_provisioned() {
     OrganizationDto organization = db.organizations().insert();
     ComponentDto provisionedProject = db.components().insertComponent(newProjectDto(organization).setKey("provisioned.project").setName("Provisioned Project"));
-    ComponentDto provisionedView = db.components().insertView(organization, (dto) -> {
-    });
+    ComponentDto provisionedView = db.components().insertView(organization);
     String projectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newProjectDto(organization)).getComponentUuid();
     String disabledProjectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newProjectDto(organization).setEnabled(false)).getComponentUuid();
     String viewUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newView(organization)).getComponentUuid();