use of org.apache.nifi.processors.evtx.parser.FileHeader in project nifi by apache.
the class ParseEvtx method processRecordGranularity.
protected void processRecordGranularity(ProcessSession session, ComponentLog componentLog, FlowFile flowFile, String basename, InputStream in) throws IOException {
FileHeader fileHeader = fileHeaderFactory.create(in, componentLog);
while (fileHeader.hasNext()) {
try {
ChunkHeader chunkHeader = fileHeader.next();
while (chunkHeader.hasNext()) {
FlowFile updated = session.create(flowFile);
AtomicReference<Exception> exceptionReference = new AtomicReference<>(null);
try {
Record record = chunkHeader.next();
updated = session.write(updated, out -> {
try (RootNodeHandler rootNodeHandler = rootNodeHandlerFactory.create(out)) {
try {
rootNodeHandler.handle(record.getRootNode());
} catch (IOException e) {
exceptionReference.set(e);
}
} catch (IOException e) {
exceptionReference.set(e);
}
});
resultProcessor.process(session, componentLog, updated, exceptionReference.get(), getName(basename, chunkHeader.getChunkNumber(), record.getRecordNum(), XML_EXTENSION));
} catch (Exception e) {
exceptionReference.set(e);
session.remove(updated);
}
if (exceptionReference.get() != null) {
malformedChunkHandler.handle(flowFile, session, getName(basename, chunkHeader.getChunkNumber(), null, EVTX_EXTENSION), chunkHeader.getBinaryReader().getBytes());
}
}
} catch (MalformedChunkException e) {
malformedChunkHandler.handle(flowFile, session, getName(basename, e.getChunkNum(), null, EVTX_EXTENSION), e.getBadChunk());
}
}
}
use of org.apache.nifi.processors.evtx.parser.FileHeader in project nifi by apache.
the class ParseEvtx method processChunkGranularity.
protected void processChunkGranularity(ProcessSession session, ComponentLog componentLog, FlowFile flowFile, String basename, InputStream in) throws IOException {
FileHeader fileHeader = fileHeaderFactory.create(in, componentLog);
while (fileHeader.hasNext()) {
try {
ChunkHeader chunkHeader = fileHeader.next();
FlowFile updated = session.create(flowFile);
AtomicReference<Exception> exceptionReference = new AtomicReference<>(null);
updated = session.write(updated, out -> {
try (RootNodeHandler rootNodeHandler = rootNodeHandlerFactory.create(out)) {
while (chunkHeader.hasNext()) {
try {
rootNodeHandler.handle(chunkHeader.next().getRootNode());
} catch (IOException e) {
exceptionReference.set(e);
break;
}
}
} catch (IOException e) {
exceptionReference.set(e);
}
});
Exception exception = exceptionReference.get();
resultProcessor.process(session, componentLog, updated, exception, getName(basename, chunkHeader.getChunkNumber(), null, XML_EXTENSION));
if (exception != null) {
malformedChunkHandler.handle(flowFile, session, getName(basename, chunkHeader.getChunkNumber(), null, EVTX_EXTENSION), chunkHeader.getBinaryReader().getBytes());
}
} catch (MalformedChunkException e) {
malformedChunkHandler.handle(flowFile, session, getName(basename, e.getChunkNum(), null, EVTX_EXTENSION), e.getBadChunk());
}
}
}
Aggregations