Search in sources :

Example 6 with SQLiteDB

use of com.djrapitops.plan.storage.database.SQLiteDB in project Plan by plan-player-analytics.

the class DatabaseCommands method performRestore.

public void performRestore(CMDSender sender, File backupDBFile, Database toDB) {
    try {
        SQLiteDB fromDB = sqliteFactory.usingFile(backupDBFile);
        fromDB.init();
        sender.send(locale.getString(CommandLang.DB_WRITE, toDB.getType().getName()));
        toDB.executeTransaction(new BackupCopyTransaction(fromDB, toDB)).get();
        sender.send(locale.getString(CommandLang.PROGRESS_SUCCESS));
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    } catch (DBOpException | ExecutionException e) {
        errorLogger.error(e, ErrorContext.builder().related(backupDBFile, toDB.getType(), toDB.getState()).build());
        sender.send(locale.getString(CommandLang.PROGRESS_FAIL, e.getMessage()));
    }
}
Also used : DBOpException(com.djrapitops.plan.exceptions.database.DBOpException) SQLiteDB(com.djrapitops.plan.storage.database.SQLiteDB) BackupCopyTransaction(com.djrapitops.plan.storage.database.transactions.BackupCopyTransaction) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

SQLiteDB (com.djrapitops.plan.storage.database.SQLiteDB)6 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)4 Test (org.junit.jupiter.api.Test)4 PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)3 DBSystem (com.djrapitops.plan.storage.database.DBSystem)3 BackupCopyTransaction (com.djrapitops.plan.storage.database.transactions.BackupCopyTransaction)2 File (java.io.File)2 EnableException (com.djrapitops.plan.exceptions.EnableException)1 DBOpException (com.djrapitops.plan.exceptions.database.DBOpException)1 Database (com.djrapitops.plan.storage.database.Database)1 ExecutionException (java.util.concurrent.ExecutionException)1 VelocityMockComponent (utilities.mocks.VelocityMockComponent)1