From 31afc162b11772f013f2306fbd052b11623c7ae8 Mon Sep 17 00:00:00 2001 From: Ann Priestman Date: Fri, 11 Aug 2017 12:52:45 -0400 Subject: [PATCH] Make sure the case and datasource are in the central repo when tagging artifacts --- .../datamodel/AbstractSqlEamDb.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CentralRepository/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java b/CentralRepository/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java index 2fa17e42d8..e6fa8730a7 100644 --- a/CentralRepository/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java +++ b/CentralRepository/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java @@ -1095,6 +1095,20 @@ public abstract class AbstractSqlEamDb implements EamDb { preparedUpdate.executeUpdate(); } else { + // In this case, the user is tagging something that isn't in the database, + // which means the case and/or datasource may also not be in the database. + // We could improve effiency by keeping a list of all datasources and cases + // in the database, but we don't expect the user to be tagging large numbers + // of items (that didn't have the CE ingest module run on them) at once. + + if(null == getCaseDetails(eamInstance.getEamCase().getCaseUUID())){ + newCase(eamInstance.getEamCase()); + } + + if (null == getDataSourceDetails(eamInstance.getEamDataSource().getDeviceID())) { + newDataSource(eamInstance.getEamDataSource()); + } + eamArtifact.getInstances().get(0).setKnownStatus(TskData.FileKnown.BAD); addArtifact(eamArtifact); }