mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Merge pull request #1729 from karlmortensen/getDocumentIdUpdate
Get document id update
This commit is contained in:
commit
4d0a8df983
@ -36,6 +36,9 @@ import org.sleuthkit.datamodel.BlackboardArtifact;
|
|||||||
import org.sleuthkit.datamodel.Content;
|
import org.sleuthkit.datamodel.Content;
|
||||||
import org.sleuthkit.datamodel.ContentVisitor;
|
import org.sleuthkit.datamodel.ContentVisitor;
|
||||||
import org.sleuthkit.datamodel.Directory;
|
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,
|
* Displays the indexed text associated with a file or a blackboard artifact,
|
||||||
@ -257,21 +260,36 @@ public class ExtractedContentViewer implements DataContentViewer {
|
|||||||
* @return The document ID or zero, which is an invalid document ID.
|
* @return The document ID or zero, which is an invalid document ID.
|
||||||
*/
|
*/
|
||||||
private Long getDocumentId(Node node) {
|
private Long getDocumentId(Node node) {
|
||||||
/*
|
/**
|
||||||
* If the node is a Blackboard artifact node for anything other than a
|
* If the node is a Blackboard artifact node for anything other than a
|
||||||
* keyword hit, the document ID for the text extracted from the artifact
|
* keyword hit, the document ID for the text extracted from the artifact
|
||||||
* (the concatenation of its attributes) is the artifact ID, a large,
|
* (the concatenation of its attributes) is the artifact ID, a large,
|
||||||
* negative integer.
|
* negative integer. If it is a keyword hit, see if there is an
|
||||||
|
* associated artifact. If there is, get the associated artifact's ID
|
||||||
|
* and return it.
|
||||||
*/
|
*/
|
||||||
BlackboardArtifact artifact = node.getLookup().lookup(BlackboardArtifact.class);
|
BlackboardArtifact artifact = node.getLookup().lookup(BlackboardArtifact.class);
|
||||||
if (null != artifact && artifact.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
|
if (null != artifact) {
|
||||||
return artifact.getArtifactID();
|
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 blackboardAttributes.get(0).getValueLong();
|
||||||
|
}
|
||||||
|
} catch (TskCoreException ex) {
|
||||||
|
logger.log(Level.SEVERE, "Error getting associated artifact attributes", ex); //NON-NLS
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For keyword search hit artifact nodes and all other nodes, the
|
* For keyword search hit artifact nodes and all other nodes, the
|
||||||
* document ID for the extracted text is the ID of the associated
|
* document ID for the extracted text is the ID of the associated
|
||||||
* content, if any.
|
* content, if any, unless there is an associated artifact, which
|
||||||
|
* is handled above.
|
||||||
*/
|
*/
|
||||||
Content content = node.getLookup().lookup(Content.class);
|
Content content = node.getLookup().lookup(Content.class);
|
||||||
if (content != null) {
|
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.impl.XMLResponseParser;
|
||||||
import org.apache.solr.client.solrj.response.CoreAdminResponse;
|
import org.apache.solr.client.solrj.response.CoreAdminResponse;
|
||||||
import org.apache.solr.common.SolrDocument;
|
import org.apache.solr.common.SolrDocument;
|
||||||
|
import org.apache.solr.common.SolrDocumentList;
|
||||||
import org.apache.solr.common.SolrException;
|
import org.apache.solr.common.SolrException;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case.CaseType;
|
import org.sleuthkit.autopsy.casemodule.Case.CaseType;
|
||||||
import org.sleuthkit.autopsy.coreutils.UNCPathUtilities;
|
import org.sleuthkit.autopsy.coreutils.UNCPathUtilities;
|
||||||
@ -1020,7 +1021,7 @@ public class Server {
|
|||||||
currentCoreLock.readLock().unlock();
|
currentCoreLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to return ingester instance
|
* Method to return ingester instance
|
||||||
*
|
*
|
||||||
@ -1129,7 +1130,7 @@ public class Server {
|
|||||||
CoreAdminResponse response = CoreAdminRequest.getStatus(coreName, currentSolrServer);
|
CoreAdminResponse response = CoreAdminRequest.getStatus(coreName, currentSolrServer);
|
||||||
Object dataDirPath = response.getCoreStatus(coreName).get("dataDir"); //NON-NLS
|
Object dataDirPath = response.getCoreStatus(coreName).get("dataDir"); //NON-NLS
|
||||||
if (null != dataDirPath) {
|
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();
|
return indexDir.exists();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -1234,16 +1235,20 @@ public class Server {
|
|||||||
q.setFields(Schema.TEXT.toString());
|
q.setFields(Schema.TEXT.toString());
|
||||||
try {
|
try {
|
||||||
// Get the first result.
|
// Get the first result.
|
||||||
SolrDocument solrDocument = solrCore.query(q).getResults().get(0);
|
SolrDocumentList solrDocuments = solrCore.query(q).getResults();
|
||||||
if (solrDocument != null) {
|
|
||||||
Collection<Object> fieldValues = solrDocument.getFieldValues(Schema.TEXT.toString());
|
if (!solrDocuments.isEmpty()) {
|
||||||
if (fieldValues.size() == 1) // The indexed text field for artifacts will only have a single value.
|
SolrDocument solrDocument = solrDocuments.get(0);
|
||||||
{
|
if (solrDocument != null) {
|
||||||
return fieldValues.toArray(new String[0])[0];
|
Collection<Object> fieldValues = solrDocument.getFieldValues(Schema.TEXT.toString());
|
||||||
} else // The indexed text for files has 2 values, the file name and the file content.
|
if (fieldValues.size() == 1) // The indexed text field for artifacts will only have a single value.
|
||||||
// We return the file content value.
|
{
|
||||||
{
|
return fieldValues.toArray(new String[0])[0];
|
||||||
return fieldValues.toArray(new String[0])[1];
|
} 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) {
|
} catch (SolrServerException ex) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user