Updated ModuleDataEvent to reflect the use of ArtifactTypeID, used new methods in ModuleDataEvent anywhere relevant, i.e. wherever the ArifactType was used in other classes that used ModuleDataEvent.

This commit is contained in:
Oliver Spohngellert 2016-01-08 11:52:50 -05:00
parent 4d7c9a7635
commit edd842500b
7 changed files with 63 additions and 24 deletions

View File

@ -226,7 +226,7 @@ public class EmailExtracted implements AutopsyVisitableItem {
* for the event to have a null oldValue. * for the event to have a null oldValue.
*/ */
ModuleDataEvent eventData = (ModuleDataEvent) evt.getOldValue(); ModuleDataEvent eventData = (ModuleDataEvent) evt.getOldValue();
if (null != eventData && eventData.getArtifactType() == BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG) { if (null != eventData && eventData.getArtifactTypeId() == BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()) {
emailResults.update(); emailResults.update();
} }
} catch (IllegalStateException notUsed) { } catch (IllegalStateException notUsed) {

View File

@ -164,9 +164,17 @@ public class ExtractedContent implements AutopsyVisitableItem {
* the event is a remote event. * the event is a remote event.
*/ */
final ModuleDataEvent event = (ModuleDataEvent) evt.getOldValue(); final ModuleDataEvent event = (ModuleDataEvent) evt.getOldValue();
if (null != event && doNotShow.contains(event.getArtifactType()) == false) { if (null != event) {
boolean passed = true;
for(BlackboardArtifact.ARTIFACT_TYPE type: doNotShow) {
if(type.getTypeID() == event.getArtifactTypeId()) {
passed = false;
}
}
if(passed) {
refresh(true); refresh(true);
} }
}
} catch (IllegalStateException notUsed) { } catch (IllegalStateException notUsed) {
/** /**
* Case is closed, do nothing. * Case is closed, do nothing.
@ -416,7 +424,7 @@ public class ExtractedContent implements AutopsyVisitableItem {
* for the event to have a null oldValue. * for the event to have a null oldValue.
*/ */
final ModuleDataEvent event = (ModuleDataEvent) evt.getOldValue(); final ModuleDataEvent event = (ModuleDataEvent) evt.getOldValue();
if (null != event && event.getArtifactType() == type) { if (null != event && event.getArtifactTypeId() == type.getTypeID()) {
refresh(true); refresh(true);
} }
} catch (IllegalStateException notUsed) { } catch (IllegalStateException notUsed) {

View File

@ -204,7 +204,7 @@ public class HashsetHits implements AutopsyVisitableItem {
* oldValue if the event is a remote event. * oldValue if the event is a remote event.
*/ */
ModuleDataEvent eventData = (ModuleDataEvent) evt.getOldValue(); ModuleDataEvent eventData = (ModuleDataEvent) evt.getOldValue();
if (null != eventData && eventData.getArtifactType() == ARTIFACT_TYPE.TSK_HASHSET_HIT) { if (null != eventData && eventData.getArtifactTypeId() == ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()) {
hashsetResults.update(); hashsetResults.update();
} }
} catch (IllegalStateException notUsed) { } catch (IllegalStateException notUsed) {

View File

@ -195,8 +195,8 @@ public class InterestingHits implements AutopsyVisitableItem {
* for the event to have a null oldValue. * for the event to have a null oldValue.
*/ */
ModuleDataEvent eventData = (ModuleDataEvent) evt.getOldValue(); ModuleDataEvent eventData = (ModuleDataEvent) evt.getOldValue();
if (null != eventData && (eventData.getArtifactType() == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT if (null != eventData && (eventData.getArtifactTypeId() == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()
|| eventData.getArtifactType() == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT)) { || eventData.getArtifactTypeId() == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT.getTypeID())) {
interestingResults.update(); interestingResults.update();
} }
} catch (IllegalStateException notUsed) { } catch (IllegalStateException notUsed) {

View File

@ -268,7 +268,7 @@ public class KeywordHits implements AutopsyVisitableItem {
* for the event to have a null oldValue. * for the event to have a null oldValue.
*/ */
ModuleDataEvent eventData = (ModuleDataEvent) evt.getOldValue(); ModuleDataEvent eventData = (ModuleDataEvent) evt.getOldValue();
if (null != eventData && eventData.getArtifactType() == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT) { if (null != eventData && eventData.getArtifactTypeId() == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
keywordResults.update(); keywordResults.update();
} }
} catch (IllegalStateException notUsed) { } catch (IllegalStateException notUsed) {

View File

@ -50,7 +50,8 @@ public class ModuleDataEvent extends ChangeEvent {
private String moduleName; private String moduleName;
private ARTIFACT_TYPE artifactType; private ARTIFACT_TYPE artifactType;
private Collection<BlackboardArtifact> artifactIDs; private int artifactTypeId;
private Collection<BlackboardArtifact> artifacts;
/** /**
* @param moduleName Module name * @param moduleName Module name
@ -58,19 +59,49 @@ public class ModuleDataEvent extends ChangeEvent {
*/ */
public ModuleDataEvent(String moduleName, ARTIFACT_TYPE artifactType) { public ModuleDataEvent(String moduleName, ARTIFACT_TYPE artifactType) {
super(artifactType); super(artifactType);
this.artifactTypeId = artifactType.getTypeID();
this.moduleName = moduleName; this.moduleName = moduleName;
this.artifactType = artifactType; this.artifactType = artifactType;
} }
/** /**
* @param moduleName Module name * @param moduleName Module name
* @param artifactType Type of artifact that was posted to blackboard * @param artifactTypeId ID of the type of artifact posted to the blackboard
* @param artifactIDs List of specific artifact ID values that were added
* to blackboard
*/ */
public ModuleDataEvent(String moduleName, ARTIFACT_TYPE artifactType, Collection<BlackboardArtifact> artifactIDs) { public ModuleDataEvent(String moduleName, int artifactTypeId) {
super(ARTIFACT_TYPE.fromID(artifactTypeId));
this.artifactTypeId = artifactTypeId;
this.moduleName = moduleName;
}
/**
* @param moduleName Module name
* @param artifactTypeId ID of the type of artifact posted to the blackboard
* @param artifacts List of specific artifact ID values that were added to
* blackboard
*/
public ModuleDataEvent(String moduleName, int artifactTypeId, Collection<BlackboardArtifact> artifacts) {
this(moduleName, artifactTypeId);
this.artifacts = artifacts;
}
/**
* @param moduleName Module name
* @param artifactType Type of artifact that was posted to blackboard
* @param artifacts List of specific artifact values that were added to
* blackboard
*/
public ModuleDataEvent(String moduleName, ARTIFACT_TYPE artifactType, Collection<BlackboardArtifact> artifacts) {
this(moduleName, artifactType); this(moduleName, artifactType);
this.artifactIDs = artifactIDs; this.artifacts = artifacts;
}
/**
* Gets the ID of the new artifacts associated with the event
* @return The artifact ID
*/
public int getArtifactTypeId() {
return this.artifactTypeId;
} }
/** /**
@ -79,13 +110,13 @@ public class ModuleDataEvent extends ChangeEvent {
* @return Collection of artifact ids or null if not provided * @return Collection of artifact ids or null if not provided
*/ */
public Collection<BlackboardArtifact> getArtifacts() { public Collection<BlackboardArtifact> getArtifacts() {
return artifactIDs; return artifacts;
} }
/** /**
* get artifact type of the new artifacts associated with the event * get artifact type of the new artifacts associated with the event
* * If it is a user defined artifact, it will return null
* @return * @return the artifact type
*/ */
public ARTIFACT_TYPE getArtifactType() { public ARTIFACT_TYPE getArtifactType() {
return artifactType; return artifactType;

View File

@ -61,7 +61,7 @@ public final class BlackboardPostEvent extends AutopsyEvent implements Serializa
*/ */
super( super(
IngestManager.IngestModuleEvent.DATA_ADDED.toString(), IngestManager.IngestModuleEvent.DATA_ADDED.toString(),
new SerializableEventData(eventData.getModuleName(), eventData.getArtifactType(), eventData.getArtifacts() != null new SerializableEventData(eventData.getModuleName(), eventData.getArtifactTypeId(), eventData.getArtifacts() != null
? eventData.getArtifacts() ? eventData.getArtifacts()
.stream() .stream()
.map(BlackboardArtifact::getArtifactID) .map(BlackboardArtifact::getArtifactID)
@ -96,7 +96,7 @@ public final class BlackboardPostEvent extends AutopsyEvent implements Serializa
for (Long id : data.artifactIds) { for (Long id : data.artifactIds) {
artifacts.add(Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(id)); artifacts.add(Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(id));
} }
eventData = new ModuleDataEvent(data.moduleName, data.artifactType, !artifacts.isEmpty() ? artifacts : null); eventData = new ModuleDataEvent(data.moduleName, data.artifactTypeId, !artifacts.isEmpty() ? artifacts : null);
return eventData; return eventData;
} catch (IllegalStateException | TskCoreException ex) { } catch (IllegalStateException | TskCoreException ex) {
logger.log(Level.SEVERE, "Error doing lazy load for remote event", ex); logger.log(Level.SEVERE, "Error doing lazy load for remote event", ex);
@ -112,12 +112,12 @@ public final class BlackboardPostEvent extends AutopsyEvent implements Serializa
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final String moduleName; private final String moduleName;
private ARTIFACT_TYPE artifactType; private int artifactTypeId;
private Collection<Long> artifactIds; private Collection<Long> artifactIds;
private SerializableEventData(String moduleName, ARTIFACT_TYPE artifactType, Collection<Long> artifactIds) { private SerializableEventData(String moduleName, int artifactTypeId, Collection<Long> artifactIds) {
this.moduleName = moduleName; this.moduleName = moduleName;
this.artifactType = artifactType; this.artifactTypeId = artifactTypeId;
this.artifactIds = new ArrayList<>(artifactIds); this.artifactIds = new ArrayList<>(artifactIds);
} }