DM (Deployment Manager) Export OIM Categories in XML Format

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package com.massiveGaze.export;


import java.io.BufferedWriter;
import java.io.FileWriter;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

import oracle.iam.platform.OIMClient;
import Thor.API.Exceptions.tcAPIException;
import Thor.API.Operations.tcExportOperationsIntf;

import com.massiveGaze.connection.OIMConnection;
import com.thortech.xl.ddm.exception.DDMException;
import com.thortech.xl.vo.ddm.RootObject;

public class ExportCategoryUtils {

 public static void main(String str[]) throws tcAPIException, DDMException
 {
  try
  {
   java.util.Date date= new java.util.Date();
            String outputFileName = "Export.xml";
   Collection<RootObject> rdbmsRootObjects = null;
   Collection<RootObject> rdbmsRootObjectsChildren = null;
   Collection<RootObject> rdbmsRootObjectsDependency = null;
   Collection<RootObject> rdbmsRootObjectsDependencytree = null;
   Collection<RootObject> allObjects =  new ArrayList();

            FileWriter fstream = new FileWriter(outputFileName);
   BufferedWriter out = new BufferedWriter(fstream);
   
   OIMClient oIMConnection = OIMConnection.getConnection();
                       // c.login(username, password.toCharArray());
             tcExportOperationsIntf exportIntf =  (tcExportOperationsIntf) oIMConnection.getService(Thor.API.Operations.tcExportOperationsIntf.class);
             int count=0;           
           
             
            Collection<String> categories = exportIntf.retrieveCategories();

            Iterator<String> catIter = categories.iterator();
            while (catIter.hasNext()) {
                System.out.println(" Category : "+ ++count +"  "+catIter.next());
            }
            count=0;
            /*
             *  eventhandlers
    Process Form
    Organization
    ITResource
    NOTIFICATIONTEMPLATE
    PasswordPolicy
    RequestDataset
    Role and Orgs UDF
    DataObjectDef
    RequestTemplate
    UserGroup
    PrepopAdapter
    Process
    ITResourceDef
    Resource
    OESPolicy
    EmailDef
    TaskAdapter
    SystemProperties
    GenericConnector
    GTCProvider
    Rule
    ApprovalPolicy
    Job
    Lookup
    scheduledTask
    User UDF
    ErrorCode
             * 
             */
            String exportCategory = "GenericConnector"; // Which Category user needs to Export
            String searchString = "GTC2*"; //matching String else * for All
            System.out.println("------------------------------------------------------------------------");
            System.out.println(" Start Time : " +new Timestamp(date.getTime()));
            System.out.println("------------------------------------------------------------------------");
            System.out.println(" Finding Objects For Category : '"+exportCategory+"'");
            
   rdbmsRootObjects = exportIntf.findObjects(exportCategory, searchString);
   rdbmsRootObjects.addAll(exportIntf.findObjects("Job", "GTC2_GTC"));
   if (rdbmsRootObjects == null || rdbmsRootObjects.size() < 1) {
    throw new DDMException("No Rdbms Objects found");
   }
   Iterator<RootObject> rootObjects = rdbmsRootObjects.iterator();
            while (rootObjects.hasNext()) {
                System.out.println(" Search results : "+ ++count +"  "+rootObjects.next());
            } 
            count=0;
   //Get the child objects
   System.out.println(" Getting Child Objects For Parent Object...!");   
   rdbmsRootObjectsChildren = exportIntf.retrieveChildren(rdbmsRootObjects);
            Iterator<RootObject> rdbmsRootObjectsChld = rdbmsRootObjectsChildren.iterator();
            while (rdbmsRootObjectsChld.hasNext()) {
                System.out.println(" Child Object : "+ ++count + "  "+rdbmsRootObjectsChld.next());
            } 
            count=0;
   System.out.println(" Collecting All Child Objects Into List...!");
   allObjects.addAll(rdbmsRootObjectsChildren);
   
   //Get the  dependencies
   System.out.println(" Getting Dependency Object...!");
   rdbmsRootObjectsDependency = exportIntf.getDependencies(rdbmsRootObjectsChildren);
   System.out.println(" Processing Please Wait...!");
   for (Iterator iter = rdbmsRootObjectsDependency.iterator(); iter.hasNext();) {
    RootObject child = (RootObject) iter.next();    
    if (!allObjects.contains(child)) {
      System.out.println(" Dependency Child Object : "+ ++count + "  "+child);
     allObjects.add(child);
    }
   }
   //Get the  dependencies tree
   System.out.println(" Creating Object Dependency Tree... !");
   rdbmsRootObjectsDependencytree =exportIntf.retrieveDependencyTree(allObjects);

   //store all the root objects in 'rdbmsRootObjectsDependencytree' object before export takes off..
   System.out.println(" Processing Root Objects Dependency Tree Please Wait...!");
   for (Iterator iter = allObjects.iterator(); iter.hasNext();) {
    RootObject child = (RootObject) iter.next();
    if (!rdbmsRootObjectsDependencytree.contains(child)) {
     rdbmsRootObjectsDependencytree.add(child);
    }
   }
   // Export the XML file
   System.out.println(" Exporting XML File. Please Wait...!");
   String s = exportIntf.getExportXML(rdbmsRootObjectsDependencytree, "*");

   //System.out.println(s);
   //Store it in XML file.
   out.write(s);
   System.out.println(" '"+exportCategory+"' Objects Successfully Exported : " + outputFileName);
   System.out.println(" DM Export Completed...");
   out.close();
   System.out.println("------------------------------------------------------------------------");
   System.out.println(" End Time : " +new Timestamp(new java.util.Date().getTime()));  
   System.out.println("------------------------------------------------------------------------");
  }
  catch(Exception ex)
  {
   System.out.println(ex);
   ex.printStackTrace();
   throw new DDMException(ex.getMessage());
  }

 }
}

1 comment:

About OIM

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

Popular Posts