Total Pageviews

Tuesday, October 23, 2018

Code to fetch UserKey from UserLogin OIM

public String getUserkey(String userLogin) {
          logger.info("getUserkey method started");
          UserManager usrMgr = Platform.getService(UserManager.class);
          User user = new User(userLogin);
          Set restSet = new HashSet();
          restSet.add("usr_key");
          String userKey = null;

          try {
              user =
    usrMgr.getDetails("User Login", userLogin, null); // getting the user key based on userlogin
          } catch (NoSuchUserException e) {
              logger.log(Level.SEVERE, e.getMessage(), e);
          } catch (UserLookupException e) {
              logger.log(Level.SEVERE, e.getMessage(), e);
          } catch (SearchKeyNotUniqueException e) {
              logger.log(Level.SEVERE, e.getMessage(), e);
          } catch (NullPointerException e) {
              logger.log(Level.SEVERE, e.getMessage(), e);
          } catch (Exception e) {
              logger.log(Level.SEVERE, e.getMessage(), e);
          }

          userKey = user.getEntityId();

          return userKey;
      }

Code to fetch DB connection from weblogic datasource

Context initialContext = new InitialContext();
            datasource =
                    (DataSource)initialContext.lookup("jdbc/operationsDB");
            con = datasource.getConnection();
            stmt = con.createStatement();

Code to fetch OIM lookup details

    public Map getLookupMap() {
        final String methodName = " :: getLookupMap - ";
        logger.info(methodName + "START");
        String lookupName = "Lookup.MySyn.userType";
        Map lookupMap = new HashMap();
        tcLookupOperationsIntf lookupService =
            Platform.getService(tcLookupOperationsIntf.class);
        try {
            tcResultSet resultSet = lookupService.getLookupValues(lookupName);
            String codeKey, meaningValue;
            for (int i = 0; i < resultSet.getRowCount(); i++) {
                resultSet.goToRow(i);
                codeKey =
                        resultSet.getStringValue("Lookup Definition.Lookup Code Information.Code Key");
                meaningValue =
                        resultSet.getStringValue("Lookup Definition.Lookup Code Information.Decode");
                lookupMap.put(codeKey, meaningValue);
                //logger.info(methodName + " \nLookup Key: [" + codeKey +
                //          "], Lookup Value:[" + meaningValue + "])");
            }
        } catch (tcAPIException e) {
            logger.severe(methodName +
                          "Exception occured while reading lookup " +
                          e.getMessage());
            e.printStackTrace();
        } catch (tcInvalidLookupException e) {
            logger.severe(methodName +
                          "Exception occured while reading lookup " +
                          e.getMessage());
            e.printStackTrace();
        } catch (tcColumnNotFoundException e) {
            logger.severe(methodName +
                          "Exception occured while reading lookup " +
                          e.getMessage());
            e.printStackTrace();
        }
        logger.info(methodName + "END");
        return lookupMap;
    }

Friday, October 12, 2018

Query to read lookup values from OIM DB

select LKV_ENCODEd, LKV_DECODED from LKV, LKU WHERE lku.lku_type_string_key='LookupName' and lkv.lku_key = lku.lku_key