]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6038 Rename XXXReferentials server classes by XXXRepository
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 13 Jan 2015 15:59:17 +0000 (16:59 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 13 Jan 2015 16:00:23 +0000 (17:00 +0100)
26 files changed:
server/sonar-server/src/main/java/org/sonar/server/batch/BatchWs.java
server/sonar-server/src/main/java/org/sonar/server/batch/GlobalReferentialsAction.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/batch/GlobalRepositoryAction.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsAction.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsLoader.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsQuery.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/batch/ProjectRepositoryAction.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/batch/ProjectRepositoryLoader.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/batch/ProjectRepositoryQuery.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsTest.java
server/sonar-server/src/test/java/org/sonar/server/batch/GlobalReferentialsActionTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/batch/GlobalRepositoryActionTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsLoaderMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/batch/ProjectRepositoryActionTest.java [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalReferentialsActionTest/return_global_referentials.json [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalReferentialsActionTest/return_global_settings.json [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalReferentialsActionTest/return_no_secured_settings_without_scan_and_preview_permission.json [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalReferentialsActionTest/return_only_license_settings_without_scan_but_with_preview_permission.json [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalRepositoryActionTest/return_global_referentials.json [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalRepositoryActionTest/return_global_settings.json [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalRepositoryActionTest/return_no_secured_settings_without_scan_and_preview_permission.json [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalRepositoryActionTest/return_only_license_settings_without_scan_but_with_preview_permission.json [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/project_referentials.json [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectRepositoryActionTest/project_referentials.json [new file with mode: 0644]

index ae4d87cebf3c4b8a8e873de727ad48648d9c0338..defb80f84d1e1d2a7d8b00a8c2c82255de6a719f 100644 (file)
@@ -33,13 +33,13 @@ public class BatchWs implements WebService {
   public static final String API_ENDPOINT = "batch";
 
   private final BatchIndex batchIndex;
-  private final GlobalReferentialsAction globalReferentialsAction;
-  private final ProjectReferentialsAction projectReferentialsAction;
+  private final GlobalRepositoryAction globalRepositoryAction;
+  private final ProjectRepositoryAction projectRepositoryAction;
 
-  public BatchWs(BatchIndex batchIndex, GlobalReferentialsAction globalReferentialsAction, ProjectReferentialsAction projectReferentialsAction) {
+  public BatchWs(BatchIndex batchIndex, GlobalRepositoryAction globalRepositoryAction, ProjectRepositoryAction projectRepositoryAction) {
     this.batchIndex = batchIndex;
-    this.globalReferentialsAction = globalReferentialsAction;
-    this.projectReferentialsAction = projectReferentialsAction;
+    this.globalRepositoryAction = globalRepositoryAction;
+    this.projectRepositoryAction = projectRepositoryAction;
   }
 
   @Override
@@ -50,8 +50,8 @@ public class BatchWs implements WebService {
 
     defineIndexAction(controller);
     defineFileAction(controller);
-    globalReferentialsAction.define(controller);
-    projectReferentialsAction.define(controller);
+    globalRepositoryAction.define(controller);
+    projectRepositoryAction.define(controller);
 
     controller.done();
   }
diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/GlobalReferentialsAction.java b/server/sonar-server/src/main/java/org/sonar/server/batch/GlobalReferentialsAction.java
deleted file mode 100644 (file)
index 03251c8..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.batch;
-
-import org.apache.commons.io.IOUtils;
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.RequestHandler;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.batch.protocol.input.GlobalReferentials;
-import org.sonar.core.measure.db.MetricDto;
-import org.sonar.core.permission.GlobalPermissions;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.properties.PropertiesDao;
-import org.sonar.core.properties.PropertyDto;
-import org.sonar.server.db.DbClient;
-import org.sonar.server.plugins.MimeTypes;
-import org.sonar.server.user.UserSession;
-
-public class GlobalReferentialsAction implements RequestHandler {
-
-  private final DbClient dbClient;
-  private final PropertiesDao propertiesDao;
-
-  public GlobalReferentialsAction(DbClient dbClient, PropertiesDao propertiesDao) {
-    this.dbClient = dbClient;
-    this.propertiesDao = propertiesDao;
-  }
-
-  void define(WebService.NewController controller) {
-    controller.createAction("global")
-      .setDescription("Return metrics and global properties")
-      .setSince("4.5")
-      .setInternal(true)
-      .setHandler(this);
-  }
-
-  @Override
-  public void handle(Request request, Response response) throws Exception {
-    UserSession userSession = UserSession.get();
-    boolean hasScanPerm = userSession.hasGlobalPermission(GlobalPermissions.SCAN_EXECUTION);
-    boolean hasDryRunPerm = userSession.hasGlobalPermission(GlobalPermissions.DRY_RUN_EXECUTION);
-
-    DbSession session = dbClient.openSession(false);
-    try {
-      GlobalReferentials ref = new GlobalReferentials();
-      addMetrics(ref, session);
-      addSettings(ref, hasScanPerm, hasDryRunPerm, session);
-
-      response.stream().setMediaType(MimeTypes.JSON);
-      IOUtils.write(ref.toJson(), response.stream().output());
-    } finally {
-      MyBatis.closeQuietly(session);
-    }
-  }
-
-  private void addMetrics(GlobalReferentials ref, DbSession session) {
-    for (MetricDto metric : dbClient.metricDao().findEnabled(session)) {
-      Boolean optimizedBestValue = metric.isOptimizedBestValue();
-      ref.addMetric(
-        new org.sonar.batch.protocol.input.Metric(metric.getId(), metric.getKey(),
-          metric.getValueType(),
-          metric.getDescription(),
-          metric.getDirection(),
-          metric.getName(),
-          metric.isQualitative(),
-          metric.isUserManaged(),
-          metric.getWorstValue(),
-          metric.getBestValue(),
-          optimizedBestValue != null ? optimizedBestValue : false));
-    }
-  }
-
-  private void addSettings(GlobalReferentials ref, boolean hasScanPerm, boolean hasDryRunPerm, DbSession session) {
-    for (PropertyDto propertyDto : propertiesDao.selectGlobalProperties(session)) {
-      String key = propertyDto.getKey();
-      String value = propertyDto.getValue();
-
-      if (isPropertyAllowed(key, hasScanPerm, hasDryRunPerm)) {
-        ref.addGlobalSetting(key, value);
-      }
-    }
-  }
-
-  private static boolean isPropertyAllowed(String key, boolean hasScanPerm, boolean hasDryRunPerm) {
-    return !key.contains(".secured") || hasScanPerm || (key.contains(".license") && hasDryRunPerm);
-  }
-
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/GlobalRepositoryAction.java b/server/sonar-server/src/main/java/org/sonar/server/batch/GlobalRepositoryAction.java
new file mode 100644 (file)
index 0000000..59451e4
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.batch;
+
+import org.apache.commons.io.IOUtils;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.RequestHandler;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.batch.protocol.input.GlobalReferentials;
+import org.sonar.core.measure.db.MetricDto;
+import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.core.persistence.MyBatis;
+import org.sonar.core.properties.PropertiesDao;
+import org.sonar.core.properties.PropertyDto;
+import org.sonar.server.db.DbClient;
+import org.sonar.server.plugins.MimeTypes;
+import org.sonar.server.user.UserSession;
+
+public class GlobalRepositoryAction implements RequestHandler {
+
+  private final DbClient dbClient;
+  private final PropertiesDao propertiesDao;
+
+  public GlobalRepositoryAction(DbClient dbClient, PropertiesDao propertiesDao) {
+    this.dbClient = dbClient;
+    this.propertiesDao = propertiesDao;
+  }
+
+  void define(WebService.NewController controller) {
+    controller.createAction("global")
+      .setDescription("Return metrics and global properties")
+      .setSince("4.5")
+      .setInternal(true)
+      .setHandler(this);
+  }
+
+  @Override
+  public void handle(Request request, Response response) throws Exception {
+    UserSession userSession = UserSession.get();
+    boolean hasScanPerm = userSession.hasGlobalPermission(GlobalPermissions.SCAN_EXECUTION);
+    boolean hasDryRunPerm = userSession.hasGlobalPermission(GlobalPermissions.DRY_RUN_EXECUTION);
+
+    DbSession session = dbClient.openSession(false);
+    try {
+      GlobalReferentials ref = new GlobalReferentials();
+      addMetrics(ref, session);
+      addSettings(ref, hasScanPerm, hasDryRunPerm, session);
+
+      response.stream().setMediaType(MimeTypes.JSON);
+      IOUtils.write(ref.toJson(), response.stream().output());
+    } finally {
+      MyBatis.closeQuietly(session);
+    }
+  }
+
+  private void addMetrics(GlobalReferentials ref, DbSession session) {
+    for (MetricDto metric : dbClient.metricDao().findEnabled(session)) {
+      Boolean optimizedBestValue = metric.isOptimizedBestValue();
+      ref.addMetric(
+        new org.sonar.batch.protocol.input.Metric(metric.getId(), metric.getKey(),
+          metric.getValueType(),
+          metric.getDescription(),
+          metric.getDirection(),
+          metric.getName(),
+          metric.isQualitative(),
+          metric.isUserManaged(),
+          metric.getWorstValue(),
+          metric.getBestValue(),
+          optimizedBestValue != null ? optimizedBestValue : false));
+    }
+  }
+
+  private void addSettings(GlobalReferentials ref, boolean hasScanPerm, boolean hasDryRunPerm, DbSession session) {
+    for (PropertyDto propertyDto : propertiesDao.selectGlobalProperties(session)) {
+      String key = propertyDto.getKey();
+      String value = propertyDto.getValue();
+
+      if (isPropertyAllowed(key, hasScanPerm, hasDryRunPerm)) {
+        ref.addGlobalSetting(key, value);
+      }
+    }
+  }
+
+  private static boolean isPropertyAllowed(String key, boolean hasScanPerm, boolean hasDryRunPerm) {
+    return !key.contains(".secured") || hasScanPerm || (key.contains(".license") && hasDryRunPerm);
+  }
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsAction.java b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsAction.java
deleted file mode 100644 (file)
index 34a51d7..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.batch;
-
-import org.apache.commons.io.IOUtils;
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.RequestHandler;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.batch.protocol.input.ProjectReferentials;
-import org.sonar.server.plugins.MimeTypes;
-
-public class ProjectReferentialsAction implements RequestHandler {
-
-  private static final String PARAM_KEY = "key";
-  private static final String PARAM_PROFILE = "profile";
-  private static final String PARAM_PREVIEW = "preview";
-
-  private final ProjectReferentialsLoader projectReferentialsLoader;
-
-  public ProjectReferentialsAction(ProjectReferentialsLoader projectReferentialsLoader) {
-    this.projectReferentialsLoader = projectReferentialsLoader;
-  }
-
-  void define(WebService.NewController controller) {
-    WebService.NewAction action = controller.createAction("project")
-      .setDescription("Return project referentials")
-      .setSince("4.5")
-      .setInternal(true)
-      .setHandler(this);
-
-    action
-      .createParam(PARAM_KEY)
-      .setRequired(true)
-      .setDescription("Project or module key")
-      .setExampleValue("org.codehaus.sonar:sonar");
-
-    action
-      .createParam(PARAM_PROFILE)
-      .setDescription("Profile name")
-      .setExampleValue("SonarQube Way");
-
-    action
-      .createParam(PARAM_PREVIEW)
-      .setDescription("Preview mode or not")
-      .setDefaultValue(false)
-      .setBooleanPossibleValues();
-  }
-
-  @Override
-  public void handle(Request request, Response response) throws Exception {
-    ProjectReferentials ref = projectReferentialsLoader.load(ProjectReferentialsQuery.create()
-      .setModuleKey(request.mandatoryParam(PARAM_KEY))
-      .setProfileName(request.param(PARAM_PROFILE))
-      .setPreview(request.mandatoryParamAsBoolean(PARAM_PREVIEW)));
-    response.stream().setMediaType(MimeTypes.JSON);
-    IOUtils.write(ref.toJson(), response.stream().output());
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsLoader.java b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsLoader.java
deleted file mode 100644 (file)
index 4579670..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.batch;
-
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Multimap;
-import org.sonar.api.ServerComponent;
-import org.sonar.api.resources.Language;
-import org.sonar.api.resources.Languages;
-import org.sonar.batch.protocol.input.ProjectReferentials;
-import org.sonar.core.UtcDateUtils;
-import org.sonar.core.component.ComponentDto;
-import org.sonar.core.permission.GlobalPermissions;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.properties.PropertyDto;
-import org.sonar.core.qualityprofile.db.QualityProfileDto;
-import org.sonar.server.db.DbClient;
-import org.sonar.server.exceptions.ForbiddenException;
-import org.sonar.server.qualityprofile.ActiveRule;
-import org.sonar.server.qualityprofile.QProfileFactory;
-import org.sonar.server.qualityprofile.QProfileLoader;
-import org.sonar.server.rule.Rule;
-import org.sonar.server.rule.RuleService;
-import org.sonar.server.user.UserSession;
-
-import javax.annotation.Nullable;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static com.google.common.collect.Maps.newHashMap;
-
-public class ProjectReferentialsLoader implements ServerComponent {
-
-  private final DbClient dbClient;
-  private final QProfileFactory qProfileFactory;
-  private final QProfileLoader qProfileLoader;
-  private final RuleService ruleService;
-  private final Languages languages;
-
-  public ProjectReferentialsLoader(DbClient dbClient, QProfileFactory qProfileFactory, QProfileLoader qProfileLoader, RuleService ruleService,
-                                   Languages languages) {
-    this.dbClient = dbClient;
-    this.qProfileFactory = qProfileFactory;
-    this.qProfileLoader = qProfileLoader;
-    this.ruleService = ruleService;
-    this.languages = languages;
-  }
-
-  public ProjectReferentials load(ProjectReferentialsQuery query) {
-    boolean hasScanPerm = UserSession.get().hasGlobalPermission(GlobalPermissions.SCAN_EXECUTION);
-    checkPermission(query.isPreview());
-
-    DbSession session = dbClient.openSession(false);
-    try {
-      ProjectReferentials ref = new ProjectReferentials();
-      String projectKey = query.getModuleKey();
-      ComponentDto module = dbClient.componentDao().getNullableByKey(session, query.getModuleKey());
-      // Current project/module can be null when analysing a new project
-      if (module != null) {
-        ComponentDto project = dbClient.componentDao().getNullableRootProjectByKey(query.getModuleKey(), session);
-
-        // Can be null if the given project is a provisioned one
-        if (project != null) {
-          if (!project.key().equals(module.key())) {
-            addSettings(ref, module.getKey(), getSettingsFromParents(module.key(), hasScanPerm, session));
-            projectKey = project.key();
-          }
-
-          List<PropertyDto> moduleSettings = dbClient.propertiesDao().selectProjectProperties(query.getModuleKey(), session);
-          List<ComponentDto> moduleChildren = dbClient.componentDao().findChildrenModulesFromModule(session, query.getModuleKey());
-          List<PropertyDto> moduleChildrenSettings = newArrayList();
-          if (!moduleChildren.isEmpty()) {
-            moduleChildrenSettings = dbClient.propertiesDao().findChildrenModuleProperties(query.getModuleKey(), session);
-          }
-          TreeModuleSettings treeModuleSettings = new TreeModuleSettings(moduleChildren, moduleChildrenSettings, module, moduleSettings);
-
-          addSettingsToChildrenModules(ref, query.getModuleKey(), Maps.<String, String>newHashMap(), treeModuleSettings, hasScanPerm, session);
-        } else {
-          // Add settings of the provisioned project
-          addSettings(ref, query.getModuleKey(), getPropertiesMap(dbClient.propertiesDao().selectProjectProperties(query.getModuleKey(), session), hasScanPerm));
-        }
-      }
-
-      addProfiles(ref, projectKey, query.getProfileName(), session);
-      addActiveRules(ref);
-      return ref;
-    } finally {
-      MyBatis.closeQuietly(session);
-    }
-  }
-
-  private Map<String, String> getSettingsFromParents(String moduleKey, boolean hasScanPerm, DbSession session) {
-    List<ComponentDto> parents = newArrayList();
-    aggregateParentModules(moduleKey, parents, session);
-    Collections.reverse(parents);
-
-    Map<String, String> parentProperties = newHashMap();
-    for (ComponentDto parent : parents) {
-      parentProperties.putAll(getPropertiesMap(dbClient.propertiesDao().selectProjectProperties(parent.key(), session), hasScanPerm));
-    }
-    return parentProperties;
-  }
-
-  private void aggregateParentModules(String component, List<ComponentDto> parents, DbSession session) {
-    ComponentDto parent = dbClient.componentDao().getParentModuleByKey(component, session);
-    if (parent != null) {
-      parents.add(parent);
-      aggregateParentModules(parent.key(), parents, session);
-    }
-  }
-
-  private void addSettingsToChildrenModules(ProjectReferentials ref, String moduleKey, Map<String, String> parentProperties, TreeModuleSettings treeModuleSettings,
-                                            boolean hasScanPerm, DbSession session) {
-    Map<String, String> currentParentProperties = newHashMap();
-    currentParentProperties.putAll(parentProperties);
-    currentParentProperties.putAll(getPropertiesMap(treeModuleSettings.findModuleSettings(moduleKey), hasScanPerm));
-    addSettings(ref, moduleKey, currentParentProperties);
-
-    for (ComponentDto childModule : treeModuleSettings.findChildrenModule(moduleKey)) {
-      addSettings(ref, childModule.getKey(), currentParentProperties);
-      addSettingsToChildrenModules(ref, childModule.getKey(), currentParentProperties, treeModuleSettings, hasScanPerm, session);
-    }
-  }
-
-  private void addSettings(ProjectReferentials ref, String module, Map<String, String> properties) {
-    if (!properties.isEmpty()) {
-      ref.addSettings(module, properties);
-    }
-  }
-
-  private Map<String, String> getPropertiesMap(List<PropertyDto> propertyDtos, boolean hasScanPerm) {
-    Map<String, String> properties = newHashMap();
-    for (PropertyDto propertyDto : propertyDtos) {
-      String key = propertyDto.getKey();
-      String value = propertyDto.getValue();
-      if (isPropertyAllowed(key, hasScanPerm)) {
-        properties.put(key, value);
-      }
-    }
-    return properties;
-  }
-
-  private static boolean isPropertyAllowed(String key, boolean hasScanPerm) {
-    return !key.contains(".secured") || hasScanPerm;
-  }
-
-  private void addProfiles(ProjectReferentials ref, @Nullable String projectKey, @Nullable String profileName, DbSession session) {
-    for (Language language : languages.all()) {
-      String languageKey = language.getKey();
-      QualityProfileDto qualityProfileDto = getProfile(languageKey, projectKey, profileName, session);
-      ref.addQProfile(new org.sonar.batch.protocol.input.QProfile(
-        qualityProfileDto.getKey(),
-        qualityProfileDto.getName(),
-        qualityProfileDto.getLanguage(),
-        UtcDateUtils.parseDateTime(qualityProfileDto.getRulesUpdatedAt())));
-    }
-  }
-
-  /**
-   * First try to find a quality profile matching the given name (if provided) and current language
-   * If no profile found, try to find the quality profile set on the project (if provided)
-   * If still no profile found, try to find the default profile of the language
-   * <p/>
-   * Never return null because a default profile should always be set on ech language
-   */
-  private QualityProfileDto getProfile(String languageKey, @Nullable String projectKey, @Nullable String profileName, DbSession session) {
-    QualityProfileDto qualityProfileDto = profileName != null ? qProfileFactory.getByNameAndLanguage(session, profileName, languageKey) : null;
-    if (qualityProfileDto == null && projectKey != null) {
-      qualityProfileDto = qProfileFactory.getByProjectAndLanguage(session, projectKey, languageKey);
-    }
-    qualityProfileDto = qualityProfileDto != null ? qualityProfileDto : qProfileFactory.getDefault(session, languageKey);
-    if (qualityProfileDto != null) {
-      return qualityProfileDto;
-    } else {
-      throw new IllegalStateException(String.format("No quality profile can been found on language '%s' for project '%s'", languageKey, projectKey));
-    }
-  }
-
-  private void addActiveRules(ProjectReferentials ref) {
-    for (org.sonar.batch.protocol.input.QProfile qProfile : ref.qProfiles()) {
-      for (ActiveRule activeRule : qProfileLoader.findActiveRulesByProfile(qProfile.key())) {
-        Rule rule = ruleService.getNonNullByKey(activeRule.key().ruleKey());
-        org.sonar.batch.protocol.input.ActiveRule inputActiveRule = new org.sonar.batch.protocol.input.ActiveRule(
-          activeRule.key().ruleKey().repository(),
-          activeRule.key().ruleKey().rule(),
-          rule.name(),
-          activeRule.severity(),
-          rule.internalKey(),
-          qProfile.language());
-        for (Map.Entry<String, String> entry : activeRule.params().entrySet()) {
-          inputActiveRule.addParam(entry.getKey(), entry.getValue());
-        }
-        ref.addActiveRule(inputActiveRule);
-      }
-    }
-  }
-
-  private void checkPermission(boolean preview) {
-    UserSession userSession = UserSession.get();
-    boolean hasScanPerm = userSession.hasGlobalPermission(GlobalPermissions.SCAN_EXECUTION);
-    boolean hasPreviewPerm = userSession.hasGlobalPermission(GlobalPermissions.DRY_RUN_EXECUTION);
-    if (!hasPreviewPerm && !hasScanPerm) {
-      throw new ForbiddenException("You're not authorized to execute any SonarQube analysis. Please contact your SonarQube administrator.");
-    }
-    if (!preview && !hasScanPerm) {
-      throw new ForbiddenException("You're only authorized to execute a local (dry run) SonarQube analysis without pushing the results to the SonarQube server. " +
-        "Please contact your SonarQube administrator.");
-    }
-  }
-
-  private static class TreeModuleSettings {
-
-    private Map<String, Long> moduleIdsByKey;
-    private Map<String, String> moduleUuidsByKey;
-    private Multimap<Long, PropertyDto> propertiesByModuleId;
-    private Multimap<String, ComponentDto> moduleChildrenByModuleUuid;
-
-    private TreeModuleSettings(List<ComponentDto> moduleChildren, List<PropertyDto> moduleChildrenSettings, ComponentDto module, List<PropertyDto> moduleSettings) {
-      propertiesByModuleId = ArrayListMultimap.create();
-      moduleIdsByKey = newHashMap();
-      moduleUuidsByKey = newHashMap();
-      moduleChildrenByModuleUuid = ArrayListMultimap.create();
-
-      for (PropertyDto settings : moduleChildrenSettings) {
-        propertiesByModuleId.put(settings.getResourceId(), settings);
-      }
-      propertiesByModuleId.putAll(module.getId(), moduleSettings);
-
-      moduleIdsByKey.put(module.key(), module.getId());
-      moduleUuidsByKey.put(module.key(), module.uuid());
-      for (ComponentDto componentDto : moduleChildren) {
-        moduleIdsByKey.put(componentDto.key(), componentDto.getId());
-        moduleUuidsByKey.put(componentDto.key(), componentDto.uuid());
-        String moduleUuid = componentDto.moduleUuid();
-        if (moduleUuid != null) {
-          moduleChildrenByModuleUuid.put(moduleUuid, componentDto);
-        } else {
-          moduleChildrenByModuleUuid.put(module.uuid(), componentDto);
-        }
-      }
-    }
-
-    private  List<PropertyDto> findModuleSettings(String moduleKey) {
-      Long moduleId = moduleIdsByKey.get(moduleKey);
-      return newArrayList(propertiesByModuleId.get(moduleId));
-    }
-
-    private List<ComponentDto> findChildrenModule(String moduleKey) {
-      String moduleUuid = moduleUuidsByKey.get(moduleKey);
-      return newArrayList(moduleChildrenByModuleUuid.get(moduleUuid));
-    }
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsQuery.java b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsQuery.java
deleted file mode 100644 (file)
index 301e2b0..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.batch;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-public class ProjectReferentialsQuery {
-
-  private String projectOrModuleKey;
-  private String profileName;
-  private boolean preview;
-
-  private ProjectReferentialsQuery() {
-    // No direct call
-  }
-
-  public boolean isPreview() {
-    return preview;
-  }
-
-  public ProjectReferentialsQuery setPreview(boolean preview) {
-    this.preview = preview;
-    return this;
-  }
-
-  @CheckForNull
-  public String getProfileName() {
-    return profileName;
-  }
-
-  public ProjectReferentialsQuery setProfileName(@Nullable String profileName) {
-    this.profileName = profileName;
-    return this;
-  }
-
-  public String getModuleKey() {
-    return projectOrModuleKey;
-  }
-
-  public ProjectReferentialsQuery setModuleKey(String projectOrModuleKey) {
-    this.projectOrModuleKey = projectOrModuleKey;
-    return this;
-  }
-
-  public static ProjectReferentialsQuery create(){
-    return new ProjectReferentialsQuery();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectRepositoryAction.java b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectRepositoryAction.java
new file mode 100644 (file)
index 0000000..dd7d45c
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.batch;
+
+import org.apache.commons.io.IOUtils;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.RequestHandler;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.batch.protocol.input.ProjectReferentials;
+import org.sonar.server.plugins.MimeTypes;
+
+public class ProjectRepositoryAction implements RequestHandler {
+
+  private static final String PARAM_KEY = "key";
+  private static final String PARAM_PROFILE = "profile";
+  private static final String PARAM_PREVIEW = "preview";
+
+  private final ProjectRepositoryLoader projectReferentialsLoader;
+
+  public ProjectRepositoryAction(ProjectRepositoryLoader projectReferentialsLoader) {
+    this.projectReferentialsLoader = projectReferentialsLoader;
+  }
+
+  void define(WebService.NewController controller) {
+    WebService.NewAction action = controller.createAction("project")
+      .setDescription("Return project repository")
+      .setSince("4.5")
+      .setInternal(true)
+      .setHandler(this);
+
+    action
+      .createParam(PARAM_KEY)
+      .setRequired(true)
+      .setDescription("Project or module key")
+      .setExampleValue("org.codehaus.sonar:sonar");
+
+    action
+      .createParam(PARAM_PROFILE)
+      .setDescription("Profile name")
+      .setExampleValue("SonarQube Way");
+
+    action
+      .createParam(PARAM_PREVIEW)
+      .setDescription("Preview mode or not")
+      .setDefaultValue(false)
+      .setBooleanPossibleValues();
+  }
+
+  @Override
+  public void handle(Request request, Response response) throws Exception {
+    ProjectReferentials ref = projectReferentialsLoader.load(ProjectRepositoryQuery.create()
+      .setModuleKey(request.mandatoryParam(PARAM_KEY))
+      .setProfileName(request.param(PARAM_PROFILE))
+      .setPreview(request.mandatoryParamAsBoolean(PARAM_PREVIEW)));
+    response.stream().setMediaType(MimeTypes.JSON);
+    IOUtils.write(ref.toJson(), response.stream().output());
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectRepositoryLoader.java b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectRepositoryLoader.java
new file mode 100644 (file)
index 0000000..08212e7
--- /dev/null
@@ -0,0 +1,276 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.batch;
+
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Multimap;
+import org.sonar.api.ServerComponent;
+import org.sonar.api.resources.Language;
+import org.sonar.api.resources.Languages;
+import org.sonar.batch.protocol.input.ProjectReferentials;
+import org.sonar.core.UtcDateUtils;
+import org.sonar.core.component.ComponentDto;
+import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.core.persistence.MyBatis;
+import org.sonar.core.properties.PropertyDto;
+import org.sonar.core.qualityprofile.db.QualityProfileDto;
+import org.sonar.server.db.DbClient;
+import org.sonar.server.exceptions.ForbiddenException;
+import org.sonar.server.qualityprofile.ActiveRule;
+import org.sonar.server.qualityprofile.QProfileFactory;
+import org.sonar.server.qualityprofile.QProfileLoader;
+import org.sonar.server.rule.Rule;
+import org.sonar.server.rule.RuleService;
+import org.sonar.server.user.UserSession;
+
+import javax.annotation.Nullable;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import static com.google.common.collect.Lists.newArrayList;
+import static com.google.common.collect.Maps.newHashMap;
+
+public class ProjectRepositoryLoader implements ServerComponent {
+
+  private final DbClient dbClient;
+  private final QProfileFactory qProfileFactory;
+  private final QProfileLoader qProfileLoader;
+  private final RuleService ruleService;
+  private final Languages languages;
+
+  public ProjectRepositoryLoader(DbClient dbClient, QProfileFactory qProfileFactory, QProfileLoader qProfileLoader, RuleService ruleService,
+    Languages languages) {
+    this.dbClient = dbClient;
+    this.qProfileFactory = qProfileFactory;
+    this.qProfileLoader = qProfileLoader;
+    this.ruleService = ruleService;
+    this.languages = languages;
+  }
+
+  public ProjectReferentials load(ProjectRepositoryQuery query) {
+    boolean hasScanPerm = UserSession.get().hasGlobalPermission(GlobalPermissions.SCAN_EXECUTION);
+    checkPermission(query.isPreview());
+
+    DbSession session = dbClient.openSession(false);
+    try {
+      ProjectReferentials ref = new ProjectReferentials();
+      String projectKey = query.getModuleKey();
+      ComponentDto module = dbClient.componentDao().getNullableByKey(session, query.getModuleKey());
+      // Current project/module can be null when analysing a new project
+      if (module != null) {
+        ComponentDto project = dbClient.componentDao().getNullableRootProjectByKey(query.getModuleKey(), session);
+
+        // Can be null if the given project is a provisioned one
+        if (project != null) {
+          if (!project.key().equals(module.key())) {
+            addSettings(ref, module.getKey(), getSettingsFromParents(module.key(), hasScanPerm, session));
+            projectKey = project.key();
+          }
+
+          List<PropertyDto> moduleSettings = dbClient.propertiesDao().selectProjectProperties(query.getModuleKey(), session);
+          List<ComponentDto> moduleChildren = dbClient.componentDao().findChildrenModulesFromModule(session, query.getModuleKey());
+          List<PropertyDto> moduleChildrenSettings = newArrayList();
+          if (!moduleChildren.isEmpty()) {
+            moduleChildrenSettings = dbClient.propertiesDao().findChildrenModuleProperties(query.getModuleKey(), session);
+          }
+          TreeModuleSettings treeModuleSettings = new TreeModuleSettings(moduleChildren, moduleChildrenSettings, module, moduleSettings);
+
+          addSettingsToChildrenModules(ref, query.getModuleKey(), Maps.<String, String>newHashMap(), treeModuleSettings, hasScanPerm, session);
+        } else {
+          // Add settings of the provisioned project
+          addSettings(ref, query.getModuleKey(), getPropertiesMap(dbClient.propertiesDao().selectProjectProperties(query.getModuleKey(), session), hasScanPerm));
+        }
+      }
+
+      addProfiles(ref, projectKey, query.getProfileName(), session);
+      addActiveRules(ref);
+      return ref;
+    } finally {
+      MyBatis.closeQuietly(session);
+    }
+  }
+
+  private Map<String, String> getSettingsFromParents(String moduleKey, boolean hasScanPerm, DbSession session) {
+    List<ComponentDto> parents = newArrayList();
+    aggregateParentModules(moduleKey, parents, session);
+    Collections.reverse(parents);
+
+    Map<String, String> parentProperties = newHashMap();
+    for (ComponentDto parent : parents) {
+      parentProperties.putAll(getPropertiesMap(dbClient.propertiesDao().selectProjectProperties(parent.key(), session), hasScanPerm));
+    }
+    return parentProperties;
+  }
+
+  private void aggregateParentModules(String component, List<ComponentDto> parents, DbSession session) {
+    ComponentDto parent = dbClient.componentDao().getParentModuleByKey(component, session);
+    if (parent != null) {
+      parents.add(parent);
+      aggregateParentModules(parent.key(), parents, session);
+    }
+  }
+
+  private void addSettingsToChildrenModules(ProjectReferentials ref, String moduleKey, Map<String, String> parentProperties, TreeModuleSettings treeModuleSettings,
+                                            boolean hasScanPerm, DbSession session) {
+    Map<String, String> currentParentProperties = newHashMap();
+    currentParentProperties.putAll(parentProperties);
+    currentParentProperties.putAll(getPropertiesMap(treeModuleSettings.findModuleSettings(moduleKey), hasScanPerm));
+    addSettings(ref, moduleKey, currentParentProperties);
+
+    for (ComponentDto childModule : treeModuleSettings.findChildrenModule(moduleKey)) {
+      addSettings(ref, childModule.getKey(), currentParentProperties);
+      addSettingsToChildrenModules(ref, childModule.getKey(), currentParentProperties, treeModuleSettings, hasScanPerm, session);
+    }
+  }
+
+  private void addSettings(ProjectReferentials ref, String module, Map<String, String> properties) {
+    if (!properties.isEmpty()) {
+      ref.addSettings(module, properties);
+    }
+  }
+
+  private Map<String, String> getPropertiesMap(List<PropertyDto> propertyDtos, boolean hasScanPerm) {
+    Map<String, String> properties = newHashMap();
+    for (PropertyDto propertyDto : propertyDtos) {
+      String key = propertyDto.getKey();
+      String value = propertyDto.getValue();
+      if (isPropertyAllowed(key, hasScanPerm)) {
+        properties.put(key, value);
+      }
+    }
+    return properties;
+  }
+
+  private static boolean isPropertyAllowed(String key, boolean hasScanPerm) {
+    return !key.contains(".secured") || hasScanPerm;
+  }
+
+  private void addProfiles(ProjectReferentials ref, @Nullable String projectKey, @Nullable String profileName, DbSession session) {
+    for (Language language : languages.all()) {
+      String languageKey = language.getKey();
+      QualityProfileDto qualityProfileDto = getProfile(languageKey, projectKey, profileName, session);
+      ref.addQProfile(new org.sonar.batch.protocol.input.QProfile(
+        qualityProfileDto.getKey(),
+        qualityProfileDto.getName(),
+        qualityProfileDto.getLanguage(),
+        UtcDateUtils.parseDateTime(qualityProfileDto.getRulesUpdatedAt())));
+    }
+  }
+
+  /**
+   * First try to find a quality profile matching the given name (if provided) and current language
+   * If no profile found, try to find the quality profile set on the project (if provided)
+   * If still no profile found, try to find the default profile of the language
+   * <p/>
+   * Never return null because a default profile should always be set on ech language
+   */
+  private QualityProfileDto getProfile(String languageKey, @Nullable String projectKey, @Nullable String profileName, DbSession session) {
+    QualityProfileDto qualityProfileDto = profileName != null ? qProfileFactory.getByNameAndLanguage(session, profileName, languageKey) : null;
+    if (qualityProfileDto == null && projectKey != null) {
+      qualityProfileDto = qProfileFactory.getByProjectAndLanguage(session, projectKey, languageKey);
+    }
+    qualityProfileDto = qualityProfileDto != null ? qualityProfileDto : qProfileFactory.getDefault(session, languageKey);
+    if (qualityProfileDto != null) {
+      return qualityProfileDto;
+    } else {
+      throw new IllegalStateException(String.format("No quality profile can been found on language '%s' for project '%s'", languageKey, projectKey));
+    }
+  }
+
+  private void addActiveRules(ProjectReferentials ref) {
+    for (org.sonar.batch.protocol.input.QProfile qProfile : ref.qProfiles()) {
+      for (ActiveRule activeRule : qProfileLoader.findActiveRulesByProfile(qProfile.key())) {
+        Rule rule = ruleService.getNonNullByKey(activeRule.key().ruleKey());
+        org.sonar.batch.protocol.input.ActiveRule inputActiveRule = new org.sonar.batch.protocol.input.ActiveRule(
+          activeRule.key().ruleKey().repository(),
+          activeRule.key().ruleKey().rule(),
+          rule.name(),
+          activeRule.severity(),
+          rule.internalKey(),
+          qProfile.language());
+        for (Map.Entry<String, String> entry : activeRule.params().entrySet()) {
+          inputActiveRule.addParam(entry.getKey(), entry.getValue());
+        }
+        ref.addActiveRule(inputActiveRule);
+      }
+    }
+  }
+
+  private void checkPermission(boolean preview) {
+    UserSession userSession = UserSession.get();
+    boolean hasScanPerm = userSession.hasGlobalPermission(GlobalPermissions.SCAN_EXECUTION);
+    boolean hasPreviewPerm = userSession.hasGlobalPermission(GlobalPermissions.DRY_RUN_EXECUTION);
+    if (!hasPreviewPerm && !hasScanPerm) {
+      throw new ForbiddenException("You're not authorized to execute any SonarQube analysis. Please contact your SonarQube administrator.");
+    }
+    if (!preview && !hasScanPerm) {
+      throw new ForbiddenException("You're only authorized to execute a local (dry run) SonarQube analysis without pushing the results to the SonarQube server. " +
+        "Please contact your SonarQube administrator.");
+    }
+  }
+
+  private static class TreeModuleSettings {
+
+    private Map<String, Long> moduleIdsByKey;
+    private Map<String, String> moduleUuidsByKey;
+    private Multimap<Long, PropertyDto> propertiesByModuleId;
+    private Multimap<String, ComponentDto> moduleChildrenByModuleUuid;
+
+    private TreeModuleSettings(List<ComponentDto> moduleChildren, List<PropertyDto> moduleChildrenSettings, ComponentDto module, List<PropertyDto> moduleSettings) {
+      propertiesByModuleId = ArrayListMultimap.create();
+      moduleIdsByKey = newHashMap();
+      moduleUuidsByKey = newHashMap();
+      moduleChildrenByModuleUuid = ArrayListMultimap.create();
+
+      for (PropertyDto settings : moduleChildrenSettings) {
+        propertiesByModuleId.put(settings.getResourceId(), settings);
+      }
+      propertiesByModuleId.putAll(module.getId(), moduleSettings);
+
+      moduleIdsByKey.put(module.key(), module.getId());
+      moduleUuidsByKey.put(module.key(), module.uuid());
+      for (ComponentDto componentDto : moduleChildren) {
+        moduleIdsByKey.put(componentDto.key(), componentDto.getId());
+        moduleUuidsByKey.put(componentDto.key(), componentDto.uuid());
+        String moduleUuid = componentDto.moduleUuid();
+        if (moduleUuid != null) {
+          moduleChildrenByModuleUuid.put(moduleUuid, componentDto);
+        } else {
+          moduleChildrenByModuleUuid.put(module.uuid(), componentDto);
+        }
+      }
+    }
+
+    private  List<PropertyDto> findModuleSettings(String moduleKey) {
+      Long moduleId = moduleIdsByKey.get(moduleKey);
+      return newArrayList(propertiesByModuleId.get(moduleId));
+    }
+
+    private List<ComponentDto> findChildrenModule(String moduleKey) {
+      String moduleUuid = moduleUuidsByKey.get(moduleKey);
+      return newArrayList(moduleChildrenByModuleUuid.get(moduleUuid));
+    }
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectRepositoryQuery.java b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectRepositoryQuery.java
new file mode 100644 (file)
index 0000000..3de8d77
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.batch;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
+public class ProjectRepositoryQuery {
+
+  private String projectOrModuleKey;
+  private String profileName;
+  private boolean preview;
+
+  private ProjectRepositoryQuery() {
+    // No direct call
+  }
+
+  public boolean isPreview() {
+    return preview;
+  }
+
+  public ProjectRepositoryQuery setPreview(boolean preview) {
+    this.preview = preview;
+    return this;
+  }
+
+  @CheckForNull
+  public String getProfileName() {
+    return profileName;
+  }
+
+  public ProjectRepositoryQuery setProfileName(@Nullable String profileName) {
+    this.profileName = profileName;
+    return this;
+  }
+
+  public String getModuleKey() {
+    return projectOrModuleKey;
+  }
+
+  public ProjectRepositoryQuery setModuleKey(String projectOrModuleKey) {
+    this.projectOrModuleKey = projectOrModuleKey;
+    return this;
+  }
+
+  public static ProjectRepositoryQuery create() {
+    return new ProjectRepositoryQuery();
+  }
+}
index 1009c303197885f03db9b334111d8cea59c41b46..77457db98cbf54be739d044e50258d8fc8fa39e0 100644 (file)
@@ -348,9 +348,9 @@ class ServerComponents {
 
     // batch
     pico.addSingleton(BatchIndex.class);
-    pico.addSingleton(GlobalReferentialsAction.class);
-    pico.addSingleton(ProjectReferentialsAction.class);
-    pico.addSingleton(ProjectReferentialsLoader.class);
+    pico.addSingleton(GlobalRepositoryAction.class);
+    pico.addSingleton(ProjectRepositoryAction.class);
+    pico.addSingleton(ProjectRepositoryLoader.class);
     pico.addSingleton(SubmitReportWsAction.class);
     pico.addSingleton(BatchWs.class);
 
index d2a01b11f67dda1c218e325a5365dbfdaea8ac32..58b5fcf6a0dcee81d124e4fcdc66ffabf20a49db 100644 (file)
@@ -56,8 +56,8 @@ public class BatchWsTest {
   @Before
   public void before() throws IOException {
     tester = new WsTester(new BatchWs(batchIndex,
-      new GlobalReferentialsAction(mock(DbClient.class), mock(PropertiesDao.class)),
-      new ProjectReferentialsAction(mock(ProjectReferentialsLoader.class))));
+      new GlobalRepositoryAction(mock(DbClient.class), mock(PropertiesDao.class)),
+      new ProjectRepositoryAction(mock(ProjectRepositoryLoader.class))));
   }
 
   @Test
diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/GlobalReferentialsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/GlobalReferentialsActionTest.java
deleted file mode 100644 (file)
index 4468e1b..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.batch;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.sonar.core.measure.db.MetricDto;
-import org.sonar.core.permission.GlobalPermissions;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.properties.PropertiesDao;
-import org.sonar.core.properties.PropertyDto;
-import org.sonar.server.db.DbClient;
-import org.sonar.server.measure.persistence.MetricDao;
-import org.sonar.server.user.MockUserSession;
-import org.sonar.server.ws.WsTester;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public class GlobalReferentialsActionTest {
-
-  @Mock
-  DbSession session;
-
-  @Mock
-  MetricDao metricDao;
-
-  @Mock
-  PropertiesDao propertiesDao;
-
-  WsTester tester;
-
-  @Before
-  public void setUp() throws Exception {
-    DbClient dbClient = mock(DbClient.class);
-    when(dbClient.openSession(false)).thenReturn(session);
-    when(dbClient.metricDao()).thenReturn(metricDao);
-
-    tester = new WsTester(new BatchWs(mock(BatchIndex.class), new GlobalReferentialsAction(dbClient, propertiesDao), mock(ProjectReferentialsAction.class)));
-  }
-
-  @Test
-  public void return_metrics() throws Exception {
-    when(metricDao.findEnabled(session)).thenReturn(newArrayList(
-      MetricDto.createFor("coverage").setDescription("Coverage by unit tests").setValueType("PERCENT").setQualitative(true)
-        .setWorstValue(0d).setBestValue(100d).setOptimizedBestValue(false).setDirection(1).setEnabled(true)
-    ));    
-    
-    WsTester.TestRequest request = tester.newGetRequest("batch", "global");
-    request.execute().assertJson(getClass(), "return_global_referentials.json");
-  }
-
-  @Test
-  public void return_global_settings() throws Exception {
-    MockUserSession.set().setLogin("john").setGlobalPermissions(GlobalPermissions.SCAN_EXECUTION, GlobalPermissions.DRY_RUN_EXECUTION);
-
-    when(propertiesDao.selectGlobalProperties(session)).thenReturn(newArrayList(
-      new PropertyDto().setKey("foo").setValue("bar"),
-      new PropertyDto().setKey("foo.secured").setValue("1234"),
-      new PropertyDto().setKey("foo.license.secured").setValue("5678")
-    ));
-
-    WsTester.TestRequest request = tester.newGetRequest("batch", "global");
-    request.execute().assertJson(getClass(), "return_global_settings.json");
-  }
-
-  @Test
-  public void return_only_license_settings_without_scan_but_with_preview_permission() throws Exception {
-    MockUserSession.set().setLogin("john").setGlobalPermissions(GlobalPermissions.DRY_RUN_EXECUTION);
-
-    when(propertiesDao.selectGlobalProperties(session)).thenReturn(newArrayList(
-      new PropertyDto().setKey("foo").setValue("bar"),
-      new PropertyDto().setKey("foo.secured").setValue("1234"),
-      new PropertyDto().setKey("foo.license.secured").setValue("5678")
-    ));
-
-    WsTester.TestRequest request = tester.newGetRequest("batch", "global");
-    request.execute().assertJson(getClass(), "return_only_license_settings_without_scan_but_with_preview_permission.json");
-  }
-
-  @Test
-  public void return_no_secured_settings_without_scan_and_preview_permission() throws Exception {
-    MockUserSession.set().setLogin("john").setGlobalPermissions();
-
-    when(propertiesDao.selectGlobalProperties(session)).thenReturn(newArrayList(
-      new PropertyDto().setKey("foo").setValue("bar"),
-      new PropertyDto().setKey("foo.secured").setValue("1234"),
-      new PropertyDto().setKey("foo.license.secured").setValue("5678")
-    ));
-
-    WsTester.TestRequest request = tester.newGetRequest("batch", "global");
-    request.execute().assertJson(getClass(), "return_no_secured_settings_without_scan_and_preview_permission.json");
-  }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/GlobalRepositoryActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/GlobalRepositoryActionTest.java
new file mode 100644 (file)
index 0000000..8ec5ca9
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.batch;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.sonar.core.measure.db.MetricDto;
+import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.core.properties.PropertiesDao;
+import org.sonar.core.properties.PropertyDto;
+import org.sonar.server.db.DbClient;
+import org.sonar.server.measure.persistence.MetricDao;
+import org.sonar.server.user.MockUserSession;
+import org.sonar.server.ws.WsTester;
+
+import static com.google.common.collect.Lists.newArrayList;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class GlobalRepositoryActionTest {
+
+  @Mock
+  DbSession session;
+
+  @Mock
+  MetricDao metricDao;
+
+  @Mock
+  PropertiesDao propertiesDao;
+
+  WsTester tester;
+
+  @Before
+  public void setUp() throws Exception {
+    DbClient dbClient = mock(DbClient.class);
+    when(dbClient.openSession(false)).thenReturn(session);
+    when(dbClient.metricDao()).thenReturn(metricDao);
+
+    tester = new WsTester(new BatchWs(mock(BatchIndex.class), new GlobalRepositoryAction(dbClient, propertiesDao), mock(ProjectRepositoryAction.class)));
+  }
+
+  @Test
+  public void return_metrics() throws Exception {
+    when(metricDao.findEnabled(session)).thenReturn(newArrayList(
+      MetricDto.createFor("coverage").setDescription("Coverage by unit tests").setValueType("PERCENT").setQualitative(true)
+        .setWorstValue(0d).setBestValue(100d).setOptimizedBestValue(false).setDirection(1).setEnabled(true)
+      ));
+
+    WsTester.TestRequest request = tester.newGetRequest("batch", "global");
+    request.execute().assertJson(getClass(), "return_global_referentials.json");
+  }
+
+  @Test
+  public void return_global_settings() throws Exception {
+    MockUserSession.set().setLogin("john").setGlobalPermissions(GlobalPermissions.SCAN_EXECUTION, GlobalPermissions.DRY_RUN_EXECUTION);
+
+    when(propertiesDao.selectGlobalProperties(session)).thenReturn(newArrayList(
+      new PropertyDto().setKey("foo").setValue("bar"),
+      new PropertyDto().setKey("foo.secured").setValue("1234"),
+      new PropertyDto().setKey("foo.license.secured").setValue("5678")
+      ));
+
+    WsTester.TestRequest request = tester.newGetRequest("batch", "global");
+    request.execute().assertJson(getClass(), "return_global_settings.json");
+  }
+
+  @Test
+  public void return_only_license_settings_without_scan_but_with_preview_permission() throws Exception {
+    MockUserSession.set().setLogin("john").setGlobalPermissions(GlobalPermissions.DRY_RUN_EXECUTION);
+
+    when(propertiesDao.selectGlobalProperties(session)).thenReturn(newArrayList(
+      new PropertyDto().setKey("foo").setValue("bar"),
+      new PropertyDto().setKey("foo.secured").setValue("1234"),
+      new PropertyDto().setKey("foo.license.secured").setValue("5678")
+      ));
+
+    WsTester.TestRequest request = tester.newGetRequest("batch", "global");
+    request.execute().assertJson(getClass(), "return_only_license_settings_without_scan_but_with_preview_permission.json");
+  }
+
+  @Test
+  public void return_no_secured_settings_without_scan_and_preview_permission() throws Exception {
+    MockUserSession.set().setLogin("john").setGlobalPermissions();
+
+    when(propertiesDao.selectGlobalProperties(session)).thenReturn(newArrayList(
+      new PropertyDto().setKey("foo").setValue("bar"),
+      new PropertyDto().setKey("foo.secured").setValue("1234"),
+      new PropertyDto().setKey("foo.license.secured").setValue("5678")
+      ));
+
+    WsTester.TestRequest request = tester.newGetRequest("batch", "global");
+    request.execute().assertJson(getClass(), "return_no_secured_settings_without_scan_and_preview_permission.json");
+  }
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java
deleted file mode 100644 (file)
index 70789b8..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.batch;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.sonar.batch.protocol.input.ProjectReferentials;
-import org.sonar.server.ws.WsTester;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public class ProjectReferentialsActionTest {
-
-  @Mock
-  ProjectReferentialsLoader projectReferentialsLoader;
-
-  WsTester tester;
-
-  @Before
-  public void setUp() throws Exception {
-    tester = new WsTester(new BatchWs(mock(BatchIndex.class), mock(GlobalReferentialsAction.class),
-      new ProjectReferentialsAction(projectReferentialsLoader)));
-  }
-
-  @Test
-  public void project_referentials() throws Exception {
-    String projectKey = "org.codehaus.sonar:sonar";
-
-    ProjectReferentials projectReferentials = mock(ProjectReferentials.class);
-    when(projectReferentials.toJson()).thenReturn("{\"settingsByModule\": {}}");
-
-    ArgumentCaptor<ProjectReferentialsQuery> queryArgumentCaptor = ArgumentCaptor.forClass(ProjectReferentialsQuery.class);
-    when(projectReferentialsLoader.load(queryArgumentCaptor.capture())).thenReturn(projectReferentials);
-
-    WsTester.TestRequest request = tester.newGetRequest("batch", "project")
-      .setParam("key", projectKey)
-      .setParam("profile", "Default")
-      .setParam("preview", "false");
-    request.execute().assertJson("{\"settingsByModule\": {}}");
-
-    assertThat(queryArgumentCaptor.getValue().getModuleKey()).isEqualTo(projectKey);
-    assertThat(queryArgumentCaptor.getValue().getProfileName()).isEqualTo("Default");
-    assertThat(queryArgumentCaptor.getValue().isPreview()).isFalse();
-  }
-
-}
index c4ccf2ae1f2bd828e2880f702a8aeedacefffa98..158de23c5d5b37d472572583df33899dbb0b07c1 100644 (file)
@@ -67,13 +67,13 @@ public class ProjectReferentialsLoaderMediumTest {
 
   DbSession dbSession;
 
-  ProjectReferentialsLoader loader;
+  ProjectRepositoryLoader loader;
 
   @Before
   public void before() {
     tester.clearDbAndIndexes();
     dbSession = tester.get(DbClient.class).openSession(false);
-    loader = tester.get(ProjectReferentialsLoader.class);
+    loader = tester.get(ProjectRepositoryLoader.class);
   }
 
   @After
@@ -99,12 +99,12 @@ public class ProjectReferentialsLoaderMediumTest {
       dbSession);
     dbSession.commit();
 
-    ProjectReferentials ref = loader.load(ProjectReferentialsQuery.create().setModuleKey(project.key()));
+    ProjectReferentials ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(project.key()));
     Map<String, String> projectSettings = ref.settings(project.key());
     assertThat(projectSettings).isEqualTo(ImmutableMap.of(
       "sonar.jira.project.key", "SONAR",
       "sonar.jira.login.secured", "john"
-    ));
+      ));
   }
 
   @Test
@@ -125,11 +125,11 @@ public class ProjectReferentialsLoaderMediumTest {
       dbSession);
     dbSession.commit();
 
-    ProjectReferentials ref = loader.load(ProjectReferentialsQuery.create().setModuleKey(project.key()).setPreview(true));
+    ProjectReferentials ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(project.key()).setPreview(true));
     Map<String, String> projectSettings = ref.settings(project.key());
     assertThat(projectSettings).isEqualTo(ImmutableMap.of(
       "sonar.jira.project.key", "SONAR"
-    ));
+      ));
   }
 
   @Test
@@ -160,16 +160,16 @@ public class ProjectReferentialsLoaderMediumTest {
 
     dbSession.commit();
 
-    ProjectReferentials ref = loader.load(ProjectReferentialsQuery.create().setModuleKey(project.key()));
+    ProjectReferentials ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(project.key()));
     assertThat(ref.settings(project.key())).isEqualTo(ImmutableMap.of(
       "sonar.jira.project.key", "SONAR",
       "sonar.jira.login.secured", "john"
-    ));
+      ));
     assertThat(ref.settings(module.key())).isEqualTo(ImmutableMap.of(
       "sonar.jira.project.key", "SONAR-SERVER",
       "sonar.jira.login.secured", "john",
       "sonar.coverage.exclusions", "**/*.java"
-    ));
+      ));
   }
 
   @Test
@@ -196,15 +196,15 @@ public class ProjectReferentialsLoaderMediumTest {
 
     dbSession.commit();
 
-    ProjectReferentials ref = loader.load(ProjectReferentialsQuery.create().setModuleKey(project.key()));
+    ProjectReferentials ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(project.key()));
     assertThat(ref.settings(project.key())).isEqualTo(ImmutableMap.of(
       "sonar.jira.project.key", "SONAR",
       "sonar.jira.login.secured", "john"
-    ));
+      ));
     assertThat(ref.settings(module.key())).isEqualTo(ImmutableMap.of(
       "sonar.jira.project.key", "SONAR",
       "sonar.jira.login.secured", "john"
-    ));
+      ));
   }
 
   @Test
@@ -244,21 +244,21 @@ public class ProjectReferentialsLoaderMediumTest {
 
     dbSession.commit();
 
-    ProjectReferentials ref = loader.load(ProjectReferentialsQuery.create().setModuleKey(project.key()));
+    ProjectReferentials ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(project.key()));
     assertThat(ref.settings(project.key())).isEqualTo(ImmutableMap.of(
       "sonar.jira.project.key", "SONAR",
       "sonar.jira.login.secured", "john"
-    ));
+      ));
     assertThat(ref.settings(module.key())).isEqualTo(ImmutableMap.of(
       "sonar.jira.project.key", "SONAR-SERVER",
       "sonar.jira.login.secured", "john",
       "sonar.coverage.exclusions", "**/*.java"
-    ));
+      ));
     assertThat(ref.settings(subModule.key())).isEqualTo(ImmutableMap.of(
       "sonar.jira.project.key", "SONAR-SERVER-DAO",
       "sonar.jira.login.secured", "john",
       "sonar.coverage.exclusions", "**/*.java"
-    ));
+      ));
   }
 
   @Test
@@ -289,24 +289,25 @@ public class ProjectReferentialsLoaderMediumTest {
     tester.get(DbClient.class).snapshotDao().insert(dbSession, SnapshotTesting.createForComponent(module2, projectSnapshot));
 
     // Module 2 property
-    tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-APPLICATION").setResourceId(module2.getId()), dbSession);
+    tester.get(DbClient.class).propertiesDao()
+      .setProperty(new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-APPLICATION").setResourceId(module2.getId()), dbSession);
 
     dbSession.commit();
 
-    ProjectReferentials ref = loader.load(ProjectReferentialsQuery.create().setModuleKey(project.key()));
+    ProjectReferentials ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(project.key()));
     assertThat(ref.settings(project.key())).isEqualTo(ImmutableMap.of(
       "sonar.jira.project.key", "SONAR",
       "sonar.jira.login.secured", "john"
-    ));
+      ));
     assertThat(ref.settings(module1.key())).isEqualTo(ImmutableMap.of(
       "sonar.jira.project.key", "SONAR-SERVER",
       "sonar.jira.login.secured", "john",
       "sonar.coverage.exclusions", "**/*.java"
-    ));
+      ));
     assertThat(ref.settings(module2.key())).isEqualTo(ImmutableMap.of(
       "sonar.jira.project.key", "SONAR-APPLICATION",
       "sonar.jira.login.secured", "john"
-    ));
+      ));
   }
 
   @Test
