Configuring FTP channel to pickup based on Filename
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);
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
Hareesh Gampa replied
>>>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