Win a copy of Head First Android this week in the Android forum!

sally tkhilaishvili

Greenhorn
+ Follow
since Feb 05, 2017
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sally tkhilaishvili


down vote
favorite
I want to get real name of file from one previous flowfile and then match how many flowfile with this name exists in certain directory , here is my code but it trows exception which tells that startup failed because unexpected char 0XFFFF, here is my code what should i change?

how should i connect certain hadoop directory?
if my configuration details are placed in xml how can i connect to hdfs directory?

import org.apache.commons.io.IOUtils import java.nio.charset.StandardCharsets

4 years ago
I have several flowfiles in success queue in which I have parameter count and I have to transfer only counter amount of flowfiles, every time the counter value is different so any time I will have to get it from flowfile (all flowfiles from this success queue have this attribute), I have tried this logic below (I mean my code) and several modifications of it but I can't fulfill this task. Could you tell me what's wrong with this code?


import org.apache.commons.io.IOUtils
import java.nio.charset.StandardCharsets
import groovy.lang.*

def flowFile = session.get();
if (!flowFile)
   return;
int numb = (flowFile.getAttribute("count") as Double).round()
def filename = flowFile.getAttribute("filename")

def flowfileList = session.get(numb-1)

if (flowfileList.size() == numb-1) {
   session.transfer(flowfile,REL_SUCCESS);
   session.transfer(flowfileList,REL_SUCCESS);
} else {
   session.rollback()
}
4 years ago
Yes  i did , but  it  doesn't  help  then  i  change nodePrint    by  def newXml=  groovy.xml.XmlUtil.serialize( xml ) and   it  worked   perfectly
4 years ago
I want to get xml content then update it and send it back to it's original place, but evry time i run my code it seems that extra characters are added ('\r' and '\n') with this updated data and as a result it increases file size , how can i remove this characters?  When  i try to  update  my  xml   at   first  time  it  changes  xml  tag  values  but  on  the  other  attempts it  neither  trows  exception nor updates  data,  is  it  because  that  this  '\n'  are changing  position  xml tag  values?  :
[code=groovy]def xml = new XmlParser().parseText(content)
           for(int i=0;i<value.size();i++) {
               date = value.get(i).substring(0, 10);
               xml.Mr.ross.details.findAll( { p ->
                  p.runAs[0].text() == "true" &&  date.toString()== p.start[0].text();
               }).each({ p ->
                   p.start[0].value =addDays( p.start[0].text())
                   p.runAs[0].value ="true"
               })
           }

For example xml data looks like:


<?xml version="1.0" encoding="UTF-8" standalone="no"?><service>
 <Ms>
   <ross>
     <details>
       <start>
                                                                     2017-09-07                                              
       </start>
       <startDate>
                                                                     2017-02-02                                                
       </startDate>
       <endDate>
                                                                     2017-03-02                                                
       </endDate>
       <runAs>
                                                                     true                                                
       </runAs>
       <makeVersion>
                                                                     1                                                
       </makeVersion>
       <patch>
                                                                     this is  patch                                                
       </patch>
       <parameter>
                                                                     1                                                
       </parameter>
     </details>
   </ross>

 </Ms>
</service>
4 years ago