@@ -324,11 +325,11 @@ public class ProjectReferentialsLoaderMediumTest {
 
     dbSession.commit();
 
-    ProjectReferentials ref = loader.load(ProjectReferentialsQuery.create().setModuleKey(project.key()));
+    ProjectReferentials ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(project.key()));
     assertThat(ref.settings(project.key())).isEqualTo(ImmutableMap.of(
       "sonar.jira.project.key", "SONAR",
       "sonar.jira.login.secured", "john"
-    ));
+      ));
   }
 
   @Test
@@ -359,14 +360,14 @@ public class ProjectReferentialsLoaderMediumTest {
 
     dbSession.commit();
 
-    ProjectReferentials ref = loader.load(ProjectReferentialsQuery.create().setModuleKey(subModule.key()));
+    ProjectReferentials ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(subModule.key()));
     assertThat(ref.settings(project.key())).isEmpty();
     assertThat(ref.settings(module.key())).isEmpty();
     assertThat(ref.settings(subModule.key())).isEqualTo(ImmutableMap.of(
       "sonar.jira.project.key", "SONAR",
       "sonar.jira.login.secured", "john",
       "sonar.coverage.exclusions", "**/*.java"
-    ));
+      ));
   }
 
   @Test
@@ -399,14 +400,14 @@ public class ProjectReferentialsLoaderMediumTest {
 
     dbSession.commit();
 
-    ProjectReferentials ref = loader.load(ProjectReferentialsQuery.create().setModuleKey(subModule.key()));
+    ProjectReferentials ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(subModule.key()));
     assertThat(ref.settings(project.key())).isEmpty();
     assertThat(ref.settings(module.key())).isEmpty();
     assertThat(ref.settings(subModule.key())).isEqualTo(ImmutableMap.of(
       "sonar.jira.project.key", "SONAR",
       "sonar.jira.login.secured", "john",
       "sonar.coverage.exclusions", "**/*.java"
-    ));
+      ));
   }
 
   @Test
