Fixed merge.

This commit is contained in:
U-BASIS\dgrove 2018-02-09 23:35:34 -05:00
parent cb125a5e65
commit dca73677b3
2 changed files with 20 additions and 20 deletions

View File

@ -42,8 +42,8 @@ import org.sleuthkit.datamodel.TskData;
*/
public class FileTypeDetector {
private static final Logger LOGGER = Logger.getLogger(FileTypeDetector.class.getName());
private static final Tika TIKA = new Tika();
private static final Logger logger = Logger.getLogger(FileTypeDetector.class.getName());
private static final Tika tika = new Tika();
private static final int SLACK_FILE_THRESHOLD = 4096;
private final List<FileType> userDefinedFileTypes;
private final List<FileType> autopsyDefinedFileTypes;
@ -224,7 +224,7 @@ public class FileTypeDetector {
ReadContentInputStream stream = new ReadContentInputStream(file);
try (TikaInputStream tikaInputStream = TikaInputStream.get(stream)) {
String tikaType = TIKA.detect(tikaInputStream, file.getName());
String tikaType = tika.detect(tikaInputStream, file.getName());
/*
* Remove the Tika suffix from the MIME type name.
@ -367,7 +367,7 @@ public class FileTypeDetector {
*
* @throws TskCoreException if detection is required and there is a problem
* writing the result to the case database.
* @deprecated Use detectMIMEType instead, and call AbstractFile.setMIMEType
* @deprecated Use getMIMEType instead, and call AbstractFile.setMIMEType
* and AbstractFile.save to save the result to the file object and the
* database.
*/
@ -391,7 +391,7 @@ public class FileTypeDetector {
* @throws TskCoreException if detection is required and there is a problem
* writing the result to the case database.
*
* @deprecated Use detectMIMEType instead, and call AbstractFile.setMIMEType
* @deprecated Use getMIMEType instead, and call AbstractFile.setMIMEType
* and AbstractFile.save to save the result to the file object and the
* database.
*/
@ -413,7 +413,7 @@ public class FileTypeDetector {
* were uncertain, octet-stream is returned.
*
* @throws TskCoreException
* @deprecated Use detectMIMEType instead.
* @deprecated Use getMIMEType instead.
*/
@Deprecated
public String detect(AbstractFile file) throws TskCoreException {

View File

@ -47,10 +47,10 @@ import org.sleuthkit.datamodel.TskCoreException;
})
public class FileTypeIdIngestModule implements FileIngestModule {
private static final Logger LOGGER = Logger.getLogger(FileTypeIdIngestModule.class.getName());
private static final Logger logger = Logger.getLogger(FileTypeIdIngestModule.class.getName());
private long jobId;
private static final HashMap<Long, IngestJobTotals> INGEST_JOB_TOTALS = new HashMap<>();
private static final IngestModuleReferenceCounter REF_COUNTER = new IngestModuleReferenceCounter();
private static final HashMap<Long, IngestJobTotals> totalsForIngestJobs = new HashMap<>();
private static final IngestModuleReferenceCounter refCounter = new IngestModuleReferenceCounter();
private FileTypeDetector fileTypeDetector;
/**
@ -67,7 +67,7 @@ public class FileTypeIdIngestModule implements FileIngestModule {
try {
return new FileTypeDetector().isDetectable(mimeType);
} catch (FileTypeDetector.FileTypeDetectorInitException ex) {
LOGGER.log(Level.SEVERE, "Failed to create file type detector", ex); //NON-NLS
logger.log(Level.SEVERE, "Failed to create file type detector", ex); //NON-NLS
return false;
}
}
@ -82,7 +82,7 @@ public class FileTypeIdIngestModule implements FileIngestModule {
@Override
public void startUp(IngestJobContext context) throws IngestModuleException {
jobId = context.getJobId();
REF_COUNTER.incrementAndGet(jobId);
refCounter.incrementAndGet(jobId);
try {
fileTypeDetector = new FileTypeDetector();
} catch (FileTypeDetector.FileTypeDetectorInitException ex) {
@ -99,7 +99,7 @@ public class FileTypeIdIngestModule implements FileIngestModule {
*/
try {
long startTime = System.currentTimeMillis();
String mimeType = fileTypeDetector.detectMIMEType(file);
String mimeType = fileTypeDetector.getMIMEType(file);
file.setMIMEType(mimeType);
FileType fileType = detectUserDefinedFileType(file);
if (fileType != null && fileType.createInterestingFileHit()) {
@ -108,7 +108,7 @@ public class FileTypeIdIngestModule implements FileIngestModule {
addToTotals(jobId, (System.currentTimeMillis() - startTime));
return ProcessResult.OK;
} catch (Exception e) {
LOGGER.log(Level.WARNING, String.format("Error while attempting to determine file type of file %d", file.getId()), e); //NON-NLS
logger.log(Level.WARNING, String.format("Error while attempting to determine file type of file %d", file.getId()), e); //NON-NLS
return ProcessResult.ERROR;
}
}
@ -157,10 +157,10 @@ public class FileTypeIdIngestModule implements FileIngestModule {
try {
Case.getCurrentCase().getServices().getBlackboard().indexArtifact(artifact);
} catch (Blackboard.BlackboardException ex) {
LOGGER.log(Level.SEVERE, String.format("Unable to index TSK_INTERESTING_FILE_HIT blackboard artifact %d (file obj_id=%d)", artifact.getArtifactID(), file.getId()), ex); //NON-NLS
logger.log(Level.SEVERE, String.format("Unable to index TSK_INTERESTING_FILE_HIT blackboard artifact %d (file obj_id=%d)", artifact.getArtifactID(), file.getId()), ex); //NON-NLS
}
} catch (TskCoreException ex) {
LOGGER.log(Level.SEVERE, String.format("Unable to create TSK_INTERESTING_FILE_HIT artifact for file (obj_id=%d)", file.getId()), ex); //NON-NLS
logger.log(Level.SEVERE, String.format("Unable to create TSK_INTERESTING_FILE_HIT artifact for file (obj_id=%d)", file.getId()), ex); //NON-NLS
}
}
@ -170,10 +170,10 @@ public class FileTypeIdIngestModule implements FileIngestModule {
* If this is the instance of this module for this ingest job, post a
* summary message to the ingest messages box.
*/
if (REF_COUNTER.decrementAndGet(jobId) == 0) {
if (refCounter.decrementAndGet(jobId) == 0) {
IngestJobTotals jobTotals;
synchronized (this) {
jobTotals = INGEST_JOB_TOTALS.remove(jobId);
jobTotals = totalsForIngestJobs.remove(jobId);
}
if (jobTotals != null) {
StringBuilder detailsSb = new StringBuilder();
@ -202,15 +202,15 @@ public class FileTypeIdIngestModule implements FileIngestModule {
* @param matchTimeInc Amount of time to add.
*/
private static synchronized void addToTotals(long jobId, long matchTimeInc) {
IngestJobTotals ingestJobTotals = INGEST_JOB_TOTALS.get(jobId);
IngestJobTotals ingestJobTotals = totalsForIngestJobs.get(jobId);
if (ingestJobTotals == null) {
ingestJobTotals = new IngestJobTotals();
INGEST_JOB_TOTALS.put(jobId, ingestJobTotals);
totalsForIngestJobs.put(jobId, ingestJobTotals);
}
ingestJobTotals.matchTime += matchTimeInc;
ingestJobTotals.numFiles++;
INGEST_JOB_TOTALS.put(jobId, ingestJobTotals);
totalsForIngestJobs.put(jobId, ingestJobTotals);
}
private static class IngestJobTotals {