FTP Post Office

Java Software for File Exchanges and Data Interchanges

Features of this Software

File Renaming

File Systems existing on various B2B Nodes do not necessarily conform to a Global Naming Scheme. A configurable policy for renaming at the "per Topic" and "per business partner" level, combined with flexible Interfaces and Factory Implementations provides a "pluggable" solution for filenames as the file based data traverses various nodes.

Server-side demo components, like the sample Web-Service code below that operates in the PostOffice pulling just received files off the wire as they were published, and writing them to a temporary, local directory with new File names, use the file.io.output.rpc.attachment property and the DefaultFileRenamePolicySesn Class to implement file renames:

File Renaming

new BufferedOutputStream(
new FileOutputStream(
new DefaultFileRenamePolicySesn().rename(
new File(
"file.io.output.rpc.attachment" ) + Integer.toString(j) + ".txt" ) ,( (AxisHttpSession)MessageContext .getCurrentContext() .getSession() ).getRep() ) ) ) );

The Business Problem

You're new Web-App is a shopping cart that's processing tons of orders and your fulfillment house is screaming about your choice of email for delivery of the order data. Email? Fughedit! They want a fully automated system interface to transmit the Purchase Order files 5 times a day. With no time, no money, no resources, you need a Better, Faster, Cheaper Solution for building the automated interface.

Problem Solved

Automated, connection oriented, scheduled movement of files is the core responsibility of this software. In the time it takes to fill in a Web Form, you can build your interface, establishing a Virtual Post Office route that uses a Java client to exchange files and data ( files like the PO's mentioned above or any other files you share with a business partner). The properties of the virtual post office route are stored in an XML file used by Client software that builds network connections on FTP Protocol and that sends any new files across the connection. Flexible System Architecture anticipates that other Net protocols like HTTP or SSH would be plugged in to replace FTP. Plug-ins remain transparent to the rest of the application by virtue of their implementation of an existing Java interface.

The Other Business Problem

Your company has a collection of server's on which is deployed a collection of Vendor packaged software and home grown applications. As a perfect example of requirement creep, you discover that a project in development is creating data files that need to be made available to 3 other systems. Without an existing Enterprise messaging platform, it is not trivial to tack on the extra work for the Scheduler to run the file movement scripts. The budget does not exist to write and test these system interfaces that will actually move the files.

Another Solution

It doesn't even take a programmer to set up a new interface using this software. A data analyst can complete the registry work to define a new Topic and a new Subscriber to the topic using 2 simple web forms. Then, a java client is run as a last step in the script that creates the data. NO Recompile is needed because the variables relating to the new interface are handled in Command line parms or in Config files. This should result in at least a 10 to 1 reduction in cost of new interfaces.

System Components

  • Client application implements the PostOffice and is what you need to code
    FtpClient - Sample for File Exchange using the Post Office
  • Web Module to generate the XML file used by the Client
    Http/JSP Form that is filled in to create new interface
    Servlet responsible for http POST This generates an XML file
  • XML
    Several XML files exist in the data directory
    ftpjax.xml is the main file
    contains the properties for Net connections
    contains details of files exchanged on the connection.
    dtd for files ftpjax.dtd
    ftpjax is updated each time files are transferred.
    A separate, default XML file is used as a template by the Servlet.
    Details on XML file paths are in the properties file.
  • JAXB API is used
    JAXB compiler used to create Run time java classes
    XML parsing functionality is included in the java classes produced by the compiler
    compiler inputs: the ftpjax.dtd and the xjs binding file
  • Properties file
    Located in the config directory
    Wrapped by Java Class com.borneo.ftp.FtpProperty using static Constructor
    Used mainly by Java Class com.borneo.ftp.xml.XmlMgr
    The Wrapper manages access to properties defining file and path locations
  • how to use this example

    How to Build the application

    1. Download and Install
      On the Project Summary page, find the "latest file releases" or go here. The "tar.gz" file can be opened in WinZip by clicking and following dialog.
    2. When the file is unpacked you will have the following directories:
    3. Install the Webmodule located in the %INSTALL_ROOT%/docroot directory.
      The J2EE WAR file is here if you need to deploy it
      By unpacking the zip file you already unpacked all elements of the Web app.

    Configure properties file

    Edit these keys/ values with the root directory where you unpacked the software:
    ( in the sample, the application was unpacked to F:\FtpPostOffice_0_8)
    1. workingDirectory
    2. xml.doctype.dtd
    3. ftpInFile - The XML file used by Client Application
    4. ftpOutFile - XML file written by Client after files moved
      Testing mode: values are different for ftpInFile and ftpOutFile
      Production mode: value for ftpInFile and ftpOutFile should be equal

    Run the Servlet and create XML input

    1. In your IDE or in your J2EE server, install the web app. in the docroot directory.
    2. Start server
    3. point your browser to URL below to activate the entry JSP create_file_exchange_session
      %server:port% %ServletContext path%/create_file_exchange_session.jsp
    4. The form for a new interface is pretty self explanatory.
      Fill out the form and submit it.
      Field Last File Processed not required when creating new interface
    5. Handling the http POST is the servlet defined as:
      class= com.borneo.ftp.xml.CreateXmlProcess
      name= demo
      URL pattern= /demo/*
    6. Servlet activities include:
      generates JAVA classes for HTTP request Parameter fields
      XML is generated from the Tree of Java objects and written to /data directory as file:
      identical XML returned to the browser where it could be saved
      XML file name is from property "ftpOutFile"
    7. The client will look for the XML using the name specified by "ftpInFile" property
      Rename the XML file if you need to.
      From the sample properties you would rename "ftpjax_new.xml" to "ftpjax.xml"

    Run the Client Application

    This is what runs periodically to send files between computers.
    It uses the XML generated by the servlet ( or manually edited XML if that's your gig )
    1. In the bin directory Edit file= runftp.bat.
      Set the "home" variables to where you installed the software.
    2. Make sure that you have JDK1.3 or higher
    3. Set JAVA_HOME
    4. Set FTPHOME to where you installed the download
    5. cd into the demo directory
    6. run the bat file from the demo directory
        $ %FTP_HOME%\demo>..\bin\runftp
    7. after the job runs, your sysout should look like sample output
    8. debug statements can be removed by setting all "debug" fields to "false"

    there's more...

    FAQ in FtpPostOffice Frequent Questions.

    XML JAXB API and auto generation of JAVA classes .

    ftp.bean.suite at IBM's open source site.

    Last updated 11/2/2001