Sleuth Kit Java Bindings (JNI)  4.3
Java bindings for using The Sleuth Kit
DerivedFile.java
Go to the documentation of this file.
1 /*
2  * SleuthKit Java Bindings
3  *
4  * Copyright 2011-2016 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;
20 
21 import java.text.MessageFormat;
22 import java.util.ResourceBundle;
23 import java.util.List;
24 import java.util.logging.Level;
25 import java.util.logging.Logger;
31 
37 public class DerivedFile extends AbstractFile {
38 
39  private volatile DerivedMethod derivedMethod;
40  private static final Logger logger = Logger.getLogger(DerivedFile.class.getName());
41  private static ResourceBundle bundle = ResourceBundle.getBundle("org.sleuthkit.datamodel.Bundle");
42  private boolean hasDerivedMethod = true;
43 
85  long objId,
86  long dataSourceObjectId,
87  String name,
90  long size,
91  long ctime, long crtime, long atime, long mtime,
93  String parentPath,
94  String localPath,
95  long parentId,
96  String mimeType,
98  // TODO (AUT-1904): The parent id should be passed to AbstractContent
99  // through the class hierarchy contructors.
100  super(db, objId, dataSourceObjectId, TskData.TSK_FS_ATTR_TYPE_ENUM.TSK_FS_ATTR_TYPE_DEFAULT, 0,
101  name, TSK_DB_FILES_TYPE_ENUM.LOCAL, 0L, 0, dirType, metaType, dirFlag,
102  metaFlags, size, ctime, crtime, atime, mtime, (short) 0, 0, 0, md5Hash, knownState, parentPath, mimeType);
103  setLocalFilePath(localPath, false);
104  setEncodingType(encodingType);
105  }
106 
113  @Override
114  public boolean isRoot() {
115  return false;
116  }
117 
126  @Override
127  public List<Content> getChildren() throws TskCoreException {
128  return getSleuthkitCase().getAbstractFileChildren(this, TSK_DB_FILES_TYPE_ENUM.DERIVED);
129  }
130 
140  @Override
141  public List<Long> getChildrenIds() throws TskCoreException {
142  return getSleuthkitCase().getAbstractFileChildrenIds(this, TSK_DB_FILES_TYPE_ENUM.DERIVED);
143  }
144 
153  public synchronized DerivedMethod getDerivedMethod() throws TskCoreException {
154  if (derivedMethod == null && hasDerivedMethod == true) {
155  try {
156  derivedMethod = getSleuthkitCase().getDerivedMethod(getId());
157  if (derivedMethod == null) {
158  hasDerivedMethod = false; //do not attempt to lazy load
159  }
160  } catch (TskCoreException e) {
161  String msg = MessageFormat.format(bundle.getString("DerviedFile.derivedMethod.exception.msg1.text"), getId());
162  logger.log(Level.WARNING, msg, e);
163  throw new TskCoreException(msg, e);
164  }
165  }
166  return derivedMethod;
167  }
168 
177  @Override
178  public <T> T accept(SleuthkitItemVisitor<T> v) {
179  return v.visit(this);
180  }
181 
190  @Override
191  public <T> T accept(ContentVisitor<T> v) {
192  return v.visit(this);
193  }
194 
200  @Override
201  protected void finalize() throws Throwable {
202  try {
203  close();
204  } finally {
205  super.finalize();
206  }
207  }
208 
218  @Override
219  public String toString(boolean preserveState) {
220  return super.toString(preserveState) + "DerivedFile{" //NON-NLS
221  + "derivedMethod=" + derivedMethod //NON-NLS
222  + ", hasDerivedMethod=" + hasDerivedMethod //NON-NLS
223  + '}';
224  }
225 
229  public static class DerivedMethod {
230 
231  private final int derivedId;
232  private String toolName;
233  private String toolVersion;
234  private String other;
235  private String rederiveDetails;
236 
237  public DerivedMethod(int derivedId, String rederiveDetails) {
238  this.derivedId = derivedId;
239  this.rederiveDetails = rederiveDetails;
240  if (this.rederiveDetails == null) {
241  this.rederiveDetails = "";
242  }
243  this.toolName = "";
244  this.toolVersion = "";
245  this.other = "";
246  }
247 
248  void setToolName(String toolName) {
249  this.toolName = toolName;
250  }
251 
252  void setToolVersion(String toolVersion) {
253  this.toolVersion = toolVersion;
254  }
255 
256  void setOther(String other) {
257  this.other = other;
258  }
259 
260  public int getDerivedId() {
261  return derivedId;
262  }
263 
264  public String getToolName() {
265  return toolName;
266  }
267 
268  public String getToolVersion() {
269  return toolVersion;
270  }
271 
272  public String getOther() {
273  return other;
274  }
275 
276  public String getRederiveDetails() {
277  return rederiveDetails;
278  }
279 
280  @Override
281  public String toString() {
282  return "DerivedMethod{" + "derived_id=" + derivedId + ", toolName=" + toolName + ", toolVersion=" + toolVersion + ", other=" + other + ", rederiveDetails=" + rederiveDetails + '}'; //NON-NLS
283  }
284  }
285 
320  @Deprecated
321  @SuppressWarnings("deprecation")
323  long objId,
324  String name,
327  long size,
328  long ctime, long crtime, long atime, long mtime,
329  String md5Hash, FileKnown knownState,
330  String parentPath,
331  String localPath,
332  long parentId) {
333  this(db, objId, db.getDataSourceObjectId(objId), name, dirType, metaType, dirFlag, metaFlags, size,
334  ctime, crtime, atime, mtime,
337  }
338 
339 }
final TSK_FS_NAME_TYPE_ENUM dirType
DerivedMethod(int derivedId, String rederiveDetails)
final TSK_FS_NAME_FLAG_ENUM dirFlag
LOCAL
Local file that was added (not from a disk image)
Definition: TskData.java:659
String toString(boolean preserveState)
final Set< TSK_FS_META_FLAG_ENUM > metaFlags
String localPath
local path as stored in db tsk_files_path, is relative to the db,
DERIVED
File derived from a parent file (i.e. from ZIP)
Definition: TskData.java:658
volatile DerivedMethod derivedMethod
synchronized DerivedMethod getDerivedMethod()
final TSK_FS_META_TYPE_ENUM metaType

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