]> source.dussan.org Git - sonarqube.git/commitdiff
Rename index type issueAuthorization to authorization
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 1 Dec 2014 12:21:16 +0000 (13:21 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 1 Dec 2014 12:21:24 +0000 (13:21 +0100)
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueAuthorizationIndexer.java
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java
server/sonar-server/src/main/java/org/sonar/server/search/IndexDefinition.java
server/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueAuthorizationIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDefinitionTest.java

index 2003e0889457b42af1388bf0bcd5ace3bb27832a..2121a661182d5e6e977d91b4007c3e5d001244e3 100644 (file)
@@ -37,7 +37,7 @@ import java.util.Date;
 import java.util.Map;
 
 /**
- * Manages the synchronization of index issues/issueAuthorization with authorization settings defined in database :
+ * Manages the synchronization of index issues/authorization with authorization settings defined in database :
  * <ul>
  *   <li>index the projects with recent permission changes</li>
  *   <li>delete project orphans from index</li>
index c78d2706ce229f939109937f0457b1441b05a308..e620fdab286ddb58da05e8e1b5d30309e6d8d28d 100644 (file)
@@ -34,7 +34,7 @@ public class IssueIndexDefinition implements IndexDefinition {
 
   public static final String INDEX = "issues";
 
-  public static final String TYPE_AUTHORIZATION = "issueAuthorization";
+  public static final String TYPE_AUTHORIZATION = "authorization";
   public static final String TYPE_ISSUE = "issue";
 
   public static final String FIELD_AUTHORIZATION_PROJECT_UUID = "project";
@@ -87,7 +87,7 @@ public class IssueIndexDefinition implements IndexDefinition {
       // else keep defaults (one shard)
     }
 
-    // type "issueAuthorization"
+    // type "authorization"
     NewIndex.NewIndexType authorizationMapping = index.createType(TYPE_AUTHORIZATION);
     authorizationMapping.setAttribute("_id", ImmutableMap.of("path", FIELD_AUTHORIZATION_PROJECT_UUID));
     authorizationMapping.createDateTimeField(FIELD_AUTHORIZATION_UPDATED_AT);
index 04d112d99bc36ec588b48ad6834656ffa77b3522..493635b55311fa7607a29d9ab66bf479601bed75 100644 (file)
@@ -100,7 +100,7 @@ public class IssueIndexer extends BaseIndexer {
   private UpdateRequest newUpsertRequest(IssueDoc issue) {
     String projectUuid = issue.projectUuid();
 
-    // parent doc is issueAuthorization
+    // type of parent doc is "authorization"
     issue.setField("_parent", projectUuid);
 
     return new UpdateRequest(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE, issue.key())
index 5947bfb33eb91a51e9654830ff0be733376e3455..fc9b36ebe17e730ba8bb664459d2501240cd8f4c 100644 (file)
@@ -39,7 +39,6 @@ public class IndexDefinition {
 
   public static final IndexDefinition RULE = new IndexDefinition("rules", "rule");
   public static final IndexDefinition ACTIVE_RULE = new IndexDefinition("rules", "activeRule");
-  public static final IndexDefinition ISSUES_AUTHORIZATION = new IndexDefinition("issues", "issueAuthorization");
   public static final IndexDefinition ISSUES = new IndexDefinition("issues", "issue");
   public static final IndexDefinition LOG = new IndexDefinition("logs", "sonarLog");
 
index a3457b7e1d9a870a5ac13babe6bf28cd8f46e16f..cbeb9db3bd126ce568d072b633f83ea9026abed9 100644 (file)
@@ -61,8 +61,6 @@ public class IndexSynchronizer {
     /* synchronize all activeRules until we have mng tables in INDEX */
     DbSession session = db.openSession(true);
     try {
-      LOG.info("Starting DB to Index synchronization");
-      long start = System.currentTimeMillis();
       List<String> projectUuids = db.componentDao().findProjectUuids(session);
       synchronize(session, db.ruleDao(), index.get(RuleIndex.class));
       issueAuthorizationIndexer.index();
@@ -75,7 +73,6 @@ public class IndexSynchronizer {
       sourceLineIndexer.index();
 
       session.commit();
-      LOG.info("Synchronization done in {}ms...", System.currentTimeMillis() - start);
     } finally {
       session.close();
     }
index a0ea5860886fd088de31071177f5be6c21ae1a6a..bc7bbb49174803c70912c7ab2558e66afdf86f5f 100644 (file)
@@ -46,7 +46,7 @@ public class IssueAuthorizationIndexerTest {
     IssueAuthorizationIndexer indexer = createIndexer();
     indexer.doIndex(0L);
 
-    assertThat(esTester.countDocuments("issues", "issueAuthorization")).isZero();
+    assertThat(esTester.countDocuments("issues", "authorization")).isZero();
   }
 
   @Test
@@ -56,7 +56,7 @@ public class IssueAuthorizationIndexerTest {
     IssueAuthorizationIndexer indexer = createIndexer();
     indexer.doIndex(0L);
 
-    List<SearchHit> docs = esTester.getDocuments("issues", "issueAuthorization");
+    List<SearchHit> docs = esTester.getDocuments("issues", "authorization");
     assertThat(docs).hasSize(1);
     SearchHit doc = docs.get(0);
     assertThat(doc.getSource().get("project")).isEqualTo("ABC");
@@ -73,7 +73,7 @@ public class IssueAuthorizationIndexerTest {
   public void do_not_fail_when_deleting_unindexed_project() throws Exception {
     IssueAuthorizationIndexer indexer = createIndexer();
     indexer.deleteProject("UNKNOWN", true);
-    assertThat(esTester.countDocuments("issues", "issueAuthorization")).isZero();
+    assertThat(esTester.countDocuments("issues", "authorization")).isZero();
   }
 
   @Test
@@ -85,13 +85,13 @@ public class IssueAuthorizationIndexerTest {
     indexer.index(Arrays.asList(authorization));
 
     // has permissions
-    assertThat(esTester.countDocuments("issues", "issueAuthorization")).isEqualTo(1);
+    assertThat(esTester.countDocuments("issues", "authorization")).isEqualTo(1);
 
     // remove permissions -> dto has no users nor groups
     authorization = new IssueAuthorizationDao.Dto("ABC", System.currentTimeMillis());
     indexer.index(Arrays.asList(authorization));
 
-    assertThat(esTester.countDocuments("issues", "issueAuthorization")).isZero();
+    assertThat(esTester.countDocuments("issues", "authorization")).isZero();
   }
 
   private IssueAuthorizationIndexer createIndexer() {
index ca25778fca5d740a4a4e631c0e8c57c0efdc6b46..241479d5751844fc52afe306b1253704de7cd921 100644 (file)
@@ -39,7 +39,7 @@ public class IssueIndexDefinitionTest {
     assertThat(context.getIndices()).hasSize(1);
     NewIndex issuesIndex = context.getIndices().get("issues");
     assertThat(issuesIndex).isNotNull();
-    assertThat(issuesIndex.getTypes().keySet()).containsOnly("issue", "issueAuthorization");
+    assertThat(issuesIndex.getTypes().keySet()).containsOnly("issue", "authorization");
 
     // no cluster by default
     assertThat(issuesIndex.getSettings().get("index.number_of_shards")).isEqualTo("1");