Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataSourceSummary.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2019 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 */
19package org.sleuthkit.autopsy.datasourcesummary.ui;
20
21import java.sql.ResultSet;
22import java.sql.SQLException;
23import java.util.logging.Level;
24import org.sleuthkit.autopsy.coreutils.Logger;
25import org.sleuthkit.autopsy.casemodule.Case;
26import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
27import org.sleuthkit.datamodel.CaseDbAccessManager;
28import org.sleuthkit.datamodel.DataSource;
29import org.sleuthkit.datamodel.IngestJobInfo.IngestJobStatusType;
30import org.sleuthkit.datamodel.TskCoreException;
31
36class DataSourceSummary {
37
38 private static final Logger logger = Logger.getLogger(DataSourceSummary.class.getName());
39 private static final String INGEST_JOB_STATUS_QUERY = "status_id FROM ingest_jobs WHERE obj_id=";
40 private final DataSource dataSource;
41 private IngestJobStatusType status = null;
42 private final String type;
43 private final long filesCount;
44 private final long resultsCount;
45 private final long tagsCount;
46
58 DataSourceSummary(DataSource dSource, String typeValue, Long numberOfFiles, Long numberOfResults, Long numberOfTags) {
59 dataSource = dSource;
60 getStatusFromDatabase();
61 type = typeValue == null ? "" : typeValue;
62 filesCount = numberOfFiles == null ? 0 : numberOfFiles;
63 resultsCount = numberOfResults == null ? 0 : numberOfResults;
64 tagsCount = numberOfTags == null ? 0 : numberOfTags;
65 }
66
70 private void getStatusFromDatabase() {
71 try {
72 IngestJobQueryCallback callback = new IngestJobQueryCallback();
73 Case.getCurrentCaseThrows().getSleuthkitCase().getCaseDbAccessManager().select(INGEST_JOB_STATUS_QUERY + dataSource.getId(), callback);
74 status = callback.getStatus();
75 } catch (NoCurrentCaseException | TskCoreException ex) {
76 logger.log(Level.WARNING, "Error getting status for data source from case database", ex);
77 }
78 }
79
85 DataSource getDataSource() {
86 return dataSource;
87 }
88
95 void setIngestStatus(IngestJobStatusType ingestStatus) {
96 status = ingestStatus;
97 }
98
104 String getType() {
105 return type;
106 }
107
113 long getFilesCount() {
114 return filesCount;
115 }
116
122 long getResultsCount() {
123 return resultsCount;
124 }
125
132 IngestJobStatusType getIngestStatus() {
133 return status;
134 }
135
141 long getTagsCount() {
142 return tagsCount;
143 }
144
149 class IngestJobQueryCallback implements CaseDbAccessManager.CaseDbAccessQueryCallback {
150
151 private IngestJobStatusType jobStatus = null;
152
153 @Override
154 public void process(ResultSet rs) {
155 try {
156 while (rs.next()) {
157 IngestJobStatusType currentStatus = IngestJobStatusType.fromID(rs.getInt("status_id"));
158 if (currentStatus == IngestJobStatusType.COMPLETED) {
159 jobStatus = currentStatus;
160 } else if (currentStatus == IngestJobStatusType.STARTED) {
161 jobStatus = currentStatus;
162 return;
163 }
164 }
165 } catch (SQLException ex) {
166 logger.log(Level.WARNING, "Error getting status for ingest job", ex);
167 }
168 }
169
175 IngestJobStatusType getStatus() {
176 return jobStatus;
177 }
178
179 }
180}

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.