From: Simon Brandhof Date: Tue, 26 Jul 2016 12:41:33 +0000 (+0200) Subject: Rename org.sonar.server.platform.WebServerSettings to ServerSettingsImpl X-Git-Tag: 6.1-RC1~491 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7858fac1ab007eaf2f21990941d230e7c1828606;p=sonarqube.git Rename org.sonar.server.platform.WebServerSettings to ServerSettingsImpl --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ServerSettingsImpl.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerSettingsImpl.java new file mode 100644 index 00000000000..b19d2939f25 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerSettingsImpl.java @@ -0,0 +1,70 @@ +/* + * 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.server.platform; + +import org.sonar.api.CoreProperties; +import org.sonar.api.config.PropertyDefinitions; +import org.sonar.api.config.Settings; + +import java.util.Collections; +import java.util.Map; +import java.util.Properties; + +/** + * Load settings in the following order (the last override the first) : + *
    + *
  1. general settings persisted in database
  2. + *
  3. file $SONAR_HOME/conf/sonar.properties
  4. + *
  5. environment variables
  6. + *
  7. system properties
  8. + *
+ */ +public class ServerSettingsImpl extends Settings implements ServerSettings { + + private final Properties properties; + + public ServerSettingsImpl(PropertyDefinitions definitions, Properties properties) { + super(definitions); + this.properties = properties; + load(Collections.emptyMap()); + // Secret key is loaded from conf/sonar.properties + getEncryption().setPathToSecretKey(getString(CoreProperties.ENCRYPTION_SECRET_KEY_PATH)); + } + + @Override + public ServerSettings activateDatabaseSettings(Map databaseProperties) { + return load(databaseProperties); + } + + @Override + public Settings getSettings() { + return this; + } + + private ServerSettings load(Map databaseSettings) { + clear(); + + // order is important : the last override the first + addProperties(databaseSettings); + addProperties(properties); + + return this; + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/WebServerSettings.java b/server/sonar-server/src/main/java/org/sonar/server/platform/WebServerSettings.java deleted file mode 100644 index 7a74f92318c..00000000000 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/WebServerSettings.java +++ /dev/null @@ -1,72 +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.server.platform; - -import org.sonar.api.CoreProperties; -import org.sonar.api.config.PropertyDefinitions; -import org.sonar.api.config.Settings; - -import java.util.Collections; -import java.util.Map; -import java.util.Properties; - -/** - * Load settings in the following order (the last override the first) : - *
    - *
  1. general settings persisted in database
  2. - *
  3. file $SONAR_HOME/conf/sonar.properties
  4. - *
  5. environment variables
  6. - *
  7. system properties
  8. - *
- * - * @since 2.12 - */ -public class WebServerSettings extends Settings implements ServerSettings { - - private final Properties properties; - - public WebServerSettings(PropertyDefinitions definitions, Properties properties) { - super(definitions); - this.properties = properties; - load(Collections.emptyMap()); - // Secret key is loaded from conf/sonar.properties - getEncryption().setPathToSecretKey(getString(CoreProperties.ENCRYPTION_SECRET_KEY_PATH)); - } - - @Override - public ServerSettings activateDatabaseSettings(Map databaseProperties) { - return load(databaseProperties); - } - - @Override - public Settings getSettings() { - return this; - } - - private ServerSettings load(Map databaseSettings) { - clear(); - - // order is important : the last override the first - addProperties(databaseSettings); - addProperties(properties); - - return this; - } -} diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java index 2d23b102dee..58053ce3498 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java @@ -46,8 +46,8 @@ import org.sonar.server.platform.DatabaseServerCompatibility; import org.sonar.server.platform.DefaultServerFileSystem; import org.sonar.server.platform.Platform; import org.sonar.server.platform.ServerImpl; +import org.sonar.server.platform.ServerSettingsImpl; import org.sonar.server.platform.TempFolderProvider; -import org.sonar.server.platform.WebServerSettings; import org.sonar.server.qualityprofile.index.ActiveRuleIndex; import org.sonar.server.ruby.PlatformRackBridge; import org.sonar.server.rule.index.RuleIndex; @@ -77,7 +77,7 @@ public class PlatformLevel1 extends PlatformLevel { SonarRuntimeImpl.forSonarQube(apiVersion, SonarQubeSide.SERVER), ProcessCommandWrapperImpl.class, RestartFlagHolderImpl.class, - WebServerSettings.class, + ServerSettingsImpl.class, ServerImpl.class, UuidFactoryImpl.INSTANCE, EmbeddedDatabaseFactory.class, diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SetDefaultTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SetDefaultTemplateActionTest.java index a9c3918e28b..b4146f29238 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SetDefaultTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SetDefaultTemplateActionTest.java @@ -44,7 +44,7 @@ import org.sonar.server.exceptions.UnauthorizedException; import org.sonar.server.i18n.I18nRule; import org.sonar.server.permission.ws.PermissionDependenciesFinder; import org.sonar.server.platform.PersistentSettings; -import org.sonar.server.platform.WebServerSettings; +import org.sonar.server.platform.ServerSettingsImpl; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.usergroups.ws.UserGroupFinder; import org.sonar.server.ws.TestRequest; @@ -82,7 +82,7 @@ public class SetDefaultTemplateActionTest { @Before public void setUp() { DbClient dbClient = db.getDbClient(); - persistentSettings = new PersistentSettings(dbClient, new WebServerSettings(new PropertyDefinitions(), new Properties())); + persistentSettings = new PersistentSettings(dbClient, new ServerSettingsImpl(new PropertyDefinitions(), new Properties())); persistentSettings.saveProperty(DEFAULT_TEMPLATE_PROPERTY, "any-template-uuid"); persistentSettings.saveProperty(defaultRootQualifierTemplateProperty(PROJECT), "any-template-uuid"); persistentSettings.saveProperty(defaultRootQualifierTemplateProperty(VIEW), "any-view-template-uuid"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java index 5a9bfaa1544..e80eaae4251 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java @@ -42,7 +42,7 @@ public class PersistentSettingsTest { DbSession dbSession = db.getSession(); private PropertiesDao dao = dbClient.propertiesDao(); - private ServerSettings settings = new WebServerSettings( + private ServerSettings settings = new ServerSettingsImpl( new PropertyDefinitions(), new Properties()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/ServerSettingsTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/ServerSettingsTest.java index 7e2aef09679..f06f5ede8e0 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/platform/ServerSettingsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/ServerSettingsTest.java @@ -33,7 +33,7 @@ public class ServerSettingsTest { Properties properties; - WebServerSettings settings; + ServerSettingsImpl settings; @Before public void before() { @@ -41,7 +41,7 @@ public class ServerSettingsTest { properties.put("hello", "world"); properties.put("in_file", "true"); properties.put("ServerSettingsTestEnv", "in_file"); - settings = new WebServerSettings(new PropertyDefinitions(), properties); + settings = new ServerSettingsImpl(new PropertyDefinitions(), properties); } @Test