]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-926 Language is null in projects table for project/module resources
authorJulien HENRY <julien.henry@sonarsource.com>
Mon, 10 Feb 2014 16:41:48 +0000 (17:41 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Mon, 10 Feb 2014 17:14:59 +0000 (18:14 +0100)
sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java
sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java
sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml
sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveCopyProject-result.xml
sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewDirectory-result.xml
sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewLibrary-result.xml
sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewMultiModulesProject-result.xml
sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewProject-result.xml
sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource-result.xml

index 3397d3a05d8dbc15e4c62a578205ce569238dd17..c658f4bc34f0b32a7c3ac45c3f5227b52cfd2759 100644 (file)
@@ -89,8 +89,8 @@ public final class DefaultResourcePersister implements ResourcePersister {
     ResourceModel model = findOrCreateModel(project);
     // Used by ResourceKeyMigration in order to know that a project has already being migrated
     model.setDeprecatedKey(project.getKey());
-    // ugly, only for projects
-    model.setLanguageKey(project.getLanguageKey());
+    // language is null for project since multi-language support
+    model.setLanguageKey(null);
 
     // For views
     if (project instanceof ResourceCopy) {
index a06718189215cb52287e8e8e928afad6d54684de..8070a0a0574be291b56f4b23f2cdbb775b4e92f7 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.batch.scan.filesystem;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.CharMatcher;
 import com.google.common.io.Files;
-import org.apache.commons.lang.StringUtils;
 import org.sonar.api.BatchComponent;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.SonarIndex;
@@ -40,7 +39,6 @@ import org.sonar.api.utils.SonarException;
 import org.sonar.batch.index.ResourceKeyMigration;
 import org.sonar.batch.scan.language.DefaultModuleLanguages;
 import org.sonar.core.resource.ResourceDao;
-import org.sonar.core.resource.ResourceDto;
 
 /**
  * Index all files/directories of the module in SQ database and importing source code.
@@ -92,8 +90,6 @@ public class ComponentIndexer implements BatchComponent {
         importSources(shouldImportSource, inputFile, sonarFile);
       }
     }
-
-    updateModuleLanguage();
   }
 
   @VisibleForTesting
@@ -116,18 +112,4 @@ public class ComponentIndexer implements BatchComponent {
         + inputFile.encoding() + "'.", e);
     }
   }
-
-  private void updateModuleLanguage() {
-    if (module.getId() != null) {
-      ResourceDto dto = resourceDao.getResource(module.getId());
-      if (moduleLanguages.keys().size() == 1) {
-        dto.setLanguage(moduleLanguages.keys().iterator().next());
-      } else if (moduleLanguages.keys().size() > 1) {
-        dto.setLanguage(StringUtils.join(moduleLanguages.keys(), ","));
-      } else {
-        dto.setLanguage(Project.NONE_LANGUAGE.getKey());
-      }
-      resourceDao.insertOrUpdate(dto);
-    }
-  }
 }
index daadbb905fdba8919a368060096bdbdc70064a8b..da49a60a9c0b66d821f635be9067a350ccf7b4e7 100644 (file)
@@ -2,7 +2,7 @@
 
   <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]"
             name="Foo" long_name="Foo" description="some description"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" path="[null]" deprecated_kee="foo"/>
+            enabled="true" language="[null]" copy_resource_id="[null]" person_id="[null]" created_at="[null]" path="[null]" deprecated_kee="foo"/>
 
   <!-- old snapshot -->
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]"
index 4726d31facb329b03fc2f7a15ea0cfd6330d5457..5c189e74b5b0b751f8ed08c9836fb6e93d9e70f6 100644 (file)
@@ -13,7 +13,7 @@
   <!-- new project -->
   <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]"
             name="Foo" long_name="Foo" description="some description"
-            enabled="true" language="java" copy_resource_id="10" person_id="[null]" path="[null]" deprecated_kee="foo" />
+            enabled="true" language="[null]" copy_resource_id="10" person_id="[null]" path="[null]" deprecated_kee="foo" />
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]"
              scope="PRJ" qualifier="TRK" created_at="2010-12-25 00:00:00.00" build_date="2010-12-25 00:00:00.00" version="[null]" path=""
index 6ca27edcd8b79bb1fcdfc49b36f3e317fc78e7c7..7b980eb2172951571c8f0ad419109ed295ff01e5 100644 (file)
@@ -13,7 +13,7 @@
   <!-- new project -->
   <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]"
             name="Foo" long_name="Foo" description="some description"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="foo" />
+            enabled="true" language="[null]" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="foo" />
 
   <projects id="1002" scope="DIR" qualifier="DIR" kee="foo:src/main/java/org/foo" root_id="1001"
             name="src/main/java/org/foo" long_name="src/main/java/org/foo" description="[null]"
index a7107a2871abe168033e5cc3d7151dca5db53c95..c4369abd323f518fe738a63557a40a24d56216c1 100644 (file)
@@ -13,7 +13,7 @@
   <!-- new project -->
   <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]"
             name="Foo" long_name="Foo" description="some description"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="foo" />
+            enabled="true" language="[null]" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="foo" />
 
   <projects id="1002" scope="PRJ" qualifier="LIB" kee="junit:junit" root_id="[null]"
             name="junit:junit" long_name="junit:junit" description="[null]"
index e34281fcddbf809731d26e0671a6351bb1271158..d9942872de37f47b623599e22d9957c3b46dac03 100644 (file)
   <!-- new project -->
   <projects id="1001" scope="PRJ" qualifier="TRK" kee="root" root_id="[null]"
             name="Root" long_name="Root" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="root" />
+            enabled="true" language="[null]" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="root" />
 
   <projects id="1002" scope="PRJ" qualifier="BRC" kee="a" root_id="1001"
             name="A" long_name="A" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="moduleA" deprecated_kee="a" />
+            enabled="true" language="[null]" copy_resource_id="[null]" person_id="[null]" path="moduleA" deprecated_kee="a" />
 
   <projects id="1003" scope="PRJ" qualifier="BRC" kee="b" root_id="1001"
             name="B" long_name="B" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="moduleB" deprecated_kee="b" />
+            enabled="true" language="[null]" copy_resource_id="[null]" person_id="[null]" path="moduleB" deprecated_kee="b" />
 
   <projects id="1004" scope="PRJ" qualifier="BRC" kee="b1" root_id="1001"
             name="B1" long_name="B1" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="moduleB1" deprecated_kee="b1" />
+            enabled="true" language="[null]" copy_resource_id="[null]" person_id="[null]" path="moduleB1" deprecated_kee="b1" />
 
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" root_project_id="1001" parent_snapshot_id="[null]"  root_snapshot_id="[null]"
index 419ed6a62787e9acd57aeb19adcc90dcaefd4c31..96172586b316720ac9accdfc8b8d9418254e90ad 100644 (file)
@@ -13,7 +13,7 @@
   <!-- new project -->
   <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]"
             name="Foo" long_name="Foo" description="some description"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="foo" />
+            enabled="true" language="[null]" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="foo" />
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]"
              scope="PRJ" qualifier="TRK" created_at="2010-12-25 00:00:00.00" build_date="2010-12-25 00:00:00.00" version="[null]" path=""
index 40b55dbf641ef019c4cbda2e7b82b70048c05724..3a4933e0629a604cde776427107f324b885170aa 100644 (file)
@@ -2,7 +2,7 @@
 
   <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]"
             name="new name" long_name="new name" description="new description"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="foo" />
+            enabled="true" language="[null]" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="foo" />
 
   <!-- old snapshot -->
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]"