@@ -437,14 +438,14 @@ public class ProjectReferentialsLoaderMediumTest {
 
     dbSession.commit();
 
-    ProjectReferentials ref = loader.load(ProjectReferentialsQuery.create().setModuleKey(subModule.key()));
+    ProjectReferentials ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(subModule.key()));
     assertThat(ref.settings(project.key())).isEmpty();
     assertThat(ref.settings(module.key())).isEmpty();
     assertThat(ref.settings(subModule.key())).isEqualTo(ImmutableMap.of(
       "sonar.jira.project.key", "SONAR",
       "sonar.jira.login.secured", "john",
       "sonar.coverage.exclusions", "**/*.java"
-    ));
+      ));
   }
 
   @Test
@@ -476,14 +477,14 @@ public class ProjectReferentialsLoaderMediumTest {
 
     dbSession.commit();
 
-    ProjectReferentials ref = loader.load(ProjectReferentialsQuery.create().setModuleKey(subModule.key()));
+    ProjectReferentials ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(subModule.key()));
     assertThat(ref.settings(project.key())).isEmpty();
     assertThat(ref.settings(module.key())).isEmpty();
     assertThat(ref.settings(subModule.key())).isEqualTo(ImmutableMap.of(
       "sonar.jira.project.key", "SONAR-SERVER",
       "sonar.jira.login.secured", "john",
       "sonar.coverage.exclusions", "**/*.java"
-    ));
+      ));
   }
 
   @Test
