diff --git a/bindings/java/src/org/sleuthkit/datamodel/DataSource.java b/bindings/java/src/org/sleuthkit/datamodel/DataSource.java index 25f09d0e12eda16b6d4d3527ff645eb28c86efc3..f2633a1172998e3efc47c9dda9502d8aaae78d3f 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/DataSource.java +++ b/bindings/java/src/org/sleuthkit/datamodel/DataSource.java @@ -66,4 +66,21 @@ public interface DataSource extends Content { */ long getContentSize(SleuthkitCase sleuthkitCase) throws TskCoreException; + /** + * Sets the acquisition details field in the case database. + * + * @param details The acquisition details + * + * @throws TskCoreException Thrown if the data can not be written + */ + void setAcquisitionDetails(String details) throws TskCoreException; + + /** + * Gets the acquisition details field from the case database. + * + * @return The acquisition details + * + * @throws TskCoreException Thrown if the data can not be read + */ + String getAcquisitionDetails() throws TskCoreException; } diff --git a/bindings/java/src/org/sleuthkit/datamodel/Image.java b/bindings/java/src/org/sleuthkit/datamodel/Image.java index d5a54b72072dc872d732d456cc9f92bf35d4f3e9..20386458994056eec2a6515b0c309be87d53acf6 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/Image.java +++ b/bindings/java/src/org/sleuthkit/datamodel/Image.java @@ -501,6 +501,30 @@ public long getContentSize(SleuthkitCase sleuthkitCase) throws TskCoreException return contentSize; } + + /** + * Sets the acquisition details field in the case database. + * + * @param details The acquisition details + * + * @throws TskCoreException Thrown if the data can not be written + */ + @Override + public void setAcquisitionDetails(String details) throws TskCoreException { + getSleuthkitCase().setAcquisitionDetails(this, details); + } + + /** + * Gets the acquisition details field from the case database. + * + * @return The acquisition details + * + * @throws TskCoreException Thrown if the data can not be read + */ + @Override + public String getAcquisitionDetails() throws TskCoreException { + return getSleuthkitCase().getAcquisitionDetails(this); + } /** * Close a ResultSet. diff --git a/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java b/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java index ed0a78b5e8e09a1ed3802f4dec895e988232d35b..1d2e25eedc0a26384d1a1946f33735097e36cc18 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java +++ b/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java @@ -179,6 +179,30 @@ static long getContentSize(SleuthkitCase sleuthkitCase, long dataSourceObjId) th return contentSize; } + + /** + * Sets the acquisition details field in the case database. + * + * @param details The acquisition details + * + * @throws TskCoreException Thrown if the data can not be written + */ + @Override + public void setAcquisitionDetails(String details) throws TskCoreException { + getSleuthkitCase().setAcquisitionDetails(this, details); + } + + /** + * Gets the acquisition details field from the case database. + * + * @return The acquisition details + * + * @throws TskCoreException Thrown if the data can not be read + */ + @Override + public String getAcquisitionDetails() throws TskCoreException { + return getSleuthkitCase().getAcquisitionDetails(this); + } /** * Close a ResultSet. diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java index 6e6bcd2cf710d15db7c92d72af48aaa6be69234b..847eaf4677d7e04af1ba47265c9a0b6dc3abcc3f 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java @@ -7908,6 +7908,66 @@ String getSha256ImageHash(Image img) throws TskCoreException { releaseSingleUserCaseReadLock(); } } + + /** + * Set the acquisition details in the data_source_info table + * + * @param datasource The data source + * @param details The acquisition details + * + * @throws TskCoreException Thrown if the database write fails + */ + void setAcquisitionDetails(DataSource datasource, String details) throws TskCoreException { + + long id = datasource.getId(); + CaseDbConnection connection = connections.getConnection(); + acquireSingleUserCaseWriteLock(); + try { + PreparedStatement statement = connection.getPreparedStatement(PREPARED_STATEMENT.UPDATE_ACQUISITION_DETAILS); + statement.clearParameters(); + statement.setString(1, details); + statement.setLong(2, id); + connection.executeUpdate(statement); + } catch (SQLException ex) { + throw new TskCoreException("Error setting acquisition details", ex); + } finally { + connection.close(); + releaseSingleUserCaseWriteLock(); + } + } + + /** + * Get the acquisition details from the data_source_info table + * + * @param datasource The data source + * + * @return The acquisition details + * + * @throws TskCoreException Thrown if the database read fails + */ + String getAcquisitionDetails(DataSource datasource) throws TskCoreException { + long id = datasource.getId(); + CaseDbConnection connection = connections.getConnection(); + acquireSingleUserCaseReadLock(); + ResultSet rs = null; + String hash = ""; + try { + PreparedStatement statement = connection.getPreparedStatement(PREPARED_STATEMENT.SELECT_ACQUISITION_DETAILS); + statement.clearParameters(); + statement.setLong(1, id); + rs = connection.executeQuery(statement); + if (rs.next()) { + hash = rs.getString("acquisition_details"); + } + return hash; + } catch (SQLException ex) { + throw new TskCoreException("Error setting acquisition details", ex); + } finally { + closeResultSet(rs); + connection.close(); + releaseSingleUserCaseReadLock(); + } + } /** * Set the review status of the given artifact to newStatus @@ -9585,6 +9645,8 @@ private enum PREPARED_STATEMENT { SELECT_IMAGE_MD5("SELECT md5 FROM tsk_image_info WHERE obj_id = ?"), //NON-NLS SELECT_IMAGE_SHA1("SELECT sha1 FROM tsk_image_info WHERE obj_id = ?"), //NON-NLS SELECT_IMAGE_SHA256("SELECT sha256 FROM tsk_image_info WHERE obj_id = ?"), //NON-NLS + UPDATE_ACQUISITION_DETAILS("UPDATE data_source_info SET acquisition_details = ? WHERE obj_id = ?"), //NON-NLS + SELECT_ACQUISITION_DETAILS("SELECT acquisition_details FROM data_source_info WHERE obj_id = ?"), //NON-NLS SELECT_LOCAL_PATH_FOR_FILE("SELECT path FROM tsk_files_path WHERE obj_id = ?"), //NON-NLS SELECT_ENCODING_FOR_FILE("SELECT encoding_type FROM tsk_files_path WHERE obj_id = ?"), // NON-NLS SELECT_LOCAL_PATH_AND_ENCODING_FOR_FILE("SELECT path, encoding_type FROM tsk_files_path WHERE obj_id = ?"), // NON_NLS