]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-15614 Drop the 'sonar.lf.aboutText' property
authorPhilippe Perrin <philippe.perrin@sonarsource.com>
Tue, 16 Nov 2021 09:53:24 +0000 (10:53 +0100)
committersonartech <sonartech@sonarsource.com>
Thu, 18 Nov 2021 20:03:33 +0000 (20:03 +0000)
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/DbVersion92.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/DropSonarLfAboutTextPropertyValue.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v92/DropSonarLfAboutTextPropertyTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v92/DropSonarLfAboutTextPropertyTest/schema.sql [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
sonar-core/src/main/java/org/sonar/core/config/WebConstants.java
sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java

index 3f1e6bf6ccc780922950c30b0e65ca1684245ff4..8d2740071793f7ccbc11430b43d19338eaef1fa8 100644 (file)
@@ -39,6 +39,7 @@ public class DbVersion92 implements DbVersion {
       .add(6111, "Change size of column 'kee' in 'components'", AlterKeeInComponentsTable.class)
       .add(6112, "Create 'project_badge_token' Table", CreateProjectBadgeTokenTable.class)
       .add(6113, "Deprecate quality profile 'Sonar way Recommended' for js and ts", DeprecateSWRecommendedQProfile.class)
+      .add(6114, "Drop the 'sonar.lf.aboutText' property value", DropSonarLfAboutTextPropertyValue.class)
     ;
   }
 }
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/DropSonarLfAboutTextPropertyValue.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/DropSonarLfAboutTextPropertyValue.java
new file mode 100644 (file)
index 0000000..d9481a5
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 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.platform.db.migration.version.v92;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DataChange;
+
+public class DropSonarLfAboutTextPropertyValue extends DataChange {
+
+  public static final String PROPERTY_TO_DELETE_KEY = "sonar.lf.aboutText";
+
+  public DropSonarLfAboutTextPropertyValue(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context
+      .prepareUpsert("delete from properties where prop_key = ?")
+      .setString(1, PROPERTY_TO_DELETE_KEY)
+      .execute()
+      .commit();
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v92/DropSonarLfAboutTextPropertyTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v92/DropSonarLfAboutTextPropertyTest.java
new file mode 100644 (file)
index 0000000..9a900d6
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 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.platform.db.migration.version.v92;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.core.util.SequenceUuidFactory;
+import org.sonar.core.util.UuidFactory;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DataChange;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+
+public class DropSonarLfAboutTextPropertyTest {
+
+  private final UuidFactory uuidFactory = new SequenceUuidFactory();
+
+  @Rule
+  public final CoreDbTester db = CoreDbTester.createForSchema(DropSonarLfAboutTextPropertyTest.class, "schema.sql");
+
+  private final DataChange underTest = new DropSonarLfAboutTextPropertyValue(db.database());
+
+  @Test
+  public void do_not_fail_if_no_rows_to_delete() {
+    assertThatCode(underTest::execute)
+      .doesNotThrowAnyException();
+  }
+
+  @Test
+  public void deletes_lf_about_text_property_when_they_exist_in_database() throws SQLException {
+    insertProperty(DropSonarLfAboutTextPropertyValue.PROPERTY_TO_DELETE_KEY, "This is an about text test sample");
+
+    underTest.execute();
+
+    assertThat(db.countSql(
+      String.format("select count(*) from properties where prop_key = '%s'",
+        DropSonarLfAboutTextPropertyValue.PROPERTY_TO_DELETE_KEY
+      ))).isZero();
+  }
+
+  private void insertProperty(String key, String value) {
+    db.executeInsert("properties",
+      "PROP_KEY", key,
+      "TEXT_VALUE", value,
+      "IS_EMPTY", String.valueOf(false),
+      "CREATED_AT", 2,
+      "UUID", uuidFactory.create());
+  }
+}
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v92/DropSonarLfAboutTextPropertyTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v92/DropSonarLfAboutTextPropertyTest/schema.sql
new file mode 100644 (file)
index 0000000..a4f7dac
--- /dev/null
@@ -0,0 +1,10 @@
+CREATE TABLE "PROPERTIES"(
+       "PROP_KEY" VARCHAR(512) NOT NULL,
+       "IS_EMPTY" BOOLEAN NOT NULL,
+       "TEXT_VALUE" VARCHAR(4000) NULL,
+       "CLOB_VALUE" VARCHAR(4000) NULL,
+       "CREATED_AT" INTEGER NOT NULL,
+       "COMPONENT_UUID" VARCHAR(40) NULL,
+       "UUID" VARCHAR(40) NOT NULL,
+       "USER_UUID" VARCHAR(255) NULL
+);
index 8200a48390544ce1792a7a222696489fa05c7926..79923fd241be6c7fdd7e00309b4e499e0d81de74 100644 (file)
@@ -136,13 +136,6 @@ public class CorePropertyDefinitions {
         .category(CoreProperties.CATEGORY_GENERAL)
         .subCategory(CoreProperties.SUBCATEGORY_LOOKNFEEL)
         .build(),
-      PropertyDefinition.builder(WebConstants.SONAR_LF_ABOUT_TEXT)
-        .name("About page text")
-        .description("Optional text that is displayed on the About page. Supports html.")
-        .category(CoreProperties.CATEGORY_GENERAL)
-        .subCategory(CoreProperties.SUBCATEGORY_LOOKNFEEL)
-        .type(PropertyType.TEXT)
-        .build(),
 
       // ISSUES
       PropertyDefinition.builder(CoreProperties.DEVELOPER_AGGREGATED_INFO_DISABLED)
index fe2d549320eef3fa75caaf21c4c45982082d5a6b..709e5fb5064a2ed3b9ac1f04672d17656b1d14a2 100644 (file)
@@ -28,7 +28,6 @@ public final class WebConstants {
   public static final String SONAR_LF_GRAVATAR_SERVER_URL = "sonar.lf.gravatarServerUrl";
   public static final String SONAR_LF_LOGO_URL = "sonar.lf.logoUrl";
   public static final String SONAR_LF_LOGO_WIDTH_PX = "sonar.lf.logoWidthPx";
-  public static final String SONAR_LF_ABOUT_TEXT = "sonar.lf.aboutText";
 
   private WebConstants() {
   }
index b0b7cb1307e0f52f5eb1d237c51e97b85aa854ee..1fcaec844ef7dcf65add283c0b70b579b580bdcc 100644 (file)
@@ -30,7 +30,7 @@ public class CorePropertyDefinitionsTest {
   @Test
   public void all() {
     List<PropertyDefinition> defs = CorePropertyDefinitions.all();
-    assertThat(defs).hasSize(53);
+    assertThat(defs).hasSize(52);
   }
 
   @Test