One Star

[resolved] Component to test if FTP folder exist?

Hello,
I am looking for a simple way to test if a ftp folder exists.
I have tested with tFTPFileExists and tFTPFileList, but no chance. When folder does not exists a java exception is thrown.
How can I do a such test with Talend?
I am working in TOS 4.1.0M3
Thanks for helping,
Eduard
1 ACCEPTED SOLUTION

Accepted Solutions

Re: [resolved] Component to test if FTP folder exist?

Try this way

tJava Code:
context.test = 
((String)globalMap.get("tFTPGet_1_ERROR_MESSAGE")).equals("test: No such file or directory") ? "yes" : "no";

if statements code:
context.test == "yes"
context.test == "no"

As I don't think there is a more soft way, that I know of atleast i may be mistaken
4 REPLIES

Re: [resolved] Component to test if FTP folder exist?

Take off die on error.
Then it will be:
tFTPGet --on Subjob Failure--> Desired Component
Look at the images below to help you.



If you want it to loop the job again until the Directory exists ask me and I will show you another example.
Regards
Brandon
One Star

Re: [resolved] Component to test if FTP folder exist?

Hi Brandon,
In my very first approach I wanted to do it "more soft" : without raising any exception.
If there isn't any other way I will do it like this, and try to workaround the exception with logging set up.
Many thanks for your help,
Eduard

Re: [resolved] Component to test if FTP folder exist?

Try this way

tJava Code:
context.test = 
((String)globalMap.get("tFTPGet_1_ERROR_MESSAGE")).equals("test: No such file or directory") ? "yes" : "no";

if statements code:
context.test == "yes"
context.test == "no"

As I don't think there is a more soft way, that I know of atleast i may be mistaken
One Star

Re: [resolved] Component to test if FTP folder exist?

Many thanks for your help Brandon,
your solution is quite good.
If there is no other solution I will set this topic as resolved.
Eduard