19 package org.sleuthkit.autopsy.datamodel;
21 import java.text.SimpleDateFormat;
22 import java.util.logging.Level;
23 import org.apache.commons.lang.StringUtils;
24 import org.openide.util.NbBundle;
25 import org.openide.util.NbBundle.Messages;
43 private final static SimpleDateFormat
dateFormatter =
new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
66 "ArtifactStringContent.attrsTableHeader.type=Type",
67 "ArtifactStringContent.attrsTableHeader.value=Value",
68 "ArtifactStringContent.attrsTableHeader.sources=Source(s)",
69 "ArtifactStringContent.failedToGetSourcePath.message=Failed to get source file path from case database",
70 "ArtifactStringContent.failedToGetAttributes.message=Failed to get some or all attributes from case database"
74 if (stringContent.isEmpty()) {
78 StringBuilder buffer =
new StringBuilder(1024);
79 buffer.append(
"<html>\n");
80 buffer.append(
"<body>\n");
85 buffer.append(
"<h3>");
86 buffer.append(artifact.getDisplayName());
87 buffer.append(
"</h3>\n");
93 buffer.append(
"<table border='1'>");
96 buffer.append(
"<tr>");
97 buffer.append(
"<th><b>");
98 buffer.append(Bundle.ArtifactStringContent_attrsTableHeader_type());
99 buffer.append(
"</b></th>");
100 buffer.append(
"<th><b>");
101 buffer.append(Bundle.ArtifactStringContent_attrsTableHeader_value());
102 buffer.append(
"</b></th>");
103 buffer.append(
"<th><b>");
104 buffer.append(Bundle.ArtifactStringContent_attrsTableHeader_sources());
105 buffer.append(
"</b></th>");
106 buffer.append(
"</tr>\n");
108 Content content = artifact.getSleuthkitCase().getContentById(artifact.getObjectID());
113 for (BlackboardAttribute attr : artifact.getAttributes()) {
119 switch (attr.getAttributeType().getValueType()) {
126 value = attr.getDisplayString();
131 long epoch = attr.getValueLong();
132 value =
"0000-00-00 00:00:00";
133 if (null != content && 0 != epoch) {
135 value = dateFormatter.format(
new java.util.Date(epoch * 1000));
143 String sources = StringUtils.join(attr.getSources(),
", ");
144 buffer.append(
makeTableRow(attr.getAttributeType().getDisplayName(), value, sources));
153 if (null != content) {
154 path = content.getUniquePath();
156 }
catch (TskCoreException ex) {
157 logger.log(Level.SEVERE, String.format(
"Error getting source content path for artifact (artifact_id=%d, obj_id=%d)", artifact.getArtifactID(), artifact.getObjectID()), ex);
158 path = Bundle.ArtifactStringContent_failedToGetSourcePath_message();
161 buffer.append(
makeTableRow(NbBundle.getMessage(
this.getClass(),
"ArtifactStringContent.getStr.srcFilePath.text"),
168 buffer.append(
makeTableRow(NbBundle.getMessage(
this.getClass(),
"ArtifactStringContent.getStr.artifactId.text"),
169 Long.toString(artifact.getArtifactID()),
""));
171 }
catch (TskCoreException ex) {
172 logger.log(Level.SEVERE, String.format(
"Error getting data for artifact (artifact_id=%d)", artifact.getArtifactID()), ex);
173 buffer.append(
makeTableRow(Bundle.ArtifactStringContent_failedToGetAttributes_message(),
"",
""));
178 buffer.append(
"</table>");
179 buffer.append(
"</html>\n");
180 stringContent = buffer.toString();
189 str = str.replaceAll(
" ",
" ");
190 str = str.replaceAll(
"<",
"<");
191 str = str.replaceAll(
">",
">");
192 str = str.replaceAll(
"(\r\n|\n)",
"<br />");
203 private String
makeTableRow(String type, String value, String source) {
static final SimpleDateFormat dateFormatter
ArtifactStringContent(BlackboardArtifact artifact)
String makeTableRow(String type, String value, String source)
static TimeZone getTimeZone(Content content)
static final Logger logger
String escapeHtmlString(String str)
synchronized static Logger getLogger(String name)
final BlackboardArtifact artifact