String message = "Bad file name (" + fileName + ") passed into addFileToQueue. Exiting.";
LOG.error(message);
throw new IllegalArgumentException(message);
}
ApplicationChannel channel = applicationChannelDao.retrieveById(channelId);
if (channel == null) {
LOG.warn("The ApplicationChannel could not be loaded.");
return new ScanCheckResultBean(ScanImportStatus.OTHER_ERROR);
}
ChannelImporter importer = channelImporterFactory.getChannelImporter(channel);
if (importer == null) {
LOG.warn("No importer could be loaded for the ApplicationChannel.");
return new ScanCheckResultBean(ScanImportStatus.OTHER_ERROR);
}
importer.setFileName(fileName);
ScanCheckResultBean result = importer.checkFile();
if ((!result.getScanCheckResult().equals(ScanImportStatus.SUCCESSFUL_SCAN)
&& !result.getScanCheckResult().equals(ScanImportStatus.EMPTY_SCAN_ERROR))) {
importer.deleteScanFile();
}
Calendar scanQueueDate = applicationChannelDao.getMostRecentQueueScanTime(channel.getId());
if (scanQueueDate != null && result.getTestDate() != null &&
!result.getTestDate().after(scanQueueDate)) {
LOG.warn(ScanImportStatus.MORE_RECENT_SCAN_ON_QUEUE.toString());
return new ScanCheckResultBean(ScanImportStatus.MORE_RECENT_SCAN_ON_QUEUE, result.getTestDate());