]> source.dussan.org Git - sonarqube.git/commitdiff
Remove useless field "permission" in IssueAuthorization index
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 31 Oct 2014 14:11:24 +0000 (15:11 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 31 Oct 2014 14:24:46 +0000 (15:24 +0100)
server/sonar-server/src/main/java/org/sonar/server/issue/db/IssueAuthorizationDao.java
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueAuthorizationDoc.java
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueAuthorizationNormalizer.java
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueAuthorizationIndexMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionServiceMediumTest.java
sonar-core/src/main/java/org/sonar/core/issue/db/IssueAuthorizationDto.java
sonar-core/src/test/java/org/sonar/core/issue/db/IssueAuthorizationDtoTest.java

index 7810f90be0d719b076f8256b45ba624da03dedb1..6289cb3816e75232b27fabced87f5b070e2e6edd 100644 (file)
@@ -71,8 +71,7 @@ public class IssueAuthorizationDao extends BaseDao<IssueAuthorizationMapper, Iss
         IssueAuthorizationDto issueAuthorizationDto = authorizationDtoMap.get(project);
         if (issueAuthorizationDto == null) {
           issueAuthorizationDto = new IssueAuthorizationDto()
-            .setProjectUuid(project)
-            .setPermission(UserRole.USER);
+            .setProjectUuid(project);
           issueAuthorizationDto.setUpdatedAt(updatedAt);
         }
         if (group != null) {
index ab5574d0c71aeebe8efd940b1197d42b001017e8..5a31cc7fad28b4d373c433074543cfa9db25ac23 100644 (file)
@@ -37,10 +37,6 @@ public class IssueAuthorizationDoc extends BaseDoc {
     return getField(IssueAuthorizationNormalizer.IssueAuthorizationField.PROJECT.field());
   }
 
-  public String permission() {
-    return getField(IssueAuthorizationNormalizer.IssueAuthorizationField.PERMISSION.field());
-  }
-
   public List<String> groups() {
     return (List<String>) getField(IssueAuthorizationNormalizer.IssueAuthorizationField.GROUPS.field());
   }
index 1519c428399929f70c9fac5d1d9315f6ba73cee7..a2bd856d303885abccd60dc860f6c1d208172445 100644 (file)
@@ -44,12 +44,11 @@ public class IssueAuthorizationNormalizer extends BaseNormalizer<IssueAuthorizat
   public static final class IssueAuthorizationField extends Indexable {
 
     public static final IndexField PROJECT = add(IndexField.Type.STRING, "project");
-    public static final IndexField PERMISSION = add(IndexField.Type.STRING, "permission");
     public static final IndexField GROUPS = add(IndexField.Type.STRING, "groups");
     public static final IndexField USERS = add(IndexField.Type.STRING, "users");
     public static final IndexField UPDATED_AT = add(IndexField.Type.DATE, BaseNormalizer.UPDATED_AT_FIELD);
 
-    public static final Set<IndexField> ALL_FIELDS = ImmutableSet.of(PROJECT, PERMISSION, GROUPS, USERS, UPDATED_AT);
+    public static final Set<IndexField> ALL_FIELDS = ImmutableSet.of(PROJECT, GROUPS, USERS, UPDATED_AT);
   }
 
   @Override
@@ -59,7 +58,6 @@ public class IssueAuthorizationNormalizer extends BaseNormalizer<IssueAuthorizat
     Preconditions.checkNotNull(dto.getProjectUuid(), "Project uuid is null");
 
     update.put(IssueAuthorizationField.PROJECT.field(), dto.getProjectUuid());
-    update.put(IssueAuthorizationField.PERMISSION.field(), dto.getPermission());
     update.put(IssueAuthorizationField.USERS.field(), dto.getUsers());
     update.put(IssueAuthorizationField.GROUPS.field(), dto.getGroups());
     update.put(IssueAuthorizationField.UPDATED_AT.field(), dto.getUpdatedAt());
index 69cfdeae4c943e52fbca90eeea85001368f4845a..3bc3b6093a5d18a73630d44f09ac75e6e70c1983 100644 (file)
@@ -40,7 +40,6 @@ import org.elasticsearch.search.sort.FieldSortBuilder;
 import org.elasticsearch.search.sort.SortBuilders;
 import org.elasticsearch.search.sort.SortOrder;
 import org.sonar.api.issue.Issue;
-import org.sonar.api.web.UserRole;
 import org.sonar.core.issue.db.IssueDto;
 import org.sonar.server.issue.IssueQuery;
 import org.sonar.server.issue.filter.IssueFilterParameters;
@@ -312,7 +311,7 @@ public class IssueIndex extends BaseIndex<Issue, IssueDto, String> {
       QueryBuilders.filteredQuery(
         QueryBuilders.matchAllQuery(),
         FilterBuilders.boolFilter()
-          .must(FilterBuilders.termFilter(IssueAuthorizationNormalizer.IssueAuthorizationField.PERMISSION.field(), UserRole.USER), groupsAndUser)
+          .must(groupsAndUser)
           .cache(true))
       );
   }
index fb8e51c52d0f9503d2c43bbb02b8ecc9b75dbac9..721ee38d81dc0ed03aff1b958b279683f423a7d9 100644 (file)
@@ -91,7 +91,6 @@ public class IssueAuthorizationIndexMediumTest {
     IssueAuthorizationDoc issueAuthorizationDoc = index.getByKey(project.uuid());
     assertThat(issueAuthorizationDoc).isNotNull();
     assertThat(issueAuthorizationDoc.project()).isEqualTo("ABCD");
-    assertThat(issueAuthorizationDoc.permission()).isEqualTo("user");
     assertThat(issueAuthorizationDoc.groups()).containsExactly("devs");
     assertThat(issueAuthorizationDoc.users()).containsExactly("john");
     assertThat(issueAuthorizationDoc.updatedAt()).isNotNull();
@@ -146,7 +145,6 @@ public class IssueAuthorizationIndexMediumTest {
     IssueAuthorizationDoc issueAuthorizationDoc = index.getByKey(project.uuid());
     assertThat(issueAuthorizationDoc).isNotNull();
     assertThat(issueAuthorizationDoc.project()).isEqualTo("ABCD");
-    assertThat(issueAuthorizationDoc.permission()).isEqualTo("user");
     assertThat(issueAuthorizationDoc.groups()).containsExactly("devs");
     assertThat(issueAuthorizationDoc.users()).containsExactly("john");
     assertThat(issueAuthorizationDoc.updatedAt()).isNotNull();
index ed2c949691102ee16fd98150f15914f75e4b72a5..34c4e622d917e743a40d159660ff61a4c2b156ad 100644 (file)
@@ -97,7 +97,6 @@ public class InternalPermissionServiceMediumTest {
     IssueAuthorizationDoc issueAuthorizationDoc = index.getNullableByKey(project.uuid());
     assertThat(issueAuthorizationDoc).isNotNull();
     assertThat(issueAuthorizationDoc.project()).isEqualTo(project.uuid());
-    assertThat(issueAuthorizationDoc.permission()).isEqualTo(UserRole.USER);
     assertThat(issueAuthorizationDoc.users()).containsExactly(user.getLogin());
     assertThat(issueAuthorizationDoc.groups()).isEmpty();
   }
@@ -126,7 +125,6 @@ public class InternalPermissionServiceMediumTest {
     IssueAuthorizationDoc issueAuthorizationDoc = index.getNullableByKey(project.uuid());
     assertThat(issueAuthorizationDoc).isNotNull();
     assertThat(issueAuthorizationDoc.project()).isEqualTo(project.uuid());
-    assertThat(issueAuthorizationDoc.permission()).isEqualTo(UserRole.USER);
     assertThat(issueAuthorizationDoc.users()).containsExactly(user2.getLogin());
     assertThat(issueAuthorizationDoc.groups()).isEmpty();
   }
index 97d3a3bb413b99643fbed87f7906d69f20d413c8..eaed351cad7fa126fe6aa90b3cde869adfc5c7a8 100644 (file)
@@ -48,15 +48,6 @@ public final class IssueAuthorizationDto extends Dto<String> implements Serializ
     return this;
   }
 
-  public String getPermission() {
-    return permission;
-  }
-
-  public IssueAuthorizationDto setPermission(String permission) {
-    this.permission = permission;
-    return this;
-  }
-
   public List<String> getGroups() {
     return groups;
   }
index 22b7e4943a8210f6247f2aac0dca919c7d717b2f..9c83be95ca716ae8077cb3dc13d56a43c0fe6748 100644 (file)
@@ -31,13 +31,11 @@ public class IssueAuthorizationDtoTest {
   public void getter_and_setter() throws Exception {
     IssueAuthorizationDto dto = new IssueAuthorizationDto()
       .setProjectUuid("Sample")
-      .setPermission("user")
       .setGroups(newArrayList("sonar-users"))
       .setUsers(newArrayList("john"));
 
     assertThat(dto.getKey()).isEqualTo("Sample");
     assertThat(dto.getProjectUuid()).isEqualTo("Sample");
-    assertThat(dto.getPermission()).isEqualTo("user");
     assertThat(dto.getGroups()).containsExactly("sonar-users");
     assertThat(dto.getUsers()).containsExactly("john");
   }
@@ -46,7 +44,6 @@ public class IssueAuthorizationDtoTest {
   public void add_group() throws Exception {
     IssueAuthorizationDto dto = new IssueAuthorizationDto()
       .setProjectUuid("Sample")
-      .setPermission("user")
       .setGroups(newArrayList("sonar-users"))
       .setUsers(newArrayList("john"));
 
@@ -61,7 +58,6 @@ public class IssueAuthorizationDtoTest {
   public void add_user() throws Exception {
     IssueAuthorizationDto dto = new IssueAuthorizationDto()
       .setProjectUuid("Sample")
-      .setPermission("user")
       .setGroups(newArrayList("sonar-users"))
       .setUsers(newArrayList("john"));