So long, SchemaFactory!
Change-Id: I7ea1b2082b8b3e0e7c0af41fe8eeda1162d6add4
This commit is contained in:
@@ -27,7 +27,6 @@ import com.google.gerrit.server.config.SitePaths;
|
|||||||
import com.google.gerrit.server.config.TrackingFooters;
|
import com.google.gerrit.server.config.TrackingFooters;
|
||||||
import com.google.gerrit.server.config.TrackingFootersProvider;
|
import com.google.gerrit.server.config.TrackingFootersProvider;
|
||||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
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.ReviewDbSchemaModule;
|
||||||
import com.google.gerrit.server.schema.SchemaCreator;
|
import com.google.gerrit.server.schema.SchemaCreator;
|
||||||
import com.google.gerrit.testing.InMemoryRepositoryManager;
|
import com.google.gerrit.testing.InMemoryRepositoryManager;
|
||||||
@@ -70,7 +69,6 @@ class InMemoryTestingDatabaseModule extends LifecycleModule {
|
|||||||
|
|
||||||
bind(MetricMaker.class).to(DisabledMetricMaker.class);
|
bind(MetricMaker.class).to(DisabledMetricMaker.class);
|
||||||
|
|
||||||
install(new DatabaseModule());
|
|
||||||
listener().to(CreateSchema.class);
|
listener().to(CreateSchema.class);
|
||||||
|
|
||||||
bind(SitePaths.class);
|
bind(SitePaths.class);
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ import com.google.gerrit.server.plugins.PluginGuiceEnvironment;
|
|||||||
import com.google.gerrit.server.plugins.PluginModule;
|
import com.google.gerrit.server.plugins.PluginModule;
|
||||||
import com.google.gerrit.server.project.DefaultProjectNameLockManager;
|
import com.google.gerrit.server.project.DefaultProjectNameLockManager;
|
||||||
import com.google.gerrit.server.restapi.RestApiModule;
|
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.JdbcAccountPatchReviewStore;
|
||||||
import com.google.gerrit.server.schema.NoteDbSchemaVersionCheck;
|
import com.google.gerrit.server.schema.NoteDbSchemaVersionCheck;
|
||||||
import com.google.gerrit.server.schema.ReviewDbSchemaModule;
|
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 GerritServerConfigModule());
|
||||||
}
|
}
|
||||||
modules.add(new DatabaseModule());
|
|
||||||
modules.add(new DropWizardMetricMaker.ApiModule());
|
modules.add(new DropWizardMetricMaker.ApiModule());
|
||||||
return Guice.createInjector(PRODUCTION, modules);
|
return Guice.createInjector(PRODUCTION, modules);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import com.google.gerrit.server.config.GerritRuntime;
|
|||||||
import com.google.gerrit.server.config.GerritServerConfigModule;
|
import com.google.gerrit.server.config.GerritServerConfigModule;
|
||||||
import com.google.gerrit.server.config.SitePath;
|
import com.google.gerrit.server.config.SitePath;
|
||||||
import com.google.gerrit.server.git.GitRepositoryManagerModule;
|
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.schema.ReviewDbSchemaModule;
|
||||||
import com.google.gerrit.server.securestore.SecureStoreClassName;
|
import com.google.gerrit.server.securestore.SecureStoreClassName;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
@@ -119,7 +118,6 @@ public abstract class SiteProgram extends AbstractProgram {
|
|||||||
});
|
});
|
||||||
Injector cfgInjector = Guice.createInjector(sitePathModule, configModule);
|
Injector cfgInjector = Guice.createInjector(sitePathModule, configModule);
|
||||||
|
|
||||||
modules.add(new DatabaseModule());
|
|
||||||
modules.add(new ReviewDbSchemaModule());
|
modules.add(new ReviewDbSchemaModule());
|
||||||
modules.add(cfgInjector.getInstance(GitRepositoryManagerModule.class));
|
modules.add(cfgInjector.getInstance(GitRepositoryManagerModule.class));
|
||||||
|
|
||||||
|
|||||||
@@ -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<Change> iterateAllEntities() {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
|
||||||
public com.google.common.util.concurrent.CheckedFuture<Change, OrmException> getAsync(
|
|
||||||
Change.Id key) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<Change> get(Iterable<Change.Id> keys) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Change get(Change.Id id) throws OrmException {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<Change> all() throws OrmException {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class PatchSetApprovals extends PatchSetApprovalAccessWrapper {
|
|
||||||
PatchSetApprovals(PatchSetApprovalAccess delegate) {
|
|
||||||
super(delegate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchSetApproval> iterateAllEntities() {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
|
||||||
public com.google.common.util.concurrent.CheckedFuture<PatchSetApproval, OrmException> getAsync(
|
|
||||||
PatchSetApproval.Key key) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchSetApproval> get(Iterable<PatchSetApproval.Key> keys) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PatchSetApproval get(PatchSetApproval.Key key) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchSetApproval> byChange(Change.Id id) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchSetApproval> byPatchSet(PatchSet.Id id) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ChangeMessages extends ChangeMessageAccessWrapper {
|
|
||||||
ChangeMessages(ChangeMessageAccess delegate) {
|
|
||||||
super(delegate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<ChangeMessage> iterateAllEntities() {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
|
||||||
public com.google.common.util.concurrent.CheckedFuture<ChangeMessage, OrmException> getAsync(
|
|
||||||
ChangeMessage.Key key) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<ChangeMessage> get(Iterable<ChangeMessage.Key> keys) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChangeMessage get(ChangeMessage.Key id) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<ChangeMessage> byChange(Change.Id id) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<ChangeMessage> byPatchSet(PatchSet.Id id) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<ChangeMessage> all() {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class PatchSets extends PatchSetAccessWrapper {
|
|
||||||
PatchSets(PatchSetAccess delegate) {
|
|
||||||
super(delegate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchSet> iterateAllEntities() {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
|
||||||
public com.google.common.util.concurrent.CheckedFuture<PatchSet, OrmException> getAsync(
|
|
||||||
PatchSet.Id key) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchSet> get(Iterable<PatchSet.Id> keys) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PatchSet get(PatchSet.Id id) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchSet> byChange(Change.Id id) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class PatchLineComments extends PatchLineCommentAccessWrapper {
|
|
||||||
PatchLineComments(PatchLineCommentAccess delegate) {
|
|
||||||
super(delegate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchLineComment> iterateAllEntities() {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
|
||||||
public com.google.common.util.concurrent.CheckedFuture<PatchLineComment, OrmException> getAsync(
|
|
||||||
PatchLineComment.Key key) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchLineComment> get(Iterable<PatchLineComment.Key> keys) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PatchLineComment get(PatchLineComment.Key id) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchLineComment> byChange(Change.Id id) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchLineComment> byPatchSet(PatchSet.Id id) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchLineComment> publishedByChangeFile(Change.Id id, String file) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchLineComment> publishedByPatchSet(PatchSet.Id patchset) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchLineComment> draftByPatchSetAuthor(
|
|
||||||
PatchSet.Id patchset, Account.Id author) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchLineComment> draftByChangeFileAuthor(
|
|
||||||
Change.Id id, String file, Account.Id author) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchLineComment> draftByAuthor(Account.Id author) {
|
|
||||||
throw new UnsupportedOperationException(MSG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -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<ReviewDb>> schemaFactory =
|
|
||||||
new TypeLiteral<SchemaFactory<ReviewDb>>() {};
|
|
||||||
bind(schemaFactory).to(NotesMigrationSchemaFactory.class);
|
|
||||||
bind(Key.get(schemaFactory, ReviewDbFactory.class))
|
|
||||||
.toInstance(
|
|
||||||
() -> {
|
|
||||||
throw new OrmException("ReviewDb no longer exists");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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.
|
|
||||||
*
|
|
||||||
* <p>See {@link NotesMigrationSchemaFactory} for discussion.
|
|
||||||
*/
|
|
||||||
class NoChangesReviewDb implements ReviewDb {
|
|
||||||
private static final String GONE = "ReviewDb is gone";
|
|
||||||
|
|
||||||
private static <T> ResultSet<T> 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<Change, Change.Id>
|
|
||||||
implements ChangeAccess {
|
|
||||||
@Override
|
|
||||||
public ResultSet<Change> all() {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ChangeMessages
|
|
||||||
extends AbstractDisabledAccess<ChangeMessage, ChangeMessage.Key>
|
|
||||||
implements ChangeMessageAccess {
|
|
||||||
@Override
|
|
||||||
public ResultSet<ChangeMessage> byChange(Change.Id id) {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<ChangeMessage> byPatchSet(PatchSet.Id id) {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<ChangeMessage> all() {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class PatchSets extends AbstractDisabledAccess<PatchSet, PatchSet.Id>
|
|
||||||
implements PatchSetAccess {
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchSet> byChange(Change.Id id) {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchSet> all() {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class PatchSetApprovals
|
|
||||||
extends AbstractDisabledAccess<PatchSetApproval, PatchSetApproval.Key>
|
|
||||||
implements PatchSetApprovalAccess {
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchSetApproval> byChange(Change.Id id) {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchSetApproval> byPatchSet(PatchSet.Id id) {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchSetApproval> byPatchSetUser(PatchSet.Id patchSet, Account.Id account) {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchSetApproval> all() {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class PatchLineComments
|
|
||||||
extends AbstractDisabledAccess<PatchLineComment, PatchLineComment.Key>
|
|
||||||
implements PatchLineCommentAccess {
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchLineComment> byChange(Change.Id id) {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchLineComment> byPatchSet(PatchSet.Id id) {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchLineComment> publishedByChangeFile(Change.Id id, String file) {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchLineComment> publishedByPatchSet(PatchSet.Id patchset) {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchLineComment> draftByPatchSetAuthor(
|
|
||||||
PatchSet.Id patchset, Account.Id author) {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchLineComment> draftByChangeFileAuthor(
|
|
||||||
Change.Id id, String file, Account.Id author) {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchLineComment> draftByAuthor(Account.Id author) {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResultSet<PatchLineComment> all() {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<ReviewDb> {
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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.
|
|
||||||
*
|
|
||||||
* <p>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 {}
|
|
||||||
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -77,7 +77,6 @@ import com.google.gerrit.server.permissions.DefaultPermissionBackendModule;
|
|||||||
import com.google.gerrit.server.plugins.ServerInformationImpl;
|
import com.google.gerrit.server.plugins.ServerInformationImpl;
|
||||||
import com.google.gerrit.server.project.DefaultProjectNameLockManager;
|
import com.google.gerrit.server.project.DefaultProjectNameLockManager;
|
||||||
import com.google.gerrit.server.restapi.RestApiModule;
|
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.InMemoryAccountPatchReviewStore;
|
||||||
import com.google.gerrit.server.schema.SchemaCreator;
|
import com.google.gerrit.server.schema.SchemaCreator;
|
||||||
import com.google.gerrit.server.schema.SchemaCreatorImpl;
|
import com.google.gerrit.server.schema.SchemaCreatorImpl;
|
||||||
@@ -187,7 +186,6 @@ public class InMemoryModule extends FactoryModule {
|
|||||||
.toInstance(MoreExecutors.newDirectExecutorService());
|
.toInstance(MoreExecutors.newDirectExecutorService());
|
||||||
bind(SecureStore.class).to(DefaultSecureStore.class);
|
bind(SecureStore.class).to(DefaultSecureStore.class);
|
||||||
|
|
||||||
install(new DatabaseModule());
|
|
||||||
install(new InMemorySchemaModule());
|
install(new InMemorySchemaModule());
|
||||||
install(NoSshKeyCache.module());
|
install(NoSshKeyCache.module());
|
||||||
install(new GerritInstanceNameModule());
|
install(new GerritInstanceNameModule());
|
||||||
|
|||||||
Reference in New Issue
Block a user