Skip to content
Snippets Groups Projects
Commit 7cf32dda authored by Kelly Kelly's avatar Kelly Kelly
Browse files

Changes based on review comments

parent 0cc106b1
Branches
No related tags found
No related merge requests found
...@@ -126,7 +126,7 @@ TimelineEventDescription parseDescription(String fullDescriptionRaw, String medD ...@@ -126,7 +126,7 @@ TimelineEventDescription parseDescription(String fullDescriptionRaw, String medD
*/ */
static class GPSTrackArtifactEventType extends TimelineEventArtifactTypeSingleDescription { static class GPSTrackArtifactEventType extends TimelineEventArtifactTypeSingleDescription {
private final TskGeoTrackpointsUtil trackpointUtil = new TskGeoTrackpointsUtil(""); private final TskGeoTrackpointsUtil trackpointUtil = new TskGeoTrackpointsUtil();
GPSTrackArtifactEventType(int typeID, String displayName, TimelineEventType superType, BlackboardArtifact.Type artifactType, BlackboardAttribute.Type descriptionAttribute) { GPSTrackArtifactEventType(int typeID, String displayName, TimelineEventType superType, BlackboardArtifact.Type artifactType, BlackboardAttribute.Type descriptionAttribute) {
// Passing TSK_GEO_TRACKPOINTS as the "time attribute" as more of a place filler, to avoid any null issues // Passing TSK_GEO_TRACKPOINTS as the "time attribute" as more of a place filler, to avoid any null issues
...@@ -144,14 +144,7 @@ public TimelineEventDescriptionWithTime makeEventDescription(BlackboardArtifact ...@@ -144,14 +144,7 @@ public TimelineEventDescriptionWithTime makeEventDescription(BlackboardArtifact
// Get the waypoint list "start time" // Get the waypoint list "start time"
GeoTrackPointList pointsList = trackpointUtil.fromAttribute(attribute); GeoTrackPointList pointsList = trackpointUtil.fromAttribute(attribute);
Long startTime = null; Long startTime = pointsList.getStartTime();
for(GeoTrackPoint point: pointsList) {
// Points are in time order so return the first non-null time stamp
startTime = point.getTimeStamp();
if (startTime != null) {
break;
}
}
// If we didn't find a startime do not create an event. // If we didn't find a startime do not create an event.
if (startTime == null) { if (startTime == null) {
......
...@@ -53,8 +53,8 @@ public final class GeoArtifactsHelper extends ArtifactHelperBase { ...@@ -53,8 +53,8 @@ public final class GeoArtifactsHelper extends ArtifactHelperBase {
public GeoArtifactsHelper(SleuthkitCase caseDb, String moduleName, String programName, Content srcFile) { public GeoArtifactsHelper(SleuthkitCase caseDb, String moduleName, String programName, Content srcFile) {
super(caseDb, moduleName, srcFile); super(caseDb, moduleName, srcFile);
this.programName = programName; this.programName = programName;
trackPointAttributeUtil = new TskGeoTrackpointsUtil(moduleName); trackPointAttributeUtil = new TskGeoTrackpointsUtil();
waypointsAttributeUtil = new TskGeoWaypointsUtil(moduleName); waypointsAttributeUtil = new TskGeoWaypointsUtil();
} }
/** /**
...@@ -84,7 +84,7 @@ public BlackboardArtifact addTrack(String trackName, GeoTrackPointList points, L ...@@ -84,7 +84,7 @@ public BlackboardArtifact addTrack(String trackName, GeoTrackPointList points, L
attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), trackName)); attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), trackName));
} }
attributes.add(trackPointAttributeUtil.toAttribute(points)); attributes.add(trackPointAttributeUtil.toAttribute(getModuleName(), points));
if (programName != null) { if (programName != null) {
attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, getModuleName(), programName)); attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, getModuleName(), programName));
...@@ -124,7 +124,7 @@ public BlackboardArtifact addRoute(String routeName, Long creationTime, GeoWaypo ...@@ -124,7 +124,7 @@ public BlackboardArtifact addRoute(String routeName, Long creationTime, GeoWaypo
BlackboardArtifact artifact = getContent().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_ROUTE); BlackboardArtifact artifact = getContent().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_ROUTE);
List<BlackboardAttribute> attributes = new ArrayList<>(); List<BlackboardAttribute> attributes = new ArrayList<>();
attributes.add(waypointsAttributeUtil.toAttribute(points)); attributes.add(waypointsAttributeUtil.toAttribute(getModuleName(), points));
if (routeName != null) { if (routeName != null) {
attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), routeName)); attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), routeName));
......
...@@ -21,29 +21,28 @@ ...@@ -21,29 +21,28 @@
import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.BlackboardAttribute;
/** /**
* An interface for Utility classes to implement for translating BlackboardAttributes * An interface for Utility classes to implement for translating
* to and from a particular format. Initial use case is for BlackboardAttributes of * BlackboardAttributes to and from a particular format. Initial use case is for
* type SK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.JSON. * BlackboardAttributes of type TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.JSON.
*/ */
public interface BlackboardAttributeUtil<T> { public interface BlackboardAttributeUtil<T> {
/** /**
* Translates the value of type T to a attribute. * Translates the value of type T to a attribute.
* *
* @param value Object to Translate to attribute. * @param moduleName Name of module creating the artifact
* * @param value Object to Translate to attribute
*
* @return BlackboardAttribute created from value * @return BlackboardAttribute created from value
*/ */
BlackboardAttribute toAttribute(T value); BlackboardAttribute toAttribute(String moduleName, T value);
/** /**
* Translates a attribute to an object of type T. * Translates a attribute to an object of type T.
* *
* @param attribute The attribute to be translated to T * @param attribute The attribute to be translated to T
* *
* @return A new instance of T created from the attribute * @return A new instance of T created from the attribute
*/ */
T fromAttribute(BlackboardAttribute attribute); T fromAttribute(BlackboardAttribute attribute);
} }
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
package org.sleuthkit.datamodel.blackboardutils.attributes; package org.sleuthkit.datamodel.blackboardutils.attributes;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
...@@ -29,27 +28,16 @@ ...@@ -29,27 +28,16 @@
import org.sleuthkit.datamodel.blackboardutils.attributes.TskGeoTrackpointsUtil.GeoTrackPointList.GeoTrackPoint; import org.sleuthkit.datamodel.blackboardutils.attributes.TskGeoTrackpointsUtil.GeoTrackPointList.GeoTrackPoint;
/** /**
* Utility class for Translating TSK_GEO_TRACKPOINTS attribute values to * Utility class for translating TSK_GEO_TRACKPOINTS attribute values to
* GeoTrackPointList objects and GeoTrackPointList to BlackboardAttributes. * GeoTrackPointList objects and GeoTrackPointList to BlackboardAttributes.
*/ */
public final class TskGeoTrackpointsUtil implements BlackboardAttributeUtil<GeoTrackPointList> { public final class TskGeoTrackpointsUtil implements BlackboardAttributeUtil<GeoTrackPointList> {
private final String moduleName;
/**
* Constructs a new instance of the Translator Utility.
*
* @param moduleName Name of calling module.
*/
public TskGeoTrackpointsUtil(String moduleName) {
this.moduleName = moduleName;
}
@Override @Override
public BlackboardAttribute toAttribute(GeoTrackPointList value) { public BlackboardAttribute toAttribute(String moduleName, GeoTrackPointList value) {
if (value == null) { if (value == null) {
throw new IllegalArgumentException("toAttribute was pass a null list."); throw new IllegalArgumentException("toAttribute was passed a null list");
} }
return new BlackboardAttribute( return new BlackboardAttribute(
...@@ -61,7 +49,7 @@ public BlackboardAttribute toAttribute(GeoTrackPointList value) { ...@@ -61,7 +49,7 @@ public BlackboardAttribute toAttribute(GeoTrackPointList value) {
@Override @Override
public GeoTrackPointList fromAttribute(BlackboardAttribute attribute) { public GeoTrackPointList fromAttribute(BlackboardAttribute attribute) {
if (attribute == null) { if (attribute == null) {
throw new IllegalArgumentException("Null value passed to fromAttribute"); throw new IllegalArgumentException("fromAttribute was passed a null attribute");
} }
BlackboardAttribute.ATTRIBUTE_TYPE type = BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attribute.getAttributeType().getTypeID()); BlackboardAttribute.ATTRIBUTE_TYPE type = BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attribute.getAttributeType().getTypeID());
...@@ -78,7 +66,7 @@ public GeoTrackPointList fromAttribute(BlackboardAttribute attribute) { ...@@ -78,7 +66,7 @@ public GeoTrackPointList fromAttribute(BlackboardAttribute attribute) {
* @param jsonString JSon string of track points. * @param jsonString JSon string of track points.
* *
* @return Timestamp ordered list of GeoTrackPoints, empty list will be * @return Timestamp ordered list of GeoTrackPoints, empty list will be
* returned if jsonString is null or empty. * returned if jsonString is null or empty.
*/ */
private static GeoTrackPointList fromJSON(String jsonString) { private static GeoTrackPointList fromJSON(String jsonString) {
if (jsonString == null || jsonString.isEmpty()) { if (jsonString == null || jsonString.isEmpty()) {
...@@ -99,17 +87,17 @@ private static String toJSON(GeoTrackPointList pointList) { ...@@ -99,17 +87,17 @@ private static String toJSON(GeoTrackPointList pointList) {
} }
/** /**
* A list of GeoTrackPoints. * A list of GeoTrackPoints.
*/ */
public static class GeoTrackPointList implements Iterable<GeoTrackPointList.GeoTrackPoint> { public static class GeoTrackPointList implements Iterable<GeoTrackPointList.GeoTrackPoint> {
private final List<GeoTrackPoint> points; private final List<GeoTrackPoint> pointList;
/** /**
* Construct an empty GeoTrackPointList. * Construct an empty GeoTrackPointList.
*/ */
public GeoTrackPointList() { public GeoTrackPointList() {
points = new ArrayList<>(); pointList = new ArrayList<>();
} }
/** /**
...@@ -120,10 +108,10 @@ public GeoTrackPointList() { ...@@ -120,10 +108,10 @@ public GeoTrackPointList() {
*/ */
public GeoTrackPointList(List<GeoTrackPoint> points) { public GeoTrackPointList(List<GeoTrackPoint> points) {
if (points == null) { if (points == null) {
throw new IllegalArgumentException("NULL list of trackpoints passed to constructor."); throw new IllegalArgumentException("Constructor was passed a null list");
} }
this.points = points; pointList = points;
} }
/** /**
...@@ -132,44 +120,45 @@ public GeoTrackPointList(List<GeoTrackPoint> points) { ...@@ -132,44 +120,45 @@ public GeoTrackPointList(List<GeoTrackPoint> points) {
* @param point A point to add to the track point list, cannot be null. * @param point A point to add to the track point list, cannot be null.
*/ */
public void addPoint(GeoTrackPoint point) { public void addPoint(GeoTrackPoint point) {
if (points == null) { if (point == null) {
throw new IllegalArgumentException("Attempted to add NULL value to track point list."); throw new IllegalArgumentException("addPoint was passed a null list");
} }
points.add(point); pointList.add(point);
} }
/** /**
* Adds a new point with the given attributes. * Adds a new point with the given attributes.
* *
* @param latitude Latitude of the trackpoint, required * @param latitude Latitude of the trackpoint, required
* @param longitude Longitude of the trackpoint, required * @param longitude Longitude of the trackpoint, required
* @param altitude Altitude of the trackpoint, maybe null * @param altitude Altitude of the trackpoint, maybe null
* @param name Name of trackpoint, maybe null * @param name Name of trackpoint, maybe null
* @param velocity Velocity in meters/sec, maybe null * @param velocity Velocity in meters/sec, maybe null
* @param distanceFromHP Trackpoint distance from an established "home * @param distanceFromHomePoint Track point distance from an established
* point", maybe null if not applicable * "home point", may be null if not
* @param distanceTraveled Overall distance traveled in meters at the * applicable
* time this trackpoint was created, maybe null * @param distanceTraveled Overall distance traveled in meters at
* if not applicable * the time this trackpoint was created,
* @param timestamp Trackpoint creation time, maybe null if not * maybe null if not applicable
* applicable * @param timestamp Trackpoint creation time, maybe null if
* not applicable
*/ */
public void addPoint(Double latitude, public void addPoint(Double latitude,
Double longitude, Double longitude,
Double altitude, Double altitude,
String name, String name,
Double velocity, Double velocity,
Double distanceFromHP, Double distanceFromHomePoint,
Double distanceTraveled, Double distanceTraveled,
Long timestamp) { Long timestamp) {
points.add(new GeoTrackPoint( pointList.add(new GeoTrackPoint(
latitude, latitude,
longitude, longitude,
altitude, altitude,
name, name,
velocity, velocity,
distanceFromHP, distanceFromHomePoint,
distanceTraveled, distanceTraveled,
timestamp)); timestamp));
} }
...@@ -181,7 +170,7 @@ public void addPoint(Double latitude, ...@@ -181,7 +170,7 @@ public void addPoint(Double latitude,
*/ */
@Override @Override
public Iterator<GeoTrackPoint> iterator() { public Iterator<GeoTrackPoint> iterator() {
return points.iterator(); return pointList.iterator();
} }
/** /**
...@@ -190,7 +179,7 @@ public Iterator<GeoTrackPoint> iterator() { ...@@ -190,7 +179,7 @@ public Iterator<GeoTrackPoint> iterator() {
* @return True if this list contains no points. * @return True if this list contains no points.
*/ */
public boolean isEmpty() { public boolean isEmpty() {
return points.isEmpty(); return pointList.isEmpty();
} }
/** /**
...@@ -234,7 +223,7 @@ public Long getEndTime() { ...@@ -234,7 +223,7 @@ public Long getEndTime() {
* @return List of points sorted by timestamps. * @return List of points sorted by timestamps.
*/ */
private List<GeoTrackPoint> getTimeOrderedPoints() { private List<GeoTrackPoint> getTimeOrderedPoints() {
return points.stream().sorted().collect(Collectors.toCollection(ArrayList::new)); return pointList.stream().sorted().collect(Collectors.toCollection(ArrayList::new));
} }
/** /**
...@@ -243,40 +232,43 @@ private List<GeoTrackPoint> getTimeOrderedPoints() { ...@@ -243,40 +232,43 @@ private List<GeoTrackPoint> getTimeOrderedPoints() {
* *
*/ */
public final static class GeoTrackPoint extends TskGeoWaypointsUtil.GeoWaypointList.GeoWaypoint implements Comparable<GeoTrackPointList.GeoTrackPoint> { public final static class GeoTrackPoint extends TskGeoWaypointsUtil.GeoWaypointList.GeoWaypoint implements Comparable<GeoTrackPointList.GeoTrackPoint> {
private final Double velocity; private final Double velocity;
private final Double distanceFromHP; private final Double distanceFromHomePoint;
private final Double distanceTraveled; private final Double distanceTraveled;
private final Long timestamp; private final Long timestamp;
/** /**
* Constructs a GeoTrackPoint with the given attributes. * Constructs a GeoTrackPoint with the given attributes.
* *
* @param latitude Latitude of the trackpoint, required * @param latitude Latitude of the track point, required
* @param longitude Longitude of the trackpoint, required * @param longitude Longitude of the track point,
* @param altitude Altitude of the trackpoint, maybe null * required
* @param name Name of trackpoint, maybe null * @param altitude Altitude of the track point, may be
* @param velocity Velocity in meters/sec, maybe null * null
* @param distanceFromHP Trackpoint distance from an established * @param name Name of track point, may be null
* "home point", maybe null if not * @param velocity Velocity in meters/sec, may be null
* applicable * @param distanceFromHomePoint Track point distance from an
* @param distanceTraveled Overall distance traveled in meters at * established "home point", maybe null
* the time this trackpoint was created, * if not applicable
* maybe null if not applicable * @param distanceTraveled Overall distance traveled in meters
* @param timestamp Trackpoint creation time, maybe null if * at the time this track point was
* not applicable * created, maybe null if not
* applicable
* @param timestamp Track point creation time, maybe
* null if not applicable
*/ */
public GeoTrackPoint(Double latitude, public GeoTrackPoint(Double latitude,
Double longitude, Double longitude,
Double altitude, Double altitude,
String name, String name,
Double velocity, Double velocity,
Double distanceFromHP, Double distanceFromHomePoint,
Double distanceTraveled, Double distanceTraveled,
Long timestamp) { Long timestamp) {
super(latitude, longitude, altitude, name); super(latitude, longitude, altitude, name);
this.velocity = velocity; this.velocity = velocity;
this.distanceFromHP = distanceFromHP; this.distanceFromHomePoint = distanceFromHomePoint;
this.distanceTraveled = distanceTraveled; this.distanceTraveled = distanceTraveled;
this.timestamp = timestamp; this.timestamp = timestamp;
} }
...@@ -297,8 +289,8 @@ public Double getVelocity() { ...@@ -297,8 +289,8 @@ public Double getVelocity() {
* @return Double velocity distance from home point, maybe null if * @return Double velocity distance from home point, maybe null if
* not available or applicable * not available or applicable
*/ */
public Double getDistanceFromHP() { public Double getDistanceFromHomePoint() {
return distanceFromHP; return distanceFromHomePoint;
} }
/** /**
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
package org.sleuthkit.datamodel.blackboardutils.attributes; package org.sleuthkit.datamodel.blackboardutils.attributes;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
...@@ -33,22 +32,11 @@ ...@@ -33,22 +32,11 @@
*/ */
public final class TskGeoWaypointsUtil implements BlackboardAttributeUtil<GeoWaypointList> { public final class TskGeoWaypointsUtil implements BlackboardAttributeUtil<GeoWaypointList> {
private final String moduleName;
/**
* Constructs a new instance of the Translator Utility.
*
* @param moduleName Name of calling module.
*/
public TskGeoWaypointsUtil(String moduleName) {
this.moduleName = moduleName;
}
@Override @Override
public BlackboardAttribute toAttribute(GeoWaypointList value) { public BlackboardAttribute toAttribute(String moduleName, GeoWaypointList value) {
if (value == null) { if (value == null) {
throw new IllegalArgumentException("toAttribute was pass a null list."); throw new IllegalArgumentException("toAttribute was pass a null list");
} }
return new BlackboardAttribute( return new BlackboardAttribute(
...@@ -60,7 +48,7 @@ public BlackboardAttribute toAttribute(GeoWaypointList value) { ...@@ -60,7 +48,7 @@ public BlackboardAttribute toAttribute(GeoWaypointList value) {
@Override @Override
public GeoWaypointList fromAttribute(BlackboardAttribute attribute) { public GeoWaypointList fromAttribute(BlackboardAttribute attribute) {
if (attribute == null) { if (attribute == null) {
throw new IllegalArgumentException("Null value passed to fromAttribute"); throw new IllegalArgumentException("fromAttribute was pass a null list");
} }
BlackboardAttribute.ATTRIBUTE_TYPE type = BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attribute.getAttributeType().getTypeID()); BlackboardAttribute.ATTRIBUTE_TYPE type = BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attribute.getAttributeType().getTypeID());
...@@ -88,7 +76,7 @@ private static GeoWaypointList fromJSON(String jsonString) { ...@@ -88,7 +76,7 @@ private static GeoWaypointList fromJSON(String jsonString) {
} }
/** /**
* Returns a JSON string can than be used as the TSK_GEO_TRACKPOINTS * Returns a JSON string can than be used as the TSK_GEO_TRACKPOINTS
* attribute of the TSK_GPS_TRACK artifact. * attribute of the TSK_GPS_TRACK artifact.
* *
* @return JSON string * @return JSON string
...@@ -158,7 +146,7 @@ public static class GeoWaypoint { ...@@ -158,7 +146,7 @@ public static class GeoWaypoint {
*/ */
public GeoWaypoint(Double latitude, Double longitude, Double altitude, String name) { public GeoWaypoint(Double latitude, Double longitude, Double altitude, String name) {
if (latitude == null || longitude == null) { if (latitude == null || longitude == null) {
throw new IllegalArgumentException("Null cordinate value passed to waypoint constructor"); throw new IllegalArgumentException("Constructor was passed null coordinate");
} }
this.latitude = latitude; this.latitude = latitude;
...@@ -194,11 +182,12 @@ public Double getLongitude() { ...@@ -194,11 +182,12 @@ public Double getLongitude() {
public Double getAltitude() { public Double getAltitude() {
return altitude; return altitude;
} }
/** /**
* Returns the name for this waypoint. * Returns the name for this waypoint.
* @return Returns waypoint name, may be null if not available or *
* applicable. * @return Returns waypoint name, may be null if not available or
* applicable.
*/ */
public String getName() { public String getName() {
return name; return name;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment