ConsumerJournalEntry journalEntry,
String name) throws XMLStreamException,
JournalException {
try {
File tempFile = JournalHelper.createTempFile();
DecodingBase64OutputStream decoder =
new DecodingBase64OutputStream(new FileOutputStream(tempFile));
while (true) {
XMLEvent event = reader.nextEvent();
if (event.isCharacters()) {
decoder.write(event.asCharacters().getData());
} else if (isEndTagEvent(event, QNAME_TAG_ARGUMENT)) {
break;
} else {
throw getUnexpectedEventInArgumentException(name,
ARGUMENT_TYPE_STREAM,
journalEntry
.getMethodName(),
event);
}
}
decoder.close();
journalEntry.addArgument(name, tempFile);
} catch (IOException e) {
throw new JournalException("failed to write stream argument to temp file",
e);
}