Autopsy  4.14.0
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-2020 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.autopsy.centralrepository.datamodel;
20 
21 import org.openide.util.NbBundle;
22 import org.openide.util.lookup.ServiceProvider;
26 import org.sleuthkit.datamodel.Content;
27 import org.sleuthkit.datamodel.DataSource;
28 import org.sleuthkit.datamodel.TskCoreException;
29 
33 @ServiceProvider(service = AutopsyService.class)
34 public class CentralRepositoryService implements AutopsyService {
35 
36  @Override
37  @NbBundle.Messages({
38  "CentralRepositoryService.serviceName=Central Repository Service"
39  })
40  public String getServiceName() {
41  return Bundle.CentralRepositoryService_serviceName();
42  }
43 
44  @NbBundle.Messages({
45  "CentralRepositoryService.progressMsg.updatingSchema=Updating schema...",
46  "CentralRepositoryService.progressMsg.updatingDataSourcesTable=Checking for v1.2 data updates...",})
47  @Override
50  return;
51  }
52 
53  ProgressIndicator progress = context.getProgressIndicator();
54  progress.progress(Bundle.CentralRepositoryService_progressMsg_updatingSchema());
55  updateSchema();
56 
57  if (context.cancelRequested()) {
58  return;
59  }
60 
61  progress.progress(Bundle.CentralRepositoryService_progressMsg_updatingDataSourcesTable());
62  dataUpgradeForVersion1dot2(context.getCase());
63  }
64 
70  private void updateSchema() throws AutopsyServiceException {
71  try {
73  } catch (CentralRepoException ex) {
74  throw new AutopsyServiceException("Failed to update the Central Repository schema", ex);
75  }
76  }
77 
85  private void dataUpgradeForVersion1dot2(Case currentCase) throws AutopsyServiceException {
86  try {
87  /*
88  * If the case is in the central repository, there may be missing
89  * data source object IDs in the data_sources.datasource_obj_id
90  * column that was added in the version 1.2 schema update.
91  */
92  CentralRepository centralRepository = CentralRepository.getInstance();
93  CorrelationCase correlationCase = centralRepository.getCase(currentCase);
94  if (correlationCase != null) {
95  for (CorrelationDataSource correlationDataSource : centralRepository.getDataSources()) {
96  /*
97  * ResultSet.getLong returns zero when the value in the
98  * result set is NULL.
99  */
100  if (correlationDataSource.getCaseID() == correlationCase.getID() && correlationDataSource.getDataSourceObjectID() == 0) {
101  for (Content dataSource : currentCase.getDataSources()) {
102  if (((DataSource) dataSource).getDeviceId().equals(correlationDataSource.getDeviceID()) && dataSource.getName().equals(correlationDataSource.getName())) {
103  centralRepository.addDataSourceObjectId(correlationDataSource.getID(), dataSource.getId());
104  break;
105  }
106  }
107  }
108  }
109  }
110  } catch (CentralRepoException | TskCoreException ex) {
111  throw new AutopsyServiceException("Failed to update data sources in the Central Repository for schema v1.2", ex);
112  }
113  }
114 
115 }
void addDataSourceObjectId(int rowId, long dataSourceObjectId)

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.