Skip to content
Snippets Groups Projects
Unverified Commit d9b19e1c authored by Richard Cordovano's avatar Richard Cordovano Committed by GitHub
Browse files

Merge pull request #2116 from gdicristofaro/updated-timeline-error-message

updated timeline error message
parents 0adddb83 5b2b2aee
No related branches found
No related tags found
No related merge requests found
...@@ -630,7 +630,7 @@ Set<TimelineEvent> addArtifactEvents(BlackboardArtifact artifact) throws TskCore ...@@ -630,7 +630,7 @@ Set<TimelineEvent> addArtifactEvents(BlackboardArtifact artifact) throws TskCore
addArtifactEvent(((TimelineEventArtifactTypeImpl) TimelineEventType.OTHER).makeEventDescription(artifact), eventType, artifact) addArtifactEvent(((TimelineEventArtifactTypeImpl) TimelineEventType.OTHER).makeEventDescription(artifact), eventType, artifact)
.ifPresent(newEvents::add); .ifPresent(newEvents::add);
} catch (DuplicateException ex) { } catch (DuplicateException ex) {
logger.log(Level.SEVERE, "Attempt to make a timeline event artifact duplicate.", ex); logger.log(Level.SEVERE, getDuplicateExceptionMessage(artifact, "Attempt to make a timeline event artifact duplicate"), ex);
} }
} else { } else {
/* /*
...@@ -650,7 +650,7 @@ Set<TimelineEvent> addArtifactEvents(BlackboardArtifact artifact) throws TskCore ...@@ -650,7 +650,7 @@ Set<TimelineEvent> addArtifactEvents(BlackboardArtifact artifact) throws TskCore
.ifPresent(newEvents::add); .ifPresent(newEvents::add);
} catch (DuplicateException ex) { } catch (DuplicateException ex) {
duplicateExists = true; duplicateExists = true;
logger.log(Level.SEVERE, "Attempt to make artifact event duplicate.", ex); logger.log(Level.SEVERE, getDuplicateExceptionMessage(artifact, "Attempt to make artifact event duplicate"), ex);
} }
} }
...@@ -659,7 +659,7 @@ Set<TimelineEvent> addArtifactEvents(BlackboardArtifact artifact) throws TskCore ...@@ -659,7 +659,7 @@ Set<TimelineEvent> addArtifactEvents(BlackboardArtifact artifact) throws TskCore
try { try {
addOtherEventDesc(artifact).ifPresent(newEvents::add); addOtherEventDesc(artifact).ifPresent(newEvents::add);
} catch (DuplicateException ex) { } catch (DuplicateException ex) {
logger.log(Level.SEVERE, "Attempt to make 'other' artifact event duplicate.", ex); logger.log(Level.SEVERE, getDuplicateExceptionMessage(artifact, "Attempt to make 'other' artifact event duplicate"), ex);
} }
} }
} }
...@@ -669,6 +669,42 @@ Set<TimelineEvent> addArtifactEvents(BlackboardArtifact artifact) throws TskCore ...@@ -669,6 +669,42 @@ Set<TimelineEvent> addArtifactEvents(BlackboardArtifact artifact) throws TskCore
return newEvents; return newEvents;
} }
/**
* Formats a message to be displayed in response to a duplicate exception.
*
* @param artifact The artifact that caused the exception.
* @param error The error message to be displayed in the core of the
* message.
*
* @return A formatted message (i.e.
* "[org.sleuthkit.datamodel.TimelineManager]: Attempt to make
* 'other' artifact event duplicate (artifactID=12345, Source=Recent
* Activity).")
*/
private String getDuplicateExceptionMessage(BlackboardArtifact artifact, String error) {
String artifactIDStr = null;
String sourceStr = null;
if (artifact != null) {
artifactIDStr = Long.toString(artifact.getId());
try {
sourceStr = artifact.getAttributes().stream()
.filter(attr -> attr != null && attr.getSources() != null && !attr.getSources().isEmpty())
.map(attr -> String.join(",", attr.getSources()))
.findFirst()
.orElse(null);
} catch (TskCoreException ex) {
logger.log(Level.WARNING, String.format("Could not fetch artifacts for artifact id: %d.", artifact.getId()), ex);
}
}
artifactIDStr = (artifactIDStr == null) ? "<null>" : artifactIDStr;
sourceStr = (sourceStr == null) ? "<null>" : sourceStr;
return String.format("%s (artifactID=%s, Source=%s).", error, artifactIDStr, sourceStr);
}
/** /**
* Adds 'other' type events for artifacts that have no corresponding * Adds 'other' type events for artifacts that have no corresponding
* TimelineEventType. * TimelineEventType.
...@@ -1285,8 +1321,9 @@ public TimelineEvent getAddedEvent() { ...@@ -1285,8 +1321,9 @@ public TimelineEvent getAddedEvent() {
* Exception thrown in the event of a duplicate. * Exception thrown in the event of a duplicate.
*/ */
private static class DuplicateException extends Exception { private static class DuplicateException extends Exception {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* Main constructor. * Main constructor.
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment