Package com.streamconverter.command.impl
Class FileBufferCommand
java.lang.Object
com.streamconverter.command.AbstractStreamCommand
com.streamconverter.command.impl.FileBufferCommand
- All Implemented Interfaces:
IStreamCommand
A pipeline command that buffers data through a temporary file between pipeline stages.
This command solves the problem where validation failures in a preceding stage can cause invalid data to be written to the output stream. By buffering through a temporary file, the upstream stage completes fully before the downstream stage begins, ensuring data integrity.
Usage example:
StreamConverter.create(
validateCmd,
FileBufferCommand.create(),
transformCmd
);
The encrypted variant (createEncrypted()) uses AES-256-GCM to protect sensitive data
written to the temporary file.
-
Field Summary
Fields inherited from class com.streamconverter.command.AbstractStreamCommand
log -
Method Summary
Modifier and TypeMethodDescriptionstatic FileBufferCommandcreate()Creates aFileBufferCommandthat buffers data through a plaintext temporary file.static FileBufferCommandCreates aFileBufferCommandthat buffers data through an AES-256-GCM encrypted temporary file.voidexecute(InputStream inputStream, OutputStream outputStream) Executes the buffering operation: writes the input stream to a temporary file, then reads the temporary file to the output stream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.streamconverter.command.IStreamCommand
commandName, withLogging, withLogging
-
Method Details
-
create
Creates aFileBufferCommandthat buffers data through a plaintext temporary file.- Returns:
- a new
FileBufferCommandinstance
-
createEncrypted
Creates aFileBufferCommandthat buffers data through an AES-256-GCM encrypted temporary file.The encryption key and IV are generated per execution and never persisted, providing confidentiality for sensitive pipeline data.
- Returns:
- a new
FileBufferCommandinstance with encryption enabled
-
execute
Executes the buffering operation: writes the input stream to a temporary file, then reads the temporary file to the output stream.- Specified by:
executein interfaceIStreamCommand- Specified by:
executein classAbstractStreamCommand- Parameters:
inputStream- the input stream to read data fromoutputStream- the output stream to write data to- Throws:
IOException- if an I/O error occurs, or if decryption authentication fails
-