mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-16 09:47:42 +00:00
Code review + bug fixes
This commit is contained in:
parent
10494299e4
commit
d03108c403
@ -34,6 +34,17 @@ final class Index {
|
||||
private static final String DEFAULT_CORE_NAME = "text_index"; //NON-NLS
|
||||
private final UNCPathUtilities uncPathUtilities = new UNCPathUtilities();
|
||||
|
||||
/**
|
||||
* Constructs a representation of a text index.
|
||||
*
|
||||
* @param indexPath The path to the index.
|
||||
* @param solrVersion The Solr version of the index.
|
||||
* @param schemaVersion The Solr schema version of the index.
|
||||
* @param coreName The core name, may be the empty string or null if
|
||||
* the corename should be generated.
|
||||
* @param caseName The name of the case, ignored if coreName does not
|
||||
* need to be generated.
|
||||
*/
|
||||
Index(String indexPath, String solrVersion, String schemaVersion, String coreName, String caseName) {
|
||||
this.indexPath = convertPathToUNC(indexPath);
|
||||
this.solrVersion = solrVersion;
|
||||
@ -53,10 +64,10 @@ final class Index {
|
||||
* @return The sanitized Solr core name
|
||||
*/
|
||||
private String createCoreName(String caseName) {
|
||||
String coreName = sanitizeCoreName(caseName);
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss");
|
||||
Date date = new Date();
|
||||
String coreName = caseName + "_" + dateFormat.format(date);
|
||||
return sanitizeCoreName(coreName);
|
||||
return coreName + "_" + dateFormat.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,8 +75,9 @@ final class Index {
|
||||
*
|
||||
* Solr:
|
||||
* http://stackoverflow.com/questions/29977519/what-makes-an-invalid-core-name
|
||||
* may not be / \ :
|
||||
* Starting Solr6: core names must consist entirely of periods, underscores, hyphens, and alphanumerics as well not start with a hyphen. may not contain space characters.
|
||||
* may not be / \ : Starting Solr6: core names must consist entirely of
|
||||
* periods, underscores, hyphens, and alphanumerics as well not start with a
|
||||
* hyphen. may not contain space characters.
|
||||
*
|
||||
* @param coreName A candidate core name.
|
||||
*
|
||||
@ -100,9 +112,6 @@ final class Index {
|
||||
}
|
||||
|
||||
String convertPathToUNC(String indexDir) {
|
||||
if (uncPathUtilities == null) {
|
||||
return indexDir;
|
||||
}
|
||||
// if we can check for UNC paths, do so, otherwise just return the indexDir
|
||||
String result = uncPathUtilities.mappedDriveToUNC(indexDir);
|
||||
if (result == null) {
|
||||
|
@ -184,7 +184,7 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
|
||||
public void openCaseResources(CaseContext context) throws AutopsyServiceException {
|
||||
ProgressIndicator progress = context.getProgressIndicator();
|
||||
int totalNumProgressUnits = 8;
|
||||
int progressUnitsCompleted = 1;
|
||||
int progressUnitsCompleted = 0;
|
||||
|
||||
List<Index> indexes = new ArrayList<>();
|
||||
try {
|
||||
@ -311,6 +311,7 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.SEVERE, String.format("Failed to delete %s when upgrade cancelled", newIndexVersionDir), ex);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// add current index to the list of indexes that exist for this case
|
||||
@ -319,6 +320,16 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// update text index metadata file
|
||||
if (!indexes.isEmpty()) {
|
||||
IndexMetadata indexMetadata = new IndexMetadata(context.getCase().getCaseDirectory(), indexes);
|
||||
}
|
||||
} catch (IndexMetadata.TextIndexMetadataException ex) {
|
||||
throw new AutopsyServiceException("Failed to save Solr core info in text index metadata file", ex);
|
||||
}
|
||||
|
||||
// open core
|
||||
try {
|
||||
progress.progress(Bundle.SolrSearch_openCore_msg(), totalNumProgressUnits - 1);
|
||||
@ -327,17 +338,6 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
|
||||
throw new AutopsyServiceException(String.format("Failed to open or create core for %s", context.getCase().getCaseDirectory()), ex);
|
||||
}
|
||||
|
||||
try {
|
||||
// update text index metadata file
|
||||
if (!indexes.isEmpty()) {
|
||||
// ELTODO REMOVE
|
||||
List<Index> FAKEindexes = new ArrayList<>();
|
||||
IndexMetadata indexMetadata = new IndexMetadata(context.getCase().getCaseDirectory(), FAKEindexes);
|
||||
}
|
||||
} catch (IndexMetadata.TextIndexMetadataException ex) {
|
||||
throw new AutopsyServiceException("Failed to save Solr core info in text index metadata file", ex);
|
||||
}
|
||||
|
||||
progress.progress(Bundle.SolrSearch_complete_msg(), totalNumProgressUnits);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user