@@ -495,13 +496,14 @@ public class ProjectReferentialsLoaderMediumTest {
     tester.get(DbClient.class).componentDao().insert(dbSession, project);
     tester.get(DbClient.class).snapshotDao().insert(dbSession, SnapshotTesting.createForProject(project));
 
-    QualityProfileDto profileDto = QProfileTesting.newDto(QProfileName.createFor(ServerTester.Xoo.KEY, "SonarQube way"), "abcd").setRulesUpdatedAt(DateUtils.formatDateTime(ruleUpdatedAt));
+    QualityProfileDto profileDto = QProfileTesting.newDto(QProfileName.createFor(ServerTester.Xoo.KEY, "SonarQube way"), "abcd").setRulesUpdatedAt(
+      DateUtils.formatDateTime(ruleUpdatedAt));
     tester.get(DbClient.class).qualityProfileDao().insert(dbSession, profileDto);
     tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.profile.xoo").setValue("SonarQube way").setResourceId(project.getId()), dbSession);
 
     dbSession.commit();
 
-    ProjectReferentials ref = loader.load(ProjectReferentialsQuery.create().setModuleKey(project.key()));
+    ProjectReferentials ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(project.key()));
     List<QProfile> profiles = newArrayList(ref.qProfiles());
     assertThat(profiles).hasSize(1);
     assertThat(profiles.get(0).key()).isEqualTo("abcd");
