Public API fixes/removes for release 4.7.0

This commit is contained in:
Richard Cordovano 2018-05-02 17:37:11 -04:00
parent fef6c5f510
commit bee4d28c14
8 changed files with 102 additions and 59 deletions

View File

@ -1,14 +1,14 @@
/* /*
* Sleuth Kit Data Model * Autopsy Forensic Browser
* *
* Copyright 2011-2016 Basis Technology Corp. * Copyright 2015-2018 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");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@ -65,7 +65,7 @@ public final class Blackboard implements Closeable {
throw new BlackboardException("Keyword search service not found"); throw new BlackboardException("Keyword search service not found");
} }
try { try {
searchService.indexArtifact(artifact); searchService.index(artifact);
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
throw new BlackboardException("Error indexing artifact", ex); throw new BlackboardException("Error indexing artifact", ex);
} }

View File

@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.sleuthkit.autopsy.corecomponentinterfaces; package org.sleuthkit.autopsy.contentviewers;
import java.awt.Component; import java.awt.Component;
import java.util.List; import java.util.List;
@ -26,7 +26,7 @@ import org.sleuthkit.datamodel.AbstractFile;
* Defines an interface for application specific content viewer * Defines an interface for application specific content viewer
* *
*/ */
public interface FileTypeViewer { interface FileTypeViewer {
/** /**
* Returns list of MIME types supported by this viewer * Returns list of MIME types supported by this viewer
@ -45,6 +45,11 @@ public interface FileTypeViewer {
/** /**
* Clears the data in the panel * Clears the data in the panel
*
* IMPORTANT IF MAKING THIS PUBLIC: I (RC) am not sure that this method
* belongs in this interface. If we are not going to use setFile(null) as a
* reset method as in DataContentViewer and DataResultViewer, then this is
* fine. Otherwise, it is ambiguous.
*/ */
void resetComponent(); void resetComponent();
} }

View File

