Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
IndexFinder.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2011-2017 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.keywordsearch;
20
21import java.io.File;
22import java.nio.file.Paths;
23import java.util.List;
24import org.apache.commons.lang.math.NumberUtils;
25import org.sleuthkit.autopsy.casemodule.Case;
26import org.sleuthkit.autopsy.appservices.AutopsyService;
27
31class IndexFinder {
32
33 private static final String KWS_OUTPUT_FOLDER_NAME = "keywordsearch";
34 private static final String KWS_DATA_FOLDER_NAME = "data";
35 private static final String INDEX_FOLDER_NAME = "index";
36 private static final String CURRENT_SOLR_VERSION = "8";
37 private static final int CURRENT_SOLR_VERSION_INT = 8;
38 private static final String CURRENT_SOLR_SCHEMA_VERSION = "2.3";
39
40 static String getCurrentSolrVersion() {
41 return CURRENT_SOLR_VERSION;
42 }
43
44 static String getCurrentSchemaVersion() {
45 return CURRENT_SOLR_SCHEMA_VERSION;
46 }
47
48 static Index findLatestVersionIndex(List<Index> allIndexes) {
49 for (Index index : allIndexes) {
50 if (index.getSolrVersion().equals(CURRENT_SOLR_VERSION) && index.getSchemaVersion().equals(CURRENT_SOLR_SCHEMA_VERSION)) {
51 return index;
52 }
53 }
54 return null;
55 }
56
57 static Index createLatestVersionIndex(Case theCase) throws AutopsyService.AutopsyServiceException {
58 String indexFolderName = "solr" + CURRENT_SOLR_VERSION + "_schema" + CURRENT_SOLR_SCHEMA_VERSION;
59 // new index should be stored in "\ModuleOutput\keywordsearch\data\solrX_schemaY\index"
60 File targetDirPath = Paths.get(theCase.getModuleDirectory(), KWS_OUTPUT_FOLDER_NAME, KWS_DATA_FOLDER_NAME, indexFolderName, INDEX_FOLDER_NAME).toFile(); //NON-NLS
61 return new Index(targetDirPath.getAbsolutePath(), CURRENT_SOLR_VERSION, CURRENT_SOLR_SCHEMA_VERSION, "", theCase.getName());
62 }
63
64 static Index identifyIndexToUse(List<Index> allIndexes) {
65 /*
66 * NOTE: All of the following paths are valid multi-user index paths:
67 * (Solr 4, schema 1.8)
68 * X:\Case\ingest1\ModuleOutput\keywordsearch\data\index
69 * X:\Case\ingest4\ModuleOutput\keywordsearch\data\solr6_schema2.0\index
70 * X:\Case\ingest4\ModuleOutput\keywordsearch\data\solr6_schema1.8\index
71 * X:\Case\ingest4\ModuleOutput\keywordsearch\data\solr7_schema2.0\index
72 */
73 Index bestCandidateIndex = null;
74 double solrVerFound = 0.0;
75 double schemaVerFound = 0.0;
76 for (Index index : allIndexes) {
77 if (NumberUtils.toDouble(index.getSolrVersion()) > CURRENT_SOLR_VERSION_INT) {
78 // "legacy" Solr server cannot open "future" versions of Solr indexes
79 continue;
80 }
81 // higher Solr version takes priority because it may negate index upgrade
82 if (NumberUtils.toDouble(index.getSolrVersion()) >= solrVerFound) {
83 // if same solr version, pick the one with highest schema version
84 if (NumberUtils.toDouble(index.getSchemaVersion()) >= schemaVerFound) {
85 bestCandidateIndex = index;
86 solrVerFound = NumberUtils.toDouble(index.getSolrVersion());
87 schemaVerFound = NumberUtils.toDouble(index.getSchemaVersion());
88 }
89 }
90 }
91 return bestCandidateIndex;
92 }
93
103 static String isFutureIndexPresent(List<Index> allIndexes) {
104 for (Index index : allIndexes) {
105 if (NumberUtils.toDouble(index.getSolrVersion()) > CURRENT_SOLR_VERSION_INT) {
106 // "legacy" Solr server cannot open "future" versions of Solr indexes
107 return index.getSolrVersion();
108 }
109 }
110 return "";
111 }
112}

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