@@ -519,13 +521,14 @@ public class ProjectReferentialsLoaderMediumTest {
     tester.get(DbClient.class).componentDao().insert(dbSession, project);
     tester.get(DbClient.class).snapshotDao().insert(dbSession, SnapshotTesting.createForProject(project));
 
-    QualityProfileDto profileDto = QProfileTesting.newDto(QProfileName.createFor(ServerTester.Xoo.KEY, "SonarQube way"), "abcd").setRulesUpdatedAt(DateUtils.formatDateTime(ruleUpdatedAt));
+    QualityProfileDto profileDto = QProfileTesting.newDto(QProfileName.createFor(ServerTester.Xoo.KEY, "SonarQube way"), "abcd").setRulesUpdatedAt(
+      DateUtils.formatDateTime(ruleUpdatedAt));
     tester.get(DbClient.class).qualityProfileDao().insert(dbSession, profileDto);
     tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.profile.xoo").setValue("SonarQube way"), dbSession);
 
     dbSession.commit();
 
-    ProjectReferentials ref = loader.load(ProjectReferentialsQuery.create().setModuleKey(project.key()));
+    ProjectReferentials ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(project.key()));
     List<QProfile> profiles = newArrayList(ref.qProfiles());
     assertThat(profiles).hasSize(1);
     assertThat(profiles.get(0).key()).isEqualTo("abcd");
