mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 08:56:15 +00:00
Merge pull request #1674 from rcordovano/kws_open_core_error_handling
Kws open core error handling
This commit is contained in:
commit
fc313f15ad
@ -59,4 +59,11 @@ public class RuntimeProperties {
|
|||||||
public static boolean coreComponentsAreActive() {
|
public static boolean coreComponentsAreActive() {
|
||||||
return coreComponentsActive;
|
return coreComponentsActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private constructor to prevent creation of instances of this class.
|
||||||
|
*/
|
||||||
|
private RuntimeProperties() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,5 +195,5 @@ MultiUserSettingsPanel.tbMsgHostname.text=
|
|||||||
MultiUserSettingsPanel.lbTestMessageWarning.text=
|
MultiUserSettingsPanel.lbTestMessageWarning.text=
|
||||||
MultiUserSettingsPanel.lbTestSolrWarning.text=
|
MultiUserSettingsPanel.lbTestSolrWarning.text=
|
||||||
MultiUserSettingsPanel.lbTestDbWarning.text=
|
MultiUserSettingsPanel.lbTestDbWarning.text=
|
||||||
MultiUserSettingsPanel.KeywordSearchNull=Cannot find Keyword Search service
|
MultiUserSettingsPanel.KeywordSearchNull=Cannot find keyword search service
|
||||||
MultiUserSettingsPanel.InvalidPortNumber=Invalid port number.
|
MultiUserSettingsPanel.InvalidPortNumber=Invalid port number
|
@ -83,6 +83,8 @@ KeywordSearchConfigurationPanel1.customizeComponents.title=Delete a keyword list
|
|||||||
KeywordSearchConfigurationPanel1.customizeComponents.body=This will delete the keyword list globally (for all Cases). Do you want to proceed with the deletion?
|
KeywordSearchConfigurationPanel1.customizeComponents.body=This will delete the keyword list globally (for all Cases). Do you want to proceed with the deletion?
|
||||||
KeywordSearchConfigurationPanel1.customizeComponents.keywordListEmptyErr=Keyword List is empty and cannot be saved
|
KeywordSearchConfigurationPanel1.customizeComponents.keywordListEmptyErr=Keyword List is empty and cannot be saved
|
||||||
KeywordSearch.newKwListTitle=New keyword list name\:
|
KeywordSearch.newKwListTitle=New keyword list name\:
|
||||||
|
KeywordSearch.openCore.notification.msg=Could not open keyword search index
|
||||||
|
KeywordSearch.closeCore.notification.msg=Error closing keyword search index
|
||||||
KeywordSearchConfigurationPanel1.customizeComponents.noOwDefaultMsg=Cannot overwrite default list
|
KeywordSearchConfigurationPanel1.customizeComponents.noOwDefaultMsg=Cannot overwrite default list
|
||||||
KeywordSearchConfigurationPanel1.customizeComponents.kwListExistMsg=Keyword List <{0}> already exists, do you want to replace it?
|
KeywordSearchConfigurationPanel1.customizeComponents.kwListExistMsg=Keyword List <{0}> already exists, do you want to replace it?
|
||||||
KeywordSearchConfigurationPanel1.customizeComponents.kwListSavedMsg=Keyword List <{0}> saved
|
KeywordSearchConfigurationPanel1.customizeComponents.kwListSavedMsg=Keyword List <{0}> saved
|
||||||
@ -220,10 +222,9 @@ Server.query.exception.msg=Error running query\: {0}
|
|||||||
Server.query2.exception.msg=Error running query\: {0}
|
Server.query2.exception.msg=Error running query\: {0}
|
||||||
Server.queryTerms.exception.msg=Error running terms 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\:
|
||||||
Server.openCore.exception.msg=Core open requested, but server not yet running
|
Server.openCore.exception.msg=Keyword search service not yet running
|
||||||
Server.openCore.exception.cantOpen.msg=Could not open Core
|
Server.openCore.exception.cantOpen.msg=Could not open index
|
||||||
Server.openCore.exception.cantOpen.msg2=Could not open Core
|
Server.openCore.exception.noIndexDir.msg=Index directory could not be created or is missing
|
||||||
Server.openCore.exception.cantOpenForCase.msg=Could not create keyword search index for case {0}
|
|
||||||
Server.request.exception.exception.msg=Could not issue Solr request
|
Server.request.exception.exception.msg=Could not issue Solr request
|
||||||
Server.commit.exception.msg=Could not commit index
|
Server.commit.exception.msg=Could not commit index
|
||||||
Server.addDoc.exception.msg=Could not add document to index via update handler\: {0}
|
Server.addDoc.exception.msg=Could not add document to index via update handler\: {0}
|
||||||
@ -287,7 +288,8 @@ KeywordSearchModuleFactory.createFileIngestModule.exception.msg=Expected setting
|
|||||||
SearchRunner.Searcher.done.err.msg=Error performing keyword search
|
SearchRunner.Searcher.done.err.msg=Error performing keyword search
|
||||||
KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.toolTipText=Fastest overall, but no results until the end
|
KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.toolTipText=Fastest overall, but no results until the end
|
||||||
KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.text=No periodic searches
|
KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.text=No periodic searches
|
||||||
KeywordSearchIngestModule.startUp.fileTypeDetectorInitializationException.msg=Error initializing the file type detector.
|
KeywordSearchIngestModule.startUp.noOpenCore.msg=The index could not be opened or does not exist
|
||||||
|
KeywordSearchIngestModule.startUp.fileTypeDetectorInitializationException.msg=Error initializing the file type detector
|
||||||
SolrConnectionCheck.HostnameOrPort=Invalid hostname and/or port number.
|
SolrConnectionCheck.HostnameOrPort=Invalid hostname and/or port number.
|
||||||
SolrConnectionCheck.Hostname=Invalid hostname.
|
SolrConnectionCheck.Hostname=Invalid hostname.
|
||||||
SolrConnectionCheck.Port=Invalid port number.
|
SolrConnectionCheck.Port=Invalid port number.
|
||||||
|
@ -223,7 +223,7 @@ class DropdownToolbar extends javax.swing.JPanel {
|
|||||||
String changed = evt.getPropertyName();
|
String changed = evt.getPropertyName();
|
||||||
if (changed.equals(Case.Events.CURRENT_CASE.toString())) {
|
if (changed.equals(Case.Events.CURRENT_CASE.toString())) {
|
||||||
dropPanel.resetSearchBox();
|
dropPanel.resetSearchBox();
|
||||||
setFields(null != evt.getNewValue() && RuntimeProperties.coreComponentsAreActive());
|
setFields(null != evt.getNewValue() && RuntimeProperties.coreComponentsAreActive() && KeywordSearch.getServer().coreIsOpen());
|
||||||
} else if (changed.equals(Server.CORE_EVT)) {
|
} else if (changed.equals(Server.CORE_EVT)) {
|
||||||
final Server.CORE_EVT_STATES state = (Server.CORE_EVT_STATES) evt.getNewValue();
|
final Server.CORE_EVT_STATES state = (Server.CORE_EVT_STATES) evt.getNewValue();
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2011 Basis Technology Corp.
|
* Copyright 2011-2015 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -38,13 +38,14 @@ import org.sleuthkit.autopsy.coreutils.Version;
|
|||||||
class Installer extends ModuleInstall {
|
class Installer extends ModuleInstall {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(Installer.class.getName());
|
private static final Logger logger = Logger.getLogger(Installer.class.getName());
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restored() {
|
public void restored() {
|
||||||
//Setup the default KeywordSearch configuration files
|
//Setup the default KeywordSearch configuration files
|
||||||
KeywordSearchSettings.setDefaults();
|
KeywordSearchSettings.setDefaults();
|
||||||
|
|
||||||
Case.addPropertyChangeListener(new KeywordSearch.CaseChangeListener());
|
Case.addEventSubscriber(Case.Events.CURRENT_CASE.toString(), new KeywordSearch.CaseChangeListener());
|
||||||
|
|
||||||
final Server server = KeywordSearch.getServer();
|
final Server server = KeywordSearch.getServer();
|
||||||
try {
|
try {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2011 Basis Technology Corp.
|
* Copyright 2011-2015 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -26,7 +26,6 @@ import java.util.logging.FileHandler;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.logging.SimpleFormatter;
|
import java.util.logging.SimpleFormatter;
|
||||||
import org.openide.util.Exceptions;
|
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
||||||
@ -75,10 +74,8 @@ public class KeywordSearch {
|
|||||||
TIKA_LOGGER.addHandler(tikaLogHandler);
|
TIKA_LOGGER.addHandler(tikaLogHandler);
|
||||||
//do not forward to the parent autopsy logger
|
//do not forward to the parent autopsy logger
|
||||||
TIKA_LOGGER.setUseParentHandlers(false);
|
TIKA_LOGGER.setUseParentHandlers(false);
|
||||||
} catch (IOException ex) {
|
} catch (IOException | SecurityException ex) {
|
||||||
Exceptions.printStackTrace(ex);
|
logger.log(Level.SEVERE, "Error setting up tika logging", ex);
|
||||||
} catch (SecurityException ex) {
|
|
||||||
Exceptions.printStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,37 +114,29 @@ public class KeywordSearch {
|
|||||||
*/
|
*/
|
||||||
static class CaseChangeListener implements PropertyChangeListener {
|
static class CaseChangeListener implements PropertyChangeListener {
|
||||||
|
|
||||||
CaseChangeListener() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
public void propertyChange(PropertyChangeEvent evt) {
|
||||||
String changed = evt.getPropertyName();
|
if (evt.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) {
|
||||||
|
if (null != evt.getOldValue()) {
|
||||||
final Logger logger = Logger.getLogger(CaseChangeListener.class.getName());
|
Case closedCase = (Case) evt.getOldValue();
|
||||||
if (changed.equals(Case.Events.CURRENT_CASE.toString())) {
|
|
||||||
/*
|
|
||||||
* don't call getOld/NewValue() unless they are needed, since
|
|
||||||
* they might do expensive db operations to load transient
|
|
||||||
* values lost in serialization
|
|
||||||
*/
|
|
||||||
Object oldValue = evt.getOldValue();
|
|
||||||
Object newValue = evt.getNewValue();
|
|
||||||
if (newValue != null) {
|
|
||||||
// new case is open
|
|
||||||
try {
|
|
||||||
server.openCore();
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.log(Level.WARNING, "Could not open core."); //NON-NLS
|
|
||||||
}
|
|
||||||
} else if (oldValue != null) {
|
|
||||||
// a case was closed
|
|
||||||
try {
|
try {
|
||||||
BlackboardResultWriter.stopAllWriters();
|
BlackboardResultWriter.stopAllWriters();
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000); // TODO (RC): This is a fragile way to wait here.
|
||||||
server.closeCore();
|
server.closeCore();
|
||||||
} catch (Exception e) {
|
} catch (Exception ex) {
|
||||||
logger.log(Level.WARNING, "Could not close core."); //NON-NLS
|
String caseName = closedCase.getName();
|
||||||
|
logger.log(Level.SEVERE, String.format("Failed to close core for %s", caseName), ex);
|
||||||
|
MessageNotifyUtil.Notify.error(NbBundle.getMessage(KeywordSearch.class, "KeywordSearch.closeCore.notification..msg"), ex.getCause().getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (null != evt.getNewValue()) {
|
||||||
|
Case openedCase = (Case) evt.getNewValue();
|
||||||
|
try {
|
||||||
|
server.openCoreForCase(openedCase);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
String caseName = openedCase.getName();
|
||||||
|
logger.log(Level.SEVERE, String.format("Failed to open or create core for %s", caseName), ex);
|
||||||
|
MessageNotifyUtil.Notify.error(NbBundle.getMessage(KeywordSearch.class, "KeywordSearch.openCore.notification.msg"), ex.getCause().getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,6 +134,11 @@ public final class KeywordSearchIngestModule implements FileIngestModule {
|
|||||||
jobId = context.getJobId();
|
jobId = context.getJobId();
|
||||||
dataSourceId = context.getDataSource().getId();
|
dataSourceId = context.getDataSource().getId();
|
||||||
|
|
||||||
|
Server server = KeywordSearch.getServer();
|
||||||
|
if (server.coreIsOpen() == false) {
|
||||||
|
throw new IngestModuleException(NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.startUp.noOpenCore.msg"));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fileTypeDetector = new FileTypeDetector();
|
fileTypeDetector = new FileTypeDetector();
|
||||||
} catch (FileTypeDetector.FileTypeDetectorInitException ex) {
|
} catch (FileTypeDetector.FileTypeDetectorInitException ex) {
|
||||||
@ -170,7 +175,6 @@ public final class KeywordSearchIngestModule implements FileIngestModule {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// for single-user cases need to verify connection to local SOLR service
|
// for single-user cases need to verify connection to local SOLR service
|
||||||
final Server server = KeywordSearch.getServer();
|
|
||||||
try {
|
try {
|
||||||
if (!server.isRunning()) {
|
if (!server.isRunning()) {
|
||||||
String msg = NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.badInitMsg");
|
String msg = NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.badInitMsg");
|
||||||
|
@ -38,8 +38,8 @@ import java.nio.file.Paths;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
@ -169,6 +169,7 @@ public class Server {
|
|||||||
private int currentSolrStopPort = 0;
|
private int currentSolrStopPort = 0;
|
||||||
private static final boolean DEBUG = false;//(Version.getBuildType() == Version.Type.DEVELOPMENT);
|
private static final boolean DEBUG = false;//(Version.getBuildType() == Version.Type.DEVELOPMENT);
|
||||||
private final UNCPathUtilities uncPathUtilities = new UNCPathUtilities();
|
private final UNCPathUtilities uncPathUtilities = new UNCPathUtilities();
|
||||||
|
private static final String INDEX_DIR_NAME = "index";
|
||||||
|
|
||||||
public enum CORE_EVT_STATES {
|
public enum CORE_EVT_STATES {
|
||||||
|
|
||||||
@ -183,6 +184,7 @@ public class Server {
|
|||||||
private HttpSolrServer currentSolrServer;
|
private HttpSolrServer currentSolrServer;
|
||||||
|
|
||||||
private Core currentCore;
|
private Core currentCore;
|
||||||
|
private final ReentrantReadWriteLock currentCoreLock;
|
||||||
|
|
||||||
private final File solrFolder;
|
private final File solrFolder;
|
||||||
private final ServerAction serverAction;
|
private final ServerAction serverAction;
|
||||||
@ -199,7 +201,9 @@ public class Server {
|
|||||||
serverAction = new ServerAction();
|
serverAction = new ServerAction();
|
||||||
solrFolder = InstalledFileLocator.getDefault().locate("solr", Server.class.getPackage().getName(), false); //NON-NLS
|
solrFolder = InstalledFileLocator.getDefault().locate("solr", Server.class.getPackage().getName(), false); //NON-NLS
|
||||||
javaPath = PlatformUtil.getJavaPath();
|
javaPath = PlatformUtil.getJavaPath();
|
||||||
|
|
||||||
|
currentCoreLock = new ReentrantReadWriteLock(true);
|
||||||
|
|
||||||
logger.log(Level.INFO, "Created Server instance"); //NON-NLS
|
logger.log(Level.INFO, "Created Server instance"); //NON-NLS
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -590,35 +594,57 @@ public class Server {
|
|||||||
/*
|
/*
|
||||||
* ** Convenience methods for use while we only open one case at a time ***
|
* ** Convenience methods for use while we only open one case at a time ***
|
||||||
*/
|
*/
|
||||||
synchronized void openCore() throws KeywordSearchModuleException {
|
/**
|
||||||
if (currentCore != null) {
|
* Opens or creates a core (index) for a case.
|
||||||
throw new KeywordSearchModuleException(
|
*
|
||||||
NbBundle.getMessage(this.getClass(), "Server.openCore.exception.alreadyOpen.msg"));
|
* @param theCase the case for which the core is to be opened or created.
|
||||||
}
|
*
|
||||||
|
* @throws KeywordSearchModuleException
|
||||||
Case currentCase = Case.getCurrentCase();
|
*/
|
||||||
|
void openCoreForCase(Case theCase) throws KeywordSearchModuleException {
|
||||||
|
currentCoreLock.writeLock().lock();
|
||||||
try {
|
try {
|
||||||
currentCore = openCore(currentCase);
|
currentCore = openCore(theCase);
|
||||||
} catch (KeywordSearchModuleException ex) {
|
serverAction.putValue(CORE_EVT, CORE_EVT_STATES.STARTED);
|
||||||
MessageNotifyUtil.Notify.error(NbBundle.getMessage(Server.class, "Server.openCore.exception.cantOpenForCase.msg", currentCase.getName()), ex.getCause().getMessage());
|
} finally {
|
||||||
throw ex;
|
currentCoreLock.writeLock().unlock();
|
||||||
}
|
}
|
||||||
serverAction.putValue(CORE_EVT, CORE_EVT_STATES.STARTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void closeCore() throws KeywordSearchModuleException {
|
/**
|
||||||
if (currentCore == null) {
|
* Determines whether or not there is a currently open core (index).
|
||||||
return;
|
*
|
||||||
|
* @return true or false
|
||||||
|
*/
|
||||||
|
boolean coreIsOpen() {
|
||||||
|
currentCoreLock.readLock().lock();
|
||||||
|
try {
|
||||||
|
return (null != currentCore);
|
||||||
|
} finally {
|
||||||
|
currentCoreLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
currentCore.close();
|
void closeCore() throws KeywordSearchModuleException {
|
||||||
currentCore = null;
|
currentCoreLock.writeLock().lock();
|
||||||
serverAction.putValue(CORE_EVT, CORE_EVT_STATES.STOPPED);
|
try {
|
||||||
|
if (null != currentCore) {
|
||||||
|
currentCore.close();
|
||||||
|
currentCore = null;
|
||||||
|
serverAction.putValue(CORE_EVT, CORE_EVT_STATES.STOPPED);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
currentCoreLock.writeLock().unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addDocument(SolrInputDocument doc) throws KeywordSearchModuleException {
|
void addDocument(SolrInputDocument doc) throws KeywordSearchModuleException {
|
||||||
currentCore.addDocument(doc);
|
currentCoreLock.readLock().lock();
|
||||||
|
try {
|
||||||
|
currentCore.addDocument(doc);
|
||||||
|
} finally {
|
||||||
|
currentCoreLock.readLock().unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -651,7 +677,7 @@ public class Server {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private synchronized Core openCore(Case theCase) throws KeywordSearchModuleException {
|
private Core openCore(Case theCase) throws KeywordSearchModuleException {
|
||||||
try {
|
try {
|
||||||
if (theCase.getCaseType() == CaseType.SINGLE_USER_CASE) {
|
if (theCase.getCaseType() == CaseType.SINGLE_USER_CASE) {
|
||||||
currentSolrServer = this.localSolrServer;
|
currentSolrServer = this.localSolrServer;
|
||||||
@ -673,22 +699,32 @@ public class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* commit current core if it exists
|
* Commits current core if it exists
|
||||||
*
|
*
|
||||||
* @throws SolrServerException, NoOpenCoreException
|
* @throws SolrServerException, NoOpenCoreException
|
||||||
*/
|
*/
|
||||||
synchronized void commit() throws SolrServerException, NoOpenCoreException {
|
void commit() throws SolrServerException, NoOpenCoreException {
|
||||||
if (currentCore == null) {
|
currentCoreLock.readLock().lock();
|
||||||
throw new NoOpenCoreException();
|
try {
|
||||||
|
if (null == currentCore) {
|
||||||
|
throw new NoOpenCoreException();
|
||||||
|
}
|
||||||
|
currentCore.commit();
|
||||||
|
} finally {
|
||||||
|
currentCoreLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
currentCore.commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NamedList<Object> request(SolrRequest request) throws SolrServerException, NoOpenCoreException {
|
NamedList<Object> request(SolrRequest request) throws SolrServerException, NoOpenCoreException {
|
||||||
if (currentCore == null) {
|
currentCoreLock.readLock().lock();
|
||||||
throw new NoOpenCoreException();
|
try {
|
||||||
|
if (null == currentCore) {
|
||||||
|
throw new NoOpenCoreException();
|
||||||
|
}
|
||||||
|
return currentCore.request(request);
|
||||||
|
} finally {
|
||||||
|
currentCoreLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
return currentCore.request(request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -702,16 +738,19 @@ public class Server {
|
|||||||
* @throws NoOpenCoreException
|
* @throws NoOpenCoreException
|
||||||
*/
|
*/
|
||||||
public int queryNumIndexedFiles() throws KeywordSearchModuleException, NoOpenCoreException {
|
public int queryNumIndexedFiles() throws KeywordSearchModuleException, NoOpenCoreException {
|
||||||
if (currentCore == null) {
|
currentCoreLock.readLock().lock();
|
||||||
throw new NoOpenCoreException();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
return currentCore.queryNumIndexedFiles();
|
if (null == currentCore) {
|
||||||
} catch (SolrServerException ex) {
|
throw new NoOpenCoreException();
|
||||||
throw new KeywordSearchModuleException(
|
}
|
||||||
NbBundle.getMessage(this.getClass(), "Server.queryNumIdxFiles.exception.msg"), ex);
|
try {
|
||||||
|
return currentCore.queryNumIndexedFiles();
|
||||||
|
} catch (SolrServerException ex) {
|
||||||
|
throw new KeywordSearchModuleException(NbBundle.getMessage(this.getClass(), "Server.queryNumIdxFiles.exception.msg"), ex);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
currentCoreLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -724,14 +763,18 @@ public class Server {
|
|||||||
* @throws NoOpenCoreException
|
* @throws NoOpenCoreException
|
||||||
*/
|
*/
|
||||||
public int queryNumIndexedChunks() throws KeywordSearchModuleException, NoOpenCoreException {
|
public int queryNumIndexedChunks() throws KeywordSearchModuleException, NoOpenCoreException {
|
||||||
if (currentCore == null) {
|
currentCoreLock.readLock().lock();
|
||||||
throw new NoOpenCoreException();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
return currentCore.queryNumIndexedChunks();
|
if (null == currentCore) {
|
||||||
} catch (SolrServerException ex) {
|
throw new NoOpenCoreException();
|
||||||
throw new KeywordSearchModuleException(
|
}
|
||||||
NbBundle.getMessage(this.getClass(), "Server.queryNumIdxChunks.exception.msg"), ex);
|
try {
|
||||||
|
return currentCore.queryNumIndexedChunks();
|
||||||
|
} catch (SolrServerException ex) {
|
||||||
|
throw new KeywordSearchModuleException(NbBundle.getMessage(this.getClass(), "Server.queryNumIdxChunks.exception.msg"), ex);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
currentCoreLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -745,14 +788,18 @@ public class Server {
|
|||||||
* @throws NoOpenCoreException
|
* @throws NoOpenCoreException
|
||||||
*/
|
*/
|
||||||
public int queryNumIndexedDocuments() throws KeywordSearchModuleException, NoOpenCoreException {
|
public int queryNumIndexedDocuments() throws KeywordSearchModuleException, NoOpenCoreException {
|
||||||
if (currentCore == null) {
|
currentCoreLock.readLock().lock();
|
||||||
throw new NoOpenCoreException();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
return currentCore.queryNumIndexedDocuments();
|
if (null == currentCore) {
|
||||||
} catch (SolrServerException ex) {
|
throw new NoOpenCoreException();
|
||||||
throw new KeywordSearchModuleException(
|
}
|
||||||
NbBundle.getMessage(this.getClass(), "Server.queryNumIdxDocs.exception.msg"), ex);
|
try {
|
||||||
|
return currentCore.queryNumIndexedDocuments();
|
||||||
|
} catch (SolrServerException ex) {
|
||||||
|
throw new KeywordSearchModuleException(NbBundle.getMessage(this.getClass(), "Server.queryNumIdxDocs.exception.msg"), ex);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
currentCoreLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -767,14 +814,19 @@ public class Server {
|
|||||||
* @throws NoOpenCoreException
|
* @throws NoOpenCoreException
|
||||||
*/
|
*/
|
||||||
public boolean queryIsIndexed(long contentID) throws KeywordSearchModuleException, NoOpenCoreException {
|
public boolean queryIsIndexed(long contentID) throws KeywordSearchModuleException, NoOpenCoreException {
|
||||||
if (currentCore == null) {
|
currentCoreLock.readLock().lock();
|
||||||
throw new NoOpenCoreException();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
return currentCore.queryIsIndexed(contentID);
|
if (null == currentCore) {
|
||||||
} catch (SolrServerException ex) {
|
throw new NoOpenCoreException();
|
||||||
throw new KeywordSearchModuleException(
|
}
|
||||||
NbBundle.getMessage(this.getClass(), "Server.queryIsIdxd.exception.msg"), ex);
|
try {
|
||||||
|
return currentCore.queryIsIndexed(contentID);
|
||||||
|
} catch (SolrServerException ex) {
|
||||||
|
throw new KeywordSearchModuleException(NbBundle.getMessage(this.getClass(), "Server.queryIsIdxd.exception.msg"), ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
currentCoreLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -790,14 +842,18 @@ public class Server {
|
|||||||
* @throws NoOpenCoreException
|
* @throws NoOpenCoreException
|
||||||
*/
|
*/
|
||||||
public int queryNumFileChunks(long fileID) throws KeywordSearchModuleException, NoOpenCoreException {
|
public int queryNumFileChunks(long fileID) throws KeywordSearchModuleException, NoOpenCoreException {
|
||||||
if (currentCore == null) {
|
currentCoreLock.readLock().lock();
|
||||||
throw new NoOpenCoreException();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
return currentCore.queryNumFileChunks(fileID);
|
if (null == currentCore) {
|
||||||
} catch (SolrServerException ex) {
|
throw new NoOpenCoreException();
|
||||||
throw new KeywordSearchModuleException(
|
}
|
||||||
NbBundle.getMessage(this.getClass(), "Server.queryNumFileChunks.exception.msg"), ex);
|
try {
|
||||||
|
return currentCore.queryNumFileChunks(fileID);
|
||||||
|
} catch (SolrServerException ex) {
|
||||||
|
throw new KeywordSearchModuleException(NbBundle.getMessage(this.getClass(), "Server.queryNumFileChunks.exception.msg"), ex);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
currentCoreLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -812,14 +868,18 @@ public class Server {
|
|||||||
* @throws NoOpenCoreException
|
* @throws NoOpenCoreException
|
||||||
*/
|
*/
|
||||||
public QueryResponse query(SolrQuery sq) throws KeywordSearchModuleException, NoOpenCoreException {
|
public QueryResponse query(SolrQuery sq) throws KeywordSearchModuleException, NoOpenCoreException {
|
||||||
if (currentCore == null) {
|
currentCoreLock.readLock().lock();
|
||||||
throw new NoOpenCoreException();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
return currentCore.query(sq);
|
if (null == currentCore) {
|
||||||
} catch (SolrServerException ex) {
|
throw new NoOpenCoreException();
|
||||||
throw new KeywordSearchModuleException(
|
}
|
||||||
NbBundle.getMessage(this.getClass(), "Server.query.exception.msg", sq.getQuery()), ex);
|
try {
|
||||||
|
return currentCore.query(sq);
|
||||||
|
} catch (SolrServerException ex) {
|
||||||
|
throw new KeywordSearchModuleException(NbBundle.getMessage(this.getClass(), "Server.query.exception.msg", sq.getQuery()), ex);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
currentCoreLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -835,14 +895,18 @@ public class Server {
|
|||||||
* @throws NoOpenCoreException
|
* @throws NoOpenCoreException
|
||||||
*/
|
*/
|
||||||
public QueryResponse query(SolrQuery sq, SolrRequest.METHOD method) throws KeywordSearchModuleException, NoOpenCoreException {
|
public QueryResponse query(SolrQuery sq, SolrRequest.METHOD method) throws KeywordSearchModuleException, NoOpenCoreException {
|
||||||
if (currentCore == null) {
|
currentCoreLock.readLock().lock();
|
||||||
throw new NoOpenCoreException();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
return currentCore.query(sq, method);
|
if (null == currentCore) {
|
||||||
} catch (SolrServerException ex) {
|
throw new NoOpenCoreException();
|
||||||
throw new KeywordSearchModuleException(
|
}
|
||||||
NbBundle.getMessage(this.getClass(), "Server.query2.exception.msg", sq.getQuery()), ex);
|
try {
|
||||||
|
return currentCore.query(sq, method);
|
||||||
|
} catch (SolrServerException ex) {
|
||||||
|
throw new KeywordSearchModuleException(NbBundle.getMessage(this.getClass(), "Server.query2.exception.msg", sq.getQuery()), ex);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
currentCoreLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -857,14 +921,18 @@ public class Server {
|
|||||||
* @throws NoOpenCoreException
|
* @throws NoOpenCoreException
|
||||||
*/
|
*/
|
||||||
public TermsResponse queryTerms(SolrQuery sq) throws KeywordSearchModuleException, NoOpenCoreException {
|
public TermsResponse queryTerms(SolrQuery sq) throws KeywordSearchModuleException, NoOpenCoreException {
|
||||||
if (currentCore == null) {
|
currentCoreLock.readLock().lock();
|
||||||
throw new NoOpenCoreException();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
return currentCore.queryTerms(sq);
|
if (null == currentCore) {
|
||||||
} catch (SolrServerException ex) {
|
throw new NoOpenCoreException();
|
||||||
throw new KeywordSearchModuleException(
|
}
|
||||||
NbBundle.getMessage(this.getClass(), "Server.queryTerms.exception.msg", sq.getQuery()), ex);
|
try {
|
||||||
|
return currentCore.queryTerms(sq);
|
||||||
|
} catch (SolrServerException ex) {
|
||||||
|
throw new KeywordSearchModuleException(NbBundle.getMessage(this.getClass(), "Server.queryTerms.exception.msg", sq.getQuery()), ex);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
currentCoreLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -878,10 +946,15 @@ public class Server {
|
|||||||
* @throws NoOpenCoreException
|
* @throws NoOpenCoreException
|
||||||
*/
|
*/
|
||||||
public String getSolrContent(final Content content) throws NoOpenCoreException {
|
public String getSolrContent(final Content content) throws NoOpenCoreException {
|
||||||
if (currentCore == null) {
|
currentCoreLock.readLock().lock();
|
||||||
throw new NoOpenCoreException();
|
try {
|
||||||
|
if (null == currentCore) {
|
||||||
|
throw new NoOpenCoreException();
|
||||||
|
}
|
||||||
|
return currentCore.getSolrContent(content.getId(), 0);
|
||||||
|
} finally {
|
||||||
|
currentCoreLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
return currentCore.getSolrContent(content.getId(), 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -897,10 +970,15 @@ public class Server {
|
|||||||
* @throws NoOpenCoreException
|
* @throws NoOpenCoreException
|
||||||
*/
|
*/
|
||||||
public String getSolrContent(final Content content, int chunkID) throws NoOpenCoreException {
|
public String getSolrContent(final Content content, int chunkID) throws NoOpenCoreException {
|
||||||
if (currentCore == null) {
|
currentCoreLock.readLock().lock();
|
||||||
throw new NoOpenCoreException();
|
try {
|
||||||
|
if (null == currentCore) {
|
||||||
|
throw new NoOpenCoreException();
|
||||||
|
}
|
||||||
|
return currentCore.getSolrContent(content.getId(), chunkID);
|
||||||
|
} finally {
|
||||||
|
currentCoreLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
return currentCore.getSolrContent(content.getId(), chunkID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -913,10 +991,15 @@ public class Server {
|
|||||||
* @throws NoOpenCoreException
|
* @throws NoOpenCoreException
|
||||||
*/
|
*/
|
||||||
String getSolrContent(final long objectID) throws NoOpenCoreException {
|
String getSolrContent(final long objectID) throws NoOpenCoreException {
|
||||||
if (currentCore == null) {
|
currentCoreLock.readLock().lock();
|
||||||
throw new NoOpenCoreException();
|
try {
|
||||||
|
if (null == currentCore) {
|
||||||
|
throw new NoOpenCoreException();
|
||||||
|
}
|
||||||
|
return currentCore.getSolrContent(objectID, 0);
|
||||||
|
} finally {
|
||||||
|
currentCoreLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
return currentCore.getSolrContent(objectID, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -930,11 +1013,15 @@ public class Server {
|
|||||||
* @throws NoOpenCoreException
|
* @throws NoOpenCoreException
|
||||||
*/
|
*/
|
||||||
String getSolrContent(final long objectID, final int chunkID) throws NoOpenCoreException {
|
String getSolrContent(final long objectID, final int chunkID) throws NoOpenCoreException {
|
||||||
if (currentCore == null) {
|
currentCoreLock.readLock().lock();
|
||||||
throw new NoOpenCoreException();
|
try {
|
||||||
|
if (null == currentCore) {
|
||||||
|
throw new NoOpenCoreException();
|
||||||
|
}
|
||||||
|
return currentCore.getSolrContent(objectID, chunkID);
|
||||||
|
} finally {
|
||||||
|
currentCoreLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
return currentCore.getSolrContent(objectID, chunkID);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -982,26 +1069,25 @@ public class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isCoreLoaded(coreName)) {
|
if (!isCoreLoaded(coreName)) {
|
||||||
CoreAdminRequest.Create createCore = new CoreAdminRequest.Create();
|
CoreAdminRequest.Create createCoreRequest = new CoreAdminRequest.Create();
|
||||||
createCore.setDataDir(dataDir.getAbsolutePath());
|
createCoreRequest.setDataDir(dataDir.getAbsolutePath());
|
||||||
createCore.setCoreName(coreName);
|
createCoreRequest.setCoreName(coreName);
|
||||||
createCore.setConfigSet("AutopsyConfig"); //NON-NLS
|
createCoreRequest.setConfigSet("AutopsyConfig"); //NON-NLS
|
||||||
createCore.setIsLoadOnStartup(false);
|
createCoreRequest.setIsLoadOnStartup(false);
|
||||||
createCore.setIsTransient(true);
|
createCoreRequest.setIsTransient(true);
|
||||||
|
currentSolrServer.request(createCoreRequest);
|
||||||
currentSolrServer.request(createCore);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final Core newCore = new Core(coreName, caseType);
|
File indexDir = Paths.get(dataDir.getAbsolutePath(), INDEX_DIR_NAME).toFile();
|
||||||
|
if (!indexDir.exists()) {
|
||||||
|
throw new IOException(NbBundle.getMessage(this.getClass(), "Server.openCore.exception.noIndexDir.msg"));
|
||||||
|
}
|
||||||
|
|
||||||
return newCore;
|
return new Core(coreName, caseType);
|
||||||
|
|
||||||
} catch (SolrServerException | SolrException ex) {
|
} catch (SolrServerException | SolrException | IOException ex) {
|
||||||
throw new KeywordSearchModuleException(
|
throw new KeywordSearchModuleException(
|
||||||
NbBundle.getMessage(this.getClass(), "Server.openCore.exception.cantOpen.msg"), ex);
|
NbBundle.getMessage(this.getClass(), "Server.openCore.exception.cantOpen.msg"), ex);
|
||||||
} catch (IOException ex) {
|
|
||||||
throw new KeywordSearchModuleException(
|
|
||||||
NbBundle.getMessage(this.getClass(), "Server.openCore.exception.cantOpen.msg2"), ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user