mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 17:27:43 +00:00
6103: Add persona tables on CR database upgrade.
This commit is contained in:
parent
dd2ceabe21
commit
837cd5110c
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Central Repository
|
||||||
|
*
|
||||||
|
* Copyright 2020 Basis Technology Corp.
|
||||||
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
|
*
|
||||||
|
* 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 org.sleuthkit.autopsy.centralrepository.datamodel;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import org.sleuthkit.datamodel.CaseDbSchemaVersionNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class updates CR schema to 1.5
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CentralRepoDbUpgrader14To15 implements CentralRepoDbUpgrader {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void upgradeSchema(CaseDbSchemaVersionNumber dbSchemaVersion, Connection connection) throws CentralRepoException, SQLException {
|
||||||
|
|
||||||
|
if (dbSchemaVersion.compareTo(new CaseDbSchemaVersionNumber(1, 5)) < 0) {
|
||||||
|
|
||||||
|
try (Statement statement = connection.createStatement();) {
|
||||||
|
CentralRepoPlatforms selectedPlatform = CentralRepoDbManager.getSavedDbChoice().getDbPlatform();
|
||||||
|
|
||||||
|
// create persona tables and insert default data
|
||||||
|
RdbmsCentralRepoFactory.createPersonaTables(statement, selectedPlatform);
|
||||||
|
RdbmsCentralRepoFactory.insertDefaultPersonaTablesContent(connection, selectedPlatform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -3787,6 +3787,9 @@ abstract class RdbmsCentralRepo implements CentralRepository {
|
|||||||
// Upgrade to 1.4
|
// Upgrade to 1.4
|
||||||
(new CentralRepoDbUpgrader13To14()).upgradeSchema(dbSchemaVersion, conn);
|
(new CentralRepoDbUpgrader13To14()).upgradeSchema(dbSchemaVersion, conn);
|
||||||
|
|
||||||
|
// Upgrade to 1.5
|
||||||
|
(new CentralRepoDbUpgrader14To15()).upgradeSchema(dbSchemaVersion, conn);
|
||||||
|
|
||||||
updateSchemaVersion(conn);
|
updateSchemaVersion(conn);
|
||||||
conn.commit();
|
conn.commit();
|
||||||
logger.log(Level.INFO, String.format("Central Repository schema updated to version %s", SOFTWARE_CR_DB_SCHEMA_VERSION));
|
logger.log(Level.INFO, String.format("Central Repository schema updated to version %s", SOFTWARE_CR_DB_SCHEMA_VERSION));
|
||||||
|
@ -169,7 +169,7 @@ public class RdbmsCentralRepoFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// create Persona tables.
|
// create Persona tables.
|
||||||
createPersonaTables(stmt);
|
createPersonaTables(stmt, selectedPlatform);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
LOGGER.log(Level.SEVERE, "Error initializing db schema.", ex); // NON-NLS
|
LOGGER.log(Level.SEVERE, "Error initializing db schema.", ex); // NON-NLS
|
||||||
return false;
|
return false;
|
||||||
@ -606,7 +606,7 @@ public class RdbmsCentralRepoFactory {
|
|||||||
*
|
*
|
||||||
* @return True if success, False otherwise.
|
* @return True if success, False otherwise.
|
||||||
*/
|
*/
|
||||||
private boolean createPersonaTables(Statement stmt) throws SQLException {
|
static boolean createPersonaTables(Statement stmt, CentralRepoPlatforms selectedPlatform) throws SQLException {
|
||||||
|
|
||||||
stmt.execute(getCreateConfidenceTableStatement(selectedPlatform));
|
stmt.execute(getCreateConfidenceTableStatement(selectedPlatform));
|
||||||
stmt.execute(getCreateExaminersTableStatement(selectedPlatform));
|
stmt.execute(getCreateExaminersTableStatement(selectedPlatform));
|
||||||
@ -806,7 +806,7 @@ public class RdbmsCentralRepoFactory {
|
|||||||
*
|
*
|
||||||
* @return True if success, false otherwise.
|
* @return True if success, false otherwise.
|
||||||
*/
|
*/
|
||||||
private static boolean insertDefaultPersonaTablesContent(Connection conn, CentralRepoPlatforms selectedPlatform) {
|
static boolean insertDefaultPersonaTablesContent(Connection conn, CentralRepoPlatforms selectedPlatform) {
|
||||||
|
|
||||||
try (Statement stmt = conn.createStatement()) {
|
try (Statement stmt = conn.createStatement()) {
|
||||||
// populate the confidence table
|
// populate the confidence table
|
||||||
|
Loading…
x
Reference in New Issue
Block a user