@@ -543,13 +546,14 @@ public class ProjectReferentialsLoaderMediumTest {
     tester.get(DbClient.class).componentDao().insert(dbSession, project);
     tester.get(DbClient.class).snapshotDao().insert(dbSession, SnapshotTesting.createForProject(project));
 
-    QualityProfileDto profileDto = QProfileTesting.newDto(QProfileName.createFor(ServerTester.Xoo.KEY, "SonarQube way"), "abcd").setRulesUpdatedAt(DateUtils.formatDateTime(ruleUpdatedAt));
+    QualityProfileDto profileDto = QProfileTesting.newDto(QProfileName.createFor(ServerTester.Xoo.KEY, "SonarQube way"), "abcd").setRulesUpdatedAt(
+      DateUtils.formatDateTime(ruleUpdatedAt));
     tester.get(DbClient.class).qualityProfileDao().insert(dbSession, profileDto);
     tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.profile.xoo").setValue("SonarQube way"), dbSession);
 
     dbSession.commit();
 
-    ProjectReferentials ref = loader.load(ProjectReferentialsQuery.create().setModuleKey(project.key()).setProfileName("SonarQube way"));
+    ProjectReferentials ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(project.key()).setProfileName("SonarQube way"));
     List<QProfile> profiles = newArrayList(ref.qProfiles());
     assertThat(profiles).hasSize(1);
     assertThat(profiles.get(0).key()).isEqualTo("abcd");
