FTP Post Office
Java Software for File Exchanges and Data Interchanges
- Virtual Post Office exchanges files by running on a regular
schedule.
- Post Office connects computers at different companies using plug-in protocols
- Very Easy to establish interfaces between computers or between
systems
- Capable of generating a new system interface by filling out an
Http/JSP Form
- Open source modules ( IBM and GNU ) are employed
- XML is used extensively for:
-
- Storage of Network Connection properties
- Storage of file system information involved in data interchange
- Logs of file interchange activity
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
((DataHandler)attachments[j]).writeTo(
new BufferedOutputStream(
new FileOutputStream(
new DefaultFileRenamePolicySesn().rename(
new File(
POProperty.get(
"file.io.output.rpc.attachment"
)
+ Integer.toString(j)
+ ".txt"
)
,( (AxisHttpSession)MessageContext
.getCurrentContext()
.getSession()
).getRep()
)
)
)
);
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.
how to use this example
- 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.
- When the file is unpacked you will have the following
directories:
- bin - property
files and scripts
- classes - for java
class files
- config - contains
the properties file
- data - for XML
files
- demo - the Sample Client application is here
- docroot - Web
Module for creating XML files is here
- htdocs - Project
Documentation.
- See index in the htdocs directory to get
started.
- Index of documentation
- htdocs/api/com/borneo -
main Java API documentation for this
application
- htdocs/api/com/ibm -
IBM open source FTP implementation is used for Connections
- htdocs/api/gnu/regex -
gnu Regular Expressions used to adapt file name filters
- htdocs/jaxb/api -
XML implementation chosen for this project
- lib - for JAR files
- src - java source
code for web module and for main application
- 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.
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)
- workingDirectory
- xml.doctype.dtd
- ftpInFile - The XML
file used by Client Application
- 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
- In your IDE or in your J2EE server, install the web app. in the
docroot directory.
- Start server
- point your browser to URL below to activate the entry JSP create_file_exchange_session
%server:port% %ServletContext path%/create_file_exchange_session.jsp
- 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
- Handling the http POST is the servlet defined as:
- class=
com.borneo.ftp.xml.CreateXmlProcess
- name= demo
- URL pattern= /demo/*
- 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:
- <%getProperty("ftpOutFile")%>
- identical XML returned to the browser where it could be saved
- XML file name is from property "ftpOutFile"
- 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"
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 )
- In the bin directory Edit file= runftp.bat.
-
Set the "home" variables to where you installed the software.
- Make sure that you have JDK1.3 or higher
- Set JAVA_HOME
- Set FTPHOME to where you installed the download
- cd into the demo directory
- run the bat file from the demo directory
$ %FTP_HOME%\demo>..\bin\runftp
- after the job runs, your sysout should look like sample output
- 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