for sharing

This commit is contained in:
Karl Mortensen
2015-11-20 09:23:42 -05:00
parent 8919188172
commit ac5eb058ea
2 changed files with 38 additions and 16 deletions
@@ -36,6 +36,9 @@ import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.ContentVisitor;
import org.sleuthkit.datamodel.Directory;
import org.openide.util.Exceptions;
import org.sleuthkit.datamodel.TskCoreException;
import org.sleuthkit.datamodel.BlackboardAttribute;
/**
* Displays the indexed text associated with a file or a blackboard artifact,
@@ -262,16 +265,30 @@ public class ExtractedContentViewer implements DataContentViewer {
* keyword hit, the document ID for the text extracted from the artifact
* (the concatenation of its attributes) is the artifact ID, a large,
* negative integer.
*/
*/ // KDM update comments.
BlackboardArtifact artifact = node.getLookup().lookup(BlackboardArtifact.class);
if (null != artifact && artifact.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
return artifact.getArtifactID();
if (null != artifact) {
if (artifact.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
return artifact.getArtifactID();
} else {
try {
// Get the associated artifact attribute and return its value as the ID
List<BlackboardAttribute> blackboardAttributes = artifact.getAttributes(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT);
if (blackboardAttributes.isEmpty()) {
return artifact.getArtifactID();
} else {
return artifact.getAttributes(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT).get(0).getArtifactID();
}
} catch (TskCoreException ex) {
Exceptions.printStackTrace(ex); // KDM
}
}
}
/*
* For keyword search hit artifact nodes and all other nodes, the
* document ID for the extracted text is the ID of the associated
* content, if any.
* content, if any. KDM update comments
*/
Content content = node.getLookup().lookup(Content.class);
if (content != null) {
@@ -61,6 +61,7 @@ import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.client.solrj.impl.XMLResponseParser;
import org.apache.solr.client.solrj.response.CoreAdminResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrException;
import org.sleuthkit.autopsy.casemodule.Case.CaseType;
import org.sleuthkit.autopsy.coreutils.UNCPathUtilities;
@@ -1020,7 +1021,7 @@ public class Server {
currentCoreLock.readLock().unlock();
}
}
/**
* Method to return ingester instance
*
@@ -1129,7 +1130,7 @@ public class Server {
CoreAdminResponse response = CoreAdminRequest.getStatus(coreName, currentSolrServer);
Object dataDirPath = response.getCoreStatus(coreName).get("dataDir"); //NON-NLS
if (null != dataDirPath) {
File indexDir = Paths.get((String)dataDirPath, "index").toFile(); //NON-NLS
File indexDir = Paths.get((String) dataDirPath, "index").toFile(); //NON-NLS
return indexDir.exists();
} else {
return false;
@@ -1234,16 +1235,20 @@ public class Server {
q.setFields(Schema.TEXT.toString());
try {
// Get the first result.
SolrDocument solrDocument = solrCore.query(q).getResults().get(0);
if (solrDocument != null) {
Collection<Object> fieldValues = solrDocument.getFieldValues(Schema.TEXT.toString());
if (fieldValues.size() == 1) // The indexed text field for artifacts will only have a single value.
{
return fieldValues.toArray(new String[0])[0];
} else // The indexed text for files has 2 values, the file name and the file content.
// We return the file content value.
{
return fieldValues.toArray(new String[0])[1];
SolrDocumentList solrDocuments = solrCore.query(q).getResults();
if (!solrDocuments.isEmpty()) {
SolrDocument solrDocument = solrDocuments.get(0);
if (solrDocument != null) {
Collection<Object> fieldValues = solrDocument.getFieldValues(Schema.TEXT.toString());
if (fieldValues.size() == 1) // The indexed text field for artifacts will only have a single value.
{
return fieldValues.toArray(new String[0])[0];
} else // The indexed text for files has 2 values, the file name and the file content.
// We return the file content value.
{
return fieldValues.toArray(new String[0])[1];
}
}
}
} catch (SolrServerException ex) {