Remove obsolete H2 class
Move its static createUrl method into JdbcAccountPatchReviewStore which
is the only caller.
Change-Id: Ib99b3bcdc792f596ab409a8a99a70b7f59fe7c0e
Signed-off-by: Edwin Kempin <ekempin@google.com>
diff --git a/java/com/google/gerrit/server/schema/H2.java b/java/com/google/gerrit/server/schema/H2.java
deleted file mode 100644
index 641f5e3..0000000
--- a/java/com/google/gerrit/server/schema/H2.java
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (C) 2012 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.server.schema;
-
-import com.google.gerrit.server.config.GerritServerConfig;
-import com.google.gerrit.server.config.SitePaths;
-import com.google.inject.Inject;
-import java.nio.file.Path;
-import org.eclipse.jgit.lib.Config;
-
-class H2 {
-
- protected final Config cfg;
- private final SitePaths site;
-
- @Inject
- H2(SitePaths site, @GerritServerConfig Config cfg) {
- this.cfg = cfg;
- this.site = site;
- }
-
- public String getUrl() {
- String database = cfg.getString("database", null, "database");
- if (database == null || database.isEmpty()) {
- database = "db/ReviewDB";
- }
- return appendUrlOptions(cfg, createUrl(site.resolve(database)));
- }
-
- public static String createUrl(Path path) {
- return new StringBuilder().append("jdbc:h2:").append(path.toUri().toString()).toString();
- }
-
- public static String appendUrlOptions(Config cfg, String url) {
- long h2CacheSize = cfg.getLong("database", "h2", "cacheSize", -1);
- boolean h2AutoServer = cfg.getBoolean("database", "h2", "autoServer", false);
-
- StringBuilder urlBuilder = new StringBuilder().append(url);
-
- if (h2CacheSize >= 0) {
- // H2 CACHE_SIZE is always given in KB
- urlBuilder.append(";CACHE_SIZE=").append(h2CacheSize / 1024);
- }
- if (h2AutoServer) {
- urlBuilder.append(";AUTO_SERVER=TRUE");
- }
- return urlBuilder.toString();
- }
-}
diff --git a/java/com/google/gerrit/server/schema/JdbcAccountPatchReviewStore.java b/java/com/google/gerrit/server/schema/JdbcAccountPatchReviewStore.java
index 83a0986..1ef69db 100644
--- a/java/com/google/gerrit/server/schema/JdbcAccountPatchReviewStore.java
+++ b/java/com/google/gerrit/server/schema/JdbcAccountPatchReviewStore.java
@@ -32,6 +32,7 @@
import com.google.gerrit.server.config.ThreadSettingsConfig;
import com.google.gwtorm.server.OrmDuplicateKeyException;
import com.google.gwtorm.server.OrmException;
+import java.nio.file.Path;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -115,7 +116,7 @@
private static String getUrl(@GerritServerConfig Config cfg, SitePaths sitePaths) {
String url = cfg.getString(ACCOUNT_PATCH_REVIEW_DB, null, URL);
if (url == null) {
- return H2.createUrl(sitePaths.db_dir.resolve("account_patch_reviews"));
+ return createH2Url(sitePaths.db_dir.resolve("account_patch_reviews"));
}
return url;
}
@@ -352,4 +353,8 @@
}
return 0;
}
+
+ private static String createH2Url(Path path) {
+ return new StringBuilder().append("jdbc:h2:").append(path.toUri().toString()).toString();
+ }
}