From 808e4f107fdd1659a41bb616660090fc04a9d7c0 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Mon, 13 Jan 2014 20:49:01 +0100 Subject: SONAR-3024 Introduce deprecated key on resources to ease transition --- .../org/sonar/core/component/ComponentKeys.java | 13 ++++++++++++ .../sonar/core/persistence/DatabaseVersion.java | 2 +- .../java/org/sonar/core/resource/ResourceDto.java | 10 +++++++++ .../sonar/core/resource/ResourceKeyUpdaterDao.java | 9 ++++++-- .../org/sonar/core/persistence/rows-h2.sql | 1 + .../org/sonar/core/persistence/schema-h2.ddl | 1 + .../core/resource/ResourceKeyUpdaterMapper.xml | 9 ++++---- .../org/sonar/core/resource/ResourceMapper.xml | 7 ++++--- .../sonar/core/component/ComponentKeysTest.java | 5 +++-- .../sonar/core/issue/IssueNotificationsTest.java | 9 ++++---- .../org/sonar/core/resource/ResourceDaoTest.java | 15 +++++++++----- .../java/org/sonar/core/user/AuthorDaoTest.java | 6 ++++-- ...eHistoricalDataOfDirectoriesAndFiles-result.xml | 6 +++--- ...ldDeleteHistoricalDataOfDirectoriesAndFiles.xml | 6 +++--- ...dDisableResourcesWithoutLastSnapshot-result.xml | 6 +++--- .../shouldDisableResourcesWithoutLastSnapshot.xml | 6 +++--- .../PurgeDaoTest/shouldPurgeProject-result.xml | 2 +- .../core/purge/PurgeDaoTest/shouldPurgeProject.xml | 2 +- .../resource/ResourceDaoTest/insert-result.xml | 8 ++++---- .../resource/ResourceDaoTest/update-result.xml | 2 +- .../sonar/core/resource/ResourceDaoTest/update.xml | 2 +- .../resource/ResourceKeyUpdaterDaoTest/shared.xml | 24 +++++++++++----------- .../shouldBulkUpdateKey-result.xml | 24 +++++++++++----------- ...houldBulkUpdateKeyOnOnlyOneSubmodule-result.xml | 24 +++++++++++----------- .../shouldNotUpdateAllSubmodules-result.xml | 22 ++++++++++---------- .../shouldNotUpdateAllSubmodules.xml | 22 ++++++++++---------- .../shouldUpdateKey-result.xml | 24 +++++++++++----------- 27 files changed, 153 insertions(+), 114 deletions(-) (limited to 'sonar-core') diff --git a/sonar-core/src/main/java/org/sonar/core/component/ComponentKeys.java b/sonar-core/src/main/java/org/sonar/core/component/ComponentKeys.java index 985b64c7699..550bf27eee2 100644 --- a/sonar-core/src/main/java/org/sonar/core/component/ComponentKeys.java +++ b/sonar-core/src/main/java/org/sonar/core/component/ComponentKeys.java @@ -55,6 +55,19 @@ public final class ComponentKeys { return key; } + public static String createDeprecatedKey(Project project, Resource resource) { + String key = resource.getKey(); + if (!StringUtils.equals(Scopes.PROJECT, resource.getScope())) { + // not a project nor a library + key = new StringBuilder(ResourceModel.KEY_SIZE) + .append(project.getKey()) + .append(':') + .append(resource.getDeprecatedKey()) + .toString(); + } + return key; + } + /** *

Test if given parameter is valid for a project/module. Valid format is:

*