19 package org.sleuthkit.datamodel;
21 import java.sql.PreparedStatement;
22 import java.sql.ResultSet;
23 import java.sql.SQLException;
24 import java.sql.Statement;
25 import java.util.List;
26 import java.util.Objects;
41 this.skCase = Objects.requireNonNull(skCase,
"Cannot create Blackboard for null SleuthkitCase");
57 String query =
"SELECT tsk_files.* FROM tsk_files JOIN tsk_objects ON tsk_objects.obj_id = tsk_files.obj_id "
58 +
" WHERE tsk_objects.par_obj_id = ? AND tsk_files.name = ? ";
61 query +=
" AND tsk_files.extension = ? ";
66 PreparedStatement statement = connection.getPreparedStatement(query, Statement.RETURN_GENERATED_KEYS);
67 statement.clearParameters();
68 statement.setLong(1, parentId);
69 statement.setString(2, name);
72 statement.setString(3, ext);
75 try (ResultSet rs = connection.executeQuery(statement)) {
76 return skCase.resultSetToAbstractFiles(rs, connection);
78 }
catch (SQLException ex) {
79 throw new TskCoreException(
"SQLException thrown when calling query: " + query +
" for parentID = " + parentId +
" and name " + name, ex);
99 String normalizedPath = path;
100 if (!normalizedPath.startsWith(
"/")) {
101 normalizedPath =
"/" + normalizedPath;
103 if (!normalizedPath.endsWith(
"/")) {
104 normalizedPath = normalizedPath +
"/";
112 PreparedStatement statement;
114 query =
"SELECT tsk_files.* FROM tsk_files JOIN tsk_objects ON tsk_objects.obj_id = tsk_files.obj_id WHERE parent_path = ? AND name = ? AND data_source_obj_id = ?";
115 statement = connection.getPreparedStatement(query, Statement.RETURN_GENERATED_KEYS);
116 statement.clearParameters();
117 statement.setString(1, normalizedPath);
118 statement.setString(2, name);
119 statement.setLong(3, dataSource.getId());
122 query =
"SELECT tsk_files.* FROM tsk_files JOIN tsk_objects ON tsk_objects.obj_id = tsk_files.obj_id WHERE extension = ? AND parent_path = ? AND name = ? AND data_source_obj_id = ?";
123 statement = connection.getPreparedStatement(query, Statement.RETURN_GENERATED_KEYS);
124 statement.clearParameters();
125 statement.setString(1, ext);
126 statement.setString(2, normalizedPath);
127 statement.setString(3, name);
128 statement.setLong(4, dataSource.getId());
130 try (ResultSet rs = connection.executeQuery(statement)) {
131 return skCase.resultSetToAbstractFiles(rs, connection);
133 }
catch (SQLException ex) {
134 throw new TskCoreException(
"SQLException thrown when calling query: " + query +
" for parent path = " + path +
" and name " + name, ex);
List< AbstractFile > findFilesExactName(long parentId, String name)
void releaseSingleUserCaseReadLock()
void acquireSingleUserCaseReadLock()
List< AbstractFile > findFilesExactNameExactPath(Content dataSource, String name, String path)