]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 27 Oct 2014 12:39:27 +0000 (13:39 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 27 Oct 2014 12:39:52 +0000 (13:39 +0100)
sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java

index 6c73eade4e8daa7d5593d8e4ab66ca0b346d2c89..0054efd697659861fada6ce97bfebf150a4ca501 100644 (file)
@@ -34,6 +34,7 @@ import static com.google.common.collect.Maps.newHashMap;
 
 public class AuthorizationDao implements ServerComponent, DaoComponent {
 
+  private static final String USER_ID_PARAM = "userId";
   private final MyBatis mybatis;
 
   public AuthorizationDao(MyBatis mybatis) {
@@ -61,16 +62,12 @@ public class AuthorizationDao implements ServerComponent, DaoComponent {
       params = ImmutableMap.of("role", role, "componentKeys", componentKeys);
     } else {
       sql = "keepAuthorizedComponentKeysForUser";
-      params = ImmutableMap.of("userId", userId, "role", role, "componentKeys", componentKeys);
+      params = ImmutableMap.of(USER_ID_PARAM, userId, "role", role, "componentKeys", componentKeys);
     }
 
     return Sets.newHashSet(session.<String>selectList(sql, params));
   }
 
-  public boolean isAuthorizedComponentKey(String componentKey, @Nullable Integer userId, String role) {
-    return keepAuthorizedComponentKeys(Sets.newHashSet(componentKey), userId, role).size() == 1;
-  }
-
   public Collection<String> selectAuthorizedRootProjectsKeys(@Nullable Integer userId, String role) {
     SqlSession session = mybatis.openSession(false);
     try {
@@ -95,7 +92,7 @@ public class AuthorizationDao implements ServerComponent, DaoComponent {
     String sql;
     Map<String, Object> params = newHashMap();
     sql = "selectAuthorizedRootProjectsKeys";
-    params.put("userId", userId);
+    params.put(USER_ID_PARAM, userId);
     params.put("role", role);
 
     return session.selectList(sql, params);
@@ -105,7 +102,7 @@ public class AuthorizationDao implements ServerComponent, DaoComponent {
     String sql;
     Map<String, Object> params = newHashMap();
     sql = "selectAuthorizedRootProjectsUuids";
-    params.put("userId", userId);
+    params.put(USER_ID_PARAM, userId);
     params.put("role", role);
 
     return session.selectList(sql, params);