Recently I needed to write custom script to override flow file content, when
script was prepared I fount that it can be executed with ExecuteScript
processor, but ExecuteGroovyScript fails to compile the same script, it
shows the error: unable to resolve class import
org.apache.commons.io.IOUtils.
<http://apache-nifi-developer-list.39713.n7.nabble.com/file/t949/groovy_script_error.png>
Script is the following:
import org.apache.commons.io.IOUtils
import java.nio.charset.*
def flowFile = session.get()
if (!flowFile) return
flowFile = session.write(flowFile,
{ inputStream, outputStream ->
def text = org.apache.commons.io.IOUtils.toString(inputStream,
StandardCharsets.UTF_8)
text = text + '\n' + new Date()
outputStream.write(text.getBytes(StandardCharsets.UTF_8))
} as StreamCallback)
session.transfer(flowFile, ExecuteScript.REL_SUCCESS)
Also you could check it with template GroovyScriptIsInvalid.xml
<http://apache-nifi-developer-list.39713.n7.nabble.com/file/t949/GroovyScriptIsInvalid.xml>
Thanks,
Max
--
Sent from: http://apache-nifi-developer-list.39713.n7.nabble.com/