diff --git a/bindings/java/src/org/sleuthkit/datamodel/TimelineEventTypes.java b/bindings/java/src/org/sleuthkit/datamodel/TimelineEventTypes.java index b588427577fb91321aa6101decaea033ea7ff6e7..258bab58fc83c03c6207ebe4029ecbca0e5d802f 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/TimelineEventTypes.java +++ b/bindings/java/src/org/sleuthkit/datamodel/TimelineEventTypes.java @@ -126,7 +126,7 @@ TimelineEventDescription parseDescription(String fullDescriptionRaw, String medD */ 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) { // 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 // Get the waypoint list "start time" GeoTrackPointList pointsList = trackpointUtil.fromAttribute(attribute); - Long startTime = null; - for(GeoTrackPoint point: pointsList) { - // Points are in time order so return the first non-null time stamp - startTime = point.getTimeStamp(); - if (startTime != null) { - break; - } - } + Long startTime = pointsList.getStartTime(); // If we didn't find a startime do not create an event. if (startTime == null) { diff --git a/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/GeoArtifactsHelper.java b/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/GeoArtifactsHelper.java index 2e5db329ca094991a2f4d2980f20eb8ce8cfaf88..9bb29bd10d6a9d2fba199e9c72200348972c465a 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/GeoArtifactsHelper.java +++ b/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/GeoArtifactsHelper.java @@ -53,8 +53,8 @@ public final class GeoArtifactsHelper extends ArtifactHelperBase { public GeoArtifactsHelper(SleuthkitCase caseDb, String moduleName, String programName, Content srcFile) { super(caseDb, moduleName, srcFile); this.programName = programName; - trackPointAttributeUtil = new TskGeoTrackpointsUtil(moduleName); - waypointsAttributeUtil = new TskGeoWaypointsUtil(moduleName); + trackPointAttributeUtil = new TskGeoTrackpointsUtil(); + waypointsAttributeUtil = new TskGeoWaypointsUtil(); } /** @@ -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(trackPointAttributeUtil.toAttribute(points)); + attributes.add(trackPointAttributeUtil.toAttribute(getModuleName(), points)); if (programName != null) { attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, getModuleName(), programName)); @@ -124,7 +124,7 @@ public BlackboardArtifact addRoute(String routeName, Long creationTime, GeoWaypo BlackboardArtifact artifact = getContent().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_ROUTE); List<BlackboardAttribute> attributes = new ArrayList<>(); - attributes.add(waypointsAttributeUtil.toAttribute(points)); + attributes.add(waypointsAttributeUtil.toAttribute(getModuleName(), points)); if (routeName != null) { attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), routeName)); diff --git a/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/BlackboardAttributeUtil.java b/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/BlackboardAttributeUtil.java index a0660853b2d0ed103852c219019fbf42c64b2d74..d32b264a56a6309498990d944c4125089b9bb48a 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/BlackboardAttributeUtil.java +++ b/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/BlackboardAttributeUtil.java @@ -21,29 +21,28 @@ import org.sleuthkit.datamodel.BlackboardAttribute; /** - * An interface for Utility classes to implement for translating BlackboardAttributes - * to and from a particular format. Initial use case is for BlackboardAttributes of - * type SK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.JSON. + * An interface for Utility classes to implement for translating + * BlackboardAttributes to and from a particular format. Initial use case is for + * BlackboardAttributes of type TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.JSON. */ public interface BlackboardAttributeUtil<T> { /** * 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 */ - BlackboardAttribute toAttribute(T value); - + BlackboardAttribute toAttribute(String moduleName, T value); + /** * Translates a attribute to an object of type T. - * + * * @param attribute The attribute to be translated to T - * + * * @return A new instance of T created from the attribute */ T fromAttribute(BlackboardAttribute attribute); } - - diff --git a/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/TskGeoTrackpointsUtil.java b/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/TskGeoTrackpointsUtil.java index a886560e8fc1e55da386d4c218130e453eca4fe4..ad434f5c7d3e1da86cbf7620629b9fb0a9c9b835 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/TskGeoTrackpointsUtil.java +++ b/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/TskGeoTrackpointsUtil.java @@ -19,7 +19,6 @@ package org.sleuthkit.datamodel.blackboardutils.attributes; import com.google.gson.Gson; -import com.google.gson.annotations.SerializedName; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -29,27 +28,16 @@ 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. */ 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 - public BlackboardAttribute toAttribute(GeoTrackPointList value) { + public BlackboardAttribute toAttribute(String moduleName, GeoTrackPointList value) { if (value == null) { - throw new IllegalArgumentException("toAttribute was pass a null list."); + throw new IllegalArgumentException("toAttribute was passed a null list"); } return new BlackboardAttribute( @@ -61,7 +49,7 @@ public BlackboardAttribute toAttribute(GeoTrackPointList value) { @Override public GeoTrackPointList fromAttribute(BlackboardAttribute attribute) { 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()); @@ -78,7 +66,7 @@ public GeoTrackPointList fromAttribute(BlackboardAttribute attribute) { * @param jsonString JSon string of track points. * * @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) { if (jsonString == null || jsonString.isEmpty()) { @@ -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> { - private final List<GeoTrackPoint> points; + private final List<GeoTrackPoint> pointList; /** * Construct an empty GeoTrackPointList. */ public GeoTrackPointList() { - points = new ArrayList<>(); + pointList = new ArrayList<>(); } /** @@ -120,10 +108,10 @@ public GeoTrackPointList() { */ public GeoTrackPointList(List<GeoTrackPoint> points) { 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) { * @param point A point to add to the track point list, cannot be null. */ public void addPoint(GeoTrackPoint point) { - if (points == null) { - throw new IllegalArgumentException("Attempted to add NULL value to track point list."); + if (point == null) { + throw new IllegalArgumentException("addPoint was passed a null list"); } - points.add(point); + pointList.add(point); } /** * Adds a new point with the given attributes. * - * @param latitude Latitude of the trackpoint, required - * @param longitude Longitude of the trackpoint, required - * @param altitude Altitude of the trackpoint, maybe null - * @param name Name of trackpoint, maybe null - * @param velocity Velocity in meters/sec, maybe null - * @param distanceFromHP Trackpoint distance from an established "home - * point", maybe null if not applicable - * @param distanceTraveled Overall distance traveled in meters at the - * time this trackpoint was created, maybe null - * if not applicable - * @param timestamp Trackpoint creation time, maybe null if not - * applicable + * @param latitude Latitude of the trackpoint, required + * @param longitude Longitude of the trackpoint, required + * @param altitude Altitude of the trackpoint, maybe null + * @param name Name of trackpoint, maybe null + * @param velocity Velocity in meters/sec, maybe null + * @param distanceFromHomePoint Track point distance from an established + * "home point", may be null if not + * applicable + * @param distanceTraveled Overall distance traveled in meters at + * the time this trackpoint was created, + * maybe null if not applicable + * @param timestamp Trackpoint creation time, maybe null if + * not applicable */ public void addPoint(Double latitude, Double longitude, Double altitude, String name, Double velocity, - Double distanceFromHP, + Double distanceFromHomePoint, Double distanceTraveled, Long timestamp) { - points.add(new GeoTrackPoint( + pointList.add(new GeoTrackPoint( latitude, longitude, altitude, name, velocity, - distanceFromHP, + distanceFromHomePoint, distanceTraveled, timestamp)); } @@ -181,7 +170,7 @@ public void addPoint(Double latitude, */ @Override public Iterator<GeoTrackPoint> iterator() { - return points.iterator(); + return pointList.iterator(); } /** @@ -190,7 +179,7 @@ public Iterator<GeoTrackPoint> iterator() { * @return True if this list contains no points. */ public boolean isEmpty() { - return points.isEmpty(); + return pointList.isEmpty(); } /** @@ -234,7 +223,7 @@ public Long getEndTime() { * @return List of points sorted by timestamps. */ 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() { * */ public final static class GeoTrackPoint extends TskGeoWaypointsUtil.GeoWaypointList.GeoWaypoint implements Comparable<GeoTrackPointList.GeoTrackPoint> { - + private final Double velocity; - private final Double distanceFromHP; + private final Double distanceFromHomePoint; private final Double distanceTraveled; private final Long timestamp; /** * Constructs a GeoTrackPoint with the given attributes. * - * @param latitude Latitude of the trackpoint, required - * @param longitude Longitude of the trackpoint, required - * @param altitude Altitude of the trackpoint, maybe null - * @param name Name of trackpoint, maybe null - * @param velocity Velocity in meters/sec, maybe null - * @param distanceFromHP Trackpoint distance from an established - * "home point", maybe null if not - * applicable - * @param distanceTraveled Overall distance traveled in meters at - * the time this trackpoint was created, - * maybe null if not applicable - * @param timestamp Trackpoint creation time, maybe null if - * not applicable + * @param latitude Latitude of the track point, required + * @param longitude Longitude of the track point, + * required + * @param altitude Altitude of the track point, may be + * null + * @param name Name of track point, may be null + * @param velocity Velocity in meters/sec, may be null + * @param distanceFromHomePoint Track point distance from an + * established "home point", maybe null + * if not applicable + * @param distanceTraveled Overall distance traveled in meters + * at the time this track point was + * created, maybe null if not + * applicable + * @param timestamp Track point creation time, maybe + * null if not applicable */ public GeoTrackPoint(Double latitude, Double longitude, Double altitude, String name, Double velocity, - Double distanceFromHP, + Double distanceFromHomePoint, Double distanceTraveled, Long timestamp) { super(latitude, longitude, altitude, name); this.velocity = velocity; - this.distanceFromHP = distanceFromHP; + this.distanceFromHomePoint = distanceFromHomePoint; this.distanceTraveled = distanceTraveled; this.timestamp = timestamp; } @@ -297,8 +289,8 @@ public Double getVelocity() { * @return Double velocity distance from home point, maybe null if * not available or applicable */ - public Double getDistanceFromHP() { - return distanceFromHP; + public Double getDistanceFromHomePoint() { + return distanceFromHomePoint; } /** diff --git a/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/TskGeoWaypointsUtil.java b/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/TskGeoWaypointsUtil.java index d8aeec73a7239de59bef613ef89408b783b921e0..08d5a1c6bd6a77ab67bf0992c5a73a2d4e58ebe5 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/TskGeoWaypointsUtil.java +++ b/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/TskGeoWaypointsUtil.java @@ -19,7 +19,6 @@ package org.sleuthkit.datamodel.blackboardutils.attributes; import com.google.gson.Gson; -import com.google.gson.annotations.SerializedName; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -33,22 +32,11 @@ */ 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 - public BlackboardAttribute toAttribute(GeoWaypointList value) { + public BlackboardAttribute toAttribute(String moduleName, GeoWaypointList value) { if (value == null) { - throw new IllegalArgumentException("toAttribute was pass a null list."); + throw new IllegalArgumentException("toAttribute was pass a null list"); } return new BlackboardAttribute( @@ -60,7 +48,7 @@ public BlackboardAttribute toAttribute(GeoWaypointList value) { @Override public GeoWaypointList fromAttribute(BlackboardAttribute attribute) { 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()); @@ -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. * * @return JSON string @@ -158,7 +146,7 @@ public static class GeoWaypoint { */ public GeoWaypoint(Double latitude, Double longitude, Double altitude, String name) { 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; @@ -194,11 +182,12 @@ public Double getLongitude() { public Double getAltitude() { return altitude; } - + /** - * Returns the name for this waypoint. - * @return Returns waypoint name, may be null if not available or - * applicable. + * Returns the name for this waypoint. + * + * @return Returns waypoint name, may be null if not available or + * applicable. */ public String getName() { return name;