diff --git a/java/com/google/gerrit/acceptance/InMemoryTestingDatabaseModule.java b/java/com/google/gerrit/acceptance/InMemoryTestingDatabaseModule.java index ab93eed35d..acd5702389 100644 --- a/java/com/google/gerrit/acceptance/InMemoryTestingDatabaseModule.java +++ b/java/com/google/gerrit/acceptance/InMemoryTestingDatabaseModule.java @@ -27,7 +27,6 @@ import com.google.gerrit.server.config.SitePaths; import com.google.gerrit.server.config.TrackingFooters; import com.google.gerrit.server.config.TrackingFootersProvider; import com.google.gerrit.server.git.GitRepositoryManager; -import com.google.gerrit.server.schema.DatabaseModule; import com.google.gerrit.server.schema.ReviewDbSchemaModule; import com.google.gerrit.server.schema.SchemaCreator; import com.google.gerrit.testing.InMemoryRepositoryManager; @@ -70,7 +69,6 @@ class InMemoryTestingDatabaseModule extends LifecycleModule { bind(MetricMaker.class).to(DisabledMetricMaker.class); - install(new DatabaseModule()); listener().to(CreateSchema.class); bind(SitePaths.class); diff --git a/java/com/google/gerrit/httpd/init/WebAppInitializer.java b/java/com/google/gerrit/httpd/init/WebAppInitializer.java index 9f6049e07b..b0e4815316 100644 --- a/java/com/google/gerrit/httpd/init/WebAppInitializer.java +++ b/java/com/google/gerrit/httpd/init/WebAppInitializer.java @@ -84,7 +84,6 @@ import com.google.gerrit.server.plugins.PluginGuiceEnvironment; import com.google.gerrit.server.plugins.PluginModule; import com.google.gerrit.server.project.DefaultProjectNameLockManager; import com.google.gerrit.server.restapi.RestApiModule; -import com.google.gerrit.server.schema.DatabaseModule; import com.google.gerrit.server.schema.JdbcAccountPatchReviewStore; import com.google.gerrit.server.schema.NoteDbSchemaVersionCheck; import com.google.gerrit.server.schema.ReviewDbSchemaModule; @@ -275,7 +274,6 @@ public class WebAppInitializer extends GuiceServletContextListener implements Fi }); modules.add(new GerritServerConfigModule()); } - modules.add(new DatabaseModule()); modules.add(new DropWizardMetricMaker.ApiModule()); return Guice.createInjector(PRODUCTION, modules); } diff --git a/java/com/google/gerrit/pgm/util/SiteProgram.java b/java/com/google/gerrit/pgm/util/SiteProgram.java index a889277f1c..0926eb6355 100644 --- a/java/com/google/gerrit/pgm/util/SiteProgram.java +++ b/java/com/google/gerrit/pgm/util/SiteProgram.java @@ -25,7 +25,6 @@ import com.google.gerrit.server.config.GerritRuntime; import com.google.gerrit.server.config.GerritServerConfigModule; import com.google.gerrit.server.config.SitePath; import com.google.gerrit.server.git.GitRepositoryManagerModule; -import com.google.gerrit.server.schema.DatabaseModule; import com.google.gerrit.server.schema.ReviewDbSchemaModule; import com.google.gerrit.server.securestore.SecureStoreClassName; import com.google.gwtorm.server.OrmException; @@ -119,7 +118,6 @@ public abstract class SiteProgram extends AbstractProgram { }); Injector cfgInjector = Guice.createInjector(sitePathModule, configModule); - modules.add(new DatabaseModule()); modules.add(new ReviewDbSchemaModule()); modules.add(cfgInjector.getInstance(GitRepositoryManagerModule.class)); diff --git a/java/com/google/gerrit/reviewdb/server/DisallowedReviewDb.java b/java/com/google/gerrit/reviewdb/server/DisallowedReviewDb.java deleted file mode 100644 index 60c3c95fb9..0000000000 --- a/java/com/google/gerrit/reviewdb/server/DisallowedReviewDb.java +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright (C) 2016 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.reviewdb.server; - -import com.google.gerrit.reviewdb.client.Account; -import com.google.gerrit.reviewdb.client.Change; -import com.google.gerrit.reviewdb.client.ChangeMessage; -import com.google.gerrit.reviewdb.client.PatchLineComment; -import com.google.gerrit.reviewdb.client.PatchSet; -import com.google.gerrit.reviewdb.client.PatchSetApproval; -import com.google.gwtorm.server.OrmException; -import com.google.gwtorm.server.ResultSet; - -public class DisallowedReviewDb extends ReviewDbWrapper { - private static final String MSG = "This table has been migrated to NoteDb"; - - private final Changes changes; - private final PatchSetApprovals patchSetApprovals; - private final ChangeMessages changeMessages; - private final PatchSets patchSets; - private final PatchLineComments patchComments; - - public DisallowedReviewDb(ReviewDb db) { - super(db); - changes = new Changes(delegate.changes()); - patchSetApprovals = new PatchSetApprovals(delegate.patchSetApprovals()); - changeMessages = new ChangeMessages(delegate.changeMessages()); - patchSets = new PatchSets(delegate.patchSets()); - patchComments = new PatchLineComments(delegate.patchComments()); - } - - @Override - public ChangeAccess changes() { - return changes; - } - - @Override - public PatchSetApprovalAccess patchSetApprovals() { - return patchSetApprovals; - } - - @Override - public ChangeMessageAccess changeMessages() { - return changeMessages; - } - - @Override - public PatchSetAccess patchSets() { - return patchSets; - } - - @Override - public PatchLineCommentAccess patchComments() { - return patchComments; - } - - private static class Changes extends ChangeAccessWrapper { - - protected Changes(ChangeAccess delegate) { - super(delegate); - } - - @Override - public ResultSet iterateAllEntities() { - throw new UnsupportedOperationException(MSG); - } - - @SuppressWarnings("deprecation") - @Override - public com.google.common.util.concurrent.CheckedFuture getAsync( - Change.Id key) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet get(Iterable keys) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public Change get(Change.Id id) throws OrmException { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet all() throws OrmException { - throw new UnsupportedOperationException(MSG); - } - } - - private static class PatchSetApprovals extends PatchSetApprovalAccessWrapper { - PatchSetApprovals(PatchSetApprovalAccess delegate) { - super(delegate); - } - - @Override - public ResultSet iterateAllEntities() { - throw new UnsupportedOperationException(MSG); - } - - @SuppressWarnings("deprecation") - @Override - public com.google.common.util.concurrent.CheckedFuture getAsync( - PatchSetApproval.Key key) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet get(Iterable keys) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public PatchSetApproval get(PatchSetApproval.Key key) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet byChange(Change.Id id) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet byPatchSet(PatchSet.Id id) { - throw new UnsupportedOperationException(MSG); - } - } - - private static class ChangeMessages extends ChangeMessageAccessWrapper { - ChangeMessages(ChangeMessageAccess delegate) { - super(delegate); - } - - @Override - public ResultSet iterateAllEntities() { - throw new UnsupportedOperationException(MSG); - } - - @SuppressWarnings("deprecation") - @Override - public com.google.common.util.concurrent.CheckedFuture getAsync( - ChangeMessage.Key key) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet get(Iterable keys) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ChangeMessage get(ChangeMessage.Key id) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet byChange(Change.Id id) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet byPatchSet(PatchSet.Id id) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet all() { - throw new UnsupportedOperationException(MSG); - } - } - - private static class PatchSets extends PatchSetAccessWrapper { - PatchSets(PatchSetAccess delegate) { - super(delegate); - } - - @Override - public ResultSet iterateAllEntities() { - throw new UnsupportedOperationException(MSG); - } - - @SuppressWarnings("deprecation") - @Override - public com.google.common.util.concurrent.CheckedFuture getAsync( - PatchSet.Id key) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet get(Iterable keys) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public PatchSet get(PatchSet.Id id) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet byChange(Change.Id id) { - throw new UnsupportedOperationException(MSG); - } - } - - private static class PatchLineComments extends PatchLineCommentAccessWrapper { - PatchLineComments(PatchLineCommentAccess delegate) { - super(delegate); - } - - @Override - public ResultSet iterateAllEntities() { - throw new UnsupportedOperationException(MSG); - } - - @SuppressWarnings("deprecation") - @Override - public com.google.common.util.concurrent.CheckedFuture getAsync( - PatchLineComment.Key key) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet get(Iterable keys) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public PatchLineComment get(PatchLineComment.Key id) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet byChange(Change.Id id) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet byPatchSet(PatchSet.Id id) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet publishedByChangeFile(Change.Id id, String file) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet publishedByPatchSet(PatchSet.Id patchset) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet draftByPatchSetAuthor( - PatchSet.Id patchset, Account.Id author) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet draftByChangeFileAuthor( - Change.Id id, String file, Account.Id author) { - throw new UnsupportedOperationException(MSG); - } - - @Override - public ResultSet draftByAuthor(Account.Id author) { - throw new UnsupportedOperationException(MSG); - } - } -} diff --git a/java/com/google/gerrit/reviewdb/server/ReviewDbWrapper.java b/java/com/google/gerrit/reviewdb/server/ReviewDbWrapper.java deleted file mode 100644 index 5a77e011f9..0000000000 --- a/java/com/google/gerrit/reviewdb/server/ReviewDbWrapper.java +++ /dev/null @@ -1,1250 +0,0 @@ -// Copyright (C) 2016 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.reviewdb.server; - -import static java.util.Objects.requireNonNull; - -import com.google.gerrit.reviewdb.client.Account; -import com.google.gerrit.reviewdb.client.AccountGroup; -import com.google.gerrit.reviewdb.client.AccountGroupById; -import com.google.gerrit.reviewdb.client.AccountGroupByIdAud; -import com.google.gerrit.reviewdb.client.AccountGroupMember; -import com.google.gerrit.reviewdb.client.AccountGroupMemberAudit; -import com.google.gerrit.reviewdb.client.AccountGroupName; -import com.google.gerrit.reviewdb.client.Change; -import com.google.gerrit.reviewdb.client.ChangeMessage; -import com.google.gerrit.reviewdb.client.PatchLineComment; -import com.google.gerrit.reviewdb.client.PatchSet; -import com.google.gerrit.reviewdb.client.PatchSetApproval; -import com.google.gwtorm.jdbc.JdbcSchema; -import com.google.gwtorm.server.Access; -import com.google.gwtorm.server.AtomicUpdate; -import com.google.gwtorm.server.OrmException; -import com.google.gwtorm.server.ResultSet; -import com.google.gwtorm.server.StatementExecutor; -import java.util.Map; - -public class ReviewDbWrapper implements ReviewDb { - public static JdbcSchema unwrapJbdcSchema(ReviewDb db) { - if (db instanceof ReviewDbWrapper) { - return unwrapJbdcSchema(((ReviewDbWrapper) db).unsafeGetDelegate()); - } - return (JdbcSchema) db; - } - - protected final ReviewDb delegate; - - private boolean inTransaction; - - protected ReviewDbWrapper(ReviewDb delegate) { - this.delegate = requireNonNull(delegate); - } - - public ReviewDb unsafeGetDelegate() { - return delegate; - } - - public boolean inTransaction() { - return inTransaction; - } - - public void beginTransaction() { - inTransaction = true; - } - - @Override - public void commit() throws OrmException { - if (!inTransaction) { - // This reads a little weird, we're not in a transaction, so why are we calling commit? - // Because we want to let the underlying ReviewDb do its normal thing in this case (which may - // be throwing an exception, or not, depending on implementation). - delegate.commit(); - } - } - - @Override - public void rollback() throws OrmException { - if (inTransaction) { - inTransaction = false; - } else { - // See comment in commit(): we want to let the underlying ReviewDb do its thing. - delegate.rollback(); - } - } - - @Override - public void updateSchema(StatementExecutor e) throws OrmException { - delegate.updateSchema(e); - } - - @Override - public void pruneSchema(StatementExecutor e) throws OrmException { - delegate.pruneSchema(e); - } - - @Override - public Access[] allRelations() { - return delegate.allRelations(); - } - - @Override - public void close() { - delegate.close(); - } - - @Override - public ChangeAccess changes() { - return delegate.changes(); - } - - @Override - public PatchSetApprovalAccess patchSetApprovals() { - return delegate.patchSetApprovals(); - } - - @Override - public ChangeMessageAccess changeMessages() { - return delegate.changeMessages(); - } - - @Override - public PatchSetAccess patchSets() { - return delegate.patchSets(); - } - - @Override - public PatchLineCommentAccess patchComments() { - return delegate.patchComments(); - } - - @Override - @SuppressWarnings("deprecation") - public int nextChangeId() throws OrmException { - return delegate.nextChangeId(); - } - - public static class ChangeAccessWrapper implements ChangeAccess { - protected final ChangeAccess delegate; - - protected ChangeAccessWrapper(ChangeAccess delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public String getRelationName() { - return delegate.getRelationName(); - } - - @Override - public int getRelationID() { - return delegate.getRelationID(); - } - - @Override - public ResultSet iterateAllEntities() throws OrmException { - return delegate.iterateAllEntities(); - } - - @Override - public Change.Id primaryKey(Change entity) { - return delegate.primaryKey(entity); - } - - @Override - public Map toMap(Iterable c) { - return delegate.toMap(c); - } - - @SuppressWarnings("deprecation") - @Override - public com.google.common.util.concurrent.CheckedFuture getAsync( - Change.Id key) { - return delegate.getAsync(key); - } - - @Override - public ResultSet get(Iterable keys) throws OrmException { - return delegate.get(keys); - } - - @Override - public void insert(Iterable instances) throws OrmException { - delegate.insert(instances); - } - - @Override - public void update(Iterable instances) throws OrmException { - delegate.update(instances); - } - - @Override - public void upsert(Iterable instances) throws OrmException { - delegate.upsert(instances); - } - - @Override - public void deleteKeys(Iterable keys) throws OrmException { - delegate.deleteKeys(keys); - } - - @Override - public void delete(Iterable instances) throws OrmException { - delegate.delete(instances); - } - - @Override - public void beginTransaction(Change.Id key) throws OrmException { - delegate.beginTransaction(key); - } - - @Override - public Change atomicUpdate(Change.Id key, AtomicUpdate update) throws OrmException { - return delegate.atomicUpdate(key, update); - } - - @Override - public Change get(Change.Id id) throws OrmException { - return delegate.get(id); - } - - @Override - public ResultSet all() throws OrmException { - return delegate.all(); - } - } - - public static class PatchSetApprovalAccessWrapper implements PatchSetApprovalAccess { - protected final PatchSetApprovalAccess delegate; - - protected PatchSetApprovalAccessWrapper(PatchSetApprovalAccess delegate) { - this.delegate = delegate; - } - - @Override - public String getRelationName() { - return delegate.getRelationName(); - } - - @Override - public int getRelationID() { - return delegate.getRelationID(); - } - - @Override - public ResultSet iterateAllEntities() throws OrmException { - return delegate.iterateAllEntities(); - } - - @Override - public PatchSetApproval.Key primaryKey(PatchSetApproval entity) { - return delegate.primaryKey(entity); - } - - @Override - public Map toMap(Iterable c) { - return delegate.toMap(c); - } - - @SuppressWarnings("deprecation") - @Override - public com.google.common.util.concurrent.CheckedFuture getAsync( - PatchSetApproval.Key key) { - return delegate.getAsync(key); - } - - @Override - public ResultSet get(Iterable keys) - throws OrmException { - return delegate.get(keys); - } - - @Override - public void insert(Iterable instances) throws OrmException { - delegate.insert(instances); - } - - @Override - public void update(Iterable instances) throws OrmException { - delegate.update(instances); - } - - @Override - public void upsert(Iterable instances) throws OrmException { - delegate.upsert(instances); - } - - @Override - public void deleteKeys(Iterable keys) throws OrmException { - delegate.deleteKeys(keys); - } - - @Override - public void delete(Iterable instances) throws OrmException { - delegate.delete(instances); - } - - @Override - public void beginTransaction(PatchSetApproval.Key key) throws OrmException { - delegate.beginTransaction(key); - } - - @Override - public PatchSetApproval atomicUpdate( - PatchSetApproval.Key key, AtomicUpdate update) throws OrmException { - return delegate.atomicUpdate(key, update); - } - - @Override - public PatchSetApproval get(PatchSetApproval.Key key) throws OrmException { - return delegate.get(key); - } - - @Override - public ResultSet byChange(Change.Id id) throws OrmException { - return delegate.byChange(id); - } - - @Override - public ResultSet byPatchSet(PatchSet.Id id) throws OrmException { - return delegate.byPatchSet(id); - } - - @Override - public ResultSet byPatchSetUser(PatchSet.Id patchSet, Account.Id account) - throws OrmException { - return delegate.byPatchSetUser(patchSet, account); - } - - @Override - public ResultSet all() throws OrmException { - return delegate.all(); - } - } - - public static class ChangeMessageAccessWrapper implements ChangeMessageAccess { - protected final ChangeMessageAccess delegate; - - protected ChangeMessageAccessWrapper(ChangeMessageAccess delegate) { - this.delegate = delegate; - } - - @Override - public String getRelationName() { - return delegate.getRelationName(); - } - - @Override - public int getRelationID() { - return delegate.getRelationID(); - } - - @Override - public ResultSet iterateAllEntities() throws OrmException { - return delegate.iterateAllEntities(); - } - - @Override - public ChangeMessage.Key primaryKey(ChangeMessage entity) { - return delegate.primaryKey(entity); - } - - @Override - public Map toMap(Iterable c) { - return delegate.toMap(c); - } - - @SuppressWarnings("deprecation") - @Override - public com.google.common.util.concurrent.CheckedFuture getAsync( - ChangeMessage.Key key) { - return delegate.getAsync(key); - } - - @Override - public ResultSet get(Iterable keys) throws OrmException { - return delegate.get(keys); - } - - @Override - public void insert(Iterable instances) throws OrmException { - delegate.insert(instances); - } - - @Override - public void update(Iterable instances) throws OrmException { - delegate.update(instances); - } - - @Override - public void upsert(Iterable instances) throws OrmException { - delegate.upsert(instances); - } - - @Override - public void deleteKeys(Iterable keys) throws OrmException { - delegate.deleteKeys(keys); - } - - @Override - public void delete(Iterable instances) throws OrmException { - delegate.delete(instances); - } - - @Override - public void beginTransaction(ChangeMessage.Key key) throws OrmException { - delegate.beginTransaction(key); - } - - @Override - public ChangeMessage atomicUpdate(ChangeMessage.Key key, AtomicUpdate update) - throws OrmException { - return delegate.atomicUpdate(key, update); - } - - @Override - public ChangeMessage get(ChangeMessage.Key id) throws OrmException { - return delegate.get(id); - } - - @Override - public ResultSet byChange(Change.Id id) throws OrmException { - return delegate.byChange(id); - } - - @Override - public ResultSet byPatchSet(PatchSet.Id id) throws OrmException { - return delegate.byPatchSet(id); - } - - @Override - public ResultSet all() throws OrmException { - return delegate.all(); - } - } - - public static class PatchSetAccessWrapper implements PatchSetAccess { - protected final PatchSetAccess delegate; - - protected PatchSetAccessWrapper(PatchSetAccess delegate) { - this.delegate = delegate; - } - - @Override - public String getRelationName() { - return delegate.getRelationName(); - } - - @Override - public int getRelationID() { - return delegate.getRelationID(); - } - - @Override - public ResultSet iterateAllEntities() throws OrmException { - return delegate.iterateAllEntities(); - } - - @Override - public PatchSet.Id primaryKey(PatchSet entity) { - return delegate.primaryKey(entity); - } - - @Override - public Map toMap(Iterable c) { - return delegate.toMap(c); - } - - @SuppressWarnings("deprecation") - @Override - public com.google.common.util.concurrent.CheckedFuture getAsync( - PatchSet.Id key) { - return delegate.getAsync(key); - } - - @Override - public ResultSet get(Iterable keys) throws OrmException { - return delegate.get(keys); - } - - @Override - public void insert(Iterable instances) throws OrmException { - delegate.insert(instances); - } - - @Override - public void update(Iterable instances) throws OrmException { - delegate.update(instances); - } - - @Override - public void upsert(Iterable instances) throws OrmException { - delegate.upsert(instances); - } - - @Override - public void deleteKeys(Iterable keys) throws OrmException { - delegate.deleteKeys(keys); - } - - @Override - public void delete(Iterable instances) throws OrmException { - delegate.delete(instances); - } - - @Override - public void beginTransaction(PatchSet.Id key) throws OrmException { - delegate.beginTransaction(key); - } - - @Override - public PatchSet atomicUpdate(PatchSet.Id key, AtomicUpdate update) - throws OrmException { - return delegate.atomicUpdate(key, update); - } - - @Override - public PatchSet get(PatchSet.Id id) throws OrmException { - return delegate.get(id); - } - - @Override - public ResultSet byChange(Change.Id id) throws OrmException { - return delegate.byChange(id); - } - - @Override - public ResultSet all() throws OrmException { - return delegate.all(); - } - } - - public static class PatchLineCommentAccessWrapper implements PatchLineCommentAccess { - protected PatchLineCommentAccess delegate; - - protected PatchLineCommentAccessWrapper(PatchLineCommentAccess delegate) { - this.delegate = delegate; - } - - @Override - public String getRelationName() { - return delegate.getRelationName(); - } - - @Override - public int getRelationID() { - return delegate.getRelationID(); - } - - @Override - public ResultSet iterateAllEntities() throws OrmException { - return delegate.iterateAllEntities(); - } - - @Override - public PatchLineComment.Key primaryKey(PatchLineComment entity) { - return delegate.primaryKey(entity); - } - - @Override - public Map toMap(Iterable c) { - return delegate.toMap(c); - } - - @SuppressWarnings("deprecation") - @Override - public com.google.common.util.concurrent.CheckedFuture getAsync( - PatchLineComment.Key key) { - return delegate.getAsync(key); - } - - @Override - public ResultSet get(Iterable keys) - throws OrmException { - return delegate.get(keys); - } - - @Override - public void insert(Iterable instances) throws OrmException { - delegate.insert(instances); - } - - @Override - public void update(Iterable instances) throws OrmException { - delegate.update(instances); - } - - @Override - public void upsert(Iterable instances) throws OrmException { - delegate.upsert(instances); - } - - @Override - public void deleteKeys(Iterable keys) throws OrmException { - delegate.deleteKeys(keys); - } - - @Override - public void delete(Iterable instances) throws OrmException { - delegate.delete(instances); - } - - @Override - public void beginTransaction(PatchLineComment.Key key) throws OrmException { - delegate.beginTransaction(key); - } - - @Override - public PatchLineComment atomicUpdate( - PatchLineComment.Key key, AtomicUpdate update) throws OrmException { - return delegate.atomicUpdate(key, update); - } - - @Override - public PatchLineComment get(PatchLineComment.Key id) throws OrmException { - return delegate.get(id); - } - - @Override - public ResultSet byChange(Change.Id id) throws OrmException { - return delegate.byChange(id); - } - - @Override - public ResultSet byPatchSet(PatchSet.Id id) throws OrmException { - return delegate.byPatchSet(id); - } - - @Override - public ResultSet publishedByChangeFile(Change.Id id, String file) - throws OrmException { - return delegate.publishedByChangeFile(id, file); - } - - @Override - public ResultSet publishedByPatchSet(PatchSet.Id patchset) - throws OrmException { - return delegate.publishedByPatchSet(patchset); - } - - @Override - public ResultSet draftByPatchSetAuthor( - PatchSet.Id patchset, Account.Id author) throws OrmException { - return delegate.draftByPatchSetAuthor(patchset, author); - } - - @Override - public ResultSet draftByChangeFileAuthor( - Change.Id id, String file, Account.Id author) throws OrmException { - return delegate.draftByChangeFileAuthor(id, file, author); - } - - @Override - public ResultSet draftByAuthor(Account.Id author) throws OrmException { - return delegate.draftByAuthor(author); - } - - @Override - public ResultSet all() throws OrmException { - return delegate.all(); - } - } - - public static class AccountGroupAccessWrapper implements AccountGroupAccess { - protected final AccountGroupAccess delegate; - - protected AccountGroupAccessWrapper(AccountGroupAccess delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public String getRelationName() { - return delegate.getRelationName(); - } - - @Override - public int getRelationID() { - return delegate.getRelationID(); - } - - @Override - public ResultSet iterateAllEntities() throws OrmException { - return delegate.iterateAllEntities(); - } - - @Override - public AccountGroup.Id primaryKey(AccountGroup entity) { - return delegate.primaryKey(entity); - } - - @Override - public Map toMap(Iterable c) { - return delegate.toMap(c); - } - - @SuppressWarnings("deprecation") - @Override - public com.google.common.util.concurrent.CheckedFuture getAsync( - AccountGroup.Id key) { - return delegate.getAsync(key); - } - - @Override - public ResultSet get(Iterable keys) throws OrmException { - return delegate.get(keys); - } - - @Override - public void insert(Iterable instances) throws OrmException { - delegate.insert(instances); - } - - @Override - public void update(Iterable instances) throws OrmException { - delegate.update(instances); - } - - @Override - public void upsert(Iterable instances) throws OrmException { - delegate.upsert(instances); - } - - @Override - public void deleteKeys(Iterable keys) throws OrmException { - delegate.deleteKeys(keys); - } - - @Override - public void delete(Iterable instances) throws OrmException { - delegate.delete(instances); - } - - @Override - public void beginTransaction(AccountGroup.Id key) throws OrmException { - delegate.beginTransaction(key); - } - - @Override - public AccountGroup atomicUpdate(AccountGroup.Id key, AtomicUpdate update) - throws OrmException { - return delegate.atomicUpdate(key, update); - } - - @Override - public AccountGroup get(AccountGroup.Id id) throws OrmException { - return delegate.get(id); - } - - @Override - public ResultSet byUUID(AccountGroup.UUID uuid) throws OrmException { - return delegate.byUUID(uuid); - } - - @Override - public ResultSet all() throws OrmException { - return delegate.all(); - } - } - - public static class AccountGroupNameAccessWrapper implements AccountGroupNameAccess { - protected final AccountGroupNameAccess delegate; - - protected AccountGroupNameAccessWrapper(AccountGroupNameAccess delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public String getRelationName() { - return delegate.getRelationName(); - } - - @Override - public int getRelationID() { - return delegate.getRelationID(); - } - - @Override - public ResultSet iterateAllEntities() throws OrmException { - return delegate.iterateAllEntities(); - } - - @Override - public AccountGroup.NameKey primaryKey(AccountGroupName entity) { - return delegate.primaryKey(entity); - } - - @Override - public Map toMap(Iterable c) { - return delegate.toMap(c); - } - - @SuppressWarnings("deprecation") - @Override - public com.google.common.util.concurrent.CheckedFuture getAsync( - AccountGroup.NameKey key) { - return delegate.getAsync(key); - } - - @Override - public ResultSet get(Iterable keys) - throws OrmException { - return delegate.get(keys); - } - - @Override - public void insert(Iterable instances) throws OrmException { - delegate.insert(instances); - } - - @Override - public void update(Iterable instances) throws OrmException { - delegate.update(instances); - } - - @Override - public void upsert(Iterable instances) throws OrmException { - delegate.upsert(instances); - } - - @Override - public void deleteKeys(Iterable keys) throws OrmException { - delegate.deleteKeys(keys); - } - - @Override - public void delete(Iterable instances) throws OrmException { - delegate.delete(instances); - } - - @Override - public void beginTransaction(AccountGroup.NameKey key) throws OrmException { - delegate.beginTransaction(key); - } - - @Override - public AccountGroupName atomicUpdate( - AccountGroup.NameKey key, AtomicUpdate update) throws OrmException { - return delegate.atomicUpdate(key, update); - } - - @Override - public AccountGroupName get(AccountGroup.NameKey name) throws OrmException { - return delegate.get(name); - } - - @Override - public ResultSet all() throws OrmException { - return delegate.all(); - } - } - - public static class AccountGroupMemberAccessWrapper implements AccountGroupMemberAccess { - protected final AccountGroupMemberAccess delegate; - - protected AccountGroupMemberAccessWrapper(AccountGroupMemberAccess delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public String getRelationName() { - return delegate.getRelationName(); - } - - @Override - public int getRelationID() { - return delegate.getRelationID(); - } - - @Override - public ResultSet iterateAllEntities() throws OrmException { - return delegate.iterateAllEntities(); - } - - @Override - public AccountGroupMember.Key primaryKey(AccountGroupMember entity) { - return delegate.primaryKey(entity); - } - - @Override - public Map toMap(Iterable c) { - return delegate.toMap(c); - } - - @SuppressWarnings("deprecation") - @Override - public com.google.common.util.concurrent.CheckedFuture - getAsync(AccountGroupMember.Key key) { - return delegate.getAsync(key); - } - - @Override - public ResultSet get(Iterable keys) - throws OrmException { - return delegate.get(keys); - } - - @Override - public void insert(Iterable instances) throws OrmException { - delegate.insert(instances); - } - - @Override - public void update(Iterable instances) throws OrmException { - delegate.update(instances); - } - - @Override - public void upsert(Iterable instances) throws OrmException { - delegate.upsert(instances); - } - - @Override - public void deleteKeys(Iterable keys) throws OrmException { - delegate.deleteKeys(keys); - } - - @Override - public void delete(Iterable instances) throws OrmException { - delegate.delete(instances); - } - - @Override - public void beginTransaction(AccountGroupMember.Key key) throws OrmException { - delegate.beginTransaction(key); - } - - @Override - public AccountGroupMember atomicUpdate( - AccountGroupMember.Key key, AtomicUpdate update) throws OrmException { - return delegate.atomicUpdate(key, update); - } - - @Override - public AccountGroupMember get(AccountGroupMember.Key key) throws OrmException { - return delegate.get(key); - } - - @Override - public ResultSet byAccount(Account.Id id) throws OrmException { - return delegate.byAccount(id); - } - - @Override - public ResultSet byGroup(AccountGroup.Id id) throws OrmException { - return delegate.byGroup(id); - } - } - - public static class AccountGroupMemberAuditAccessWrapper - implements AccountGroupMemberAuditAccess { - protected final AccountGroupMemberAuditAccess delegate; - - protected AccountGroupMemberAuditAccessWrapper(AccountGroupMemberAuditAccess delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public String getRelationName() { - return delegate.getRelationName(); - } - - @Override - public int getRelationID() { - return delegate.getRelationID(); - } - - @Override - public ResultSet iterateAllEntities() throws OrmException { - return delegate.iterateAllEntities(); - } - - @Override - public AccountGroupMemberAudit.Key primaryKey(AccountGroupMemberAudit entity) { - return delegate.primaryKey(entity); - } - - @Override - public Map toMap( - Iterable c) { - return delegate.toMap(c); - } - - @SuppressWarnings("deprecation") - @Override - public com.google.common.util.concurrent.CheckedFuture - getAsync(AccountGroupMemberAudit.Key key) { - return delegate.getAsync(key); - } - - @Override - public ResultSet get(Iterable keys) - throws OrmException { - return delegate.get(keys); - } - - @Override - public void insert(Iterable instances) throws OrmException { - delegate.insert(instances); - } - - @Override - public void update(Iterable instances) throws OrmException { - delegate.update(instances); - } - - @Override - public void upsert(Iterable instances) throws OrmException { - delegate.upsert(instances); - } - - @Override - public void deleteKeys(Iterable keys) throws OrmException { - delegate.deleteKeys(keys); - } - - @Override - public void delete(Iterable instances) throws OrmException { - delegate.delete(instances); - } - - @Override - public void beginTransaction(AccountGroupMemberAudit.Key key) throws OrmException { - delegate.beginTransaction(key); - } - - @Override - public AccountGroupMemberAudit atomicUpdate( - AccountGroupMemberAudit.Key key, AtomicUpdate update) - throws OrmException { - return delegate.atomicUpdate(key, update); - } - - @Override - public AccountGroupMemberAudit get(AccountGroupMemberAudit.Key key) throws OrmException { - return delegate.get(key); - } - - @Override - public ResultSet byGroupAccount( - AccountGroup.Id groupId, Account.Id accountId) throws OrmException { - return delegate.byGroupAccount(groupId, accountId); - } - - @Override - public ResultSet byGroup(AccountGroup.Id groupId) throws OrmException { - return delegate.byGroup(groupId); - } - } - - public static class AccountGroupByIdAccessWrapper implements AccountGroupByIdAccess { - protected final AccountGroupByIdAccess delegate; - - protected AccountGroupByIdAccessWrapper(AccountGroupByIdAccess delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public String getRelationName() { - return delegate.getRelationName(); - } - - @Override - public int getRelationID() { - return delegate.getRelationID(); - } - - @Override - public ResultSet iterateAllEntities() throws OrmException { - return delegate.iterateAllEntities(); - } - - @Override - public AccountGroupById.Key primaryKey(AccountGroupById entity) { - return delegate.primaryKey(entity); - } - - @Override - public Map toMap(Iterable c) { - return delegate.toMap(c); - } - - @SuppressWarnings("deprecation") - @Override - public com.google.common.util.concurrent.CheckedFuture getAsync( - AccountGroupById.Key key) { - return delegate.getAsync(key); - } - - @Override - public ResultSet get(Iterable keys) - throws OrmException { - return delegate.get(keys); - } - - @Override - public void insert(Iterable instances) throws OrmException { - delegate.insert(instances); - } - - @Override - public void update(Iterable instances) throws OrmException { - delegate.update(instances); - } - - @Override - public void upsert(Iterable instances) throws OrmException { - delegate.upsert(instances); - } - - @Override - public void deleteKeys(Iterable keys) throws OrmException { - delegate.deleteKeys(keys); - } - - @Override - public void delete(Iterable instances) throws OrmException { - delegate.delete(instances); - } - - @Override - public void beginTransaction(AccountGroupById.Key key) throws OrmException { - delegate.beginTransaction(key); - } - - @Override - public AccountGroupById atomicUpdate( - AccountGroupById.Key key, AtomicUpdate update) throws OrmException { - return delegate.atomicUpdate(key, update); - } - - @Override - public AccountGroupById get(AccountGroupById.Key key) throws OrmException { - return delegate.get(key); - } - - @Override - public ResultSet byIncludeUUID(AccountGroup.UUID uuid) throws OrmException { - return delegate.byIncludeUUID(uuid); - } - - @Override - public ResultSet byGroup(AccountGroup.Id id) throws OrmException { - return delegate.byGroup(id); - } - - @Override - public ResultSet all() throws OrmException { - return delegate.all(); - } - } - - public static class AccountGroupByIdAudAccessWrapper implements AccountGroupByIdAudAccess { - protected final AccountGroupByIdAudAccess delegate; - - protected AccountGroupByIdAudAccessWrapper(AccountGroupByIdAudAccess delegate) { - this.delegate = requireNonNull(delegate); - } - - @Override - public String getRelationName() { - return delegate.getRelationName(); - } - - @Override - public int getRelationID() { - return delegate.getRelationID(); - } - - @Override - public ResultSet iterateAllEntities() throws OrmException { - return delegate.iterateAllEntities(); - } - - @Override - public AccountGroupByIdAud.Key primaryKey(AccountGroupByIdAud entity) { - return delegate.primaryKey(entity); - } - - @Override - public Map toMap( - Iterable c) { - return delegate.toMap(c); - } - - @SuppressWarnings("deprecation") - @Override - public com.google.common.util.concurrent.CheckedFuture - getAsync(AccountGroupByIdAud.Key key) { - return delegate.getAsync(key); - } - - @Override - public ResultSet get(Iterable keys) - throws OrmException { - return delegate.get(keys); - } - - @Override - public void insert(Iterable instances) throws OrmException { - delegate.insert(instances); - } - - @Override - public void update(Iterable instances) throws OrmException { - delegate.update(instances); - } - - @Override - public void upsert(Iterable instances) throws OrmException { - delegate.upsert(instances); - } - - @Override - public void deleteKeys(Iterable keys) throws OrmException { - delegate.deleteKeys(keys); - } - - @Override - public void delete(Iterable instances) throws OrmException { - delegate.delete(instances); - } - - @Override - public void beginTransaction(AccountGroupByIdAud.Key key) throws OrmException { - delegate.beginTransaction(key); - } - - @Override - public AccountGroupByIdAud atomicUpdate( - AccountGroupByIdAud.Key key, AtomicUpdate update) throws OrmException { - return delegate.atomicUpdate(key, update); - } - - @Override - public AccountGroupByIdAud get(AccountGroupByIdAud.Key key) throws OrmException { - return delegate.get(key); - } - - @Override - public ResultSet byGroupInclude( - AccountGroup.Id groupId, AccountGroup.UUID incGroupUUID) throws OrmException { - return delegate.byGroupInclude(groupId, incGroupUUID); - } - - @Override - public ResultSet byGroup(AccountGroup.Id groupId) throws OrmException { - return delegate.byGroup(groupId); - } - } -} diff --git a/java/com/google/gerrit/server/schema/DatabaseModule.java b/java/com/google/gerrit/server/schema/DatabaseModule.java deleted file mode 100644 index c65b20e3db..0000000000 --- a/java/com/google/gerrit/server/schema/DatabaseModule.java +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2009 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.extensions.config.FactoryModule; -import com.google.gerrit.reviewdb.server.ReviewDb; -import com.google.gwtorm.server.OrmException; -import com.google.gwtorm.server.SchemaFactory; -import com.google.inject.Key; -import com.google.inject.TypeLiteral; - -/** Loads the database with standard dependencies. */ -public class DatabaseModule extends FactoryModule { - @Override - protected void configure() { - TypeLiteral> schemaFactory = - new TypeLiteral>() {}; - bind(schemaFactory).to(NotesMigrationSchemaFactory.class); - bind(Key.get(schemaFactory, ReviewDbFactory.class)) - .toInstance( - () -> { - throw new OrmException("ReviewDb no longer exists"); - }); - } -} diff --git a/java/com/google/gerrit/server/schema/NoChangesReviewDb.java b/java/com/google/gerrit/server/schema/NoChangesReviewDb.java deleted file mode 100644 index bdb2b0dee5..0000000000 --- a/java/com/google/gerrit/server/schema/NoChangesReviewDb.java +++ /dev/null @@ -1,224 +0,0 @@ -// Copyright (C) 2017 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.common.collect.ImmutableList; -import com.google.gerrit.reviewdb.client.Account; -import com.google.gerrit.reviewdb.client.Change; -import com.google.gerrit.reviewdb.client.ChangeMessage; -import com.google.gerrit.reviewdb.client.PatchLineComment; -import com.google.gerrit.reviewdb.client.PatchSet; -import com.google.gerrit.reviewdb.client.PatchSetApproval; -import com.google.gerrit.reviewdb.server.ChangeAccess; -import com.google.gerrit.reviewdb.server.ChangeMessageAccess; -import com.google.gerrit.reviewdb.server.PatchLineCommentAccess; -import com.google.gerrit.reviewdb.server.PatchSetAccess; -import com.google.gerrit.reviewdb.server.PatchSetApprovalAccess; -import com.google.gerrit.reviewdb.server.ReviewDb; -import com.google.gwtorm.server.Access; -import com.google.gwtorm.server.ListResultSet; -import com.google.gwtorm.server.ResultSet; -import com.google.gwtorm.server.StatementExecutor; - -/** - * Wrapper for ReviewDb that never calls the underlying change tables. - * - *

See {@link NotesMigrationSchemaFactory} for discussion. - */ -class NoChangesReviewDb implements ReviewDb { - private static final String GONE = "ReviewDb is gone"; - - private static ResultSet empty() { - return new ListResultSet<>(ImmutableList.of()); - } - - private final ChangeAccess changes; - private final PatchSetApprovalAccess patchSetApprovals; - private final ChangeMessageAccess changeMessages; - private final PatchSetAccess patchSets; - private final PatchLineCommentAccess patchComments; - - NoChangesReviewDb() { - changes = new Changes(); - patchSetApprovals = new PatchSetApprovals(); - changeMessages = new ChangeMessages(); - patchSets = new PatchSets(); - patchComments = new PatchLineComments(); - } - - @Override - public ChangeAccess changes() { - return changes; - } - - @Override - public PatchSetApprovalAccess patchSetApprovals() { - return patchSetApprovals; - } - - @Override - public ChangeMessageAccess changeMessages() { - return changeMessages; - } - - @Override - public PatchSetAccess patchSets() { - return patchSets; - } - - @Override - public PatchLineCommentAccess patchComments() { - return patchComments; - } - - @Override - public int nextChangeId() { - throw new UnsupportedOperationException(GONE); - } - - @Override - public void commit() {} - - @Override - public void rollback() {} - - @Override - public void updateSchema(StatementExecutor e) { - throw new UnsupportedOperationException(GONE); - } - - @Override - public void pruneSchema(StatementExecutor e) { - throw new UnsupportedOperationException(GONE); - } - - @Override - public Access[] allRelations() { - throw new UnsupportedOperationException(GONE); - } - - @Override - public void close() {} - - private static class Changes extends AbstractDisabledAccess - implements ChangeAccess { - @Override - public ResultSet all() { - return empty(); - } - } - - private static class ChangeMessages - extends AbstractDisabledAccess - implements ChangeMessageAccess { - @Override - public ResultSet byChange(Change.Id id) { - return empty(); - } - - @Override - public ResultSet byPatchSet(PatchSet.Id id) { - return empty(); - } - - @Override - public ResultSet all() { - return empty(); - } - } - - private static class PatchSets extends AbstractDisabledAccess - implements PatchSetAccess { - @Override - public ResultSet byChange(Change.Id id) { - return empty(); - } - - @Override - public ResultSet all() { - return empty(); - } - } - - private static class PatchSetApprovals - extends AbstractDisabledAccess - implements PatchSetApprovalAccess { - @Override - public ResultSet byChange(Change.Id id) { - return empty(); - } - - @Override - public ResultSet byPatchSet(PatchSet.Id id) { - return empty(); - } - - @Override - public ResultSet byPatchSetUser(PatchSet.Id patchSet, Account.Id account) { - return empty(); - } - - @Override - public ResultSet all() { - return empty(); - } - } - - private static class PatchLineComments - extends AbstractDisabledAccess - implements PatchLineCommentAccess { - @Override - public ResultSet byChange(Change.Id id) { - return empty(); - } - - @Override - public ResultSet byPatchSet(PatchSet.Id id) { - return empty(); - } - - @Override - public ResultSet publishedByChangeFile(Change.Id id, String file) { - return empty(); - } - - @Override - public ResultSet publishedByPatchSet(PatchSet.Id patchset) { - return empty(); - } - - @Override - public ResultSet draftByPatchSetAuthor( - PatchSet.Id patchset, Account.Id author) { - return empty(); - } - - @Override - public ResultSet draftByChangeFileAuthor( - Change.Id id, String file, Account.Id author) { - return empty(); - } - - @Override - public ResultSet draftByAuthor(Account.Id author) { - return empty(); - } - - @Override - public ResultSet all() { - return empty(); - } - } -} diff --git a/java/com/google/gerrit/server/schema/NotesMigrationSchemaFactory.java b/java/com/google/gerrit/server/schema/NotesMigrationSchemaFactory.java deleted file mode 100644 index a4ae7043c2..0000000000 --- a/java/com/google/gerrit/server/schema/NotesMigrationSchemaFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2016 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.reviewdb.server.DisallowedReviewDb; -import com.google.gerrit.reviewdb.server.ReviewDb; -import com.google.gwtorm.server.OrmException; -import com.google.gwtorm.server.SchemaFactory; -import com.google.inject.Inject; -import com.google.inject.Singleton; - -@Singleton -public class NotesMigrationSchemaFactory implements SchemaFactory { - @Inject - NotesMigrationSchemaFactory() {} - - @Override - public ReviewDb open() throws OrmException { - // TODO(dborowitz): This class is purely vestigial, and documenting the historical reasons for - // this specific behavior is not worth it. Remove this class instead. - ReviewDb db = new NoChangesReviewDb(); - db = new DisallowedReviewDb(db); - return db; - } -} diff --git a/java/com/google/gerrit/server/schema/ReviewDbFactory.java b/java/com/google/gerrit/server/schema/ReviewDbFactory.java deleted file mode 100644 index 86f5d06eea..0000000000 --- a/java/com/google/gerrit/server/schema/ReviewDbFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2016 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 static java.lang.annotation.RetentionPolicy.RUNTIME; - -import com.google.inject.BindingAnnotation; -import java.lang.annotation.Retention; - -/** - * Marker on {@link com.google.gwtorm.server.SchemaFactory} implementation that talks to the - * underlying traditional {@link com.google.gerrit.reviewdb.server.ReviewDb} database. - * - *

During the migration to NoteDb, the actual {@code ReviewDb} will be a wrapper with certain - * tables enabled/disabled; this marker goes on the low-level implementation that has all tables. - */ -@Retention(RUNTIME) -@BindingAnnotation -public @interface ReviewDbFactory {} diff --git a/java/com/google/gerrit/testing/DisabledReviewDb.java b/java/com/google/gerrit/testing/DisabledReviewDb.java deleted file mode 100644 index e90474b3f5..0000000000 --- a/java/com/google/gerrit/testing/DisabledReviewDb.java +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2015 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.testing; - -import com.google.gerrit.reviewdb.server.ChangeAccess; -import com.google.gerrit.reviewdb.server.ChangeMessageAccess; -import com.google.gerrit.reviewdb.server.PatchLineCommentAccess; -import com.google.gerrit.reviewdb.server.PatchSetAccess; -import com.google.gerrit.reviewdb.server.PatchSetApprovalAccess; -import com.google.gerrit.reviewdb.server.ReviewDb; -import com.google.gwtorm.server.Access; -import com.google.gwtorm.server.StatementExecutor; - -/** ReviewDb that is disabled for testing. */ -public class DisabledReviewDb implements ReviewDb { - public static class Disabled extends RuntimeException { - private static final long serialVersionUID = 1L; - - private Disabled() { - super("ReviewDb is disabled for this test"); - } - } - - @Override - public void close() { - // Do nothing. - } - - @Override - public void commit() { - throw new Disabled(); - } - - @Override - public void rollback() { - throw new Disabled(); - } - - @Override - public void updateSchema(StatementExecutor e) { - throw new Disabled(); - } - - @Override - public void pruneSchema(StatementExecutor e) { - throw new Disabled(); - } - - @Override - public Access[] allRelations() { - throw new Disabled(); - } - - @Override - public ChangeAccess changes() { - throw new Disabled(); - } - - @Override - public PatchSetApprovalAccess patchSetApprovals() { - throw new Disabled(); - } - - @Override - public ChangeMessageAccess changeMessages() { - throw new Disabled(); - } - - @Override - public PatchSetAccess patchSets() { - throw new Disabled(); - } - - @Override - public PatchLineCommentAccess patchComments() { - throw new Disabled(); - } - - @Override - public int nextChangeId() { - throw new Disabled(); - } -} diff --git a/java/com/google/gerrit/testing/InMemoryModule.java b/java/com/google/gerrit/testing/InMemoryModule.java index 0ee0beddf8..64819bf03b 100644 --- a/java/com/google/gerrit/testing/InMemoryModule.java +++ b/java/com/google/gerrit/testing/InMemoryModule.java @@ -77,7 +77,6 @@ import com.google.gerrit.server.permissions.DefaultPermissionBackendModule; import com.google.gerrit.server.plugins.ServerInformationImpl; import com.google.gerrit.server.project.DefaultProjectNameLockManager; import com.google.gerrit.server.restapi.RestApiModule; -import com.google.gerrit.server.schema.DatabaseModule; import com.google.gerrit.server.schema.InMemoryAccountPatchReviewStore; import com.google.gerrit.server.schema.SchemaCreator; import com.google.gerrit.server.schema.SchemaCreatorImpl; @@ -187,7 +186,6 @@ public class InMemoryModule extends FactoryModule { .toInstance(MoreExecutors.newDirectExecutorService()); bind(SecureStore.class).to(DefaultSecureStore.class); - install(new DatabaseModule()); install(new InMemorySchemaModule()); install(NoSshKeyCache.module()); install(new GerritInstanceNameModule());