use of ddf.catalog.transform.InputCollectionTransformer in project ddf by codice.
the class IngestCommand method processIncludeContent.
private void processIncludeContent(ArrayBlockingQueue<Metacard> metacardQueue) {
File inputFile = new File(filePath);
Map<String, Serializable> arguments = new HashMap<>();
arguments.put(DumpCommand.FILE_PATH, inputFile.getParent() + File.separator);
arguments.put(FILE_NAME, inputFile.getName());
ByteSource byteSource = com.google.common.io.Files.asByteSource(inputFile);
Optional<InputCollectionTransformer> zipDecompression = getZipDecompression();
if (zipDecompression.isPresent()) {
try (InputStream inputStream = byteSource.openBufferedStream()) {
List<Metacard> metacardList = zipDecompression.get().transform(inputStream, arguments).stream().filter(Objects::nonNull).collect(Collectors.toList());
if (!metacardList.isEmpty()) {
metacardFileMapping = generateFileMap(new File(inputFile.getParent(), CONTENT_PATH));
fileCount.set(metacardList.size());
for (Metacard metacard : metacardList) {
putMetacardOnQueue(metacardQueue, metacard);
}
}
} catch (IOException | CatalogTransformerException e) {
LOGGER.info("Unable to transform zip file into metacard list.", e);
INGEST_LOGGER.warn("Unable to transform zip file into metacard list.", e);
}
} else {
LOGGER.info("No Zip Transformer found. Unable to transform zip file into metacard list.");
INGEST_LOGGER.warn("No Zip Transformer found. Unable to transform zip file into metacard list.");
}
}
Aggregations