@ -31,7 +31,6 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector; import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector;
import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.autopsy.corecomponentinterfaces.FileTypeViewer;
/** /**
* Generic Application content viewer * Generic Application content viewer

View File

@ -24,7 +24,6 @@ import java.awt.Dimension;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.sleuthkit.autopsy.corecomponentinterfaces.FileTypeViewer;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.AbstractFile;

View File

@ -58,7 +58,6 @@ import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskCoreException;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.sleuthkit.autopsy.corecomponentinterfaces.FileTypeViewer;
/** /**
* PListViewer - a file viewer for binary plist files. * PListViewer - a file viewer for binary plist files.

View File

@ -50,7 +50,6 @@ import org.sleuthkit.autopsy.datamodel.ContentUtils;
import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.SleuthkitCase;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskCoreException;
import org.sleuthkit.autopsy.corecomponentinterfaces.FileTypeViewer;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
/** /**

View File

@ -197,6 +197,7 @@ public final class IngestServices {
* *
* @deprecated Use getCase instead. * @deprecated Use getCase instead.
*/ */
@Deprecated
public Case getCurrentCase() { public Case getCurrentCase() {
return Case.getCurrentCase(); return Case.getCurrentCase();
} }

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2018 Basis Technology Corp. * Copyright 2015-2018 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");
@ -68,61 +68,68 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
private static final Logger logger = Logger.getLogger(SolrSearchService.class.getName()); private static final Logger logger = Logger.getLogger(SolrSearchService.class.getName());
/** /**
* Adds an artifact to the keyword search text index as a concantenation of * Indexes the given content for keyword search.
* all of its attributes.
* *
* @param artifact The artifact to index. * IMPORTANT: Currently, there are two correct uses for this code:
*
* 1) Indexing an artifact created during while either the file level ingest
* module pipeline or the first stage data source level ingest module
* pipeline of an ingest job is running.
*
* 2) Indexing a report.
* *
* @throws org.sleuthkit.datamodel.TskCoreException
*/
@Override
public void indexArtifact(BlackboardArtifact artifact) throws TskCoreException {
if (artifact == null) {
return;
}
// We only support artifact indexing for Autopsy versions that use
// the negative range for artifact ids.
if (artifact.getArtifactID() > 0) {
return;
}
final Ingester ingester = Ingester.getDefault();
try {
ingester.indexMetaDataOnly(artifact);
ingester.indexText(new ArtifactTextExtractor(), artifact, null);
} catch (Ingester.IngesterException ex) {
throw new TskCoreException(ex.getCause().getMessage(), ex);
}
}
/**
* Add the given Content object to the text index.
* @param content The content to index. * @param content The content to index.
* @throws TskCoreException *
* @throws TskCoreException If there is a problem indexing the content.
*/ */
@Override @Override
public void index(Content content) throws TskCoreException { public void index(Content content) throws TskCoreException {
/*
* TODO (JIRA-1099): The following code has some issues that need to be
* resolved. For artifacts, it is assumed that the posting of artifacts
* is only occuring during an ingest job with an enabled keyword search
* ingest module handling index commits; it also assumes that the
* artifacts are only posted by modules in the either the file level
* ingest pipeline or the first stage data source level ingest pipeline,
* so that the artifacts will be searched during a periodic or final
* keyword search. It also assumes that the only other type of Content
* for which this API will be called are Reports generated at a time
* when doing a commit is required and desirable, i.e., in a context
* other than an ingest job.
*/
if (content == null) { if (content == null) {
return; return;
} }
final Ingester ingester = Ingester.getDefault(); final Ingester ingester = Ingester.getDefault();
if (content instanceof BlackboardArtifact) {
try { BlackboardArtifact artifact = (BlackboardArtifact) content;
ingester.indexText(new TikaTextExtractor(), content, null); if (artifact.getArtifactID() > 0) {
} catch (Ingester.IngesterException ex) { /*
try { * Artifact indexing is only supported for artifacts that use
// Try the StringsTextExtractor if Tika extractions fails. * negative artifact ids to avoid overlapping with the object
ingester.indexText(new StringsTextExtractor(), content, null); * ids of other types of Content.
} catch (Ingester.IngesterException ex1) { */
throw new TskCoreException(ex.getCause().getMessage(), ex1); return;
} }
try {
ingester.indexMetaDataOnly(artifact);
ingester.indexText(new ArtifactTextExtractor(), artifact, null);
} catch (Ingester.IngesterException ex) {
throw new TskCoreException(ex.getCause().getMessage(), ex);
}
} else {
try {
ingester.indexText(new TikaTextExtractor(), content, null);
} catch (Ingester.IngesterException ex) {
try {
// Try the StringsTextExtractor if Tika extractions fails.
ingester.indexText(new StringsTextExtractor(), content, null);
} catch (Ingester.IngesterException ex1) {
throw new TskCoreException(ex.getCause().getMessage(), ex1);
}
}
ingester.commit();
} }
// TODO: Review whether this is the right thing to do. We typically use
// a combination of autoCommit and the SearchRunner to ensure that data
// is committed but that might not be sufficient for reports (or artifacts).
ingester.commit();
} }
/** /**
@ -213,9 +220,9 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
//this code this code will only execute if an index for the current core was not found //this code this code will only execute if an index for the current core was not found
logger.log(Level.WARNING, NbBundle.getMessage(SolrSearchService.class, logger.log(Level.WARNING, NbBundle.getMessage(SolrSearchService.class,
"SolrSearchService.exceptionMessage.noCurrentSolrCore")); "SolrSearchService.exceptionMessage.noCurrentSolrCore"));
throw new KeywordSearchServiceException(NbBundle.getMessage(SolrSearchService.class, throw new KeywordSearchServiceException(NbBundle.getMessage(SolrSearchService.class,
"SolrSearchService.exceptionMessage.noCurrentSolrCore")); "SolrSearchService.exceptionMessage.noCurrentSolrCore"));
} }
@Override @Override
@ -231,6 +238,7 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
* Creates/opens the Solr core/text index for a case * Creates/opens the Solr core/text index for a case
* *
* @param context The case context. * @param context The case context.
*
* @throws * @throws
* org.sleuthkit.autopsy.appservices.AutopsyService.AutopsyServiceException * org.sleuthkit.autopsy.appservices.AutopsyService.AutopsyServiceException
*/ */
@ -379,6 +387,7 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
* Closes the open core. * Closes the open core.
* *
* @param context * @param context
*
* @throws * @throws
* org.sleuthkit.autopsy.appservices.AutopsyService.AutopsyServiceException * org.sleuthkit.autopsy.appservices.AutopsyService.AutopsyServiceException
*/ */
@ -403,4 +412,36 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
throw new AutopsyServiceException(String.format("Failed to close core for %s", context.getCase().getCaseDirectory()), ex); throw new AutopsyServiceException(String.format("Failed to close core for %s", context.getCase().getCaseDirectory()), ex);
} }
} }
/**
* Adds an artifact to the keyword search text index as a concantenation of
* all of its attributes.
*
* @param artifact The artifact to index.
*
* @throws org.sleuthkit.datamodel.TskCoreException
* @deprecated Call index(Content) instead.
*/
@Deprecated
@Override
public void indexArtifact(BlackboardArtifact artifact) throws TskCoreException {
if (artifact == null) {
return;
}
// We only support artifact indexing for Autopsy versions that use
// the negative range for artifact ids.
if (artifact.getArtifactID() > 0) {
return;
}
final Ingester ingester = Ingester.getDefault();
try {
ingester.indexMetaDataOnly(artifact);
ingester.indexText(new ArtifactTextExtractor(), artifact, null);
} catch (Ingester.IngesterException ex) {
throw new TskCoreException(ex.getCause().getMessage(), ex);
}
}
} }