9 Replies Latest reply: Jan 22, 2008 8:34 AM by 553447 Branched to a new discussion. RSS

    Advanced request Creation

      I'm trying to user OIM API to create a request to provision user some resources.
      Here is my code for raising a request to provision user (lUserKey) with resource object (lObjectKey)

      ///Created the request object for provisioning the RO
      requestObj = (tcRequestOperationsIntf) utilFactory.getUtility("Thor.API.Operations.tcRequestOperationsIntf");
      HashMap reqMap = new HashMap();
      reqMap.put("Requests.Target Type", "U");
      reqMap.put("Requests.Object Request Type", "Add");
      reqMap.put("Requests.Type", "U");
      lRequestKey = requestObj.createRequest(reqMap);

      //Adding user to be provisioned for
      requestObj.addRequestUser(lRequestKey, lUserKey);
      //Adding object to be provisioned
      requestObj.addRequestObject(lRequestKey, lObjectKey);
      //create the request

      But before calling requestObj.completeRequestCreation(lRequestKey) I must somehow to fill in the Resource form (I can't provision user with an empty resource form)...
      What API should I use?

      And another question - what if user is already provisioned, and I want do create request just to modify some resource account settings? Then I don't need to specify request object, but somehow I must modify resource form fields.
        • 1. Re: Advanced request Creation
          Or should I do direct provisioning?
          Something like:
          // Initiate provisioning process
          long OBIkey =provisionObject(plUserKey, plObjectKey);
          // Get object form
          // get child form (if any)
          // set form data
          // set child form data

          And then I must somehow re-initiate provisioning process..
          • 2. Re: Advanced request Creation
            The code below will create a request and populate it with a resource object. You must create the formHash with all required fields using the combination of the actual form column name and a value. The code below will let all approvals trigger as usual as well.

            Hashtable reqHash = new Hashtable();
            reqHash.put("Requests.Object Request Type", "Add");
            reqHash.put("Requests.Target Type", "U");
            long reqKey = reqIntf.createRequest(reqHash);
            log.debug("reqKey: " + reqKey);

            //Add user to Request
            reqIntf.addRequestUser(reqKey, userKey);

            //Find Object
            Hashtable objHash = new Hashtable();

            //Find the object result set of the resource object you want to add to the request
            objHash.put("Objects.Name", objectName);
            tcResultSet objSet = objIntf.findObjects(objHash);

            //Add object to request
            long objInstanceKey = reqIntf.addRequestObject(reqKey, objSet.getLongValue("Objects.Key"));
            log.debug("objInstanceKey: " + objInstanceKey);

            Hashtable formHash = new Hashtable();
            formHash.put(<UD_FORMFIELD NAME>, <VALUE>) -> You must supply all required fields on the object form

            //Set the object form data
            formIntf.setObjectFormData(objInstanceKey, formHash);

            //Complete the request creation
            • 3. Re: Advanced request Creation
              And what about direct provisioning ?
              Have you ever used the ProvisionObject method?
              • 4. Re: Advanced request Creation
                Here is some code to provision an object that allows only one instance of the object for the user. If you supply the userkey, resource object name, and provisioning process definition name. This is for an object that has no object form and is all pre-populates.

                public String provisionObject(long userKey, String objectName, String processName, tcDataProvider ioDatabase) throws Exception {
                     log.debug("provisionObject() Parameter Variables passed are:" +
                               "userKey=[" + userKey + "]" +
                               "objectName=[" + objectName + "]" +
                               "processName=[" + processName + "]");

                     tcUserOperationsIntf usrIntf =(tcUserOperationsIntf)tcUtilityFactory.getUtility(ioDatabase,"Thor.API.Operations.tcUserOperationsIntf");
                     tcObjectOperationsIntf objIntf =(tcObjectOperationsIntf)tcUtilityFactory.getUtility(ioDatabase,"Thor.API.Operations.tcObjectOperationsIntf");
                     String response = "";

                     //Check to see if parent object exists
                     String check = com.thortech.xl.util.adapters.tcUtilXellerateOperations.chckProcOrderedForUser(ioDatabase, processName.trim(), String.valueOf(userKey));
                     if (!check.equals("1")){
                          Hashtable objectHash = new Hashtable();
                          objectHash.put("Objects.Name", objectName.trim());          
                          tcResultSet objectResultSet = objIntf.findObjects(objectHash);          
                          usrIntf.provisionObject(userKey, objectResultSet.getLongValue("Objects.Key"));
                          log.debug(objectName + " provisioned to user");     
                          response = "OBJECT_PROVISIONED";
                          }catch(Exception ex){
                               response = "ERROR";
                          log.debug(objectName + " already provisioned to user");     
                          response = "OBJECT_EXISTS";

                     return response;

                The code below is an example if you require values on your object form and the resource object is "Allow Multiple"

                public String provisionObject(long userKey, String objectName, tcDataProvider ioDatabase) throws Exception {
                     log.debug("provisionObject() Parameter Variables passed are:" +
                               "userKey=[" + userKey + "]" +
                               "objectName=[" + objectName + "]");
                Hashtable objectHash = new Hashtable();
                objectHash.put("Objects.Name", objectName);          
                tcResultSet objectResultSet = objIntf.findObjects(objectHash);          
                long userObjectInstanceKey = userIntf.provisionObject(userKey, objectResultSet.getLongValue("Objects.Key"));
                log.debug("userObjectInstanceKey=[" userObjectInstanceKey "]");

                //Retrieve all objects provisioned to the user
                tcResultSet userObjects = userIntf.getObjects(userKey);
                for (int i=0;i<userObjects.getTotalRowCount();i++){
                     //Matches the newly created user object instance key to a resource now available on the user's profile
                     if (userObjectInstanceKey==userObjects.getLongValue("Users-Object Instance For User.Key")){
                          //Retrieve object instance key
                          long objectInstanceKey = userObjects.getLongValue("Object Instance.Key");
                          log.debug("objectInstanceKey: " +objectInstanceKey);
                          inputHash.put(<OBJECT_FORM_COLUMN-UD_...>, <VALUE>)
                          inputHash.put(<OBJECT_FORM_COLUMN-UD_...>, <VALUE>)
                          inputHash.put(<OBJECT_FORM_COLUMN-UD_...>, <VALUE>)

                          //Sets the object data
                          formIntf.setObjectFormData(objectInstanceKey, inputHash);
                          log.debug("Object form data set, new instance of " + objectName + "[" + descField + "] provisioned to user");
                          response = "NEW_OBJECT_PROVISIONED";

                return response;

                • 5. Re: Advanced request Creation
                  Thanks, Kevin! You've helped me so much!
                  Now, if you don't mind, the last thing I want to clear out is:
                  What if the resource object is already provisioned to user, and I just want to call the API to edit some child form data (e.g, user group membership), but I my resource doesn't have "Allow Multiple" option set?
                  • 6. Re: Advanced request Creation
                    If you need to check to see if the object was already provisioned, you can use this entry to see if the process already exists in their profile:

                    String check = com.thortech.xl.util.adapters.tcUtilXellerateOperations.chckProcOrderedForUser(ioDatabase, processName.trim(), String.valueOf(userKey));

                    If it returns a 1, then it's provisioned, and at that point, you'll need to do the the userIntf.getObjects and then search through the result set till you find the provisioned item, then grab the processinstancekey from it, and use the formInstanceOperations.setProcessFormData with the appropriate data.

                    • 7. Re: Advanced request Creation
                      do you mean that once provisioned, the resource object keeps its processinstancekey as a constant ?
                      So if I save the processinstancekey somewhere (for a particular user and particular resource), I don't need to use API to get processinstancekey each time I want to edit something in this user's resource Provisioning Process?
                      • 8. Re: Advanced request Creation
                        Yes, processinstancekeys are static and unique.

                        • 9. Re: Advanced request Creation
                          One note for your original post, i found a much simpler way to provision objects using the following code:

                          Hashtable objectHash = new Hashtable();
                          objectHash.put("Objects.Name", objectName);
                          tcResultSet objectResultSet = objIntf.findObjects(objectHash);
                          long objectKey = objectResultSet.getLongValue("Objects.Key");
                          com.thortech.xl.vo.ResourceData data = userIntf.provisionResource(userKey, objectKey);
                          long userObjectInstanceKey = Long.parseLong(data.getOiuKey());
                          long objectInstanceKey = Long.parseLong(data.getObiKey());
                          log.debug("userObjectInstanceKey: " + userObjectInstanceKey);
                          log.debug("objectInstanceKey: " + objectInstanceKey);

                          //Populate the entry below with the object form data
                          inputHash.put("UD_FIELD1", field1);
                          inputHash.put("UD_FIELD2", field2);
                          inputHash.put("UD_FIELD3", field3);

                          //Sets the object data
                          formIntf.setObjectFormData(objectInstanceKey, inputHash);


                          long value = provIntf.createObjectInstanceWithObjectFormData(userKey, objectKey, inputHash);