From 33d0a9e3b363be049fffe8dde4a8e0d8a058c78a Mon Sep 17 00:00:00 2001 From: Nick Davis Date: Tue, 22 Apr 2014 17:01:39 -0400 Subject: [PATCH] ThunderbirdParser - Added NON-NLS tags to hardcoded strings not needing National Language Support. --- .../autopsy/thunderbirdparser/MboxParser.java | 24 +++++++-------- .../autopsy/thunderbirdparser/PstParser.java | 16 +++++----- .../ThunderbirdMboxFileIngestModule.java | 30 +++++++++---------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/MboxParser.java b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/MboxParser.java index f2ab914821..d8da65c24e 100755 --- a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/MboxParser.java +++ b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/MboxParser.java @@ -71,7 +71,7 @@ import org.sleuthkit.autopsy.ingest.IngestServices; /** * The mime type string for html text. */ - private static final String HTML_TYPE = "text/html"; + private static final String HTML_TYPE = "text/html"; //NON-NLS /** * The local path of the mbox file. @@ -89,7 +89,7 @@ import org.sleuthkit.autopsy.ingest.IngestServices; } static boolean isValidMimeTypeMbox(byte[] buffer) { - return (new String(buffer)).startsWith("From "); + return (new String(buffer)).startsWith("From "); //NON-NLS } /** @@ -115,7 +115,7 @@ import org.sleuthkit.autopsy.ingest.IngestServices; } catch (IllegalArgumentException ex) { // Not the right encoder } catch (IOException ex) { - logger.log(Level.WARNING, "couldn't find mbox file.", ex); + logger.log(Level.WARNING, "couldn't find mbox file.", ex); //NON-NLS addErrorMessage(NbBundle.getMessage(this.getClass(), "MboxParser.parse.errMsg.failedToReadFile")); return new ArrayList<>(); } @@ -136,7 +136,7 @@ import org.sleuthkit.autopsy.ingest.IngestServices; Message msg = messageBuilder.parseMessage(message.asInputStream(theEncoder.charset())); emails.add(extractEmail(msg)); } catch (IOException ex) { - logger.log(Level.WARNING, "Failed to get message from mbox: {0}", ex.getMessage()); + logger.log(Level.WARNING, "Failed to get message from mbox: {0}", ex.getMessage()); //NON-NLS failCount++; } } @@ -236,7 +236,7 @@ import org.sleuthkit.autopsy.ingest.IngestServices; break; } } catch (IOException ex) { - logger.log(Level.WARNING, "Error getting text body of mbox message", ex); + logger.log(Level.WARNING, "Error getting text body of mbox message", ex); //NON-NLS } } @@ -259,7 +259,7 @@ import org.sleuthkit.autopsy.ingest.IngestServices; addErrorMessage( NbBundle.getMessage(this.getClass(), "MboxParser.handleAttch.errMsg.failedToCreateOnDisk", filename)); - logger.log(Level.INFO, "Failed to create file output stream for: " + outPath, ex); + logger.log(Level.INFO, "Failed to create file output stream for: " + outPath, ex); //NON-NLS return; } @@ -272,14 +272,14 @@ import org.sleuthkit.autopsy.ingest.IngestServices; // This could potentially be other types. Only seen this once. } } catch (IOException ex) { - logger.log(Level.INFO, "Failed to write mbox email attachment to disk.", ex); + logger.log(Level.INFO, "Failed to write mbox email attachment to disk.", ex); //NON-NLS addErrorMessage(NbBundle.getMessage(this.getClass(), "MboxParser.handleAttch.failedWriteToDisk", filename)); return; } finally { try { fos.close(); } catch (IOException ex) { - logger.log(Level.INFO, "Failed to close file output stream", ex); + logger.log(Level.INFO, "Failed to close file output stream", ex); //NON-NLS } } @@ -338,7 +338,7 @@ import org.sleuthkit.autopsy.ingest.IngestServices; try { is = new BufferedInputStream(new FileInputStream(mboxFile)); } catch (FileNotFoundException ex) { - logger.log(Level.WARNING, "Failed to find mbox file while detecting charset"); + logger.log(Level.WARNING, "Failed to find mbox file while detecting charset"); //NON-NLS return possibleEncoders; } @@ -355,18 +355,18 @@ import org.sleuthkit.autopsy.ingest.IngestServices; } return possibleEncoders; } catch (IOException | IllegalArgumentException ex) { - logger.log(Level.WARNING, "Failed to detect charset of mbox file.", ex); + logger.log(Level.WARNING, "Failed to detect charset of mbox file.", ex); //NON-NLS return possibleEncoders; } finally { try { is.close(); } catch (IOException ex) { - logger.log(Level.INFO, "Failed to close input stream"); + logger.log(Level.INFO, "Failed to close input stream"); //NON-NLS } } } private void addErrorMessage(String msg) { - errors.append("
  • ").append(msg).append("
  • "); + errors.append("
  • ").append(msg).append("
  • "); //NON-NLS } } diff --git a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/PstParser.java b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/PstParser.java index be37525a78..0933d8f221 100755 --- a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/PstParser.java +++ b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/PstParser.java @@ -88,11 +88,11 @@ class PstParser { } return ParseResult.OK; } catch (PSTException | IOException ex) { - String msg = file.getName() + ": Failed to create internal java-libpst PST file to parse:\n" + ex.getMessage(); + String msg = file.getName() + ": Failed to create internal java-libpst PST file to parse:\n" + ex.getMessage(); //NON-NLS logger.log(Level.WARNING, msg); return ParseResult.ERROR; } catch (IllegalArgumentException ex) { - logger.log(Level.INFO, "Found encrypted PST file."); + logger.log(Level.INFO, "Found encrypted PST file."); //NON-NLS return ParseResult.ENCRYPT; } } @@ -130,7 +130,7 @@ class PstParser { subFolders = folder.getSubFolders(); } catch (PSTException | IOException ex) { subFolders = new ArrayList<>(); - logger.log(Level.INFO, "java-libpst exception while getting subfolders: {0}", ex.getMessage()); + logger.log(Level.INFO, "java-libpst exception while getting subfolders: {0}", ex.getMessage()); //NON-NLS } for (PSTFolder f : subFolders) { @@ -147,7 +147,7 @@ class PstParser { } } catch (PSTException | IOException ex) { failCount++; - logger.log(Level.INFO, "java-libpst exception while getting emails from a folder: {0}", ex.getMessage()); + logger.log(Level.INFO, "java-libpst exception while getting emails from a folder: {0}", ex.getMessage()); //NON-NLS } } @@ -174,7 +174,7 @@ class PstParser { try { rtf = msg.getRTFBody(); } catch (PSTException | IOException ex) { - logger.log(Level.INFO, "Failed to get RTF content from pst email."); + logger.log(Level.INFO, "Failed to get RTF content from pst email."); //NON-NLS } email.setRtfBody(rtf); email.setLocalPath(localPath); @@ -229,7 +229,7 @@ class PstParser { addErrorMessage( NbBundle.getMessage(this.getClass(), "PstParser.extractAttch.errMsg.failedToExtractToDisk", filename)); - logger.log(Level.WARNING, "Failed to extract attachment from pst file.", ex); + logger.log(Level.WARNING, "Failed to extract attachment from pst file.", ex); //NON-NLS } } } @@ -294,12 +294,12 @@ class PstParser { ByteBuffer bb = ByteBuffer.wrap(buffer); return bb.getInt() == PST_HEADER; } catch (TskCoreException ex) { - logger.log(Level.WARNING, "Exception while detecting if a file is a pst file."); + logger.log(Level.WARNING, "Exception while detecting if a file is a pst file."); //NON-NLS return false; } } private void addErrorMessage(String msg) { - errors.append("
  • ").append(msg).append("
  • "); + errors.append("
  • ").append(msg).append("
  • "); //NON-NLS } } diff --git a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java index 289f1fa5a0..933bf4fb4a 100644 --- a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java +++ b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java @@ -120,7 +120,7 @@ public final class ThunderbirdMboxFileIngestModule extends IngestModuleAdapter i File file = new File(fileName); if (abstractFile.getSize() >= services.getFreeDiskSpace()) { - logger.log(Level.WARNING, "Not enough disk space to write file to disk."); + logger.log(Level.WARNING, "Not enough disk space to write file to disk."); //NON-NLS IngestMessage msg = IngestMessage.createErrorMessage(EmailParserModuleFactory.getModuleName(), EmailParserModuleFactory.getModuleName(), NbBundle.getMessage(this.getClass(), "ThunderbirdMboxFileIngestModule.processPst.errMsg.outOfDiskSpace", @@ -132,7 +132,7 @@ public final class ThunderbirdMboxFileIngestModule extends IngestModuleAdapter i try { ContentUtils.writeToFile(abstractFile, file); } catch (IOException ex) { - logger.log(Level.WARNING, "Failed writing pst file to disk.", ex); + logger.log(Level.WARNING, "Failed writing pst file to disk.", ex); //NON-NLS return ProcessResult.OK; } @@ -150,7 +150,7 @@ public final class ThunderbirdMboxFileIngestModule extends IngestModuleAdapter i EmailParserModuleFactory.getModuleName(), NbBundle.getMessage(this.getClass(), "ThunderbirdMboxFileIngestModule.encryptionFileLevel"))); } catch (TskCoreException ex) { - logger.log(Level.INFO, "Failed to add encryption attribute to file: {0}", abstractFile.getName()); + logger.log(Level.INFO, "Failed to add encryption attribute to file: {0}", abstractFile.getName()); //NON-NLS } } else { // parsing error: log message @@ -159,12 +159,12 @@ public final class ThunderbirdMboxFileIngestModule extends IngestModuleAdapter i abstractFile.getName()), NbBundle.getMessage(this.getClass(), "ThunderbirdMboxFileIngestModule.processPst.errProcFile.details")); - logger.log(Level.INFO, "PSTParser failed to parse {0}", abstractFile.getName()); + logger.log(Level.INFO, "PSTParser failed to parse {0}", abstractFile.getName()); //NON-NLS return ProcessResult.ERROR; } if (file.delete() == false) { - logger.log(Level.INFO, "Failed to delete temp file: {0}", file.getName()); + logger.log(Level.INFO, "Failed to delete temp file: {0}", file.getName()); //NON-NLS } String errors = parser.getErrors(); @@ -190,20 +190,20 @@ public final class ThunderbirdMboxFileIngestModule extends IngestModuleAdapter i // use the local path to determine the e-mail folder structure String emailFolder = ""; // email folder is everything after "Mail" or ImapMail - if (mboxParentDir.contains("/Mail/")) { - emailFolder = mboxParentDir.substring(mboxParentDir.indexOf("/Mail/") + 5); - } else if (mboxParentDir.contains("/ImapMail/")) { - emailFolder = mboxParentDir.substring(mboxParentDir.indexOf("/ImapMail/") + 9); + if (mboxParentDir.contains("/Mail/")) { //NON-NLS + emailFolder = mboxParentDir.substring(mboxParentDir.indexOf("/Mail/") + 5); //NON-NLS + } else if (mboxParentDir.contains("/ImapMail/")) { //NON-NLS + emailFolder = mboxParentDir.substring(mboxParentDir.indexOf("/ImapMail/") + 9); //NON-NLS } emailFolder = emailFolder + mboxFileName; - emailFolder = emailFolder.replaceAll(".sbd", ""); + emailFolder = emailFolder.replaceAll(".sbd", ""); //NON-NLS String fileName = getTempPath() + File.separator + abstractFile.getName() + "-" + String.valueOf(abstractFile.getId()); File file = new File(fileName); if (abstractFile.getSize() >= services.getFreeDiskSpace()) { - logger.log(Level.WARNING, "Not enough disk space to write file to disk."); + logger.log(Level.WARNING, "Not enough disk space to write file to disk."); //NON-NLS postErrorMessage( NbBundle.getMessage(this.getClass(), "ThunderbirdMboxFileIngestModule.processMBox.errProcFile.msg", abstractFile.getName()), @@ -215,7 +215,7 @@ public final class ThunderbirdMboxFileIngestModule extends IngestModuleAdapter i try { ContentUtils.writeToFile(abstractFile, file); } catch (IOException ex) { - logger.log(Level.WARNING, "Failed writing mbox file to disk.", ex); + logger.log(Level.WARNING, "Failed writing mbox file to disk.", ex); //NON-NLS return ProcessResult.OK; } @@ -225,7 +225,7 @@ public final class ThunderbirdMboxFileIngestModule extends IngestModuleAdapter i processEmails(emails, abstractFile); if (file.delete() == false) { - logger.log(Level.INFO, "Failed to delete temp file: {0}", file.getName()); + logger.log(Level.INFO, "Failed to delete temp file: {0}", file.getName()); //NON-NLS } String errors = parser.getErrors(); @@ -245,7 +245,7 @@ public final class ThunderbirdMboxFileIngestModule extends IngestModuleAdapter i */ public static String getTempPath() { String tmpDir = Case.getCurrentCase().getTempDirectory() + File.separator - + "EmailParser"; + + "EmailParser"; //NON-NLS File dir = new File(tmpDir); if (dir.exists() == false) { dir.mkdirs(); @@ -383,7 +383,7 @@ public final class ThunderbirdMboxFileIngestModule extends IngestModuleAdapter i if (localPath.isEmpty() == false) { bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PATH.getTypeID(), EmailParserModuleFactory.getModuleName(), localPath)); } else { - bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PATH.getTypeID(), EmailParserModuleFactory.getModuleName(), "/foo/bar")); + bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PATH.getTypeID(), EmailParserModuleFactory.getModuleName(), "/foo/bar")); //NON-NLS } try {