Tuesday, May 21, 2013

Experience with the TDI CDE

I've ran into problems when attempting to use the CDE, so I wanted to post incase it helps anyone else.


TDI Component Development Environment (CDE) is a tool that enables an effective, efficient and consistent way of creating TDI components. It abstracts and automates functions, tasks and complexities of developing TDI components.  TDI CDE can be used by a customer to quickly develop new custom components with minimal effort. This helps build better TDI solutions enabling creation of custom TDI components by the customer for easy use. -- Source url:  http://www.ibm.com/software/brandcatalog/ismlibrary/details?catalog.label=1TW10DI0R#tab-pinfo




Video:
Discussion on connector development: http://www.youtube.com/watch?v=4aiqj7lhbrg

Known Issues I've seen with CDE:
  • Start Eclipse with the 'Run as Administrator' option, else when you use the 'File / Export / IBM Tivoli Directory Integrator / Deployable Connector' function in Eclipse to move the resource to TDI, the export windows will complete..although the resource will not be found in the TDI/jars directory.  The Export windows seems to flash to quick to see if any error is given during the export.
  • In Eclipse, I found the 'Java' not 'Java EE' perspective should be used.  If the 'Java EE' perspective is used, then the error 'The selected resource is not a valid IBM Tivoli Directory Integrator project' is seen when attempting to export the developed resource.
  • I could not find it documented in the CDE documentation on which JDK is required.
    Unexpected behavior was seen when using a non-IBM JDK. 
    • The 'Finish' button had to be pressed multiple times to confirm completion.
    • The Project structure was random and incomplete.

Wednesday, August 29, 2012

Google Voice (SMS) with TDI

Recently I've been working on an Assemblyline line which needed to send sms notification.  As most know, TDI already provides a sendMail() method in its UserFunction class to send email.  Using this method allows messages to be sent to phone numbers which have a service provider email address (e.g. 5552224444@txt.att.net).

However some providers like Google Voice(GV), do not provide this number@email option.
So with this limitation it took a little searching to find another option.

I found by using the google-voice-java API (api docs) we can send sms messages via TDI directly to a phone number, instead of relying on a phonenumber@email address.

JARs are available at:
http://code.google.com/p/google-voice-java/downloads/list

At the time of this posting, there were 5 jars (google-voice-java-1.14-java6.jar, dom4j-1.6.1.jar,
jaxen-1.1.3.jar, json.jar, jtidy.jar).
Simply add the jars to the <TDI>\jars\3rdparty\others\GoogleVoice directory

You can then use the following function from your Resource/Script library to to send sms from TDI by the way of Google Voice.



/*
 * sendGVsms uses the api made available at
 * http://code.google.com/p/google-voice-java/w/list
 */
function sendGVsms(dst,txt){
    try{
        destinationNumber = dst;
        txt = txt;
        username = system.getTDIProperty("gvuserName")
        pass = system.getTDIProperty("gvpass")
        var gvoice = Packages.com.techventus.server.voice.Voice(username,pass);
        gvoice.sendSMS(destinationNumber,txt);
        } catch (e) {
            task.logmsg(">>sms error " +e);
    }
}


NOTE:  You will need to add Google's  public certificate to the TDI truststore, otherwise you'll receive a 'java.lang.reflect.InvocationTargetException' when calling the class.

I used the following information to obtain and add the certificate to the TDI truststore.

1. Obtaining the Google certificate
a. 


b. 


c.

d.  Choose a 'Save as type' of DER when exporting the certificate.

2. Adding the certificate into the default TDI truststore.
By default, a TDI 7.x installation uses the serverapi/truststore.jks as its truststore.
This file location may vary depending on if you have a specific Solution Directory, or if the TDI Install directory is the Solution directory.  You can refer to the contents of the <TDI_Install>/bin/defaultSolDir.bat to determine the default Solution directory.

The TDI Component as a Client section in the TDI Infocenter discusses the importation of a certificate.
Here's an example of the command to import the google certificate into the testadmin.jks file.

<TDI>/jvm/jre/bin/keytool -import -trustcacerts -file google.der -keystore testadmin.jks -storepass administrator -alias googleCert