Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
Area.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 org.openide.util.NbBundle.Messages;
26 import org.sleuthkit.datamodel.BlackboardArtifact;
27 import org.sleuthkit.datamodel.BlackboardAttribute;
28 import org.sleuthkit.datamodel.blackboardutils.attributes.BlackboardJsonAttrUtil;
29 import org.sleuthkit.datamodel.blackboardutils.attributes.BlackboardJsonAttrUtil.InvalidJsonException;
30 import org.sleuthkit.datamodel.blackboardutils.attributes.GeoAreaPoints;
31 
35 public final class Area extends GeoPath {
43  public Area(BlackboardArtifact artifact) throws GeoLocationDataException {
44  this(artifact, Waypoint.getAttributesFromArtifactAsMap(artifact));
45  }
46 
55  private Area(BlackboardArtifact artifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
56  super(artifact, getAreaName(attributeMap));
57 
58  GeoAreaPoints points = getPointsList(attributeMap);
59  buildPath(points, artifact);
60  }
61 
70  private static String getAreaName(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) {
71  BlackboardAttribute attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME);
72 
73  return attribute != null ? attribute.getValueString() : "";
74  }
75 
84  @Messages({
85  "# {0} - area name",
86  "GEOArea_point_label_header=Area outline point for area: {0}"
87  })
88  private void buildPath(GeoAreaPoints points, BlackboardArtifact artifact) throws GeoLocationDataException {
89  for (GeoAreaPoints.AreaPoint point : points) {
90  addToPath(new AreaWaypoint(artifact, Bundle.GEOArea_point_label_header(getLabel()), point));
91  }
92  }
93 
104  private GeoAreaPoints getPointsList(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
105  BlackboardAttribute attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_AREAPOINTS);
106  if (attribute == null) {
107  throw new GeoLocationDataException("No TSK_GEO_AREAPOINTS attribute present in attribute map to parse.");
108  }
109 
110  try {
111  return BlackboardJsonAttrUtil.fromAttribute(attribute, GeoAreaPoints.class);
112  } catch (InvalidJsonException ex) {
113  throw new GeoLocationDataException("Unable to parse area points in TSK_GEO_AREAPOINTS attribute", ex);
114  }
115  }
116 
120  final class AreaWaypoint extends Waypoint {
121 
122  private final List<Waypoint.Property> propertyList;
123 
135  AreaWaypoint(BlackboardArtifact artifact, String pointLabel, GeoAreaPoints.AreaPoint point) throws GeoLocationDataException {
136  super(artifact, pointLabel,
137  null,
138  point.getLatitude(),
139  point.getLongitude(),
140  null,
141  null,
142  null,
143  Area.this);
144 
145  propertyList = createPropertyList(point);
146  }
147 
154  @Override
155  public List<Waypoint.Property> getOtherProperties() {
156  return Collections.unmodifiableList(propertyList);
157  }
158 
166  private List<Waypoint.Property> createPropertyList(GeoAreaPoints.AreaPoint point) {
167  List<Waypoint.Property> list = new ArrayList<>();
168  return list;
169  }
170  }
171 }
void buildPath(GeoAreaPoints points, BlackboardArtifact artifact)
Definition: Area.java:88
Area(BlackboardArtifact artifact)
Definition: Area.java:43
Area(BlackboardArtifact artifact, Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
Definition: Area.java:55
static String getAreaName(Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
Definition: Area.java:70
GeoAreaPoints getPointsList(Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
Definition: Area.java:104

Copyright © 2012-2022 Basis Technology. Generated on: Sat Sep 24 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.