on 08-24-2015 2:24 PM
Hello Experts,
I have a requirment to pick up the file from NFS, only when the first 7 postions of the filename is Numerics and next two are alphabets .Else, Ignore.
Actual scenario :
-----------------------------
Pick up any files ( .pdf ) , and post them to an FTP ( Creating Dynamic directory ).
I have used File sender adapter to pickup the file and delete it when the file gets processed .
And, I have written Java mapping with the following condition to process only when the condition is satisfied ( when first 7 postions of the filename are numerics and next two are alphabets ).
String store = oldFileName.substring(0,7);
String state = oldFileName.substring(7,9);
Pattern p = Pattern.compile( "([0-9]*)" );
Matcher str = p.matcher(store);
Pattern p1 = Pattern.compile( "([A-Z]*)" );
Matcher st = p1.matcher(state);
if(str.matches())
if(st.matches()){
conf.put(KEY_FILEPATH, dir);
conf.put(KEY_FILENAME, FileName);
Therefore, when filename condition doesn't matches the file from the source is note getting deleted. however, the file is getting copied into the Destination with wrong directory path.
To avoid this I would like to check if there is any condition in File Sender Adapter to check the filename conditions and then process the request .
Thanks for your valuable inputs
Regards,
Ram
>>>Therefore, when filename condition doesn't matches the file from the source is note getting deleted. however, the file is getting copied into the Destination with wrong directory path.
Destination folder is getting created as you are not throwing exception when the file name condition is not satisfied.
If you want to throw exception and fail the message try using below method
throw new StreamTransformationException
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rama,
SFTP supports regex, but like Vishnu said FTP adapter doesn't. The only ways, to develop a module bean or run OS are not the better ones either. If i was i will continue with the java mapping and if you have enough time i would try to do a module bean.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ram,
I don't think file adapter supports regex in the filename patterns. It will support only placeholders * and ?.
Defining Placeholders, File Name Masks, and Exclusion Masks - Advanced Adapter Engine - SAP Library
Still if you want to handle this in the channel level itself, then you need to check for OS command possibility.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try Run Operating System Command Before Message Processing option
You can write Unix commands for checking file name and place files in respective directory if it matches your requirement.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.