Disable reading from Changes table under notedb

The only places where we still want to access the Changes table is in
ChangeNotes.Factory, BatchUpdate and RebuildNoteDb. Here we need to
unwrap ReviewDb.

Change-Id: I90e6dc89825383757f7f84507eba177445483630
This commit is contained in:
Dave Borowitz
2016-02-10 17:58:05 -05:00
parent 8fba0e255e
commit 5e46d04109
4 changed files with 73 additions and 9 deletions

View File

@@ -21,6 +21,7 @@ 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;
@@ -33,6 +34,7 @@ import com.google.gwtorm.server.ResultSet;
public class DisabledChangesReviewDbWrapper extends ReviewDbWrapper {
private static final String MSG = "This table has been migrated to notedb";
private final DisabledChangeAccess changes;
private final DisabledPatchSetApprovalAccess patchSetApprovals;
private final DisabledChangeMessageAccess changeMessages;
private final DisabledPatchSetAccess patchSets;
@@ -40,6 +42,7 @@ public class DisabledChangesReviewDbWrapper extends ReviewDbWrapper {
DisabledChangesReviewDbWrapper(ReviewDb db) {
super(db);
changes = new DisabledChangeAccess(delegate.changes());
patchSetApprovals =
new DisabledPatchSetApprovalAccess(delegate.patchSetApprovals());
changeMessages = new DisabledChangeMessageAccess(delegate.changeMessages());
@@ -52,6 +55,11 @@ public class DisabledChangesReviewDbWrapper extends ReviewDbWrapper {
return delegate;
}
@Override
public ChangeAccess changes() {
return changes;
}
@Override
public PatchSetApprovalAccess patchSetApprovals() {
return patchSetApprovals;
@@ -72,6 +80,38 @@ public class DisabledChangesReviewDbWrapper extends ReviewDbWrapper {
return patchComments;
}
private static class DisabledChangeAccess extends ChangeAccessWrapper {
protected DisabledChangeAccess(ChangeAccess delegate) {
super(delegate);
}
@Override
public ResultSet<Change> iterateAllEntities() {
throw new UnsupportedOperationException(MSG);
}
@Override
public 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 DisabledPatchSetApprovalAccess
extends PatchSetApprovalAccessWrapper {
DisabledPatchSetApprovalAccess(PatchSetApprovalAccess delegate) {