on 09-23-2009 3:28 PM
Hi,
In the source file structure, some of the fields are Filename, Directoryname, statuscode.
my requirement is I should check the status code, if it is other than 200, I should copy the file (Filename) from folder1 to folder2.(folder1 contains that file).
I need UDF for this...
once the file is copied, it should be deleted in the folder1
Let me know if its not clear.
Regards,
Varun
Edited by: Varun Reddy on Sep 23, 2009 8:00 PM
Actually my Schema is financial one.
Its File to SOAP.
I need to do couple of validations before posting the message to webservice.
If it fails for any of the validations I should send mail(i am sending mail from UDF). Even when posting the message to webservice, if its not successfull(based on status code from the response file) I should retry the same message for 3 times, if I get Application error from webservice response, then send mail
So I had splited the flow into 3 sub flows
1) File to File flow which does all the validations and generate a file in the source folder to further process to webservice.
2) File to soap-which sends the validated file to webservice. (I am Archiving the validated file, because for that file, if the response from webservice has an error, then i should send the same message.)
3) File(response file from webservice) to mail - sends the mail if the status is not successfull (200 -represents success)
I am storing the Webservice response file in a folder
Now I should check the status from the fil, If its an error, copy the validated file from archive folder to Source folder to post to webservice.
i am currently looking at the 3rd flow
Let me know if anything is required
Regards,
Varun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Varun,
Why dont you then use a Script in your file Communication channel before processing ?
You can check the status using the script and if its 200 then you can first move the file from the archive folder to source folder and then your communication channel can pick the same and then process.
Also can you plz share how you are sending a mail using UDF. Aren't you using mail adapter here ?
Hi
Can you explain your requirement
For more information moving file from one directory to other you see given link may useful for you
http://www.roseindia.net/java/example/java/io/MovingFile.shtml
Thanks ,
Amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
please provice me a UDF to copy the file from one folder to another folder.... how to specify the folder path
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Varun,
This is the java program for copying one file from one location to other location.
public class CopyFile
{
public static void main(String args[])
{
String source = "GiveHereSourceFile";
C://temp/test.txt
String dest = "GiveHereDestinationFolder";
D://test/temp.txt
copy(source, dest);
}
public static void copy(File source, File dest) throws IOException
{
FileChannel in = null, out = null;
try
{
in = new FileInputStream(source).getChannel();
out = new FileOutputStream(dest).getChannel();
long size = in.size();
MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, size);
out.write(buf);
}
finally
{
if (in != null) in.close();
if (out != null) out.close();
}
}
}
Hi Varun,
What do you want to do if it is 200? You want to process it or not?
Create multimapping and for the root node check the status code using if exists function. If it doesnot exists then do a straight record to record mapping and write to the folder where ever you want.
If it is 200 if you dont want to do anything then write to the same fodler from where you are picking.
Regards,
---Satish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Varun,
I have a doubt here:
Source Fields: Filename, Directoryname, statuscode
Target Fileds:????? Plz inform
And do you want to achive this copying of file from a folder to another folder using UDF???? I doubt if its possible.
Please elaborate more on the requirement.
Regards,
Rahul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rahul,
target is mail.
If the status code is other than 200, mail will be triggered. In my case there is another flow file to soap. If the response file wich contains status code has other than 200, then i shd copy the file in the source folder and send the message agin to soap.
Regards,
varun
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.