- package com.oimacademy.orchestration;
- import java.io.InputStream;
- import java.io.ObjectInputStream;
- import java.io.Serializable;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.ResultSetMetaData;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.Map.Entry;
- import java.util.Set;
- import oracle.iam.platform.context.ContextAwareNumber;
- import oracle.iam.platform.context.ContextAwareString;
- import oracle.iam.platform.kernel.vo.EntityOrchestration;
- import oracle.iam.platform.kernel.vo.Orchestration;
- import oracle.iam.platform.kernel.vo.PostProcessOnlyBulkOrchestration;
- import com.oimacademy.connection.DataSource;
- public class DeserializeOrchestration {
- public static void main(String[] args) throws Exception {
- String statement1 = "select * from orchprocess where id=?";
- // String statement =
- // "select id, orchestration from orchprocess where entitytype='User' and operation='CREATE' order by id";
- // String statement =
- // "select orchestration from orchprocess where id in (select processid from orchevents where name='UserModifyLDAPPreProcessHandler' and status='FAILED') order by id desc";
- Connection conn = DataSource.getConnection();
- System.out.println("Something");
- // Read object from oracle
- PreparedStatement pstmt = conn.prepareStatement(statement1);
- pstmt.setLong(1, 138);
- ResultSet rs = pstmt.executeQuery();
- dumpRS(rs);
- rs.close();
- pstmt.close();
- conn.close();
- System.exit(0);
- }
- public static void dumpRS(ResultSet rs) throws Exception {
- InputStream is = null;
- ObjectInputStream oip = null;
- rs.next();
- ResultSetMetaData rsmd = rs.getMetaData();
- for (int i = 0; i < rsmd.getColumnCount(); i++) {
- String colName = rsmd.getColumnName(i + 1);
- if (colName.equalsIgnoreCase("orchestration")) {
- // is = rs.getBlob(1).getBinaryStream();
- is = rs.getBinaryStream(colName);
- oip = new ObjectInputStream(is);
- Object o = oip.readObject();
- if (o instanceof PostProcessOnlyBulkOrchestration) {
- PostProcessOnlyBulkOrchestration object = (PostProcessOnlyBulkOrchestration) o;
- System.out.println("Operation = " + object.getOperation());
- System.out.println("Target = " + object.getTarget());
- System.out.println("Action Result = " + object.getActionResult());
- System.out.println("Context value = " + object.getContextVal());
- printMap("Bulk Parameters: ", object.getBulkParameters());
- printMap("Parameters: ", object.getParameters());
- printMap("Inter event data: ", object.getInterEventData());
- } else if (o instanceof EntityOrchestration) {
- EntityOrchestration object = (EntityOrchestration) o;
- System.out.println("EntityID = " + object.getEntityId());
- System.out.println("EntityType = " + object.getEntityType());
- System.out.println("Type = " + object.getType());
- System.out.print("All Entity IDs: ");
- for (int j = 0; j < object.getAllEntityId().length; j++) {
- System.out.print(object.getAllEntityId()[j]);
- }
- System.out.println();
- } else if (o instanceof Orchestration) {
- Orchestration object = (Orchestration) o;
- System.out.println("Operation = " + object.getOperation());
- System.out.println("Target = " + object.getTarget());
- // System.out.println("Action Result = " +
- // object.getActionResult());
- System.out.println("Context value = "+ object.getContextVal());
- // printMap("Bulk Parameters: ",
- // object.getBulkParameters());
- printMap("Parameters: ", object.getParameters());
- printMap("Inter event data: ", object.getInterEventData());
- } else {
- System.out.println("UNKNOWN ORCHESTRATION BLOB");
- }
- } else {
- System.out.println(colName + " ===> " + rs.getString(colName));
- }
- }
- oip.close();
- is.close();
- }
- public static void printMap(String name,
- HashMap<String, Serializable>[] marr) {
- System.out.println("Dumping maps name = " + name);
- for (int i = 0; i < marr.length; i++) {
- System.out.println("Map element # " + i);
- HashMap<String, Serializable> m = marr[i];
- if (m == null) {
- System.out.println("Null Map found");
- continue;
- }
- Set<Entry<String, Serializable>> set = m.entrySet();
- Iterator<Entry<String, Serializable>> it = set.iterator();
- while (it.hasNext()) {
- Entry<String, Serializable> e = it.next();
- Object val = (Object) e.getValue();
- String v = "";
- if (val instanceof ContextAwareString) {
- ContextAwareString cas = (ContextAwareString) val;
- v = (String) cas.getObjectValue();
- } else if (val instanceof ContextAwareNumber) {
- ContextAwareNumber can = (ContextAwareNumber) val;
- v = String.valueOf(((Long) can.getObjectValue()));
- } else {
- v = val.toString();
- }
- System.out.println("\t" + e.getKey() + " ---> " + v);
- }
- }
- }
- public static void printMap(String name, HashMap<String, Serializable> m) {
- System.out.println("Dumping maps name = " + name);
- if (m == null) {
- System.out.println("Null Map found");
- return;
- }
- Set<Entry<String, Serializable>> set = m.entrySet();
- Iterator<Entry<String, Serializable>> it = set.iterator();
- while (it.hasNext()) {
- Entry<String, Serializable> e = it.next();
- Object val = (Object) e.getValue();
- String v = "";
- if (val instanceof ContextAwareString) {
- ContextAwareString cas = (ContextAwareString) val;
- v = (String) cas.getObjectValue();
- } else if (val instanceof ContextAwareNumber) {
- ContextAwareNumber can = (ContextAwareNumber) val;
- v = String.valueOf(((Long) can.getObjectValue()));
- } else {
- v = val.toString();
- }
- System.out.println("\t" + e.getKey() + " ---> " + v);
- }
- }
- }
Oracle Identity Manager(OIM) is the Provisioning Solution from oracle. This page contains an index with references to all OIM related posts in the oracle identity manager Academy blog. The posts included herein are intended to provide oracle identity management customers and developers with technical information about best practices for implementing OIM based solutions.
API to Deserialize ORCHPROCESS table data
Subscribe to:
Post Comments (Atom)
-
Connection Related API's : OIM DB Connection/ Data Source connection OIMClient API / OIMConnection API OIM Platform API to getSer...
-
Error : Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.springframewor...
-
In this post, we set the middle name as “MiddleName” if user does not provide middle name during user create operation. Below are high...
No comments:
Post a Comment