Here is the same java code to add entry in existing OIM Lookup and display all the Values from an existing OIM Lookup
import java.util.HashMap;
import java.util.Hashtable;
import oracle.iam.platform.OIMClient;
import Thor.API.tcResultSet;
import Thor.API.Operations.tcLookupOperationsIntf;
public class UpdateLookup {
private static final String OIM_URL = "t3s://<>:14001 ";
private static final String AUTH_CONF = "<< Path of authwl.conf >>";
private static final String OIM_USERNAME = "<< UserID >>";
private static final String OIM_PASSWORD = "<< Password >>";
private static OIMClient oimClient = null;
Hashtable env = new Hashtable();
public UpdateLookup() {
try {
env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL,
"weblogic.jndi.WLInitialContextFactory");
env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, OIM_URL);
System.setProperty("java.security.auth.login.config", AUTH_CONF);
System.setProperty("OIM.AppServerType", "wls");
System.setProperty("APPSERVER_TYPE", "wls");
oimClient = new OIMClient(env);
oimClient.login(OIM_USERNAME, OIM_PASSWORD.toCharArray());
} catch (Exception e) {
e.printStackTrace();
}
}
public void addLookupEntry(String LookupCode,String Lookup) {
try {
tcLookupOperationsIntf lookupOps = oimClient
.getService(tcLookupOperationsIntf.class);
lookupOps.addLookupValue("<>", LookupKey,
LookupValue, "", "");
} catch (Exception e) {
e.printStackTrace();
}
}
public void displayLookup(String lookupname) {
try {
tcLookupOperationsIntf lookupOps = oimClient
.getService(tcLookupOperationsIntf.class);
tcResultSet values = lookupOps.getLookupValues(lookupname);
for (int i = 0; i < values.getRowCount(); i++) {
values.goToRow(i);
System.out
.print(values
.getStringValue("Lookup Definition.Lookup Code Information.Decode"));
System.out
.println(","
+ values.getStringValue("Lookup Definition.Lookup Code Information.Code Key"));
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String args[]) {
UpdateLookup obj = new UpdateLookup();
obj.addLookupEntry("LookupKey","LookupValue");
obj.displayLookup("LookupName");
}
}
Reference:
http://docs.oracle.com/cd/E17904_01/apirefs.1111/e17334/toc.htm
import java.util.HashMap;
import java.util.Hashtable;
import oracle.iam.platform.OIMClient;
import Thor.API.tcResultSet;
import Thor.API.Operations.tcLookupOperationsIntf;
public class UpdateLookup {
private static final String OIM_URL = "t3s://<
private static final String AUTH_CONF = "<< Path of authwl.conf >>";
private static final String OIM_USERNAME = "<< UserID >>";
private static final String OIM_PASSWORD = "<< Password >>";
private static OIMClient oimClient = null;
Hashtable
public UpdateLookup() {
try {
env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL,
"weblogic.jndi.WLInitialContextFactory");
env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, OIM_URL);
System.setProperty("java.security.auth.login.config", AUTH_CONF);
System.setProperty("OIM.AppServerType", "wls");
System.setProperty("APPSERVER_TYPE", "wls");
oimClient = new OIMClient(env);
oimClient.login(OIM_USERNAME, OIM_PASSWORD.toCharArray());
} catch (Exception e) {
e.printStackTrace();
}
}
public void addLookupEntry(String LookupCode,String Lookup) {
try {
tcLookupOperationsIntf lookupOps = oimClient
.getService(tcLookupOperationsIntf.class);
lookupOps.addLookupValue("<
LookupValue, "", "");
} catch (Exception e) {
e.printStackTrace();
}
}
public void displayLookup(String lookupname) {
try {
tcLookupOperationsIntf lookupOps = oimClient
.getService(tcLookupOperationsIntf.class);
tcResultSet values = lookupOps.getLookupValues(lookupname);
for (int i = 0; i < values.getRowCount(); i++) {
values.goToRow(i);
System.out
.print(values
.getStringValue("Lookup Definition.Lookup Code Information.Decode"));
System.out
.println(","
+ values.getStringValue("Lookup Definition.Lookup Code Information.Code Key"));
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String args[]) {
UpdateLookup obj = new UpdateLookup();
obj.addLookupEntry("LookupKey","LookupValue");
obj.displayLookup("LookupName");
}
}
Reference:
http://docs.oracle.com/cd/E17904_01/apirefs.1111/e17334/toc.htm
1 comment:
Thanks a lot, it saved some time for me.
Post a Comment