Using groovy in apache-nifi

Viewed 2425

I have generated flowfile with attribute date and then I want to make some changes on my date:

import java.nio.charset.StandardCharsets 
import org.apache.commons.io.IOUtils
import org.apache.nifi.processor.io.StreamCallback

def flowfile = session.get()
def date=flowfile.getAttribute('date')
 def yourDate= new GregorianCalendar(date)
 def newdate= yourDate.getTimeInMillis()+621355968000000000
if(!flowfile) return
flowfile = session.putAttribute(flowfile, '12321312'+'_'+newdate)
session.transfer(flowfile, REL_SUCCESS)

but executescript posecor gives me exception:Cannot invoke getAtribute on null object , what should i do?

2 Answers
Related