aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectLookup.java10
-rw-r--r--sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectLookupTest.java4
2 files changed, 7 insertions, 7 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectLookup.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectLookup.java
index e286088d260..5dd735c852e 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectLookup.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectLookup.java
@@ -34,6 +34,7 @@ import org.sonar.server.user.UserSession;
import javax.annotation.CheckForNull;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -63,10 +64,11 @@ public class QProfileProjectLookup implements ServerComponent {
UserSession userSession = UserSession.get();
List<Component> result = Lists.newArrayList();
- for (String key: authorizationDao.keepAuthorizedComponentKeys(
- componentsByKeys.keySet(), userSession.userId(), UserRole.USER
- )) {
- result.add(componentsByKeys.get(key));
+ Collection<String> authorizedProjectKeys = authorizationDao.selectAuthorizedRootProjectsKeys(userSession.userId(), UserRole.USER);
+ for (String key: componentsByKeys.keySet()) {
+ if (authorizedProjectKeys.contains(key)) {
+ result.add(componentsByKeys.get(key));
+ }
}
return result;
diff --git a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectLookupTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectLookupTest.java
index f618d00c389..e4e9c747669 100644
--- a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectLookupTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectLookupTest.java
@@ -40,8 +40,6 @@ import org.sonar.server.user.MockUserSession;
import static com.google.common.collect.Lists.newArrayList;
import static org.fest.assertions.Assertions.assertThat;
import static org.fest.assertions.Fail.fail;
-import static org.mockito.Matchers.anySet;
-import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -83,7 +81,7 @@ public class QProfileProjectLookupTest {
new ComponentDto().setId(1L).setKey(key1).setName("SonarQube One"),
new ComponentDto().setId(1L).setKey(key2).setName("SonarQube Two")));
- when(authorizationDao.keepAuthorizedComponentKeys(anySet(), eq(userId), eq(UserRole.USER))).thenReturn(Sets.newHashSet(key1));
+ when(authorizationDao.selectAuthorizedRootProjectsKeys(userId, UserRole.USER)).thenReturn(Sets.newHashSet(key1));
assertThat(lookup.projects(1)).hasSize(1);
}