From 4ac3d95a0f426913886392b23485c03d798d240b Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 25 Apr 2016 13:58:51 +0200 Subject: [PATCH] Remove useless CeDbClient It's useless that DbClient return a ReadOnlyPropertiesDao, and it prevent any CE task to update a property --- .../container/ComputeEngineContainerImpl.java | 4 +- .../main/java/org/sonar/ce/db/CeDbClient.java | 45 ------------------- .../java/org/sonar/ce/db/CeDbClientTest.java | 42 ----------------- ...ReportComputeEngineContainerPopulator.java | 4 -- 4 files changed, 2 insertions(+), 93 deletions(-) delete mode 100644 server/sonar-ce/src/main/java/org/sonar/ce/db/CeDbClient.java delete mode 100644 server/sonar-ce/src/test/java/org/sonar/ce/db/CeDbClientTest.java diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java index 12a117288d9..2dcf5dcd9ec 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java @@ -35,7 +35,6 @@ import org.sonar.api.server.rule.RulesDefinitionXmlLoader; import org.sonar.api.utils.Durations; import org.sonar.api.utils.System2; import org.sonar.api.utils.UriReader; -import org.sonar.ce.db.CeDbClient; import org.sonar.ce.db.ReadOnlyPropertiesDao; import org.sonar.ce.es.EsIndexerEnabler; import org.sonar.ce.platform.ComputeEngineExtensionInstaller; @@ -56,6 +55,7 @@ import org.sonar.core.user.DeprecatedUserFinder; import org.sonar.core.util.UuidFactoryImpl; import org.sonar.db.DaoModule; import org.sonar.db.DatabaseChecker; +import org.sonar.db.DbClient; import org.sonar.db.DefaultDatabase; import org.sonar.db.permission.PermissionRepository; import org.sonar.db.purge.PurgeProfiler; @@ -159,7 +159,7 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer { DaoModule.class, // DbClient.class, replaced by CeDbClient to use ReadOnlyPropertiesDao instead of PropertiesDao ReadOnlyPropertiesDao.class, - CeDbClient.class, + DbClient.class, // MigrationStepModule.class, DB maintenance, responsibility of Web Server // Elasticsearch diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/db/CeDbClient.java b/server/sonar-ce/src/main/java/org/sonar/ce/db/CeDbClient.java deleted file mode 100644 index 6cf67f8f009..00000000000 --- a/server/sonar-ce/src/main/java/org/sonar/ce/db/CeDbClient.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.ce.db; - -import java.util.Map; -import org.sonar.db.Dao; -import org.sonar.db.Database; -import org.sonar.db.DbClient; -import org.sonar.db.MyBatis; -import org.sonar.db.property.PropertiesDao; - -public class CeDbClient extends DbClient { - private ReadOnlyPropertiesDao readOnlyPropertiesDao; - - public CeDbClient(Database database, MyBatis myBatis, Dao... daos) { - super(database, myBatis, daos); - } - - @Override - protected void doOnLoad(Map daoByClass) { - this.readOnlyPropertiesDao = getDao(daoByClass, ReadOnlyPropertiesDao.class); - } - - @Override - public PropertiesDao propertiesDao() { - return this.readOnlyPropertiesDao; - } -} diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/db/CeDbClientTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/db/CeDbClientTest.java deleted file mode 100644 index 883247ab312..00000000000 --- a/server/sonar-ce/src/test/java/org/sonar/ce/db/CeDbClientTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.ce.db; - -import org.junit.Test; -import org.sonar.db.Dao; -import org.sonar.db.Database; -import org.sonar.db.DbClient; -import org.sonar.db.MyBatis; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - -public class CeDbClientTest { - private Database database = mock(Database.class); - private MyBatis myBatis = mock(MyBatis.class); - private ReadOnlyPropertiesDao readOnlyPropertiesDao = new ReadOnlyPropertiesDao(myBatis); - - private DbClient underTest = new CeDbClient(database, myBatis, (Dao) readOnlyPropertiesDao); - - @Test - public void getPropertiesDao_returns_ReadOnlyPropertiesDao() { - assertThat(underTest.propertiesDao()).isSameAs(readOnlyPropertiesDao); - } -} diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulator.java b/server/sonar-server/src/main/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulator.java index e571ffd1363..e78c44c8e79 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulator.java @@ -26,7 +26,6 @@ import org.sonar.ce.queue.CeTask; import org.sonar.ce.settings.SettingsLoader; import org.sonar.core.issue.tracking.Tracker; import org.sonar.core.platform.ContainerPopulator; -import org.sonar.db.property.PropertiesDao; import org.sonar.plugin.ce.ReportAnalysisComponentProvider; import org.sonar.server.computation.analysis.AnalysisMetadataHolderImpl; import org.sonar.server.computation.batch.BatchReportDirectoryHolderImpl; @@ -135,9 +134,6 @@ public final class ReportComputeEngineContainerPopulator implements ContainerPop MetricModule.class, - // We need to add PropertiesDao here because otherwise we only have access to ReadOnlyPropertiesDao - PropertiesDao.class, - // holders AnalysisMetadataHolderImpl.class, CrossProjectDuplicationStatusHolderImpl.class, -- 2.39.5