Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
CentralRepositoryService.java
Go to the documentation of this file.
1/*
2 * Central Repository
3 *
4 * Copyright 2018-2021 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.centralrepository.datamodel;
20
21import org.openide.util.NbBundle;
22import org.openide.util.lookup.ServiceProvider;
23import org.sleuthkit.autopsy.appservices.AutopsyService;
24import org.sleuthkit.autopsy.progress.ProgressIndicator;
25import org.sleuthkit.autopsy.casemodule.Case;
26import org.sleuthkit.autopsy.centralrepository.eventlisteners.CaseEventListener;
27import org.sleuthkit.datamodel.Content;
28import org.sleuthkit.datamodel.DataSource;
29import org.sleuthkit.datamodel.TskCoreException;
30
34@ServiceProvider(service = AutopsyService.class)
36
38
39 @Override
40 @NbBundle.Messages({
41 "CentralRepositoryService.serviceName=Central Repository Service"
42 })
43 public String getServiceName() {
44 return Bundle.CentralRepositoryService_serviceName();
45 }
46
47 @NbBundle.Messages({
48 "CentralRepositoryService.progressMsg.updatingSchema=Checking for schema updates...",
49 "CentralRepositoryService.progressMsg.startingListener=Starting events listener..."
50 })
51 @Override
54 return;
55 }
56
58 progress.progress(Bundle.CentralRepositoryService_progressMsg_updatingSchema());
60 if (context.cancelRequested()) {
61 return;
62 }
63
65 if (context.cancelRequested()) {
66 return;
67 }
68
69 progress.progress(Bundle.CentralRepositoryService_progressMsg_startingListener());
71 caseEventListener.startUp();
72 }
73
74 @NbBundle.Messages({
75 "CentralRepositoryService.progressMsg.waitingForListeners=Finishing adding data to central repository database...."
76 })
77 @Override
80 progress.progress(Bundle.CentralRepositoryService_progressMsg_waitingForListeners());
81 if (caseEventListener != null) {
82 caseEventListener.shutdown();
83 }
84 }
85
92 private void updateSchema() throws AutopsyServiceException {
93 try {
95 } catch (CentralRepoException ex) {
96 throw new AutopsyServiceException("Failed to update the Central Repository schema", ex);
97 }
98 }
99
108 private void dataUpgradeForVersion1dot2(Case currentCase) throws AutopsyServiceException {
109 try {
110 /*
111 * If the case is in the central repository, there may be missing
112 * data source object IDs in the data_sources.datasource_obj_id
113 * column that was added in the version 1.2 schema update.
114 */
115 CentralRepository centralRepository = CentralRepository.getInstance();
116 CorrelationCase correlationCase = centralRepository.getCase(currentCase);
117 if (correlationCase != null) {
118 for (CorrelationDataSource correlationDataSource : centralRepository.getDataSources()) {
119 /*
120 * ResultSet.getLong returns zero when the value in the
121 * result set is NULL.
122 */
123 if (correlationDataSource.getCaseID() == correlationCase.getID() && correlationDataSource.getDataSourceObjectID() == 0) {
124 for (Content dataSource : currentCase.getDataSources()) {
125 if (((DataSource) dataSource).getDeviceId().equals(correlationDataSource.getDeviceID()) && dataSource.getName().equals(correlationDataSource.getName())) {
126 centralRepository.addDataSourceObjectId(correlationDataSource.getID(), dataSource.getId());
127 break;
128 }
129 }
130 }
131 }
132 }
133 } catch (CentralRepoException | TskCoreException ex) {
134 throw new AutopsyServiceException("Failed to update data sources in the Central Repository for schema v1.2", ex);
135 }
136 }
137
138}
void addDataSourceObjectId(int rowId, long dataSourceObjectId)

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