Source:
private void processFiles(Iterable<File> files) { try { JAXBContext context = JAXBContext.newInstance("org.atlasapi.remotesite.pa.profiles.bindings"); Unmarshaller unmarshaller = context.createUnmarshaller(); SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); XMLReader reader = factory.newSAXParser().getXMLReader(); reader.setContentHandler(unmarshaller.getUnmarshallerHandler()); File latestFile = BY_DATE_ORDER.max(files); Matcher matcher = FULL_FILE.matcher(latestFile.toURI().toString()); if (matcher.matches()) { log.info("Processing file " + latestFile.toString()); final File fileToProcess = store.copyForProcessing(latestFile); unmarshaller.setListener(peopleProcessingListener()); reader.parse(fileToProcess.toURI().toString()); FileUploadResult.successfulUpload(SERVICE, latestFile.getName()); DateTime bootstrapDate = dateFormatter.parseDateTime(matcher.group(1)); for (File file : files) { Matcher fileMatcher = DAILY_DATE.matcher(file.toURI().toString()); if (fileMatcher.matches()) { DateTime fileTime = dateFormatter.parseDateTime(fileMatcher.group(1)); if (fileTime.isBefore(bootstrapDate)) { FileUploadResult.successfulUpload(SERVICE, file.getName()); } } } } else { throw new RuntimeException("No full profiles dump file found"); } reportStatus(String.format("found %s files, processed most recent file %s", Iterables.size(files), latestFile.getName())); } catch (NoSuchElementException e) { log.error("No files found when running PA Complete People updater", e); Throwables.propagate(e); } catch (Exception e) { log.error("Exception running PA Complete People updater", e); Throwables.propagate(e); } }

Target:
private void processFiles(Iterable<File> files) { try { JAXBContext context = JAXBContext.newInstance("org.atlasapi.remotesite.pa.profiles.bindings"); Unmarshaller unmarshaller = context.createUnmarshaller(); SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); XMLReader reader = factory.newSAXParser().getXMLReader(); reader.setContentHandler(unmarshaller.getUnmarshallerHandler()); File latestFile = BY_DATE_ORDER.max(files); Matcher matcher = FULL_FILE.matcher(latestFile.toURI().toString()); if (!matcher.matches()) { throw new RuntimeException("No full profiles dump file found"); } else { log.info("Processing file " + latestFile.toString()); final File fileToProcess = store.copyForProcessing(latestFile); unmarshaller.setListener(peopleProcessingListener()); reader.parse(fileToProcess.toURI().toString()); FileUploadResult.successfulUpload(SERVICE, latestFile.getName()); DateTime bootstrapDate = dateFormatter.parseDateTime(matcher.group(1)); for (File file : files) { Matcher fileMatcher = DAILY_DATE.matcher(file.toURI().toString()); if (fileMatcher.matches()) { DateTime fileTime = dateFormatter.parseDateTime(fileMatcher.group(1)); if (fileTime.isBefore(bootstrapDate)) { FileUploadResult.successfulUpload(SERVICE, file.getName()); } } } } reportStatus(String.format("found %s files, processed most recent file %s", Iterables.size(files), latestFile.getName())); } catch (NoSuchElementException e) { log.error("No files found when running PA Complete People updater", e); Throwables.propagate(e); } catch (Exception e) { log.error("Exception running PA Complete People updater", e); Throwables.propagate(e); } }