From de76ce29cf55f7143ae0f468deb49f256884f999 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 6 Jul 2015 16:35:41 +0200 Subject: [PATCH] Add classes for backward compatibility of plugins/libs (like sonar-license) that are directly calling classes from the core --- .../platformlevel/PlatformLevel1.java | 7 +++- .../sonar/core/persistence/DatabaseUtils.java | 31 ++++++++++++++ .../org/sonar/core/persistence/MyBatis.java | 38 ++++++++++++++++++ .../sonar/core/properties/PropertiesDao.java | 40 +++++++++++++++++++ .../sonar/core/properties/PropertyDto.java | 40 +++++++++++++++++++ .../main/java/org/sonar/db/DatabaseUtils.java | 6 +-- .../org/sonar/db/property/PropertyDto.java | 2 +- 7 files changed, 157 insertions(+), 7 deletions(-) create mode 100644 sonar-db/src/main/java/org/sonar/core/persistence/DatabaseUtils.java create mode 100644 sonar-db/src/main/java/org/sonar/core/persistence/MyBatis.java create mode 100644 sonar-db/src/main/java/org/sonar/core/properties/PropertiesDao.java create mode 100644 sonar-db/src/main/java/org/sonar/core/properties/PropertyDto.java 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 621fa7848ec..4ed0965d145 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 @@ -123,7 +123,12 @@ public class PlatformLevel1 extends PlatformLevel { ActiveRuleIndex.class, // issues - IssueIndex.class); + IssueIndex.class, + + // Classes kept for backward compatibility of plugins/libs (like sonar-license) that are directly calling classes from the core + org.sonar.core.properties.PropertiesDao.class, + org.sonar.core.persistence.MyBatis.class + ); addAll(CorePropertyDefinitions.all()); add(MigrationStepModule.class); addAll(DaoUtils.getDaoClasses()); diff --git a/sonar-db/src/main/java/org/sonar/core/persistence/DatabaseUtils.java b/sonar-db/src/main/java/org/sonar/core/persistence/DatabaseUtils.java new file mode 100644 index 00000000000..1a153cc90cd --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/core/persistence/DatabaseUtils.java @@ -0,0 +1,31 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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.core.persistence; + +/** + * Kept for backward compatibility of plugins/libs (like sonar-license) that are directly calling classes from the core + * + * @deprecated since 5.2, should be replaced by {@link org.sonar.db.DatabaseUtils} + */ +@Deprecated +public class DatabaseUtils extends org.sonar.db.DatabaseUtils { + +} diff --git a/sonar-db/src/main/java/org/sonar/core/persistence/MyBatis.java b/sonar-db/src/main/java/org/sonar/core/persistence/MyBatis.java new file mode 100644 index 00000000000..2e6d35e9f91 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/core/persistence/MyBatis.java @@ -0,0 +1,38 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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.core.persistence; + +import org.sonar.db.Database; +import org.sonar.db.deprecated.WorkQueue; + +/** + * Kept for backward compatibility of plugins/libs (like sonar-license) that are directly calling classes from the core + * + * @deprecated since 5.2, should be replaced by {@link org.sonar.db.MyBatis} + */ +@Deprecated +public class MyBatis extends org.sonar.db.MyBatis { + + public MyBatis(Database database, WorkQueue queue) { + super(database, queue); + } + +} diff --git a/sonar-db/src/main/java/org/sonar/core/properties/PropertiesDao.java b/sonar-db/src/main/java/org/sonar/core/properties/PropertiesDao.java new file mode 100644 index 00000000000..58437280428 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/core/properties/PropertiesDao.java @@ -0,0 +1,40 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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.core.properties; + +import org.sonar.db.MyBatis; + +/** + * Kept for backward compatibility of plugins/libs (like sonar-license) that are directly calling classes from the core + * + * @deprecated since 5.2, should be replaced by {@link org.sonar.db.property.PropertiesDao} + */ +@Deprecated +public class PropertiesDao extends org.sonar.db.property.PropertiesDao { + + public PropertiesDao(MyBatis mybatis) { + super(mybatis); + } + + public void setProperty(PropertyDto property) { + super.setProperty(property); + } +} diff --git a/sonar-db/src/main/java/org/sonar/core/properties/PropertyDto.java b/sonar-db/src/main/java/org/sonar/core/properties/PropertyDto.java new file mode 100644 index 00000000000..57b2da5716f --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/core/properties/PropertyDto.java @@ -0,0 +1,40 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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.core.properties; + +/** + * Kept for backward compatibility of plugins/libs (like sonar-license) that are directly calling classes from the core + * + * @deprecated since 5.2, should be replaced by {@link org.sonar.db.property.PropertyDto} + */ +@Deprecated +public class PropertyDto extends org.sonar.db.property.PropertyDto { + + public PropertyDto setKey(String key) { + super.setKey(key); + return this; + } + + public PropertyDto setValue(String value) { + super.setValue(value); + return this; + } +} diff --git a/sonar-db/src/main/java/org/sonar/db/DatabaseUtils.java b/sonar-db/src/main/java/org/sonar/db/DatabaseUtils.java index 6d74d2474cc..71eb3596d65 100644 --- a/sonar-db/src/main/java/org/sonar/db/DatabaseUtils.java +++ b/sonar-db/src/main/java/org/sonar/db/DatabaseUtils.java @@ -33,14 +33,10 @@ import org.slf4j.LoggerFactory; import static com.google.common.collect.Lists.newArrayList; -public final class DatabaseUtils { +public class DatabaseUtils { private static final int PARTITION_SIZE_FOR_ORACLE = 1000; - private DatabaseUtils() { - // only static methods - } - public static void closeQuietly(@Nullable Connection connection) { if (connection != null) { try { diff --git a/sonar-db/src/main/java/org/sonar/db/property/PropertyDto.java b/sonar-db/src/main/java/org/sonar/db/property/PropertyDto.java index 10456ace24c..91e68f8d24b 100644 --- a/sonar-db/src/main/java/org/sonar/db/property/PropertyDto.java +++ b/sonar-db/src/main/java/org/sonar/db/property/PropertyDto.java @@ -21,7 +21,7 @@ package org.sonar.db.property; import com.google.common.base.Objects; -public final class PropertyDto { +public class PropertyDto { private Long id; private String key; private String value; -- 2.39.5