]> source.dussan.org Git - sonarqube.git/commitdiff
Fix Quality flaws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 7 Feb 2017 15:08:55 +0000 (16:08 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 8 Feb 2017 16:18:43 +0000 (17:18 +0100)
server/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplateService.java
server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentAction.java
server/sonar-server/src/main/java/org/sonar/server/user/ServerUserSession.java
server/sonar-server/src/main/java/org/sonar/server/user/ws/ChangePasswordAction.java

index 34cda3357d3550713afe2b2f9d1c3a50e30ca267..0054d91d48d9f232c35d5c870bb7e8220ad16abe 100644 (file)
@@ -77,7 +77,8 @@ public class PermissionTemplateService {
     }
 
     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;
     }
index 1dbf7b6e13929c9fa8c3b1365c6d9199ee77fa60..b15ccd19b7e2f593fec32e6232d13f846d6baa8e 100644 (file)
@@ -50,7 +50,6 @@ import org.sonar.db.property.PropertyDto;
 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;
@@ -61,6 +60,7 @@ import static org.sonar.api.measures.CoreMetrics.QUALITY_PROFILES_KEY;
 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 {
@@ -129,7 +129,7 @@ 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());
index e92b7c4a8d0ec7e2cf0353fe12aa4d22e88f58f5..7c78afca6f4fd87c301b755daf939938a8c16a5a 100644 (file)
@@ -36,7 +36,6 @@ import javax.annotation.Nullable;
 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;
 
@@ -50,10 +49,8 @@ public class ServerUserSession extends AbstractUserSession {
   @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();
@@ -62,7 +59,6 @@ public class ServerUserSession extends AbstractUserSession {
   private ServerUserSession(DbClient dbClient, @Nullable UserDto userDto) {
     this.userDto = userDto;
     this.dbClient = dbClient;
-    this.resourceDao = dbClient.resourceDao();
     this.groups = Suppliers.memoize(this::loadGroups);
   }
 
index c256a804e7c7d5034a7a831f992874396a49c110..98a959ae05a8ffe78204c8e625db55d91d0c5e6d 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.server.user.ws;
 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;