blob: bef53639347334b07a6186c3f23a0f987f9d0e65 [file] [log] [blame]
// Copyright (C) 2018 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.ericsson.gerrit.plugins.highavailability.index;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.notedb.NotesMigration;
import com.google.gwtorm.server.OrmException;
import com.google.gwtorm.server.SchemaFactory;
import com.google.inject.Inject;
public class ChangeDb {
private static final DisabledReviewDb disabledReviewDb = new DisabledReviewDb();
private final NotesMigration migration;
private final SchemaFactory<ReviewDb> schemaFactory;
@Inject
public ChangeDb(NotesMigration migration, SchemaFactory<ReviewDb> schemaFactory) {
this.migration = migration;
this.schemaFactory = schemaFactory;
}
public ReviewDb open() throws OrmException {
return migration.readChanges() ? disabledReviewDb : schemaFactory.open();
}
}