From 2ec48db5747a669af666fb90f236c182e4bf25bd Mon Sep 17 00:00:00 2001 From: Brian Carrier Date: Wed, 26 Aug 2020 09:13:26 -0400 Subject: [PATCH] renamed methods to reflect they are also associated with usage --- .../contextviewer/ContextViewer.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/contextviewer/ContextViewer.java b/Core/src/org/sleuthkit/autopsy/contentviewers/contextviewer/ContextViewer.java index 333860d600..77cee389f6 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/contextviewer/ContextViewer.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/contextviewer/ContextViewer.java @@ -55,12 +55,12 @@ public final class ContextViewer extends javax.swing.JPanel implements DataConte private static final int ATTRIBUTE_STR_MAX_LEN = 200; // defines a list of artifacts that provide context for a file - private static final List SOURCE_CONTEXT_ARTIFACTS = new ArrayList<>(); + private static final List CONTEXT_ARTIFACTS = new ArrayList<>(); private final List contextSourcePanels = new ArrayList<>(); private final List contextUsagePanels = new ArrayList<>(); static { - SOURCE_CONTEXT_ARTIFACTS.add(TSK_ASSOCIATED_OBJECT); + CONTEXT_ARTIFACTS.add(TSK_ASSOCIATED_OBJECT); } /** @@ -180,7 +180,7 @@ public final class ContextViewer extends javax.swing.JPanel implements DataConte AbstractFile file = selectedNode.getLookup().lookup(AbstractFile.class); try { - populateSourceContextData(file); + populatePanels(file); } catch (NoCurrentCaseException | TskCoreException ex) { logger.log(Level.SEVERE, String.format("Exception displaying context for file %s", file.getName()), ex); //NON-NLS } @@ -223,7 +223,7 @@ public final class ContextViewer extends javax.swing.JPanel implements DataConte // check if the node has an abstract file and the file has any context defining artifacts. if (node.getLookup().lookup(AbstractFile.class) != null) { AbstractFile abstractFile = node.getLookup().lookup(AbstractFile.class); - for (BlackboardArtifact.ARTIFACT_TYPE artifactType : SOURCE_CONTEXT_ARTIFACTS) { + for (BlackboardArtifact.ARTIFACT_TYPE artifactType : CONTEXT_ARTIFACTS) { List artifactsList; try { artifactsList = abstractFile.getArtifacts(artifactType); @@ -258,18 +258,18 @@ public final class ContextViewer extends javax.swing.JPanel implements DataConte * @throws NoCurrentCaseException * @throws TskCoreException */ - private void populateSourceContextData(AbstractFile sourceFile) throws NoCurrentCaseException, TskCoreException { + private void populatePanels(AbstractFile sourceFile) throws NoCurrentCaseException, TskCoreException { SleuthkitCase tskCase = Case.getCurrentCaseThrows().getSleuthkitCase(); // Check for all context artifacts boolean foundASource = false; - for (BlackboardArtifact.ARTIFACT_TYPE artifactType : SOURCE_CONTEXT_ARTIFACTS) { + for (BlackboardArtifact.ARTIFACT_TYPE artifactType : CONTEXT_ARTIFACTS) { List artifactsList = tskCase.getBlackboardArtifacts(artifactType, sourceFile.getId()); foundASource = !artifactsList.isEmpty(); for (BlackboardArtifact contextArtifact : artifactsList) { - addSourceEntry(contextArtifact); + addAssociatedArtifactToPanel(contextArtifact); } } javax.swing.JPanel contextContainer = new javax.swing.JPanel(); @@ -304,15 +304,14 @@ public final class ContextViewer extends javax.swing.JPanel implements DataConte } /** - * Adds a source context entry for the selected file based on the given - * context providing artifact. + * Resolves an TSK_ASSOCIATED_OBJECT artifact and adds it to the appropriate panel * * @param artifact Artifact that may provide context. * * @throws NoCurrentCaseException * @throws TskCoreException */ - private void addSourceEntry(BlackboardArtifact artifact) throws TskCoreException { + private void addAssociatedArtifactToPanel(BlackboardArtifact artifact) throws TskCoreException { if (BlackboardArtifact.ARTIFACT_TYPE.TSK_ASSOCIATED_OBJECT.getTypeID() == artifact.getArtifactTypeID()) { BlackboardAttribute associatedArtifactAttribute = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT)); @@ -320,14 +319,13 @@ public final class ContextViewer extends javax.swing.JPanel implements DataConte long artifactId = associatedArtifactAttribute.getValueLong(); BlackboardArtifact associatedArtifact = artifact.getSleuthkitCase().getBlackboardArtifact(artifactId); - setSourceFields(associatedArtifact); + addArtifactToPanels(associatedArtifact); } } } /** - * Sets the source label and text fields based on the given associated - * artifact. + * Adds th passed in artifact to the appropriate source or usage panel * * @param associatedArtifact - associated artifact * @@ -339,7 +337,7 @@ public final class ContextViewer extends javax.swing.JPanel implements DataConte "ContextViewer.recentDocs=Recent Documents: ", "ContextViewer.programExecution=Program Execution: " }) - private void setSourceFields(BlackboardArtifact associatedArtifact) throws TskCoreException { + private void addArtifactToPanels(BlackboardArtifact associatedArtifact) throws TskCoreException { if (BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE.getTypeID() == associatedArtifact.getArtifactTypeID() || BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID() == associatedArtifact.getArtifactTypeID()) { String sourceName = Bundle.ContextViewer_attachmentSource();