move getType to constructor

This commit is contained in:
Greg DiCristofaro 2021-06-18 14:44:09 -04:00
parent 60e0125189
commit 1afacd0e7b

View File

@ -119,6 +119,7 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
}; };
private final BlackboardArtifact artifact; private final BlackboardArtifact artifact;
private final BlackboardArtifact.Type artifactType;
private Content srcContent; private Content srcContent;
private volatile String translatedSourceName; private volatile String translatedSourceName;
@ -227,6 +228,15 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
public BlackboardArtifactNode(BlackboardArtifact artifact, String iconPath) { public BlackboardArtifactNode(BlackboardArtifact artifact, String iconPath) {
super(artifact, createLookup(artifact, false)); super(artifact, createLookup(artifact, false));
this.artifact = artifact; this.artifact = artifact;
BlackboardArtifact.Type artType = null;
try {
artType = artifact.getType();
} catch (TskCoreException ex) {
logger.log(Level.WARNING, MessageFormat.format("Error getting the artifact type for artifact (artifact objID={0})", artifact.getId()), ex);
}
this.artifactType = artType;
for (Content lookupContent : this.getLookup().lookupAll(Content.class)) { for (Content lookupContent : this.getLookup().lookupAll(Content.class)) {
if ((lookupContent != null) && (!(lookupContent instanceof BlackboardArtifact))) { if ((lookupContent != null) && (!(lookupContent instanceof BlackboardArtifact))) {
srcContent = lookupContent; srcContent = lookupContent;
@ -268,6 +278,15 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
public BlackboardArtifactNode(BlackboardArtifact artifact, boolean lookupIsAssociatedFile) { public BlackboardArtifactNode(BlackboardArtifact artifact, boolean lookupIsAssociatedFile) {
super(artifact, createLookup(artifact, lookupIsAssociatedFile)); super(artifact, createLookup(artifact, lookupIsAssociatedFile));
this.artifact = artifact; this.artifact = artifact;
BlackboardArtifact.Type artType = null;
try {
artType = artifact.getType();
} catch (TskCoreException ex) {
logger.log(Level.WARNING, MessageFormat.format("Error getting the artifact type for artifact (artifact objID={0})", artifact.getId()), ex);
}
this.artifactType = artType;
try { try {
//The lookup for a file may or may not exist so we define the srcContent as the parent. //The lookup for a file may or may not exist so we define the srcContent as the parent.
srcContent = artifact.getParent(); srcContent = artifact.getParent();
@ -640,13 +659,6 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
NO_DESCR, NO_DESCR,
actualMimeType)); actualMimeType));
} }
BlackboardArtifact.Type artifactType = null;
try {
artifactType = artifact.getType();
} catch (TskCoreException ex) {
logger.log(Level.WARNING, "Unable to get type for artifact with id: " + artifact.getId());
}
/* /*
* If the type of the artifact represented by this node dictates the * If the type of the artifact represented by this node dictates the