2 Replies Latest reply on Sep 16, 2008 3:55 PM by Mike Trzcianowski

    How to merge/add to an existing file from Smooks? FileOutput

    Mike Trzcianowski Newbie

      I'm using JBoss ESB 4.4. I split a file into single fragments, transform them and after that I need to output my messages/data to a single file. How would I go about it?

      Thank you

        • 1. Re: How to merge/add to an existing file from Smooks? FileOu
          Daniel Bevenius Master

          Hi,

          not sure if you might have seen it already but there is a class named 'GetFileListFromExecutionContext' in the smooks_file_splitter_router quickstart.
          This class has the following code in it:

          Object object = message.getBody().get("SmooksExecutionContext");
          if ( object != null )
          {
           List<String> listFileNames = FileListAccessor.getListFileNames( (Map) object );
          }
          

          Tthis gives you access the the list of file names created during the Smook transformation. You could then iterate through this list and merge the files into one large one.

          Regards,

          /Daniel

          • 2. Re: How to merge/add to an existing file from Smooks? FileOu
            Mike Trzcianowski Newbie

            Hi Daniel.

            Thank you for the suggestion. However, the split fragments will not come all together at the same time. They may get routed to different services and different times before being written to the final file.

            I will probably need to write a custom action that will append each fragment to a file if it already exists or write a new one.