Tivoli Directory Integrator – Before Initialize – Add Date to File Name

I wrote a different TDI blog discussing the Before Initialize Hook.  That blog discussed setting the filter in an Iterator.  Here is another use for the Before Initialize Hook, this time in a File System Connector.  As I mentioned in prior PathMaker Group blogs Tivoli Directory Integrator (TDI) is a pretty neat tool that comes packaged with IBM Tivoli Identity Manager (ITIM) with a bunch of Connectors. This blog will relate to the File System Connector.

Have you ever wanted to build create a File System Connector that creates a file that has a unique value so the process can run multiple times a day or week and you don’t have to worry about overlaying the file?  This can be accomplished with the Before Initialize.  In this case the process will only run once a day so only the date is added to the end of the file name.

In the “Before Initialize” Hook of the File System Connector, add the following logic

task.log("Configuring File Name for File System Connector");
var srcPath="C:\Temp\"
var stDateStamp=system.formatDate((new Date()),"yyyyMMdd");	

var outFile=srcPath + "fileSysOutput_" + stDateStamp + ".csv ";
task.log("Output File Name: " + outFile);
thisConnector.setConnectorParam("filePath",outFile);

The important piece of code is “thisConnector.setConnectorParam(“filePath”,outFile);“  This will set the name of the file on the connector tab with the value that is contained in the outFile attribute.  The name of the connector parameter is “filePath”.  This can be determined by clicking on File Path in the Connector Tab.  This will bring up a window where the Internal Name is visible.

Based on the code above the Assembly line will run and write the data to a file called ‘fileSysOutput_20130401.csv’ if the assembly line is executed on April 1st in the year 2013.

The date format can be modified to add the hours and minutes if needed.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply