Total Pageviews

Saturday, September 21, 2019

code to fetch it resource values


public class OIMUserUtils {

    OIMClient oimClient = null;
             
public void intialize() {

        Hashtable env = new Hashtable();
        env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL,
                "weblogic.jndi.WLInitialContextFactory");
        env.put(OIMClient.JAVA_NAMING_PROVIDER_URL,
                "t3://xxxx:14000");
        System.setProperty("java.security.auth.login.config",
                           "C:\\\\Documents\\Backup\\Software\\DesignConsoles\\designconsole - Test\\config\\authwl.conf");
        System.setProperty("OIM.AppServerType", "wls");
        System.setProperty("APPSERVER_TYPE", "wls");
        oimClient = new OIMClient(env);
        try {
            oimClient.login("xelsysadm", "password".toCharArray(), env);

            System.out.println("Successfully logged into oim");
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
    }
             
                  public final Hashtable getITResourceProperties(String itResourceName) {

        Hashtable map = new Hashtable();
        try{
        System.out.println("getITResourceProperties -- IT Resource Name: " +
                           itResourceName);

        tcITResourceInstanceOperationsIntf moitres = oimClient.getService(tcITResourceInstanceOperationsIntf.class);
        long svrKey = 0;
      
        map.put("IT Resources.Name", itResourceName);
        System.out.println("test");
       
        tcResultSet set = moitres.findITResourceInstances(map);
       
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        XMLEncoder xmlEncoder = new XMLEncoder(baos);
        xmlEncoder.writeObject(set);
        xmlEncoder.close();
       
        String xml = baos.toString();
        System.out.println(xml);
       
        svrKey = set.getLongValue("IT Resources.Key");
        System.out.println("getITResourceProperties -- IT Resources.Key = " +
                           svrKey);
        set = moitres.getITResourceInstanceParameters(svrKey);
        map.clear();
        map.put("svr_key",
                (new StringBuffer(String.valueOf(svrKey))).toString());
        System.out.println("getITResourceProperties-- svr_key = " +
                           String.valueOf(svrKey).toString());

        for (int i = 0; i < set.getRowCount(); i++) {
            set.goToRow(i);
            String s3 = set.getStringValue("IT Resources Type Parameter.Name");
            String s4 =
                set.getStringValue("IT Resources Type Parameter Value.Value");
            map.put(s3, s4);
            System.out.println(s3 + "----" + s4);
        }
           
        

           
        }
       
        catch(Exception ex) {
           
            System.out.println(ex.getMessage());
        }
       

        return map;
    }
             
             
                  public static void main(String[] s) {

        OIMUserUtils OIMUserUtils = new OIMUserUtils();
       
            OIMUserUtils.intialize();
           
        OIMUserUtils.getITResourceProperties("Exchange IT Resource");
       
        
        }
                            
                             }

No comments:

Post a Comment