Sleuth Kit Java Bindings (JNI)  4.9.0
Java bindings for using The Sleuth Kit
GeoArtifactsHelper.java
Go to the documentation of this file.
1 /*
2  * Sleuth Kit Data Model
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.datamodel.blackboardutils;
20 
21 import java.util.ArrayList;
22 import java.util.List;
32 
37 public final class GeoArtifactsHelper extends ArtifactHelperBase {
38 
41  private final String programName;
42 
57  public GeoArtifactsHelper(SleuthkitCase caseDb, String moduleName, String programName, Content srcContent) {
58  super(caseDb, moduleName, srcContent);
59  this.programName = programName;
60  }
61 
84  public BlackboardArtifact addTrack(String trackName, GeoTrackPoints trackPoints, List<BlackboardAttribute> moreAttributes) throws TskCoreException, BlackboardException {
85  if (trackPoints == null || trackPoints.isEmpty()) {
86  throw new IllegalArgumentException(String.format("addTrack was passed a null or empty list of track points"));
87  }
88 
89  List<BlackboardAttribute> attributes = new ArrayList<>();
90 
91  if (trackName != null) {
92  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), trackName));
93  }
94 
95  // acquire necessary attribute. If 'toAttribute' call throws an exception, an artifact will not be created for this instance.
96  attributes.add(BlackboardJsonAttrUtil.toAttribute(TRACKPOINTS_ATTR_TYPE, getModuleName(), trackPoints));
97 
98  if (programName != null) {
99  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, getModuleName(), programName));
100  }
101 
102  if (moreAttributes != null) {
103  attributes.addAll(moreAttributes);
104  }
105 
107  artifact.addAttributes(attributes);
108 
109  getSleuthkitCase().getBlackboard().postArtifact(artifact, getModuleName());
110 
111  return artifact;
112  }
113 
139  public BlackboardArtifact addRoute(String routeName, Long creationTime, GeoWaypoints wayPoints, List<BlackboardAttribute> moreAttributes) throws TskCoreException, BlackboardException {
140  if (wayPoints == null || wayPoints.isEmpty()) {
141  throw new IllegalArgumentException(String.format("addRoute was passed a null or empty list of waypoints"));
142  }
143 
145  List<BlackboardAttribute> attributes = new ArrayList<>();
146 
147  attributes.add(BlackboardJsonAttrUtil.toAttribute(WAYPOINTS_ATTR_TYPE, getModuleName(), wayPoints));
148 
149  if (routeName != null) {
150  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), routeName));
151  }
152 
153  if (creationTime != null) {
154  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME, getModuleName(), creationTime));
155  }
156 
157  if (programName != null) {
158  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, getModuleName(), programName));
159  }
160 
161  if (moreAttributes != null) {
162  attributes.addAll(moreAttributes);
163  }
164 
165  artifact.addAttributes(attributes);
166 
167  getSleuthkitCase().getBlackboard().postArtifact(artifact, getModuleName());
168 
169  return artifact;
170  }
171 
172 }
static< T > BlackboardAttribute toAttribute(BlackboardAttribute.Type attrType, String moduleName, T attrValue)
void addAttributes(Collection< BlackboardAttribute > attributes)
BlackboardArtifact addTrack(String trackName, GeoTrackPoints trackPoints, List< BlackboardAttribute > moreAttributes)
BlackboardArtifact newArtifact(int artifactTypeID)
GeoArtifactsHelper(SleuthkitCase caseDb, String moduleName, String programName, Content srcContent)
BlackboardArtifact addRoute(String routeName, Long creationTime, GeoWaypoints wayPoints, List< BlackboardAttribute > moreAttributes)

Copyright © 2011-2020 Brian Carrier. (carrier -at- sleuthkit -dot- org)
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.