mirror of
https://github.com/elisspace/autopsy.git
synced 2026-09-06 02:24:30 +00:00
Logic to read and write all existing Solr cores into SolrCore.properties
This commit is contained in:
@@ -52,7 +52,6 @@ public class IndexMetadata {
|
||||
private final Path metadataFilePath;
|
||||
private final String metadataFileName = "SolrCore.properties";
|
||||
private final static String ROOT_ELEMENT_NAME = "SolrCores"; //NON-NLS
|
||||
private final static String NUM_CORES_ELEMENT_NAME = "NumberOfCore"; //NON-NLS
|
||||
private final static String CORE_ELEMENT_NAME = "Core"; //NON-NLS
|
||||
private final static String CORE_NAME_ELEMENT_NAME = "CoreName"; //NON-NLS
|
||||
private final static String SCHEMA_VERSION_ELEMENT_NAME = "SchemaVersion"; //NON-NLS
|
||||
@@ -81,13 +80,13 @@ public class IndexMetadata {
|
||||
* Constructs an object that provides access to the text index metadata stored in
|
||||
* an existing text index metadata file.
|
||||
*
|
||||
* @param metadataFilePath The full path to the text index metadata file.
|
||||
* @param caseDirectory The full path to the top level case output folder.
|
||||
*
|
||||
* @throws TextIndexMetadataException If the new text index metadata file cannot be
|
||||
* read.
|
||||
*/
|
||||
public IndexMetadata(Path metadataFilePath) throws TextIndexMetadataException {
|
||||
this.metadataFilePath = metadataFilePath;
|
||||
public IndexMetadata(String caseDirectory) throws TextIndexMetadataException {
|
||||
this.metadataFilePath = Paths.get(caseDirectory, metadataFileName);
|
||||
readFromFile();
|
||||
}
|
||||
|
||||
@@ -148,7 +147,6 @@ public class IndexMetadata {
|
||||
*/
|
||||
Element rootElement = doc.createElement(ROOT_ELEMENT_NAME);
|
||||
doc.appendChild(rootElement);
|
||||
// ELTODO REMOVE createChildElement(doc, rootElement, NUM_CORES_ELEMENT_NAME, Integer.toString(indexes.size()));
|
||||
|
||||
/*
|
||||
* Create the children of the Solr cores element.
|
||||
|
||||
@@ -193,12 +193,15 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
|
||||
}
|
||||
|
||||
// check if index needs upgrade
|
||||
Index currentVersionIndex;
|
||||
Index currentVersionIndex = null;
|
||||
if (indexes.isEmpty()) {
|
||||
// new case that doesn't have an existing index. create new index folder
|
||||
progressUnitsCompleted++;
|
||||
progress.progress(Bundle.SolrSearch_creatingNewIndex_msg(), progressUnitsCompleted);
|
||||
currentVersionIndex = IndexFinder.createLatestVersionIndexDir(context.getCase());
|
||||
|
||||
// add current index to the list of indexes that exist for this case
|
||||
indexes.add(currentVersionIndex);
|
||||
} else {
|
||||
// check if one of the existing indexes is for latest Solr version and schema
|
||||
progressUnitsCompleted++;
|
||||
@@ -293,6 +296,9 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
|
||||
logger.log(Level.SEVERE, String.format("Failed to delete %s when upgrade cancelled", newIndexVersionDir), ex);
|
||||
}
|
||||
}
|
||||
|
||||
// add current index to the list of indexes that exist for this case
|
||||
indexes.add(currentVersionIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -307,11 +313,10 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
|
||||
|
||||
try {
|
||||
// store the new core name
|
||||
indexes.add(currentVersionIndex);
|
||||
IndexMetadata indexMetadata = new IndexMetadata(context.getCase().getCaseDirectory(), indexes);
|
||||
|
||||
// ELTODO remove
|
||||
IndexMetadata ind = new IndexMetadata(indexMetadata.getFilePath());
|
||||
IndexMetadata ind = new IndexMetadata(context.getCase().getCaseDirectory());
|
||||
} catch (IndexMetadata.TextIndexMetadataException ex) {
|
||||
throw new AutopsyServiceException("Failed to save core name in case metadata file", ex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user