OIM API to read History Data of Job


package com.NeedEvaluate;

import java.util.Hashtable;
import java.util.List;
import java.util.Properties;

import javax.security.auth.login.LoginException;

import oracle.iam.platform.OIMClient;
import oracle.iam.scheduler.api.SchedulerService;
import oracle.iam.scheduler.vo.JobHistory;

import com.thortech.xl.util.LocalConfiguration;

public class ReadJobHistroyData {
 private static SchedulerService schedulerService  =  getConnection().getService(SchedulerService.class);
 private static OIMClient connectionObject = null;
 public static void main(String[] args) {
  
  
   List<JobHistory> history= schedulerService.getHistoryOfJob("Entitlement List");
         if(history != null && !history.isEmpty())
         {
             for (JobHistory jobHistory : history) 
             { // Retrieving the Error Data
                 System.out.println("Error Data :"+new String(jobHistory.getErrorData() != null ? jobHistory.getErrorData() : "Success".getBytes()));
                 System.out.println("Status "+jobHistory.getStatus());
                 System.out.println("ErrorData "+jobHistory.getErrorData());                
                 try
                 {
                  if(jobHistory.getExceptionObject()!=null){
                    //Retrieving the Error Message
                      Exception exp= jobHistory.getExceptionObject();
                      if(exp != null)
                      {
                         System.out.println("Exception Message :"+exp.getMessage());
                      }
                  }
                     
                 } catch (Exception e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                 }
             }
         }

 }



 private static OIMClient connection() {
  System.out.println("Startup...");
  System.out.println("Getting configuration...");
  Hashtable env = new Hashtable();  
  env.put("java.naming.provider.url", "t3://localhost:14001");
  env.put("java.naming.factory.initial", "weblogic.jndi.WLInitialContextFactory");
        System.setProperty("java.security.auth.login.config", "/config/authwl.conf");   //Update path of authwl.conf file according to your environment
        System.setProperty("OIM.AppServerType", "wls");  
        System.setProperty("APPSERVER_TYPE", "wls");      
  OIMClient localConnection = new OIMClient(env);
  try {
   localConnection.login("xelsysadm", "Welcome1");
  } catch (LoginException e) { // TODO Auto-generated catch block
   e.printStackTrace();
  }

  Properties props = LocalConfiguration.getLocalCoreServerConfiguration();
  System.out.println(props.toString());
  return localConnection;
 }

 public static synchronized OIMClient getConnection() {

  if (connectionObject == null) {
   connectionObject = connection();
  }
  return connectionObject;
 }
 
 public static void closeConnection() {
  connectionObject.logout();
 }
 
 public static Hashtable getEnvironment(){
  Hashtable env = new Hashtable();
  env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, "t3://localhost:1401");
  env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
  return env;
 }
 
}

1 comment:

  1. When executing getExceptionObject() then I have exception like below: (this is console application)

    Nov 25, 2019 9:57:36 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
    INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@3f4681c2: display name [org.springframework.context.support.ClassPathXmlApplicationContext@3f4681c2]; startup date [Mon Nov 25 09:57:36 CET 2019]; root of context hierarchy
    Nov 25, 2019 9:57:36 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [META-INF/iam-spring-config.xml]
    Nov 25, 2019 9:57:36 AM oracle.iam.platform.utils.SpringBeanFactory createBeanFactory
    SEVERE: Instantiating Spring Bean Factory Failed.IOException parsing XML document from class path resource [META-INF/iam-spring-config.xml]; nested exception is java.io.FileNotFoundException: class path resource [META-INF/iam-spring-config.xml] cannot be opened because it does not exist
    Exception in thread "main" java.lang.ExceptionInInitializerError
    at oracle.iam.platform.Platform.(Platform.java:109)
    at oracle.iam.platform.pluginframework.PluginRegistryImpl.loadPluginPoints(PluginRegistryImpl.java:282)
    at oracle.iam.platform.pluginframework.PluginRegistryImpl.(PluginRegistryImpl.java:80)
    at oracle.iam.platform.pluginframework.PluginFramework.getPluginRegistry(PluginFramework.java:116)
    at oracle.iam.scheduler.vo.JobHistory.getExceptionObject(JobHistory.java:111)
    at pl.rkiliszek.OIM.SchedServ.ReadJobHistroyData.run(Main.java:89)
    at pl.rkiliszek.OIM.SchedServ.Main.main(Main.java:26)
    Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [META-INF/iam-spring-config.xml]; nested exception is java.io.FileNotFoundException: class path resource [META-INF/iam-spring-config.xml] cannot be opened because it does not exist

    ReplyDelete

About OIM

Oracle Identity Management enables organizations to effectively manage the end - to - end life - cycle of user ide...

Popular Posts