Using String constants for MIME types.

This commit is contained in:
U-BASIS\dgrove 2018-04-25 14:53:49 -04:00
parent 3ed6ea4add
commit a0dc448bf2

View File

@ -74,6 +74,13 @@ final class EncryptionDetectionFileIngestModule extends FileIngestModuleAdapter
private static final int FILE_SIZE_MODULUS = 512; private static final int FILE_SIZE_MODULUS = 512;
private static final double ONE_OVER_LOG2 = 1.4426950408889634073599246810019; // (1 / log(2)) private static final double ONE_OVER_LOG2 = 1.4426950408889634073599246810019; // (1 / log(2))
private static final int BYTE_OCCURENCES_BUFFER_SIZE = 256; private static final int BYTE_OCCURENCES_BUFFER_SIZE = 256;
private static final String MIME_TYPE_OOXML_PROTECTED = "application/x-ooxml-protected";
private static final String MIME_TYPE_MSWORD = "application/msword";
private static final String MIME_TYPE_MSEXCEL = "application/vnd.ms-excel";
private static final String MIME_TYPE_MSPOWERPOINT = "application/vnd.ms-powerpoint";
private static final String MIME_TYPE_MSACCESS = "application/x-msaccess";
private static final String MIME_TYPE_PDF = "application/pdf";
private final IngestServices services = IngestServices.getInstance(); private final IngestServices services = IngestServices.getInstance();
private final Logger logger = services.getLogger(EncryptionDetectionModuleFactory.getModuleName()); private final Logger logger = services.getLogger(EncryptionDetectionModuleFactory.getModuleName());
@ -247,9 +254,8 @@ final class EncryptionDetectionFileIngestModule extends FileIngestModuleAdapter
boolean passwordProtected = false; boolean passwordProtected = false;
String mimeType = file.getMIMEType(); switch (file.getMIMEType()) {
switch (mimeType) { case MIME_TYPE_OOXML_PROTECTED:
case "application/x-ooxml-protected":
/* /*
* Office Open XML files that are password protected can be * Office Open XML files that are password protected can be
* determined so simply by checking the MIME type. * determined so simply by checking the MIME type.
@ -257,10 +263,10 @@ final class EncryptionDetectionFileIngestModule extends FileIngestModuleAdapter
passwordProtected = true; passwordProtected = true;
break; break;
case "application/msword": case MIME_TYPE_MSWORD:
case "application/vnd.ms-excel": case MIME_TYPE_MSEXCEL:
case "application/vnd.ms-powerpoint": case MIME_TYPE_MSPOWERPOINT:
case "application/pdf": { case MIME_TYPE_PDF: {
/* /*
* A file of one of these types will be determined to be * A file of one of these types will be determined to be
* password protected or not by attempting to parse it via Tika. * password protected or not by attempting to parse it via Tika.
@ -292,7 +298,7 @@ final class EncryptionDetectionFileIngestModule extends FileIngestModuleAdapter
break; break;
} }
case "application/x-msaccess": { case MIME_TYPE_MSACCESS: {
/* /*
* Access databases are determined to be password protected * Access databases are determined to be password protected
* using Jackcess. If the database can be opened, the password * using Jackcess. If the database can be opened, the password