2.3 Introductory Sample

The following example is a simple demonstration of some of some basic functionality provided by the Oracle I/PM integration API. The example simply logs in to the Oracle I/PM system, lists viewable applications, and logs out.

Example 2-1 Listing Viewable Applications

package devguidesamples;
 
import java.util.List;
import java.util.Locale;
 
import oracle.imaging.Application;
import oracle.imaging.ApplicationService;
import oracle.imaging.BasicUserToken;
import oracle.imaging.ImagingException;
import oracle.imaging.NameId;
import oracle.imaging.ServicesFactory;
import oracle.imaging.UserToken;
 
public class IntroSample {
   public static void main(String[] args) {
 
      try { // try-catch
         UserToken credentials = new BasicUserToken("ipmuser", "ipmuserpwd");
         ServicesFactory servicesFactory =
            ServicesFactory.login(credentials, Locale.US, "http://ipmhost:16000/imaging/ws");
 
         try { // try-finally to ensure logout
            ApplicationService appService = servicesFactory.getApplicationService();
           
            // List the viewable applications to confirm that "Invoices" exists
            List<NameId> appsList = appService.listApplications(Application.Ability.VIEW);
            for (NameId appNameId: appsList) {
               System.out.println( appNameId );
            }
         }
         finally {
            if (servicesFactory != null) {
               servicesFactory.logout();
            }
         }
      }
      catch (ImagingException e) {
         System.out.println(e.getMessage());
      }
   }
}