Autopsy  4.16.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  })
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  dataUpgradeForVersion1dot2(context.getCase());
62  }
63 
69  private void updateSchema() throws AutopsyServiceException {
70  try {
72  } catch (CentralRepoException ex) {
73  throw new AutopsyServiceException("Failed to update the Central Repository schema", ex);
74  }
75  }
76 
84  private void dataUpgradeForVersion1dot2(Case currentCase) throws AutopsyServiceException {
85  try {
86  /*
87  * If the case is in the central repository, there may be missing
88  * data source object IDs in the data_sources.datasource_obj_id
89  * column that was added in the version 1.2 schema update.
90  */
91  CentralRepository centralRepository = CentralRepository.getInstance();
92  CorrelationCase correlationCase = centralRepository.getCase(currentCase);
93  if (correlationCase != null) {
94  for (CorrelationDataSource correlationDataSource : centralRepository.getDataSources()) {
95  /*
96  * ResultSet.getLong returns zero when the value in the
97  * result set is NULL.
98  */
99  if (correlationDataSource.getCaseID() == correlationCase.getID() && correlationDataSource.getDataSourceObjectID() == 0) {
100  for (Content dataSource : currentCase.getDataSources()) {
101  if (((DataSource) dataSource).getDeviceId().equals(correlationDataSource.getDeviceID()) && dataSource.getName().equals(correlationDataSource.getName())) {
102  centralRepository.addDataSourceObjectId(correlationDataSource.getID(), dataSource.getId());
103  break;
104  }
105  }
106  }
107  }
108  }
109  } catch (CentralRepoException | TskCoreException ex) {
110  throw new AutopsyServiceException("Failed to update data sources in the Central Repository for schema v1.2", ex);
111  }
112  }
113 
114 }
void addDataSourceObjectId(int rowId, long dataSourceObjectId)

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