@@ -563,13 +567,14 @@ public class ProjectReferentialsLoaderMediumTest {
     MockUserSession.set().setLogin("john").setGlobalPermissions(GlobalPermissions.SCAN_EXECUTION);
     Date ruleUpdatedAt = DateUtils.parseDateTime("2014-01-14T13:00:00+0100");
 
-    QualityProfileDto profileDto = QProfileTesting.newDto(QProfileName.createFor(ServerTester.Xoo.KEY, "SonarQube way"), "abcd").setRulesUpdatedAt(DateUtils.formatDateTime(ruleUpdatedAt));
+    QualityProfileDto profileDto = QProfileTesting.newDto(QProfileName.createFor(ServerTester.Xoo.KEY, "SonarQube way"), "abcd").setRulesUpdatedAt(
+      DateUtils.formatDateTime(ruleUpdatedAt));
     tester.get(DbClient.class).qualityProfileDao().insert(dbSession, profileDto);
     tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.profile.xoo").setValue("SonarQube way"), dbSession);
 
     dbSession.commit();
 
-    ProjectReferentials ref = loader.load(ProjectReferentialsQuery.create().setModuleKey("project"));
+    ProjectReferentials ref = loader.load(ProjectRepositoryQuery.create().setModuleKey("project"));
     List<QProfile> profiles = newArrayList(ref.qProfiles());
     assertThat(profiles).hasSize(1);
     assertThat(profiles.get(0).key()).isEqualTo("abcd");
@@ -578,7 +583,6 @@ public class ProjectReferentialsLoaderMediumTest {
     assertThat(profiles.get(0).rulesUpdatedAt()).isEqualTo(ruleUpdatedAt);
   }
 
-
   @Test
   public void return_provisioned_project_profile() throws Exception {
     MockUserSession.set().setLogin("john").setGlobalPermissions(GlobalPermissions.SCAN_EXECUTION);
@@ -588,13 +592,14 @@ public class ProjectReferentialsLoaderMediumTest {
     ComponentDto project = ComponentTesting.newProjectDto();
     tester.get(DbClient.class).componentDao().insert(dbSession, project);
 
-    QualityProfileDto profileDto = QProfileTesting.newDto(QProfileName.createFor(ServerTester.Xoo.KEY, "SonarQube way"), "abcd").setRulesUpdatedAt(DateUtils.formatDateTime(ruleUpdatedAt));
+    QualityProfileDto profileDto = QProfileTesting.newDto(QProfileName.createFor(ServerTester.Xoo.KEY, "SonarQube way"), "abcd").setRulesUpdatedAt(
+      DateUtils.formatDateTime(ruleUpdatedAt));
     tester.get(DbClient.class).qualityProfileDao().insert(dbSession, profileDto);
     tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.profile.xoo").setValue("SonarQube way").setResourceId(project.getId()), dbSession);
 
     dbSession.commit();
 
-    ProjectReferentials ref = loader.load(ProjectReferentialsQuery.create().setModuleKey(project.key()));
+    ProjectReferentials ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(project.key()));
     List<QProfile> profiles = newArrayList(ref.qProfiles());
     assertThat(profiles).hasSize(1);
     assertThat(profiles.get(0).key()).isEqualTo("abcd");
@@ -612,7 +617,7 @@ public class ProjectReferentialsLoaderMediumTest {
     dbSession.commit();
 
     try {
-      loader.load(ProjectReferentialsQuery.create().setModuleKey(project.key()));
+      loader.load(ProjectRepositoryQuery.create().setModuleKey(project.key()));
       fail();
     } catch (Exception e) {
       assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("No quality profile can been found on language 'xoo' for project 'org.codehaus.sonar:sonar'");
@@ -628,7 +633,8 @@ public class ProjectReferentialsLoaderMediumTest {
     tester.get(DbClient.class).componentDao().insert(dbSession, project);
     tester.get(DbClient.class).snapshotDao().insert(dbSession, SnapshotTesting.createForProject(project));
 
-    QualityProfileDto profileDto = QProfileTesting.newDto(QProfileName.createFor(ServerTester.Xoo.KEY, "SonarQube way"), "abcd").setRulesUpdatedAt(DateUtils.formatDateTime(ruleUpdatedAt));
+    QualityProfileDto profileDto = QProfileTesting.newDto(QProfileName.createFor(ServerTester.Xoo.KEY, "SonarQube way"), "abcd").setRulesUpdatedAt(
+      DateUtils.formatDateTime(ruleUpdatedAt));
     tester.get(DbClient.class).qualityProfileDao().insert(dbSession, profileDto);
     tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.profile.xoo").setValue("SonarQube way"), dbSession);
 
@@ -645,7 +651,7 @@ public class ProjectReferentialsLoaderMediumTest {
 
     dbSession.commit();
 
-    ProjectReferentials ref = loader.load(ProjectReferentialsQuery.create().setModuleKey(project.key()));
+    ProjectReferentials ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(project.key()));
     List<ActiveRule> activeRules = newArrayList(ref.activeRules());
     assertThat(activeRules).hasSize(1);
     assertThat(activeRules.get(0).repositoryKey()).isEqualTo("squid");
@@ -667,7 +673,7 @@ public class ProjectReferentialsLoaderMediumTest {
     dbSession.commit();
 
     try {
-      loader.load(ProjectReferentialsQuery.create().setModuleKey(project.key()));
+      loader.load(ProjectRepositoryQuery.create().setModuleKey(project.key()));
       fail();
     } catch (Exception e) {
       assertThat(e).isInstanceOf(ForbiddenException.class).hasMessage("You're not authorized to execute any SonarQube analysis. Please contact your SonarQube administrator.");
@@ -683,7 +689,7 @@ public class ProjectReferentialsLoaderMediumTest {
     dbSession.commit();
 
     try {
-      loader.load(ProjectReferentialsQuery.create().setModuleKey(project.key()).setPreview(false));
+      loader.load(ProjectRepositoryQuery.create().setModuleKey(project.key()).setPreview(false));
       fail();
     } catch (Exception e) {
       assertThat(e).isInstanceOf(ForbiddenException.class).hasMessage(
@@ -693,7 +699,8 @@ public class ProjectReferentialsLoaderMediumTest {
   }
 
   private void addDefaultProfile() {
-    QualityProfileDto profileDto = QProfileTesting.newDto(QProfileName.createFor(ServerTester.Xoo.KEY, "SonarQube way"), "abcd").setRulesUpdatedAt(DateUtils.formatDateTime(new Date()));
+    QualityProfileDto profileDto = QProfileTesting.newDto(QProfileName.createFor(ServerTester.Xoo.KEY, "SonarQube way"), "abcd").setRulesUpdatedAt(
+      DateUtils.formatDateTime(new Date()));
     tester.get(DbClient.class).qualityProfileDao().insert(dbSession, profileDto);
     tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.profile.xoo").setValue("SonarQube way"), dbSession);
   }
diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectRepositoryActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectRepositoryActionTest.java
new file mode 100644 (file)
index 0000000..53183b4
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.batch;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.sonar.batch.protocol.input.ProjectReferentials;
+import org.sonar.server.ws.WsTester;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ProjectRepositoryActionTest {
+
+  @Mock
+  ProjectRepositoryLoader projectReferentialsLoader;
+
+  WsTester tester;
+
+  @Before
+  public void setUp() throws Exception {
+    tester = new WsTester(new BatchWs(mock(BatchIndex.class), mock(GlobalRepositoryAction.class),
+      new ProjectRepositoryAction(projectReferentialsLoader)));
+  }
+
+  @Test
+  public void project_referentials() throws Exception {
+    String projectKey = "org.codehaus.sonar:sonar";
+
+    ProjectReferentials projectReferentials = mock(ProjectReferentials.class);
+    when(projectReferentials.toJson()).thenReturn("{\"settingsByModule\": {}}");
+
+    ArgumentCaptor<ProjectRepositoryQuery> queryArgumentCaptor = ArgumentCaptor.forClass(ProjectRepositoryQuery.class);
+    when(projectReferentialsLoader.load(queryArgumentCaptor.capture())).thenReturn(projectReferentials);
+
+    WsTester.TestRequest request = tester.newGetRequest("batch", "project")
+      .setParam("key", projectKey)
+      .setParam("profile", "Default")
+      .setParam("preview", "false");
+    request.execute().assertJson("{\"settingsByModule\": {}}");
+
+    assertThat(queryArgumentCaptor.getValue().getModuleKey()).isEqualTo(projectKey);
+    assertThat(queryArgumentCaptor.getValue().getProfileName()).isEqualTo("Default");
+    assertThat(queryArgumentCaptor.getValue().isPreview()).isFalse();
+  }
+
+}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalReferentialsActionTest/return_global_referentials.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalReferentialsActionTest/return_global_referentials.json
deleted file mode 100644 (file)
index ec34825..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-{
-  "timestamp": 0,
-  "metrics": [
-    {
-      "id": 0,
-      "key": "coverage",
-      "valueType": "PERCENT",
-      "description": "Coverage by unit tests",
-      "direction": 1,
-      "name": "coverage",
-      "qualitative": true,
-      "userManaged": false,
-      "worstValue": 0.0,
-      "bestValue": 100.0,
-      "optimizedBestValue": false
-    }
-  ],
-  "globalSettings": {}
-}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalReferentialsActionTest/return_global_settings.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalReferentialsActionTest/return_global_settings.json
deleted file mode 100644 (file)
index d6faa69..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-{
-  "timestamp": 0,
-  "metrics": [],
-  "globalSettings": {
-    "foo" : "bar",
-    "foo.secured" : "1234",
-    "foo.license.secured" : "5678"
-  }
-}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalReferentialsActionTest/return_no_secured_settings_without_scan_and_preview_permission.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalReferentialsActionTest/return_no_secured_settings_without_scan_and_preview_permission.json
deleted file mode 100644 (file)
index 6bc5b2d..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-{
-  "timestamp": 0,
-  "metrics": [],
-  "globalSettings": {
-    "foo" : "bar"
-  }
-}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalReferentialsActionTest/return_only_license_settings_without_scan_but_with_preview_permission.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalReferentialsActionTest/return_only_license_settings_without_scan_but_with_preview_permission.json
deleted file mode 100644 (file)
index b0af2f8..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "timestamp": 0,
-  "metrics": [],
-  "globalSettings": {
-    "foo" : "bar",
-    "foo.license.secured" : "5678"
-  }
-}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalRepositoryActionTest/return_global_referentials.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalRepositoryActionTest/return_global_referentials.json
new file mode 100644 (file)
index 0000000..ec34825
--- /dev/null
@@ -0,0 +1,19 @@
+{
+  "timestamp": 0,
+  "metrics": [
+    {
+      "id": 0,
+      "key": "coverage",
+      "valueType": "PERCENT",
+      "description": "Coverage by unit tests",
+      "direction": 1,
+      "name": "coverage",
+      "qualitative": true,
+      "userManaged": false,
+      "worstValue": 0.0,
+      "bestValue": 100.0,
+      "optimizedBestValue": false
+    }
+  ],
+  "globalSettings": {}
+}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalRepositoryActionTest/return_global_settings.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalRepositoryActionTest/return_global_settings.json
new file mode 100644 (file)
index 0000000..d6faa69
--- /dev/null
@@ -0,0 +1,9 @@
+{
+  "timestamp": 0,
+  "metrics": [],
+  "globalSettings": {
+    "foo" : "bar",
+    "foo.secured" : "1234",
+    "foo.license.secured" : "5678"
+  }
+}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalRepositoryActionTest/return_no_secured_settings_without_scan_and_preview_permission.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalRepositoryActionTest/return_no_secured_settings_without_scan_and_preview_permission.json
new file mode 100644 (file)
index 0000000..6bc5b2d
--- /dev/null
@@ -0,0 +1,7 @@
+{
+  "timestamp": 0,
+  "metrics": [],
+  "globalSettings": {
+    "foo" : "bar"
+  }
+}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalRepositoryActionTest/return_only_license_settings_without_scan_but_with_preview_permission.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/GlobalRepositoryActionTest/return_only_license_settings_without_scan_but_with_preview_permission.json
new file mode 100644 (file)
index 0000000..b0af2f8
--- /dev/null
@@ -0,0 +1,8 @@
+{
+  "timestamp": 0,
+  "metrics": [],
+  "globalSettings": {
+    "foo" : "bar",
+    "foo.license.secured" : "5678"
+  }
+}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/project_referentials.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/project_referentials.json
deleted file mode 100644 (file)
index ff04061..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-{
-  "timestamp": 0,
-  "qprofilesByLanguage": {
-    "java": {
-      "key": "abcd",
-      "name": "Default",
-      "language": "java",
-      "rulesUpdatedAt": "2014-01-14T13:00:00+0100"
-    }
-  },
-  "activeRules": [
-    {
-      "repositoryKey": "squid",
-      "ruleKey": "AvoidCycle",
-      "name": "Avoid Cycle",
-      "severity": "MINOR",
-      "internalKey": "squid-1",
-      "language": "java",
-      "params": {
-        "max" : "2"
-      }
-    }
-  ],
-  "settingsByModule": {
-    "org.codehaus.sonar:sonar": {
-      "sonar.jira.project.key": "SONAR",
-      "sonar.jira.login.secured": "john"
-    }
-  },
-  "fileDataByModuleAndPath": {}
-}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectRepositoryActionTest/project_referentials.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectRepositoryActionTest/project_referentials.json
new file mode 100644 (file)
index 0000000..ff04061
--- /dev/null
@@ -0,0 +1,31 @@
+{
+  "timestamp": 0,
+  "qprofilesByLanguage": {
+    "java": {
+      "key": "abcd",
+      "name": "Default",
+      "language": "java",
+      "rulesUpdatedAt": "2014-01-14T13:00:00+0100"
+    }
+  },
+  "activeRules": [
+    {
+      "repositoryKey": "squid",
+      "ruleKey": "AvoidCycle",
+      "name": "Avoid Cycle",
+      "severity": "MINOR",
+      "internalKey": "squid-1",
+      "language": "java",
+      "params": {
+        "max" : "2"
+      }
+    }
+  ],
+  "settingsByModule": {
+    "org.codehaus.sonar:sonar": {
+      "sonar.jira.project.key": "SONAR",
+      "sonar.jira.login.secured": "john"
+    }
+  },
+  "fileDataByModuleAndPath": {}
+}