85 public void index(Content content)
throws TskCoreException {
86 if (content ==
null) {
89 final Ingester ingester = Ingester.getDefault();
90 if (content instanceof BlackboardArtifact) {
91 BlackboardArtifact artifact = (BlackboardArtifact) content;
92 if (artifact.getArtifactID() > 0) {
101 Reader blackboardExtractedTextReader = KeywordSearchUtil.getReader(content);
102 String sourceName = artifact.getDisplayName() +
"_" + artifact.getArtifactID();
103 ingester.indexMetaDataOnly(artifact, sourceName);
105 ingester.search(blackboardExtractedTextReader, artifact.getArtifactID(), sourceName, content,
null,
true,
true,
null);
106 }
catch (Exception ex) {
107 throw new TskCoreException(
"Error indexing artifact", ex);
112 Reader reader = KeywordSearchUtil.getReader(content);
114 ingester.search(reader, content.getId(), content.getName(), content,
null,
true,
true,
null);
115 }
catch (Exception ex) {
116 throw new TskCoreException(
"Error indexing content", ex);
136 if (host ==
null || host.isEmpty()) {
141 }
catch (SolrServerException ex) {
142 logger.log(Level.SEVERE,
"Unable to connect to Solr server. Host: " + host +
", port: " + port, ex);
144 }
catch (IOException ex) {
145 logger.log(Level.SEVERE,
"Unable to connect to Solr server. Host: " + host +
", port: " + port, ex);
146 String result = NbBundle.getMessage(
SolrSearchService.class,
"SolrConnectionCheck.HostnameOrPort");
147 String message = ex.getCause().getMessage().toLowerCase();
152 result = Bundle.SolrConnectionCheck_Port();
154 result = NbBundle.getMessage(
SolrSearchService.class,
"SolrConnectionCheck.HostnameOrPort");
156 }
catch (IOException | MissingResourceException any) {
158 result = NbBundle.getMessage(
SolrSearchService.class,
"SolrConnectionCheck.HostnameOrPort");
161 result = NbBundle.getMessage(
SolrSearchService.class,
"SolrConnectionCheck.Hostname");
164 }
catch (NumberFormatException ex) {
165 logger.log(Level.SEVERE,
"Unable to connect to Solr server. Host: " + host +
", port: " + port, ex);
167 }
catch (IllegalArgumentException ex) {
168 logger.log(Level.SEVERE,
"Unable to connect to Solr server. Host: " + host +
", port: " + port, ex);
207 IndexMetadata indexMetadata;
209 indexMetadata =
new IndexMetadata(caseDirectory);
210 }
catch (IndexMetadata.TextIndexMetadataException ex) {
211 logger.log(Level.WARNING, NbBundle.getMessage(
SolrSearchService.class,
"SolrSearchService.exceptionMessage.noIndexMetadata", caseDirectory), ex);
215 if (indexMetadata.getIndexes().isEmpty()) {
217 "SolrSearchService.exceptionMessage.noCurrentSolrCore"));
219 "SolrSearchService.exceptionMessage.noCurrentSolrCore"));
223 for (Index
index : indexMetadata.getIndexes()) {
230 File indexDir =
new File(
index.getIndexPath()).getParentFile();
231 if (indexDir.exists()) {
271 int totalNumProgressUnits = 7;
272 int progressUnitsCompleted = 0;
276 List<Index> indexes =
new ArrayList<>();
277 progress.progress(Bundle.SolrSearch_lookingForMetadata_msg(), totalNumProgressUnits);
278 if (IndexMetadata.isMetadataFilePresent(caseDirPath)) {
281 progressUnitsCompleted++;
282 progress.progress(Bundle.SolrSearch_findingIndexes_msg(), progressUnitsCompleted);
283 IndexMetadata indexMetadata =
new IndexMetadata(caseDirPath);
284 indexes = indexMetadata.getIndexes();
285 }
catch (IndexMetadata.TextIndexMetadataException ex) {
286 logger.log(Level.SEVERE, String.format(
"Unable to read text index metadata file"), ex);
296 Index currentVersionIndex =
null;
297 if (indexes.isEmpty()) {
299 progressUnitsCompleted++;
300 progress.progress(Bundle.SolrSearch_creatingNewIndex_msg(), progressUnitsCompleted);
301 currentVersionIndex = IndexFinder.createLatestVersionIndex(theCase);
303 indexes.add(currentVersionIndex);
306 progressUnitsCompleted++;
307 progress.progress(Bundle.SolrSearch_checkingForLatestIndex_msg(), progressUnitsCompleted);
308 currentVersionIndex = IndexFinder.findLatestVersionIndex(indexes);
309 if (currentVersionIndex ==
null) {
311 progressUnitsCompleted++;
312 progress.progress(Bundle.SolrSearch_indentifyingIndex_msg(), progressUnitsCompleted);
313 Index indexToUse = IndexFinder.identifyIndexToUse(indexes);
314 if (indexToUse ==
null) {
317 String futureIndexVersion = IndexFinder.isFutureIndexPresent(indexes);
318 if (!futureIndexVersion.isEmpty()) {
319 throw new AutopsyServiceException(Bundle.SolrSearch_futureIndexVersion_msg(futureIndexVersion, IndexFinder.getCurrentSolrVersion()));
330 if (!IndexFinder.getCurrentSolrVersion().equals(indexToUse.getSolrVersion())) {
331 Index prevIndex = indexToUse;
333 if (indexToUse != prevIndex) {
334 indexes.add(indexToUse);
343 if (!indexToUse.isCompatible(IndexFinder.getCurrentSchemaVersion())) {
344 String msg =
"Text index schema version " + indexToUse.getSchemaVersion() +
" is not compatible with current schema";
345 logger.log(Level.WARNING, msg);
349 currentVersionIndex = indexToUse;
355 if (!indexes.isEmpty()) {
356 IndexMetadata indexMetadata =
new IndexMetadata(caseDirPath, indexes);
358 }
catch (IndexMetadata.TextIndexMetadataException ex) {
364 progress.progress(Bundle.SolrSearch_openCore_msg(), totalNumProgressUnits - 1);
375 progress.progress(Bundle.SolrSearch_complete_msg(), totalNumProgressUnits);
399 Component parentComponent = WindowManager.getDefault().getMainWindow();
401 parentComponent = progInd.getDialog();
414 }
catch (InterruptedException ex) {
422 int selection = JOptionPane.showOptionDialog(
425 Bundle.Server_configureSolrConnection_unsupportedSolrTitle(),
426 JOptionPane.YES_NO_OPTION,
427 JOptionPane.WARNING_MESSAGE,
430 Bundle.Server_configureSolrConnection_unsupportedSolrDisableOpt(),
431 Bundle.Server_configureSolrConnection_unsupportedSolrUpgradeOpt()
433 Bundle.Server_configureSolrConnection_unsupportedSolrDisableOpt());
435 if (selection == 1) {
436 return IndexFinder.createLatestVersionIndex(context.
getCase());
488 public void indexArtifact(BlackboardArtifact artifact)
throws TskCoreException {
489 if (artifact ==
null) {
495 if (artifact.getArtifactID() > 0) {
498 final Ingester ingester = Ingester.getDefault();
501 String sourceName = artifact.getDisplayName() +
"_" + artifact.getArtifactID();
503 Reader blackboardExtractedTextReader = blackboardExtractor.
getReader();
504 ingester.indexMetaDataOnly(artifact, sourceName);
505 ingester.search(blackboardExtractedTextReader, artifact.getId(), sourceName, artifact,
null,
true,
true,
null);
506 }
catch (Exception ex) {
507 throw new TskCoreException(ex.getCause().getMessage(), ex);