mirror of
https://github.com/elisspace/autopsy.git
synced 2026-10-03 07:49:52 +00:00
Fixes for Solr core deletion and Case delete action progress
This commit is contained in:
@@ -594,7 +594,7 @@ public class Case {
|
||||
"Case.exceptionMessage.cannotDeleteCaseOpenForOtherUser=Cannot delete the case, it is open for another user.",})
|
||||
public static void deleteCase(CaseMetadata metadata) throws CaseActionException {
|
||||
synchronized (caseActionSerializationLock) {
|
||||
if (null != currentCase && 0 == metadata.getCaseDirectory().compareTo(metadata.getCaseDirectory())) {
|
||||
if (null != currentCase) {
|
||||
throw new CaseActionException(Bundle.Case_deleteException_couldNotDeleteCase(Bundle.Case_exceptionMessage_cannotDeleteCurrentCase()));
|
||||
}
|
||||
}
|
||||
@@ -610,7 +610,6 @@ public class Case {
|
||||
progressIndicator = new LoggingProgressIndicator();
|
||||
}
|
||||
progressIndicator.start(Bundle.Case_progressMessage_preparing());
|
||||
|
||||
try {
|
||||
if (CaseType.SINGLE_USER_CASE == metadata.getCaseType()) {
|
||||
deleteCase(metadata, progressIndicator);
|
||||
@@ -624,6 +623,7 @@ public class Case {
|
||||
assert (null != dirLock);
|
||||
deleteCase(metadata, progressIndicator);
|
||||
} catch (CoordinationServiceException ex) {
|
||||
// RJCTODO: need to throw here, could not delete case at all
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
@@ -860,7 +860,7 @@ public class Case {
|
||||
* Delete the case database from the database server.
|
||||
*/
|
||||
try {
|
||||
progressIndicator.start(Bundle.Case_progressMessage_deletingCaseDatabase());
|
||||
progressIndicator.progress(Bundle.Case_progressMessage_deletingCaseDatabase());
|
||||
CaseDbConnectionInfo db;
|
||||
db = UserPreferences.getDatabaseConnectionInfo();
|
||||
Class.forName("org.postgresql.Driver"); //NON-NLS
|
||||
@@ -878,7 +878,7 @@ public class Case {
|
||||
/*
|
||||
* Delete the text index.
|
||||
*/
|
||||
progressIndicator.start(Bundle.Case_progressMessage_deletingTextIndex());
|
||||
progressIndicator.progress(Bundle.Case_progressMessage_deletingTextIndex());
|
||||
for (KeywordSearchService searchService : Lookup.getDefault().lookupAll(KeywordSearchService.class)) {
|
||||
try {
|
||||
searchService.deleteTextIndex(metadata);
|
||||
@@ -891,7 +891,7 @@ public class Case {
|
||||
/*
|
||||
* Delete the case directory.
|
||||
*/
|
||||
progressIndicator.start(Bundle.Case_progressMessage_deletingCaseDirectory());
|
||||
progressIndicator.progress(Bundle.Case_progressMessage_deletingCaseDirectory());
|
||||
if (!FileUtil.deleteDir(new File(metadata.getCaseDirectory()))) {
|
||||
logger.log(Level.SEVERE, String.format("Failed to delete case directory for %s (%s) in %s", metadata.getCaseDisplayName(), metadata.getCaseName(), metadata.getCaseDirectory()));
|
||||
errorsOccurred = true;
|
||||
|
||||
@@ -213,7 +213,7 @@ Server.queryNumFileChunks.exception.msg=Error getting number of file chunks,
|
||||
Server.query.exception.msg=Error running query\: {0}
|
||||
Server.query2.exception.msg=Error running query\: {0}
|
||||
Server.queryTerms.exception.msg=Error running terms query\: {0}
|
||||
Server.connect.exception.msg=Failed to connect to Solr server\:
|
||||
Server.connect.exception.msg=Failed to connect to Solr server\: {0}
|
||||
Server.openCore.exception.msg=Keyword search service not yet running
|
||||
Server.openCore.exception.cantOpen.msg=Could not create or open index
|
||||
Server.openCore.exception.noIndexDir.msg=Index directory could not be created or is missing
|
||||
|
||||
@@ -270,7 +270,7 @@ HighlightedMatchesSource.getMarkup.queryFailedMsg=<html><pre><span style\\\\\='b
|
||||
KeywordSearch.openCore.notification.msg=\u30ad\u30fc\u30ef\u30fc\u30c9\u691c\u7d22\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u958b\u3051\u307e\u305b\u3093\u3067\u3057\u305f
|
||||
KeywordSearch.closeCore.notification.msg=\u30ad\u30fc\u30ef\u30fc\u30c9\u691c\u7d22\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u9589\u3058\u308b\u969b\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f
|
||||
KeywordSearchListsManagementPanel.fileExtensionFilterLb2=\u30ad\u30fc\u30ef\u30fc\u30c9\u30ea\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u30a8\u30f3\u30b1\u30fc\u30b9\u3059\u308b(txt)
|
||||
Server.connect.exception.msg=Solr\u30b5\u30fc\u30d0\u30fc\u3078\u306e\u63a5\u7d9a\u306b\u5931\u6557\u3057\u307e\u3057\u305f\uff1a
|
||||
Server.connect.exception.msg=Solr\u30b5\u30fc\u30d0\u30fc\u3078\u306e\u63a5\u7d9a\u306b\u5931\u6557\u3057\u307e\u3057\u305f\uff1a{0}
|
||||
Server.openCore.exception.noIndexDir.msg=\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u307e\u305f\u306f\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002
|
||||
KeywordSearchIngestModule.startUp.noOpenCore.msg=\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u304c\u958b\u3051\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u307e\u305f\u306f\u5b58\u5728\u3057\u307e\u305b\u3093\u3002
|
||||
SolrConnectionCheck.HostnameOrPort=hostname\u3084\u30dd\u30fc\u30c8\u756a\u53f7\u304c\u7121\u52b9\u3067\u3059\u3002
|
||||
|
||||
@@ -187,7 +187,7 @@ public class Server {
|
||||
private int currentSolrServerPort = 0;
|
||||
private int currentSolrStopPort = 0;
|
||||
private static final boolean DEBUG = false;//(Version.getBuildType() == Version.Type.DEVELOPMENT);
|
||||
private static final String SOLR = "solr";
|
||||
private static final String SOLR = "solr";
|
||||
private static final String CORE_PROPERTIES = "core.properties";
|
||||
|
||||
public enum CORE_EVT_STATES {
|
||||
@@ -636,7 +636,7 @@ public class Server {
|
||||
* Creates/opens a Solr core (index) for a case.
|
||||
*
|
||||
* @param theCase The case for which the core is to be created/opened.
|
||||
* @param index The text index that the Solr core should be using.
|
||||
* @param index The text index that the Solr core should be using.
|
||||
*
|
||||
* @throws KeywordSearchModuleException If an error occurs while
|
||||
* creating/opening the core.
|
||||
@@ -645,14 +645,14 @@ public class Server {
|
||||
currentCoreLock.writeLock().lock();
|
||||
try {
|
||||
currentCore = openCore(theCase, index);
|
||||
|
||||
|
||||
try {
|
||||
// execute a test query. if it fails, an exception will be thrown
|
||||
queryNumIndexedFiles();
|
||||
} catch (NoOpenCoreException ex) {
|
||||
throw new KeywordSearchModuleException(NbBundle.getMessage(this.getClass(), "Server.openCore.exception.cantOpen.msg"), ex);
|
||||
}
|
||||
|
||||
|
||||
serverAction.putValue(CORE_EVT, CORE_EVT_STATES.STARTED);
|
||||
} finally {
|
||||
currentCoreLock.writeLock().unlock();
|
||||
@@ -684,7 +684,7 @@ public class Server {
|
||||
currentCoreLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void closeCore() throws KeywordSearchModuleException {
|
||||
currentCoreLock.writeLock().lock();
|
||||
try {
|
||||
@@ -713,7 +713,6 @@ public class Server {
|
||||
/**
|
||||
* ** end single-case specific methods ***
|
||||
*/
|
||||
|
||||
/**
|
||||
* Deletes the keyword search core for a case.
|
||||
*
|
||||
@@ -721,46 +720,66 @@ public class Server {
|
||||
*/
|
||||
@NbBundle.Messages({
|
||||
"# {0} - core name", "Server.deleteCore.exception.msg=Failed to delete Solr core {0}",})
|
||||
void deleteCore(String coreName) throws KeywordSearchServiceException {
|
||||
/*
|
||||
* Send a core unload request to the Solr server, with the parameters
|
||||
* that request deleting the index and the instance directory
|
||||
* (deleteInstanceDir removes everything related to the core, the index
|
||||
* directory, the configuration files, etc.) set to true.
|
||||
* NOTE: this method doesn't delete the actual Solr index directory. That is
|
||||
* done as part of deleting case output directory.
|
||||
*/
|
||||
|
||||
// check whether the core we are deleting is the currently open core
|
||||
currentCoreLock.readLock().lock();
|
||||
try {
|
||||
if (null != currentCore) {
|
||||
if (currentCore.getName().equals(coreName)) {
|
||||
// close current core first
|
||||
closeCore();
|
||||
void deleteCore(String coreName, Case.CaseType caseType) throws KeywordSearchServiceException {
|
||||
if (null != currentSolrServer) {
|
||||
/*
|
||||
* If there is a Solr server connection and the core to delete is
|
||||
* open, then close it.
|
||||
*/
|
||||
currentCoreLock.readLock().lock();
|
||||
try {
|
||||
if (null != currentCore) {
|
||||
if (currentCore.getName().equals(coreName)) {
|
||||
// close current core first
|
||||
closeCore();
|
||||
}
|
||||
}
|
||||
} catch (KeywordSearchModuleException ex) {
|
||||
throw new KeywordSearchServiceException(NbBundle.getMessage(Server.class, "Server.close.exception.msg"), ex);
|
||||
} finally {
|
||||
currentCoreLock.readLock().unlock();
|
||||
}
|
||||
} catch (KeywordSearchModuleException ex) {
|
||||
throw new KeywordSearchServiceException(NbBundle.getMessage(Server.class, "Server.close.exception.msg"), ex);
|
||||
} finally {
|
||||
currentCoreLock.readLock().unlock();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Send a core unload request to the Solr server, with the parameter set
|
||||
* that request deleting the index and the instance directory
|
||||
* (deleteInstanceDir = true). Note that this removes everything related
|
||||
* to the core on the server (the index directory, the configuration
|
||||
* files, etc.), but does not delete the actual Solr index directory in
|
||||
* the case directory.
|
||||
*/
|
||||
HttpSolrServer solrServer;
|
||||
if (null != currentSolrServer) {
|
||||
solrServer = currentSolrServer;
|
||||
} else {
|
||||
try {
|
||||
if (caseType == CaseType.SINGLE_USER_CASE) {
|
||||
Integer localSolrServerPort = Integer.decode(ModuleSettings.getConfigSetting(PROPERTIES_FILE, PROPERTIES_CURRENT_SERVER_PORT));
|
||||
solrServer = new HttpSolrServer("http://localhost:" + localSolrServerPort + "/solr"); //NON-NLS
|
||||
} else {
|
||||
String host = UserPreferences.getIndexingServerHost();
|
||||
String port = UserPreferences.getIndexingServerPort();
|
||||
solrServer = new HttpSolrServer("http://" + host + ":" + port + "/solr"); //NON-NLS
|
||||
}
|
||||
connectToSolrServer(solrServer);
|
||||
} catch (SolrServerException | IOException ex) {
|
||||
throw new KeywordSearchServiceException(NbBundle.getMessage(Server.class, "Server.connect.exception.msg", ex.getLocalizedMessage()), ex);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
HttpSolrServer solrServer = new HttpSolrServer("http://" + UserPreferences.getIndexingServerHost() + ":" + UserPreferences.getIndexingServerPort() + "/solr"); //NON-NLS
|
||||
connectToSolrServer(solrServer);
|
||||
org.apache.solr.client.solrj.request.CoreAdminRequest.unloadCore(coreName, true, true, solrServer);
|
||||
} catch (SolrServerException | IOException ex) {
|
||||
org.apache.solr.client.solrj.request.CoreAdminRequest.unloadCore(coreName, true, true, solrServer);
|
||||
} catch (SolrServerException | HttpSolrServer.RemoteSolrException | IOException ex) {
|
||||
throw new KeywordSearchServiceException(Bundle.Server_deleteCore_exception_msg(coreName), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates/opens a Solr core (index) for a case.
|
||||
*
|
||||
* @param theCase The case for which the core is to be created/opened.
|
||||
* @param index The text index that the Solr core should be using.
|
||||
* @param index The text index that the Solr core should be using.
|
||||
*
|
||||
* @return An object representing the created/opened core.
|
||||
*
|
||||
@@ -780,7 +799,7 @@ public class Server {
|
||||
connectToSolrServer(currentSolrServer);
|
||||
|
||||
} catch (SolrServerException | IOException ex) {
|
||||
throw new KeywordSearchModuleException(NbBundle.getMessage(Server.class, "Server.connect.exception.msg"), ex);
|
||||
throw new KeywordSearchModuleException(NbBundle.getMessage(Server.class, "Server.connect.exception.msg", ex.getLocalizedMessage()), ex);
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -891,8 +910,8 @@ public class Server {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute query that gets only number of all Solr file chunks (not
|
||||
* logical files) indexed without actually returning the content.
|
||||
* Execute query that gets only number of all Solr file chunks (not logical
|
||||
* files) indexed without actually returning the content.
|
||||
*
|
||||
* @return int representing number of indexed chunks
|
||||
*
|
||||
@@ -916,8 +935,8 @@ public class Server {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute query that gets only number of all Solr documents indexed
|
||||
* (files and chunks) without actually returning the documents
|
||||
* Execute query that gets only number of all Solr documents indexed (files
|
||||
* and chunks) without actually returning the documents
|
||||
*
|
||||
* @return int representing number of indexed files (files and chunks)
|
||||
*
|
||||
@@ -970,11 +989,10 @@ public class Server {
|
||||
/**
|
||||
* Execute query that gets number of indexed file chunks for a file
|
||||
*
|
||||
* @param fileID file id of the original file broken into chunks and
|
||||
* indexed
|
||||
* @param fileID file id of the original file broken into chunks and indexed
|
||||
*
|
||||
* @return int representing number of indexed file chunks, 0 if there is
|
||||
* no chunks
|
||||
* @return int representing number of indexed file chunks, 0 if there is no
|
||||
* chunks
|
||||
*
|
||||
* @throws KeywordSearchModuleException
|
||||
* @throws NoOpenCoreException
|
||||
@@ -1206,8 +1224,7 @@ public class Server {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether or not the index files folder for a Solr core
|
||||
* exists.
|
||||
* Determines whether or not the index files folder for a Solr core exists.
|
||||
*
|
||||
* @param coreName the name of the core.
|
||||
*
|
||||
@@ -1233,7 +1250,7 @@ public class Server {
|
||||
private final String name;
|
||||
|
||||
private final CaseType caseType;
|
||||
|
||||
|
||||
private final Index textIndex;
|
||||
|
||||
// the server to access a core needs to be built from a URL with the
|
||||
@@ -1272,7 +1289,7 @@ public class Server {
|
||||
private Index getIndexInfo() {
|
||||
return this.textIndex;
|
||||
}
|
||||
|
||||
|
||||
private QueryResponse query(SolrQuery sq) throws SolrServerException, IOException {
|
||||
return solrCore.query(sq);
|
||||
}
|
||||
@@ -1385,8 +1402,8 @@ public class Server {
|
||||
* Execute query that gets only number of all Solr files (not chunks)
|
||||
* indexed without actually returning the files
|
||||
*
|
||||
* @return int representing number of indexed files (entire files,
|
||||
* not chunks)
|
||||
* @return int representing number of indexed files (entire files, not
|
||||
* chunks)
|
||||
*
|
||||
* @throws SolrServerException
|
||||
*/
|
||||
@@ -1447,11 +1464,11 @@ public class Server {
|
||||
/**
|
||||
* Execute query that gets number of indexed file chunks for a file
|
||||
*
|
||||
* @param contentID file id of the original file broken into chunks
|
||||
* and indexed
|
||||
* @param contentID file id of the original file broken into chunks and
|
||||
* indexed
|
||||
*
|
||||
* @return int representing number of indexed file chunks, 0 if there
|
||||
* is no chunks
|
||||
* @return int representing number of indexed file chunks, 0 if there is
|
||||
* no chunks
|
||||
*
|
||||
* @throws SolrServerException
|
||||
*/
|
||||
|
||||
@@ -162,8 +162,8 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
|
||||
String currentSchema = IndexFinder.getCurrentSchemaVersion();
|
||||
String currentSolr = IndexFinder.getCurrentSolrVersion();
|
||||
for (Index index : indexMetadata.getIndexes()) {
|
||||
if (index.getSolrVersion().equals(currentSolr) && index.getSchemaVersion().equals(currentSchema)) {
|
||||
KeywordSearch.getServer().deleteCore(index.getIndexName());
|
||||
if (index.getSolrVersion().equals(currentSolr) && index.getSchemaVersion().equals(currentSchema)) { // RJCTODO
|
||||
KeywordSearch.getServer().deleteCore(index.getIndexName(), metadata.getCaseType());
|
||||
return; //only one core exists for each combination of solr and schema version
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user