IBM i > DEVELOPER > GENERAL

Using Google App API to Send Documents


In “Using Google App API to List Documents,” I began this Google API series with how to use the Google Apps for Business (GA4B) List API to retrieve the names of the existing documents in your Google Drive folder and store them in a document in the IFS.

This second of three articles provides you with steps for connecting with the GA4B cloud world to send documents from the IFS to your Google Drive folder using the Uploader API.

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

As in the first article, you need to create an interface command to prompt the user for the Google email, password, document and directory parameters to be passed to GA4B for processing and to retrieve your IFS document to send.

I created this simple command, GA4BSEND (Code Sample 1), and a panel group for command parameter help, GA4BSENDP (Code Sample 2).

To reiterate, the PASSWORD parameter on your command is not secure with just the DSPINPUT(*NO) variable setting.

The command executes the GA4BSENDC (Code Sample 3) CLLE command processor program (CPP) to set your Java Class path as before. The GA4BSENDR RPGLE program is then called with your email, password, document and directory parameters.

The GA4BSENDR RPGLE (Code Sample 4) is again a simple program that accepts four parameters passed to it, parses them into Java string objects and calls the Java main method.

Your Java program, GA4BSENDJ (Code Sample 5), was again created in Eclipse. Add this program to your existing GoogleDocs project and configure the compiler to use these packages from Google:

  • com.google.common.collect.Lists;
  • com.google.common.collect.Maps;
  • com.google.gdata.client.docs.DocsService;
  • com.google.gdata.client.media.ResumableGDataFileUploader;
  • com.google.gdata.data.Link;
  • com.google.gdata.data.docs.DocumentListEntry;
  • com.google.gdata.data.media.MediaFileSource;
  • com.google.gdata.util.ServiceException;
  • com.google.gdata.client.uploader.FileUploadData;
  • com.google.gdata.client.uploader.ProgressListener;
  • com.google.gdata.client.uploader.ResumableHttpFileUploader;

and these additional packages as well:

  • java.io.File;
  • java.io.IOException;
  • java.io.PrintStream;
  • java.net.URL;
  • java.util.Collection;
  • java.util.List;
  • java.util.Map;
  • java.util.concurrent.ExecutorService;
  • java.util.concurrent.Executors;

Configure your Java compiler to use the Java 1.5 Java Runtime Environment at a minimum and create a Java Runtime Configuration for testing and to export the Java Classes as a run-capable JAR.

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