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()) {
 
  127                             value = attr.getDisplayString();
 
  132                             long epoch = attr.getValueLong();
 
  133                             value = 
"0000-00-00 00:00:00";
 
  134                             if (null != content && 0 != epoch) {
 
  136                                 value = dateFormatter.format(
new java.util.Date(epoch * 1000));
 
  144                     String sources = StringUtils.join(attr.getSources(), 
", ");
 
  145                     buffer.append(
makeTableRow(attr.getAttributeType().getDisplayName(), value, sources));
 
  154                     if (null != content) {
 
  155                         path = content.getUniquePath();
 
  157                 } 
catch (TskCoreException ex) {
 
  158                     logger.log(Level.SEVERE, String.format(
"Error getting source content path for artifact (artifact_id=%d, obj_id=%d)", artifact.getArtifactID(), artifact.getObjectID()), ex);
 
  159                     path = Bundle.ArtifactStringContent_failedToGetSourcePath_message();
 
  162                 buffer.append(
makeTableRow(NbBundle.getMessage(
this.getClass(), 
"ArtifactStringContent.getStr.srcFilePath.text"),
 
  169                 buffer.append(
makeTableRow(NbBundle.getMessage(
this.getClass(), 
"ArtifactStringContent.getStr.artifactId.text"),
 
  170                         Long.toString(artifact.getArtifactID()), 
""));
 
  172             } 
catch (TskCoreException ex) {
 
  173                 logger.log(Level.SEVERE, String.format(
"Error getting data for artifact (artifact_id=%d)", artifact.getArtifactID()), ex);
 
  174                 buffer.append(
makeTableRow(Bundle.ArtifactStringContent_failedToGetAttributes_message(), 
"", 
""));                
 
  179                 buffer.append(
"</table>"); 
 
  180                 buffer.append(
"</html>\n"); 
 
  181                 stringContent = buffer.toString();
 
  190         str = str.replaceAll(
" ", 
" "); 
 
  191         str = str.replaceAll(
"<", 
"<"); 
 
  192         str = str.replaceAll(
">", 
">"); 
 
  193         str = str.replaceAll(
"(\r\n|\n)", 
"<br />"); 
 
  204     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