Autopsy  4.15.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
Track.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2020 Basis Technology Corp.
5  * contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.geolocation.datamodel;
20 
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.logging.Level;
26 import org.openide.util.NbBundle.Messages;
27 import org.sleuthkit.datamodel.BlackboardArtifact;
28 import org.sleuthkit.datamodel.BlackboardAttribute;
29 import org.sleuthkit.datamodel.blackboardutils.attributes.BlackboardJsonAttrUtil;
30 import org.sleuthkit.datamodel.blackboardutils.attributes.BlackboardJsonAttrUtil.InvalidJsonException;
31 import org.sleuthkit.datamodel.blackboardutils.attributes.GeoTrackPoints;
33 
37 public final class Track extends GeoPath {
38  private static final Logger LOGGER = Logger.getLogger(Track.class.getName());
39 
40  private final Long startTimestamp;
41  private final Long endTimeStamp;
42 
50  public Track(BlackboardArtifact artifact) throws GeoLocationDataException {
51  this(artifact, Waypoint.getAttributesFromArtifactAsMap(artifact));
52  }
53 
62  private Track(BlackboardArtifact artifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
63  super(artifact, getTrackName(attributeMap));
64 
65  GeoTrackPoints points = getPointsList(attributeMap);
66  buildPath(points, artifact);
67 
68  startTimestamp = points.getStartTime();
69  endTimeStamp = points.getEndTime();
70  }
71 
78  public Long getStartTime() {
79  return startTimestamp;
80  }
81 
88  public Long getEndTime() {
89  return endTimeStamp;
90  }
91 
100  private static String getTrackName(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) {
101  BlackboardAttribute attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME);
102 
103  return attribute != null ? attribute.getValueString() : "";
104  }
105 
114  @Messages({
115  "# {0} - track name",
116  "GEOTrack_point_label_header=Trackpoint for track: {0}"
117  })
118  private void buildPath(GeoTrackPoints points, BlackboardArtifact artifact) throws GeoLocationDataException {
119  for (GeoTrackPoints.TrackPoint point : points) {
120  addToPath(new TrackWaypoint(artifact, Bundle.GEOTrack_point_label_header(getLabel()), point));
121  }
122  }
123 
134  private GeoTrackPoints getPointsList(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
135  BlackboardAttribute attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_TRACKPOINTS);
136  if (attribute == null) {
137  LOGGER.log(Level.SEVERE, "No TSK_GEO_TRACKPOINTS attribute was present on the artifact.");
138  throw new GeoLocationDataException("No TSK_GEO_TRACKPOINTS attribute present in attribute map to parse.");
139  }
140 
141  try {
142  return BlackboardJsonAttrUtil.fromAttribute(attribute, GeoTrackPoints.class);
143  } catch (InvalidJsonException ex) {
144  LOGGER.log(Level.SEVERE, "TSK_GEO_TRACKPOINTS could not be properly parsed from TSK_GEO_TRACKPOINTS attribute.");
145  throw new GeoLocationDataException("Unable to parse track points in TSK_GEO_TRACKPOINTS attribute", ex);
146  }
147  }
148 
152  final class TrackWaypoint extends Waypoint {
153 
154  private final List<Waypoint.Property> propertyList;
155 
167  TrackWaypoint(BlackboardArtifact artifact, String pointLabel, GeoTrackPoints.TrackPoint point) throws GeoLocationDataException {
168  super(artifact, pointLabel,
169  point.getTimeStamp(),
170  point.getLatitude(),
171  point.getLongitude(),
172  point.getAltitude(),
173  null,
174  null,
175  Track.this);
176 
177  propertyList = createPropertyList(point);
178  }
179 
186  @Override
187  public List<Waypoint.Property> getOtherProperties() {
188  return Collections.unmodifiableList(propertyList);
189  }
190 
198  @Messages({
199  "Track_distanceTraveled_displayName=Distance traveled",
200  "Track_distanceFromHome_displayName=Distance from home point"
201  })
202  private List<Waypoint.Property> createPropertyList(GeoTrackPoints.TrackPoint point) {
203  List<Waypoint.Property> list = new ArrayList<>();
204 
205  Long timestamp = point.getTimeStamp();
206  if (timestamp != null) {
207  list.add(new Property(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getDisplayName(), timestamp.toString()));
208  }
209 
210  Double value = point.getVelocity();
211  if (value != null) {
212  list.add(new Property(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_VELOCITY.getDisplayName(), value.toString()));
213  }
214 
215  value = point.getDistanceTraveled();
216  if (value != null) {
217  list.add(new Property(Bundle.Track_distanceTraveled_displayName(), value.toString()));
218  }
219 
220  value = point.getDistanceFromHomePoint();
221  if (value != null) {
222  list.add(new Property(Bundle.Track_distanceFromHome_displayName(), value.toString()));
223  }
224 
225  return list;
226  }
227  }
228 }
Track(BlackboardArtifact artifact)
Definition: Track.java:50
Track(BlackboardArtifact artifact, Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
Definition: Track.java:62
GeoTrackPoints getPointsList(Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
Definition: Track.java:134
static String getTrackName(Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
Definition: Track.java:100
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
void buildPath(GeoTrackPoints points, BlackboardArtifact artifact)
Definition: Track.java:118

Copyright © 2012-2020 Basis Technology. Generated on: Mon Jul 6 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.