19 package org.sleuthkit.autopsy.keywordsearch;
22 import java.nio.file.Paths;
23 import java.util.List;
24 import java.util.logging.Level;
25 import org.apache.commons.lang.math.NumberUtils;
35 private static final Logger logger = Logger.getLogger(IndexFinder.class.getName());
36 private static final String KWS_OUTPUT_FOLDER_NAME =
"keywordsearch";
37 private static final String KWS_DATA_FOLDER_NAME =
"data";
38 private static final String INDEX_FOLDER_NAME =
"index";
39 private static final String CURRENT_SOLR_VERSION =
"8";
40 private static final String CURRENT_SOLR_SCHEMA_VERSION =
"2.3";
42 static String getCurrentSolrVersion() {
43 return CURRENT_SOLR_VERSION;
46 static String getCurrentSchemaVersion() {
47 return CURRENT_SOLR_SCHEMA_VERSION;
50 static Index findLatestVersionIndexDir(List<Index> allIndexes) {
51 for (Index index : allIndexes) {
52 if (index.getSolrVersion().equals(CURRENT_SOLR_VERSION) && index.getSchemaVersion().equals(CURRENT_SOLR_SCHEMA_VERSION)) {
60 String indexFolderName =
"solr" + CURRENT_SOLR_VERSION +
"_schema" + CURRENT_SOLR_SCHEMA_VERSION;
62 File targetDirPath = Paths.get(theCase.getModuleDirectory(), KWS_OUTPUT_FOLDER_NAME, KWS_DATA_FOLDER_NAME, indexFolderName, INDEX_FOLDER_NAME).toFile();
63 if (!targetDirPath.mkdirs()) {
64 logger.log(Level.SEVERE,
"Unable to create index directory: {0}", targetDirPath.toString());
65 throw new AutopsyService.
AutopsyServiceException(
"Unable to create text index directory " + targetDirPath.getAbsolutePath());
67 return new Index(targetDirPath.getAbsolutePath(), CURRENT_SOLR_VERSION, CURRENT_SOLR_SCHEMA_VERSION,
"", theCase.getName());
70 static Index identifyIndexToUse(List<Index> allIndexes) {
79 Index bestCandidateIndex = null;
80 double solrVerFound = 0.0;
81 double schemaVerFound = 0.0;
82 for (Index index : allIndexes) {
84 if (NumberUtils.toDouble(index.getSolrVersion()) >= solrVerFound) {
86 if (NumberUtils.toDouble(index.getSchemaVersion()) >= schemaVerFound) {
87 bestCandidateIndex = index;
88 solrVerFound = NumberUtils.toDouble(index.getSolrVersion());
89 schemaVerFound = NumberUtils.toDouble(index.getSchemaVersion());
93 return bestCandidateIndex;
AutopsyServiceException(String message)