]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1556: When a language is specified with the 'sonar.language' property but not...
authorGodin <mandrikov@gmail.com>
Tue, 23 Nov 2010 21:48:08 +0000 (21:48 +0000)
committerGodin <mandrikov@gmail.com>
Tue, 23 Nov 2010 21:48:08 +0000 (21:48 +0000)
sonar-batch/src/main/java/org/sonar/batch/ProjectBatch.java
sonar-plugin-api/src/main/java/org/sonar/api/resources/Languages.java

index d47ed8d69396031bc683cb80253c3d66d2fdb8ee..cee58be0c82dae883b8183de619552863936810d 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.batch;
 
+import java.util.List;
+
 import org.picocontainer.Characteristics;
 import org.picocontainer.MutablePicoContainer;
 import org.sonar.api.batch.BatchExtensionDictionnary;
@@ -30,16 +32,21 @@ import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.measures.Metric;
 import org.sonar.api.measures.Metrics;
 import org.sonar.api.resources.DefaultProjectFileSystem;
+import org.sonar.api.resources.Language;
 import org.sonar.api.resources.Languages;
 import org.sonar.api.resources.Project;
 import org.sonar.api.rules.DefaultRulesManager;
 import org.sonar.api.utils.IocContainer;
+import org.sonar.api.utils.SonarException;
 import org.sonar.batch.indexer.DefaultSonarIndex;
 import org.sonar.core.qualitymodel.DefaultModelFinder;
 import org.sonar.core.rule.DefaultRuleFinder;
-import org.sonar.jpa.dao.*;
-
-import java.util.List;
+import org.sonar.jpa.dao.AsyncMeasuresDao;
+import org.sonar.jpa.dao.AsyncMeasuresService;
+import org.sonar.jpa.dao.DaoFacade;
+import org.sonar.jpa.dao.MeasuresDao;
+import org.sonar.jpa.dao.ProfilesDao;
+import org.sonar.jpa.dao.RulesDao;
 
 public class ProjectBatch {
 
@@ -75,7 +82,7 @@ public class ProjectBatch {
     batchContainer.as(Characteristics.CACHE).addComponent(index.getBucket(project).getSnapshot());
     batchContainer.as(Characteristics.CACHE).addComponent(project.getConfiguration());
 
-    //need to be registered after the Configuration
+    // need to be registered after the Configuration
     batchContainer.getComponent(BatchPluginRepository.class).registerPlugins(batchContainer);
 
     batchContainer.as(Characteristics.CACHE).addComponent(DaoFacade.class);
@@ -107,11 +114,16 @@ public class ProjectBatch {
   }
 
   private void prepareProject(Project project, DefaultSonarIndex index) {
-    project.setLanguage(getComponent(Languages.class).get(project.getLanguageKey()));
-    index.selectProject(project, getComponent(ResourceFilters.class), getComponent(ViolationFilters.class), getComponent(MeasuresDao.class), getComponent(ViolationsDao.class));
+    Language language = getComponent(Languages.class).get(project.getLanguageKey());
+    if (language == null) {
+      throw new SonarException("Language with key '" + project.getLanguageKey() + "' not found");
+    }
+    project.setLanguage(language);
+    index.selectProject(project, getComponent(ResourceFilters.class), getComponent(ViolationFilters.class),
+        getComponent(MeasuresDao.class), getComponent(ViolationsDao.class));
 
     List<FileFilter> fileFilters = batchContainer.getComponents(FileFilter.class);
-    ((DefaultProjectFileSystem)project.getFileSystem()).addFileFilters(fileFilters);
+    ((DefaultProjectFileSystem) project.getFileSystem()).addFileFilters(fileFilters);
   }
 
   private void loadCoreComponents(MutablePicoContainer container) {
index 372100fe4ae4edc24a5f87cc46f50bdc2e43c253..9908252d11ea6314d4cebfd997403d6df6e1c4c3 100644 (file)
  */
 package org.sonar.api.resources;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.commons.lang.ArrayUtils;
 import org.sonar.api.BatchComponent;
 import org.sonar.api.ServerComponent;
 
-import java.util.*;
-
 /**
  * A class to store the list of languages
- *
+ * 
  * @since 1.10
  */
 public class Languages implements BatchComponent, ServerComponent {
@@ -47,9 +51,8 @@ public class Languages implements BatchComponent, ServerComponent {
 
   /**
    * @param keys the languages keys
-   * @return * @return the list of suffix files associates to languages included in the current object
+   * @return the list of suffix files associates to languages included in the current object
    */
-
   public String[] getSuffixes(String... keys) {
     List<String> suffixes = new ArrayList<String>();