diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-11-27 14:27:39 +0100 |
---|---|---|
committer | Eric Hartmann <hartmann.eric@gmail.Com> | 2017-12-04 13:44:55 +0100 |
commit | 8aafbd5f2ea63462d9ef6dc3e8c9a660d1cd29ea (patch) | |
tree | e4bf7d2c2512ff664403b95db28e302d96d9b2b2 /server/sonar-server | |
parent | 1bc9f1a76f98bf3c2ee18e4f1ef9d7c151be9bd3 (diff) | |
download | sonarqube-8aafbd5f2ea63462d9ef6dc3e8c9a660d1cd29ea.tar.gz sonarqube-8aafbd5f2ea63462d9ef6dc3e8c9a660d1cd29ea.zip |
SONAR-10110 Remove log detecting old projects
Diffstat (limited to 'server/sonar-server')
3 files changed, 0 insertions, 192 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java index f8c07e82b44..8613ab0ecfe 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java @@ -33,7 +33,6 @@ import org.sonar.server.qualityprofile.RegisterQualityProfiles; import org.sonar.server.rule.RegisterRules; import org.sonar.server.rule.WebServerRuleFinder; import org.sonar.server.startup.DeleteOldAnalysisReportsFromFs; -import org.sonar.server.startup.DisplayLogOnDeprecatedProjects; import org.sonar.server.startup.GeneratePluginIndex; import org.sonar.server.startup.RegisterMetrics; import org.sonar.server.startup.RegisterPermissionTemplates; @@ -67,7 +66,6 @@ public class PlatformLevelStartup extends PlatformLevel { RegisterQualityProfiles.class, RegisterPermissionTemplates.class, RenameDeprecatedPropertyKeys.class, - DisplayLogOnDeprecatedProjects.class, DeleteOldAnalysisReportsFromFs.class); // RegisterServletFilters makes the WebService engine of Level4 served by the MasterServletFilter, therefor it diff --git a/server/sonar-server/src/main/java/org/sonar/server/startup/DisplayLogOnDeprecatedProjects.java b/server/sonar-server/src/main/java/org/sonar/server/startup/DisplayLogOnDeprecatedProjects.java deleted file mode 100644 index 693feadea7b..00000000000 --- a/server/sonar-server/src/main/java/org/sonar/server/startup/DisplayLogOnDeprecatedProjects.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.startup; - -import org.picocontainer.Startable; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.db.DbClient; -import org.sonar.db.DbSession; -import org.sonar.db.component.ComponentDto; -import org.sonar.db.loadedtemplate.LoadedTemplateDto; - -/** - * Display a log for each project that hasn't been analysed since SonarQube 4.2 (column DEPRECATED_KEE is null) - * - * Should be removed after next LTS - * - * @since 5.2 - */ -public class DisplayLogOnDeprecatedProjects implements Startable { - - private static final Logger LOG = Loggers.get(DisplayLogOnDeprecatedProjects.class); - - private static final String TEMPLATE_KEY = "DisplayLogOnDeprecatedProjects"; - - private final DbClient dbClient; - - public DisplayLogOnDeprecatedProjects(DbClient dbClient) { - this.dbClient = dbClient; - } - - @Override - public void start() { - try (DbSession dbSession = dbClient.openSession(false)) { - if (!hasAlreadyBeenExecuted(dbSession)) { - return; - } - displayLogOnDeprecatedProjectKeys(dbSession); - registerTasks(dbSession); - dbSession.commit(); - } - } - - private void displayLogOnDeprecatedProjectKeys(DbSession session) { - boolean hasDetectDeprecatedProjects = false; - for (ComponentDto project : dbClient.componentDao().selectProjects(session)) { - if (project.deprecatedKey() == null) { - if (!hasDetectDeprecatedProjects) { - LOG.warn("We detected that the following projects have not been analysed on a SonarQube version greater than 4.2 (included):"); - hasDetectDeprecatedProjects = true; - } - LOG.warn(" - {}", project.getDbKey()); - } - } - if (hasDetectDeprecatedProjects) { - LOG.warn("As a consequence, some features of the Web UI will be broken for them, and any new analysis will consider all issues as new issues."); - } - } - - private boolean hasAlreadyBeenExecuted(DbSession session) { - return dbClient.loadedTemplateDao().countByTypeAndKey(LoadedTemplateDto.ONE_SHOT_TASK_TYPE, TEMPLATE_KEY, session) == 0; - } - - private void registerTasks(DbSession session) { - dbClient.loadedTemplateDao().insert(new LoadedTemplateDto(TEMPLATE_KEY, LoadedTemplateDto.ONE_SHOT_TASK_TYPE), session); - } - - @Override - public void stop() { - // Nothing to do - } -} diff --git a/server/sonar-server/src/test/java/org/sonar/server/startup/DisplayLogOnDeprecatedProjectsTest.java b/server/sonar-server/src/test/java/org/sonar/server/startup/DisplayLogOnDeprecatedProjectsTest.java deleted file mode 100644 index 31c19bf17b9..00000000000 --- a/server/sonar-server/src/test/java/org/sonar/server/startup/DisplayLogOnDeprecatedProjectsTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.startup; - -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.api.utils.log.LogTester; -import org.sonar.db.DbClient; -import org.sonar.db.DbSession; -import org.sonar.db.DbTester; -import org.sonar.db.component.ComponentTesting; -import org.sonar.db.organization.OrganizationDto; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DisplayLogOnDeprecatedProjectsTest { - - static final String PROJECT_KEY = "PROJECT_KEY"; - static final String DEPRECATED_PROJECT_KEY = "DEPRECATED_PROJECT_KEY"; - - @Rule - public LogTester logTester = new LogTester(); - - @Rule - public DbTester dbTester = DbTester.create(System2.INSTANCE); - - DbClient dbClient = dbTester.getDbClient(); - DbSession dbSession = dbTester.getSession(); - - DisplayLogOnDeprecatedProjects underTest = new DisplayLogOnDeprecatedProjects(dbClient); - - @Test - public void display_log_on_deprecated_project() throws Exception { - OrganizationDto organizationDto = dbTester.organizations().insert(); - dbClient.componentDao().insert(dbSession, ComponentTesting.newPrivateProjectDto(organizationDto) - .setDbKey(DEPRECATED_PROJECT_KEY) - .setDeprecatedKey(null)); - dbSession.commit(); - - underTest.start(); - - assertThat(logTester.logs()).containsOnly( - "We detected that the following projects have not been analysed on a SonarQube version greater than 4.2 (included):", - " - " + DEPRECATED_PROJECT_KEY, - "As a consequence, some features of the Web UI will be broken for them, and any new analysis will consider all issues as new issues."); - } - - @Test - public void not_display_log_when_task_already_executed() throws Exception { - OrganizationDto organizationDto = dbTester.organizations().insert(); - dbClient.componentDao().insert(dbSession, ComponentTesting.newPrivateProjectDto(organizationDto) - .setDbKey(DEPRECATED_PROJECT_KEY) - .setDeprecatedKey(null)); - dbSession.commit(); - - underTest.start(); - assertThat(logTester.logs()).isNotEmpty(); - logTester.clear(); - - underTest.start(); - assertThat(logTester.logs()).isEmpty(); - } - - @Test - public void nothing_do_when_no_deprecated_project() throws Exception { - OrganizationDto organizationDto = dbTester.organizations().insert(); - dbClient.componentDao().insert(dbSession, ComponentTesting.newPrivateProjectDto(organizationDto) - .setDbKey(PROJECT_KEY) - .setDeprecatedKey(PROJECT_KEY)); - dbSession.commit(); - - underTest.start(); - - assertThat(logTester.logs()).isEmpty(); - } - - @Test - public void nothing_do_when_no_project() throws Exception { - underTest.start(); - - assertThat(logTester.logs()).isEmpty(); - } -} |