19 package org.sleuthkit.autopsy.datasourceprocessors.xry;
21 import java.io.IOException;
22 import java.nio.file.Path;
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.logging.Level;
27 import org.
sleuthkit.datamodel.Blackboard.BlackboardException;
36 abstract class AbstractSingleEntityParser
implements XRYFileParser {
40 protected static final String PARSER_NAME =
"XRY DSP";
43 public void parse(XRYFileReader reader, Content parent, SleuthkitCase currentCase)
throws IOException, TskCoreException, BlackboardException {
44 Path reportPath = reader.getReportPath();
45 logger.log(Level.INFO, String.format(
"[XRY DSP] Processing report at [ %s ]", reportPath.toString()));
47 while (reader.hasNextEntity()) {
48 String xryEntity = reader.nextEntity();
49 String[] xryLines = xryEntity.split(
"\n");
51 List<XRYKeyValuePair> keyValuePairs =
new ArrayList<>();
54 logger.log(Level.INFO, String.format(
"[XRY DSP] Processing [ %s ]", xryLines[0]));
56 String
namespace = "";
58 for (
int i = 1; i < xryLines.length; i++) {
59 String xryLine = xryLines[i];
61 String candidateNamespace = xryLine.trim();
64 if (isNamespace(candidateNamespace)) {
65 namespace = candidateNamespace;
70 if(!XRYKeyValuePair.isPair(xryLine)) {
71 logger.log(Level.WARNING, String.format(
"[XRY DSP] Expected a key value "
72 +
"pair on this line (in brackets) [ %s ], but one was not detected.",
77 XRYKeyValuePair pair = XRYKeyValuePair.from(xryLine,
namespace);
80 if (!canProcess(pair)) {
81 logger.log(Level.WARNING, String.format(
"[XRY DSP] The following key, "
82 +
"value pair (in brackets) [ %s ] was not recognized. Discarding...",
88 if (pair.getValue().isEmpty()) {
89 logger.log(Level.WARNING, String.format(
"[XRY DSP] The following key value pair"
90 +
"(in brackets) [ %s ] was recognized, but the value was empty. Discarding...",
95 keyValuePairs.add(pair);
98 if(!keyValuePairs.isEmpty()) {
99 makeArtifact(keyValuePairs, parent, currentCase);
108 abstract boolean canProcess(XRYKeyValuePair pair);
125 abstract boolean isNamespace(String nameSpace);
130 abstract void makeArtifact(List<XRYKeyValuePair> keyValuePairs, Content parent, SleuthkitCase currentCase)
throws TskCoreException, BlackboardException;
synchronized static Logger getLogger(String name)