Support disabling change ReviewDb table access entirely
We already had DisabledChangesReviewDbWrapper to throw an exception indicating it's a programmer error to try to read from changes tables directly. By design, it was still possible to punch through this wrapper and get access to the ReviewDb table. We need to go deeper if we really want to shut off the changes tables. Add a new config option that adds another level of wrapping to ReviewDb, which makes all operations into complete no-ops. When this option is set, there is literally no way to write to or read from the underlying database table using the ReviewDb API. The table could go away and Gerrit would still function. Change-Id: Ia23a51449217a50eeaecd9934626270739c096e0
This commit is contained in:
@@ -24,22 +24,22 @@ import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.ResultSet;
|
||||
|
||||
public class DisabledChangesReviewDbWrapper extends ReviewDbWrapper {
|
||||
public class DisallowReadFromChangesReviewDbWrapper 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;
|
||||
private final DisabledPatchLineCommentAccess patchComments;
|
||||
private final Changes changes;
|
||||
private final PatchSetApprovals patchSetApprovals;
|
||||
private final ChangeMessages changeMessages;
|
||||
private final PatchSets patchSets;
|
||||
private final PatchLineComments patchComments;
|
||||
|
||||
public DisabledChangesReviewDbWrapper(ReviewDb db) {
|
||||
public DisallowReadFromChangesReviewDbWrapper(ReviewDb db) {
|
||||
super(db);
|
||||
changes = new DisabledChangeAccess(delegate.changes());
|
||||
patchSetApprovals = new DisabledPatchSetApprovalAccess(delegate.patchSetApprovals());
|
||||
changeMessages = new DisabledChangeMessageAccess(delegate.changeMessages());
|
||||
patchSets = new DisabledPatchSetAccess(delegate.patchSets());
|
||||
patchComments = new DisabledPatchLineCommentAccess(delegate.patchComments());
|
||||
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());
|
||||
}
|
||||
|
||||
public ReviewDb unsafeGetDelegate() {
|
||||
@@ -71,9 +71,9 @@ public class DisabledChangesReviewDbWrapper extends ReviewDbWrapper {
|
||||
return patchComments;
|
||||
}
|
||||
|
||||
private static class DisabledChangeAccess extends ChangeAccessWrapper {
|
||||
private static class Changes extends ChangeAccessWrapper {
|
||||
|
||||
protected DisabledChangeAccess(ChangeAccess delegate) {
|
||||
protected Changes(ChangeAccess delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ public class DisabledChangesReviewDbWrapper extends ReviewDbWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private static class DisabledPatchSetApprovalAccess extends PatchSetApprovalAccessWrapper {
|
||||
DisabledPatchSetApprovalAccess(PatchSetApprovalAccess delegate) {
|
||||
private static class PatchSetApprovals extends PatchSetApprovalAccessWrapper {
|
||||
PatchSetApprovals(PatchSetApprovalAccess delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
@@ -139,8 +139,8 @@ public class DisabledChangesReviewDbWrapper extends ReviewDbWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private static class DisabledChangeMessageAccess extends ChangeMessageAccessWrapper {
|
||||
DisabledChangeMessageAccess(ChangeMessageAccess delegate) {
|
||||
private static class ChangeMessages extends ChangeMessageAccessWrapper {
|
||||
ChangeMessages(ChangeMessageAccess delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
@@ -180,8 +180,8 @@ public class DisabledChangesReviewDbWrapper extends ReviewDbWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private static class DisabledPatchSetAccess extends PatchSetAccessWrapper {
|
||||
DisabledPatchSetAccess(PatchSetAccess delegate) {
|
||||
private static class PatchSets extends PatchSetAccessWrapper {
|
||||
PatchSets(PatchSetAccess delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
@@ -211,8 +211,8 @@ public class DisabledChangesReviewDbWrapper extends ReviewDbWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private static class DisabledPatchLineCommentAccess extends PatchLineCommentAccessWrapper {
|
||||
DisabledPatchLineCommentAccess(PatchLineCommentAccess delegate) {
|
||||
private static class PatchLineComments extends PatchLineCommentAccessWrapper {
|
||||
PatchLineComments(PatchLineCommentAccess delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ public class ReviewDbUtil {
|
||||
}
|
||||
|
||||
public static ReviewDb unwrapDb(ReviewDb db) {
|
||||
if (db instanceof DisabledChangesReviewDbWrapper) {
|
||||
return ((DisabledChangesReviewDbWrapper) db).unsafeGetDelegate();
|
||||
if (db instanceof DisallowReadFromChangesReviewDbWrapper) {
|
||||
return ((DisallowReadFromChangesReviewDbWrapper) db).unsafeGetDelegate();
|
||||
}
|
||||
return db;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user