mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 09:17:42 +00:00
Finished updating settings code
This commit is contained in:
parent
82cb5fa8e3
commit
2305664e11
@ -237,7 +237,7 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
return new HashDb(handle, info.getHashSetName(), info.getSearchDuringIngest(), info.getSendIngestMessages(),
|
return new HashDb(handle, info.getHashSetName(), info.getSearchDuringIngest(), info.getSendIngestMessages(),
|
||||||
info.getKnownFilesType());
|
info.getKnownFilesType());
|
||||||
} else if(info.isCentralRepoDatabaseType()){
|
} else if(info.isCentralRepoDatabaseType()){
|
||||||
throw new TskCoreException("Not done");
|
throw new TskCoreException("Not implemented yet");
|
||||||
}
|
}
|
||||||
throw new TskCoreException("Invalid database type in HashDbInfo");
|
throw new TskCoreException("Invalid database type in HashDbInfo");
|
||||||
}
|
}
|
||||||
@ -780,15 +780,7 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatabaseType getDatabaseType(){
|
public DatabaseType getDatabaseType(){
|
||||||
if(this instanceof HashDb){
|
return DatabaseType.FILE;
|
||||||
return DatabaseType.FILE;
|
|
||||||
} else {
|
|
||||||
return DatabaseType.CENTRAL_REPOSITORY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasIndexFile() {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -988,12 +980,6 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
if (!Objects.equals(this.hashSetName, other.hashSetName)) {
|
if (!Objects.equals(this.hashSetName, other.hashSetName)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.searchDuringIngest != other.searchDuringIngest) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.sendIngestMessages != other.sendIngestMessages) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.knownFilesType != other.knownFilesType) {
|
if (this.knownFilesType != other.knownFilesType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -60,20 +60,9 @@ public class HashLookupModuleFactory extends IngestModuleFactoryAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public IngestModuleIngestJobSettings getDefaultIngestJobSettings() {
|
public IngestModuleIngestJobSettings getDefaultIngestJobSettings() {
|
||||||
// All available hash sets are enabled and always calculate hashes is true by default.
|
// All available hash sets are enabled and always calculate hashes is true by default.
|
||||||
//HashDbManager hashDbManager = HashDbManager.getInstance();
|
|
||||||
//List<String> knownHashSetNames = getHashSetNames(hashDbManager.getKnownFileHashSets());
|
|
||||||
//List<String> knownBadHashSetNames = getHashSetNames(hashDbManager.getKnownBadFileHashSets());
|
|
||||||
return new HashLookupModuleSettings(true, HashDbManager.getInstance().getAllHashSetsNew());
|
return new HashLookupModuleSettings(true, HashDbManager.getInstance().getAllHashSetsNew());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getHashSetNames(List<HashDbManager.HashDb> hashDbs) {
|
|
||||||
List<String> hashSetNames = new ArrayList<>();
|
|
||||||
for (HashDbManager.HashDb db : hashDbs) {
|
|
||||||
hashSetNames.add(db.getHashSetName());
|
|
||||||
}
|
|
||||||
return hashSetNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasIngestJobSettingsPanel() {
|
public boolean hasIngestJobSettingsPanel() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -24,8 +24,10 @@ import java.util.List;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings;
|
import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings;
|
||||||
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDatabase;
|
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDatabase;
|
||||||
|
import org.sleuthkit.autopsy.modules.hashdatabase.HashLookupSettings.HashDbInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ingest job settings for the hash lookup module.
|
* Ingest job settings for the hash lookup module.
|
||||||
@ -33,12 +35,12 @@ import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDatabase;
|
|||||||
final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private HashSet<String> namesOfEnabledKnownHashSets;
|
private HashSet<String> namesOfEnabledKnownHashSets; // The four lists of hash set names are only used for upgrading
|
||||||
private HashSet<String> namesOfDisabledKnownHashSets; // Added in version 1.1
|
private HashSet<String> namesOfDisabledKnownHashSets; // from older settings files. All data should be stored in
|
||||||
private HashSet<String> namesOfEnabledKnownBadHashSets;
|
private HashSet<String> namesOfEnabledKnownBadHashSets; // the databaseInfoList list.
|
||||||
private HashSet<String> namesOfDisabledKnownBadHashSets; // Added in version 1.1
|
private HashSet<String> namesOfDisabledKnownBadHashSets;
|
||||||
private boolean shouldCalculateHashes = true;
|
private boolean shouldCalculateHashes = true;
|
||||||
private List<HashLookupSettings.HashDbInfo> databaseInfoList;
|
private List<HashDbInfo> databaseInfoList;
|
||||||
|
|
||||||
HashLookupModuleSettings(boolean shouldCalculateHashes, List<HashDatabase> hashDbList){
|
HashLookupModuleSettings(boolean shouldCalculateHashes, List<HashDatabase> hashDbList){
|
||||||
this.shouldCalculateHashes = shouldCalculateHashes;
|
this.shouldCalculateHashes = shouldCalculateHashes;
|
||||||
@ -52,7 +54,7 @@ final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This overrides the default deserialization code so we can
|
* This overrides the default deserialization code so we can
|
||||||
* copy the enabled/disabled status into the DatabaseType objects
|
* copy the enabled/disabled status into the DatabaseType objects.
|
||||||
* @param stream
|
* @param stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
@ -69,24 +71,34 @@ final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
|||||||
*
|
*
|
||||||
* @param shouldCalculateHashes Whether or not hashes should be
|
* @param shouldCalculateHashes Whether or not hashes should be
|
||||||
* calculated.
|
* calculated.
|
||||||
* @param namesOfEnabledKnownHashSets A list of enabled known hash sets.
|
* @param enabledHashSets A list of enabled hash sets.
|
||||||
* @param namesOfEnabledKnownBadHashSets A list of enabled notable hash
|
* @param disabledHashSets A list of disabled hash sets.
|
||||||
* sets.
|
|
||||||
* @param namesOfDisabledKnownHashSets A list of disabled known hash
|
|
||||||
* sets.
|
|
||||||
* @param namesOfDisabledKnownBadHashSets A list of disabled notable hash
|
|
||||||
* sets.
|
|
||||||
*/
|
*/
|
||||||
HashLookupModuleSettings(boolean shouldCalculateHashes,
|
HashLookupModuleSettings(boolean shouldCalculateHashes,
|
||||||
List<String> namesOfEnabledKnownHashSets,
|
List<HashDatabase> enabledHashSets,
|
||||||
List<String> namesOfEnabledKnownBadHashSets,
|
List<HashDatabase> disabledHashSets) {
|
||||||
List<String> namesOfDisabledKnownHashSets,
|
|
||||||
List<String> namesOfDisabledKnownBadHashSets) {
|
|
||||||
this.shouldCalculateHashes = shouldCalculateHashes;
|
this.shouldCalculateHashes = shouldCalculateHashes;
|
||||||
this.namesOfEnabledKnownHashSets = new HashSet<>(namesOfEnabledKnownHashSets);
|
|
||||||
this.namesOfEnabledKnownBadHashSets = new HashSet<>(namesOfEnabledKnownBadHashSets);
|
databaseInfoList = new ArrayList<>();
|
||||||
this.namesOfDisabledKnownHashSets = new HashSet<>(namesOfDisabledKnownHashSets);
|
for(HashDatabase db:enabledHashSets){
|
||||||
this.namesOfDisabledKnownBadHashSets = new HashSet<>(namesOfDisabledKnownBadHashSets);
|
try{
|
||||||
|
HashDbInfo dbInfo = new HashDbInfo(db);
|
||||||
|
dbInfo.setSearchDuringIngest(true);
|
||||||
|
databaseInfoList.add(dbInfo);
|
||||||
|
} catch (TskCoreException ex){
|
||||||
|
Logger.getLogger(HashLookupModuleSettings.class.getName()).log(Level.SEVERE, "Error creating hash database settings for " + db.getHashSetName(), ex); //NON-NLS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(HashDatabase db:disabledHashSets){
|
||||||
|
try{
|
||||||
|
HashDbInfo dbInfo = new HashDbInfo(db);
|
||||||
|
dbInfo.setSearchDuringIngest(false);
|
||||||
|
databaseInfoList.add(dbInfo);
|
||||||
|
} catch (TskCoreException ex){
|
||||||
|
Logger.getLogger(HashLookupModuleSettings.class.getName()).log(Level.SEVERE, "Error creating hash database settings for " + db.getHashSetName(), ex); //NON-NLS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,7 +106,6 @@ final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public long getVersionNumber() {
|
public long getVersionNumber() {
|
||||||
this.upgradeFromOlderVersions();
|
|
||||||
return HashLookupModuleSettings.serialVersionUID;
|
return HashLookupModuleSettings.serialVersionUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +116,6 @@ final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
|||||||
* @return True if hashes are to be calculated, false otherwise.
|
* @return True if hashes are to be calculated, false otherwise.
|
||||||
*/
|
*/
|
||||||
boolean shouldCalculateHashes() {
|
boolean shouldCalculateHashes() {
|
||||||
this.upgradeFromOlderVersions();
|
|
||||||
return this.shouldCalculateHashes;
|
return this.shouldCalculateHashes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,50 +128,14 @@ final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
|||||||
* @return True if the hash set is enabled, false otherwise.
|
* @return True if the hash set is enabled, false otherwise.
|
||||||
*/
|
*/
|
||||||
boolean isHashSetEnabled(HashDatabase db) {
|
boolean isHashSetEnabled(HashDatabase db) {
|
||||||
//this.upgradeFromOlderVersions();
|
for(HashDbInfo dbInfo:databaseInfoList){
|
||||||
// TEMP TEMP TEMP TEMP
|
if(dbInfo.matches(db)){
|
||||||
return db.getSearchDuringIngest();
|
return dbInfo.getSearchDuringIngest();
|
||||||
//return !(this.namesOfDisabledKnownHashSets.contains(hashSetName) || this.namesOfDisabledKnownBadHashSets.contains(hashSetName));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// We didn't find it, so return true
|
||||||
* Get the names of all explicitly enabled known files hash sets.
|
return true;
|
||||||
*
|
|
||||||
* @return The list of names.
|
|
||||||
*/
|
|
||||||
List<String> getNamesOfEnabledKnownHashSets() {
|
|
||||||
this.upgradeFromOlderVersions();
|
|
||||||
return new ArrayList<>(this.namesOfEnabledKnownHashSets);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the names of all explicitly disabled known files hash sets.
|
|
||||||
*
|
|
||||||
* @return The list of names.
|
|
||||||
*/
|
|
||||||
List<String> getNamesOfDisabledKnownHashSets() {
|
|
||||||
this.upgradeFromOlderVersions();
|
|
||||||
return new ArrayList<>(namesOfDisabledKnownHashSets);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the names of all explicitly enabled notable files hash sets.
|
|
||||||
*
|
|
||||||
* @return The list of names.
|
|
||||||
*/
|
|
||||||
List<String> getNamesOfEnabledKnownBadHashSets() {
|
|
||||||
this.upgradeFromOlderVersions();
|
|
||||||
return new ArrayList<>(this.namesOfEnabledKnownBadHashSets);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the names of all explicitly disabled notable files hash sets.
|
|
||||||
*
|
|
||||||
* @return The list of names.
|
|
||||||
*/
|
|
||||||
List<String> getNamesOfDisabledKnownBadHashSets() {
|
|
||||||
this.upgradeFromOlderVersions();
|
|
||||||
return new ArrayList<>(this.namesOfDisabledKnownBadHashSets);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -169,10 +143,8 @@ final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
|||||||
* compatible, version of this class is de-serialized.
|
* compatible, version of this class is de-serialized.
|
||||||
*/
|
*/
|
||||||
private void upgradeFromOlderVersions() {
|
private void upgradeFromOlderVersions() {
|
||||||
System.out.println("upgradeFromOlderVersions");
|
|
||||||
|
|
||||||
if(databaseInfoList != null){
|
if(databaseInfoList != null){
|
||||||
System.out.println(" No upgrade needed");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +164,7 @@ final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(HashLookupSettings.HashDbInfo db:databaseInfoList){
|
for(HashLookupSettings.HashDbInfo db:databaseInfoList){
|
||||||
if(disabledHashSetNames.contains(db.getHashSetName())){
|
if(db.isFileDatabaseType() && disabledHashSetNames.contains(db.getHashSetName())){
|
||||||
db.setSearchDuringIngest(false);
|
db.setSearchDuringIngest(false);
|
||||||
} else {
|
} else {
|
||||||
db.setSearchDuringIngest(true);
|
db.setSearchDuringIngest(true);
|
||||||
|
@ -21,9 +21,7 @@ package org.sleuthkit.autopsy.modules.hashdatabase;
|
|||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
@ -102,23 +100,20 @@ public final class HashLookupModuleSettingsPanel extends IngestModuleIngestJobSe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IngestModuleIngestJobSettings getSettings() {
|
public IngestModuleIngestJobSettings getSettings() {
|
||||||
List<String> enabledKnownHashSetNames = new ArrayList<>();
|
List<HashDatabase> enabledHashSets = new ArrayList<>();
|
||||||
List<String> disabledKnownHashSetNames = new ArrayList<>();
|
List<HashDatabase> disabledHashSets = new ArrayList<>();
|
||||||
List<String> enabledKnownBadHashSetNames = new ArrayList<>();
|
addHashSets(knownHashSetModels, enabledHashSets, disabledHashSets);
|
||||||
List<String> disabledKnownBadHashSetNames = new ArrayList<>();
|
addHashSets(knownBadHashSetModels, enabledHashSets, disabledHashSets);
|
||||||
getHashSetNames(knownHashSetModels, enabledKnownHashSetNames, disabledKnownHashSetNames);
|
|
||||||
getHashSetNames(knownBadHashSetModels, enabledKnownBadHashSetNames, disabledKnownBadHashSetNames);
|
|
||||||
return new HashLookupModuleSettings(alwaysCalcHashesCheckbox.isSelected(),
|
return new HashLookupModuleSettings(alwaysCalcHashesCheckbox.isSelected(),
|
||||||
enabledKnownHashSetNames, enabledKnownBadHashSetNames,
|
enabledHashSets, disabledHashSets);
|
||||||
disabledKnownHashSetNames, disabledKnownBadHashSetNames);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getHashSetNames(List<HashSetModel> hashSetModels, List<String> enabledHashSetNames, List<String> disabledHashSetNames) {
|
private void addHashSets(List<HashSetModel> hashSetModels, List<HashDatabase> enabledHashSets, List<HashDatabase> disabledHashSets) {
|
||||||
for (HashSetModel model : hashSetModels) {
|
for (HashSetModel model : hashSetModels) {
|
||||||
if (model.isEnabled() && model.isValid()) {
|
if (model.isEnabled() && model.isValid()) {
|
||||||
enabledHashSetNames.add(model.getName());
|
enabledHashSets.add(model.getDatabase());
|
||||||
} else {
|
} else {
|
||||||
disabledHashSetNames.add(model.getName());
|
disabledHashSets.add(model.getDatabase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,17 +131,21 @@ public final class HashLookupModuleSettingsPanel extends IngestModuleIngestJobSe
|
|||||||
|
|
||||||
void updateHashSetModels(List<HashDatabase> hashDbs, List<HashSetModel> hashSetModels) {
|
void updateHashSetModels(List<HashDatabase> hashDbs, List<HashSetModel> hashSetModels) {
|
||||||
|
|
||||||
// TEMP TEMP SKIP TEMP
|
List<HashDatabase> hashDatabases = new ArrayList<>(hashDbs);
|
||||||
/*
|
|
||||||
// Update the hash sets and detect deletions.
|
// Update the hash sets and detect deletions.
|
||||||
List<HashSetModel> deletedHashSetModels = new ArrayList<>();
|
List<HashSetModel> deletedHashSetModels = new ArrayList<>();
|
||||||
for (HashSetModel model : hashSetModels) {
|
for (HashSetModel model : hashSetModels) {
|
||||||
String hashSetName = model.getName();
|
boolean foundDatabase = false;
|
||||||
if (hashSetDbs.containsKey(hashSetName)) {
|
for(HashDatabase db : hashDatabases){
|
||||||
HashDb db = hashSetDbs.get(hashSetName);
|
if(model.getDatabase().equals(db)){
|
||||||
model.setIndexed(isHashDbValid(db));
|
model.setValid(isHashDbValid(db));
|
||||||
hashSetDbs.remove(hashSetName);
|
hashDatabases.remove(db);
|
||||||
} else {
|
foundDatabase = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(! foundDatabase){
|
||||||
deletedHashSetModels.add(model);
|
deletedHashSetModels.add(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,10 +156,9 @@ public final class HashLookupModuleSettingsPanel extends IngestModuleIngestJobSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add any new hash sets. All new sets are enabled by default.
|
// Add any new hash sets. All new sets are enabled by default.
|
||||||
for (HashDb db : hashSetDbs.values()) {
|
for (HashDatabase db : hashDatabases) {
|
||||||
String name = db.getHashSetName();
|
hashSetModels.add(new HashSetModel(db, true, isHashDbValid(db)));
|
||||||
hashSetModels.add(new HashSetModel(name, true, isHashDbValid(db)));
|
}
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset(HashLookupModuleSettings newSettings) {
|
void reset(HashLookupModuleSettings newSettings) {
|
||||||
|
@ -25,6 +25,7 @@ import java.io.IOException;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
@ -35,6 +36,7 @@ import org.sleuthkit.autopsy.core.RuntimeProperties;
|
|||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.autopsy.coreutils.PlatformUtil;
|
import org.sleuthkit.autopsy.coreutils.PlatformUtil;
|
||||||
import org.sleuthkit.autopsy.coreutils.XMLUtil;
|
import org.sleuthkit.autopsy.coreutils.XMLUtil;
|
||||||
|
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDatabase;
|
||||||
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDatabase.DatabaseType;
|
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDatabase.DatabaseType;
|
||||||
import org.sleuthkit.datamodel.TskCoreException;
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
@ -434,6 +436,74 @@ final class HashLookupSettings implements Serializable {
|
|||||||
return dbType == DatabaseType.CENTRAL_REPOSITORY;
|
return dbType == DatabaseType.CENTRAL_REPOSITORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean matches(HashDatabase hashDb){
|
||||||
|
if(hashDb == null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ! this.knownFilesType.equals(hashDb.getKnownFilesType())){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ! this.dbType.equals(hashDb.getDatabaseType())){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ! this.hashSetName.equals(hashDb.getHashSetName())){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.dbType.equals(DatabaseType.FILE)){
|
||||||
|
// FILE types will always have unique names, so no more testing required
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO TODO central repo check
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final HashDbInfo other = (HashDbInfo) obj;
|
||||||
|
|
||||||
|
if(! this.dbType.equals(other.dbType)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.dbType.equals(DatabaseType.FILE)){
|
||||||
|
// For files, we expect the name and known type to match
|
||||||
|
return (this.hashSetName.equals(other.hashSetName)
|
||||||
|
&& this.knownFilesType.equals(other.knownFilesType));
|
||||||
|
} else {
|
||||||
|
// For central repo, the name, index, and known files type should match
|
||||||
|
return (this.hashSetName.equals(other.hashSetName)
|
||||||
|
&& (this.centralRepoIndex == other.centralRepoIndex)
|
||||||
|
&& this.knownFilesType.equals(other.knownFilesType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int hash = 5;
|
||||||
|
hash = 89 * hash + Objects.hashCode(this.hashSetName);
|
||||||
|
hash = 89 * hash + Objects.hashCode(this.knownFilesType);
|
||||||
|
hash = 89 * hash + Objects.hashCode(this.dbType);
|
||||||
|
if(this.dbType.equals(DatabaseType.CENTRAL_REPOSITORY)){
|
||||||
|
hash = 89 * hash + this.centralRepoIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This overrides the default deserialization code so we can
|
* This overrides the default deserialization code so we can
|
||||||
* properly set the dbType enum and other new fields
|
* properly set the dbType enum and other new fields
|
||||||
|
@ -392,6 +392,11 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void selectRowByDatabase(HashDatabase db){
|
||||||
|
setSelection(hashSetTableModel.getIndexByDatabase(db));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void selectRowByName(String name) {
|
public void selectRowByName(String name) {
|
||||||
setSelection(hashSetTableModel.getIndexByName(name));
|
setSelection(hashSetTableModel.getIndexByName(name));
|
||||||
}
|
}
|
||||||
@ -458,6 +463,16 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getIndexByDatabase(HashDatabase db){
|
||||||
|
for (int i = 0; i < hashSets.size(); ++i) {
|
||||||
|
if (hashSets.get(i).equals(db)) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
int getIndexByName(String name) {
|
int getIndexByName(String name) {
|
||||||
for (int i = 0; i < hashSets.size(); ++i) {
|
for (int i = 0; i < hashSets.size(); ++i) {
|
||||||
if (hashSets.get(i).getHashSetName().equals(name)) {
|
if (hashSets.get(i).getHashSetName().equals(name)) {
|
||||||
@ -797,7 +812,7 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
|||||||
HashDatabase hashDb = new HashDbCreateDatabaseDialog().getHashDatabase();
|
HashDatabase hashDb = new HashDbCreateDatabaseDialog().getHashDatabase();
|
||||||
if (null != hashDb) {
|
if (null != hashDb) {
|
||||||
hashSetTableModel.refreshModel();
|
hashSetTableModel.refreshModel();
|
||||||
((HashSetTable) hashSetTable).selectRowByName(hashDb.getHashSetName());
|
((HashSetTable) hashSetTable).selectRowByDatabase(hashDb);
|
||||||
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_createDatabaseButtonActionPerformed
|
}//GEN-LAST:event_createDatabaseButtonActionPerformed
|
||||||
@ -844,7 +859,7 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
|||||||
HashDatabase hashDb = new HashDbImportDatabaseDialog().getHashDatabase();
|
HashDatabase hashDb = new HashDbImportDatabaseDialog().getHashDatabase();
|
||||||
if (null != hashDb) {
|
if (null != hashDb) {
|
||||||
hashSetTableModel.refreshModel();
|
hashSetTableModel.refreshModel();
|
||||||
((HashSetTable) hashSetTable).selectRowByName(hashDb.getHashSetName());
|
((HashSetTable) hashSetTable).selectRowByDatabase(hashDb);
|
||||||
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_importDatabaseButtonActionPerformed
|
}//GEN-LAST:event_importDatabaseButtonActionPerformed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user