IBM i > DEVELOPER > GENERAL

Using Google App API to Get Document List


In the last series of articles, I provided a proof of concept that defined how you could move IBM i DB2 data to the public cloud using the Google Apps for Business (GA4B) suite.

This follow-up series provides programmatic solutions using CMD, PNLGRP, CLLE, RPGLE and Java development to call applicable GA4B APIs to pull a list of those previously created documents to a document in the IFS and to push the same Employee.CSV, Employee_Report.PDF & Employee_Calendar.CSV/ICS date events to GA4B.

In this first of three articles are the steps to show how you can connect with the GA4B cloud world by sending a Google email and password to simply retrieve the list of documents you created in the last series of articles and store them in a document in the IFS.

This example is both useful and fully functional in that you could retrieve a list of documents populated in GA4B that you may wish to then retrieve individually for inbound processing on your IBM i or to trigger an IBM i process once a document has arrived in your GA4B environment folder.

Creating the CMD/PNLGRP/CLLE/RPGLE/Java Source

To provide a programmatic solution to get a list of your Google documents, first create an interface command to prompt the user for the Google email, password, document and directory parameters to be passed to GA4B for processing.

I created this simple command, GA4BLIST (Code Sample 1), and a panel group for command parameter help, GA4BLISTP (Code Sample 2), to do so.

A word of caution regarding the PASSWORD parameter on your command: The parameter uses the DSPINPUT(*NO) variable to not display the entered value on the prompt display and job log, however, this parameter doesn’t suppress the value entered for job log entries for a database reader job, imbedded commands (for example, a command submitted on the SBMJOB command), or commands run using the QCAPCMD, QCMDEXC or QCAEXEC APIs. To protect passwords, you may wish to store them in a DB2 table encrypted and then retrieved during execution from the specified email value for security reasons.

The command executes the GA4BLISTC (Code Sample 3) CLLE command processor program (CPP) to set your Java Class path by adding the CLASSPATH environment variable and if a CLASSPATH is already found, changing it. This is so that your run-capable JAR can be located when the Java is executed. The GA4BLISTR RPGLE program is then called with your email, password, document, directory and IBM i system name passed as parameters.

The GA4BLISTR RPGLE (Code Sample 4) is a simple program that accepts the five parameters passed to it and parses them into Java string objects. Since the Java main method is expecting five parameters as well, define your ARGS array as having five elements. The MAIN(ARGS) instruction calls your Java Class to link to your Google Document list.

Java program, GA4BLISTJ (Code Sample 5), was created in Eclipse. I first created a Java project called GoogleDocs and configured the compiler to use these packages from Google:

  • gdata-client-1.0.jar
  • gdata-client-meta-1.0.jar
  • gdata-core-1.0.jar
  • gdata-docs-3.0.jar
  • gdata-docs-meta-3.0.jar
  • gdata-media-1.0.jar
  • google-collect-1.0.jar
  • jsr305.jar

and these additional packages as well:

  • jt400.jar (from JTOpen, http://jt400.sourceforge.net)
  • mail.jar (from JavaMail api 1.4.4)
  • servlet-api.jar (from apache-tomcat-6.0.35-windows-x86)
  • activation.jar (from jaf01.1.1, the JavaBeans Activation Framework)

David Andruchuk is the senior architect for Computer Systems Design Associates Inc.



Like what you just read? To receive technical tips and articles directly in your inbox twice per month, sign up for the EXTRA e-newsletter here.



Advertisement

Advertisement

2017 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

Are You Multilingual?

Rational enables development in multiplatform environments

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters