IBM Support

FTP/SFTP Server User Exits in IBM Sterling B2B Integrator V5.2.5

Technical Blog Post


Abstract

FTP/SFTP Server User Exits in IBM Sterling B2B Integrator V5.2.5

Body

A supporting document for my another blog (https://www-304.ibm.com/connections/blogs/SterlingB2B/entry/ftpsftpue525?lang=en_us). Here I am demonstrating how I bundled my custom user exit jar. As I mentioned in main blog, I used Eclipse and Ant tools to perform the following.

Inside Eclipse, follow these steps to implement your custom user exit code for Java Interface com.sterlingcommerce.woodstock.userexit.services.ftpserver.interfaces.IFtpServerUserExit_OnPutFileAfterExecute

Keep copies of these jar files on Eclipse host before you proceed further. install/userexit/jars/ftpserver.jar & install/userexit/docs/ftpserverdocs.jar

  1. Create a Java Project (say, UE525).
  2. Right click this project and select properties. Choose Java Build Path from navigation list and highlight libraries tag then click "Add External JARs". This opens up browse file dialog box. Browse for ftpserver.jar and click OK. The jar file is added in the list.
  3. Expand this entry. Go to Javadoc and click edit and browse ftpserverdocs.jar. Click OK.

image

Environment is ready to write custom code. I created a class with name FTPUserExitPostPut_SizeCheck under package kk.ue.ftp. Use available java docs to find out parameters.

  • First Map (in) is a non-modifiable Map.
  • Second Map (out) to pass objects from one implementation to another in chain. It also contains two string buffers, one for error message and another for logging.
  • If you append anything to log buffer, then it is logged in SB2Bi's User Exit Logs provided log level is set to ALL.
  • If you want to show appropriate message to user that to be sent with 3-digit FTP reply code, then put that message in error buffer. Only initial 80 characters are used for error message and all newlines are replaced with a white space.

image

Once class is ready, it's time to build it. I used Ant tool and I integrated it with Eclipse. Here is the build.xml file used for building the jar.

<?xml version="1.0" encoding="UTF-8"?>
<project name="UserExitsKK" basedir="." default="build">
   <property name="UserExits.build" value="build" />
   <property name="UserExits.classes" value="${UserExits.build}/classes" />
   <property name="UserExits.src.dir" value="src/kk/ue/ftp" />
   <property name="UserExits.jar" value="${UserExits.build}/jar" />
   <property name="UserExits.jar.file" value="${UserExits.jar}/UserExitsIBMftp.jar" />
   <property name="UserExits.lib" value="lib" />
   <!-- classpath is added -->
   <path id="project.class.path">
      <pathelement path="." />
      <pathelement location="${UserExits.lib}/ftpserver.jar" />
   </path>
   <target name="echotime">
      <tstamp>
         <format property="TODAY_US" pattern="yyyy-MM-dd HH:mm:ss:sss zzz" locale="cn,CN" />
      </tstamp>
      <echo>Date/Time @ ${TODAY_US}</echo>
   </target>
   <target name="init">
      <echo message="****init***" />
      <mkdir dir="${UserExits.build}" />
      <mkdir dir="${UserExits.classes}" />
      <mkdir dir="${UserExits.jar}" />
   </target>
   <target name="compile" depends="init" description="Compilation target">
      <echo message="****Compile***" />
      <javac destdir="${UserExits.classes}" srcdir="${UserExits.src.dir}" deprecation="yes" includeantruntime="false">
         <classpath refid="project.class.path" />
      </javac>
   </target>
   <target name="clean" description="Deletes all the classes under build directory.">
      <echo message="****delete***" />
      <delete dir="${UserExits.build}" />
   </target>
   <target name="run" depends="clean,compile" description="Compression target">
      <echo message="****run***" />
      <jar destfile="${UserExits.jar.file}" basedir="${UserExits.classes}" />
   </target>
   <target name="build" depends="run" description="build application" />
   <target name="create_jar" depends="run, echotime">
      <echo message="****END***" />
   </target>
</project>

After successful build, UserExitsIBMftp.jar got created. It can be used with SB2Bi as mentioned in main blog. [ https://www-304.ibm.com/connections/blogs/SterlingB2B/entry/ftpsftpue525?lang=en_us ]

image


 

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SS3JSW","label":"IBM Sterling B2B Integrator"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

UID

ibm11121673