Archiving files on request based on files name with FTP Adapter in OSB 12c

This as an additional requirement from one of my previous posts which you can read here.

But for those who are interested only in this part of the solution this is a short recap of the previous post requirement: Requirement is fairly simple, there is a need to transfer a “non XML” file (in this specific case .pdf document) based on the file name which is sent in the Request message and transfer the file to another external system using HTTP POST.

Now there is a need for that file to be transferred and archived in different folder in the same folder structure on the same server. This means that we basically need to cut and paste the file/document from current folder to another which is one level down in folder structure. We can have two scenarios here with the “Archive” action:

As I used the FTP adapter to fetch the file from the server based on the file name I thought: “Ok this will be easy and straightforward.”

Why did I think that? Well the FTP Adapter has an option in “File Directories” wizard step where you can set up if you want your processed file to be archived (image below). You check Archive processed files and provide a new physical path for the archive folder. Straightforward right?

Well… Let’s just say things escalated quickly… During the deployment of the integration I got this error message:

[ERROR] The session cannot be activated due to existence of conflicts. resource: BusinessService ArchiveTestIntegration/Business/ArchiveFile error: Invalid JCA transport endpoint configuration, exception: BINDING.JCA-11000 Invalid Activation parameter. Activation parameter Physical/Logical ArchiveDirectory has invalid value {/Internal/in/archive}. Please correct the activation parameter and redeploy the process.

So I started to test a little bit:

This was actually my first time using archive option in the FTP adapter and my understanding was that this will work on the FTP server itself from which I’m retrieving the files. So with FTP adapter you can GET, you can PUT the files but you can’t “Archive” the files on the same FTP server? At least not for the Synchronous Get File option: I haven’t tried with simple Get File option in FTP Adapter.

Ok then, now for the solution part. Only thing I could do here was to split the FTP call in two. Decouple the GET and Archive part of the operation. So, in first call I retrieve the file do some other operation and transfers if everything is successful then I call the second business service which is a FTP Transfer. In the first GET operation I set the file to be deleted upon successful retrieval.

And in second Business Service I do a simple “Put file” in the Archive folder with FTP Transfer as an external service.