Work With Properties

Java API

  1. tcITResourceInstanceOperationsIntf
  2. tcLookupOperationsIntf
  3. SchedulerService

Getting access to OIM Properties is very helpful when coding batch jobs or Adapters. it can greatly reduce the need for hard
coding values in you programs.

Getting the Services from the OIMClient

tcITResourceInstanceOperationsIntf resInstOps = client.getService(tcITResourceInstanceOperationsIntf.class);
tcLookupOperationsIntf lookupOps = client.getService(Thor.API.Operations.tcLookupOperationsIntf.class);
SchedulerService scheduleOps = client.getService(SchedulerService.class);
SystemConfigurationService confService = confService = client.getService(SystemConfigurationService.class);

Get a Map Containing the Name/Values from a ITResource

public Map<String, String>  someMethod(String itResourceName) throws SomeException {
 
        HashMap<String, String> resourceMap = new HashMap<String, String>();
        try {
            HashMap<String, String> srchMap = new HashMap<String, String>();
            srchMap.put("IT Resources.Name", itResourceName);
            tcResultSet rst = resInstOps.findITResourceInstances(srchMap);
 
            if (rst.getRowCount() <= 0)
            {
                logger.error("ITResource " + itResourceName + " not found");
                throw new SomeException("ITResource " + itResourceName + " Not Found");
            }
 
            for (int i = 0; i < rst.getTotalRowCount(); i++) {
                rst.goToRow(i);
                long key = rst.getLongValue("IT Resources.Key");
                tcResultSet paramSet = resInstOps.getITResourceInstanceParameters(key);
                int amRow = paramSet.getRowCount();
                if (amRow == 0) {
                    logger.error("ITResource " + itResourceName + " not found");
                    throw new SomeException("ITResource " + itResourceName + " Not Found");
                }
 
                for (int j = 0; j < paramSet.getTotalRowCount(); j++) {
                    paramSet.goToRow(j);
                    //Setting login credentials from ITResource
                    String parmkey = paramSet.getStringValue("IT Resources Type Parameter.Name");
                    String parmval = paramSet.getStringValue("IT Resource.Parameter.Value");
                    resourceMap.put(parmkey, parmval);
 
                }
                //logger.debug("ITResource Parms: " + srchMap);
            }
            logger.info("Finished Retrieving ITResource parameters");
        } catch (tcAPIException e) {
            logger.error("tcAPIException while retrieving ITResource parameters: " + e.getMessage(), e);
            throw new SomeException(e);
        } catch (tcColumnNotFoundException e) {
            logger.error("tcColumnNotFoundException while retrieving ITResource parameters: " + e.getMessage(), e);
            throw new SomeException(e);
        } catch (tcITResourceNotFoundException e) {
            logger.error("tcITResourceNotFoundException while retrieving ITResource parameters: " + e.getMessage(), e);
            throw new SomeException(e);
        }
        return resourceMap;
    }

Get a Map Containing the Name/Values from a Lookup Table

public Map<String, String> someMethod(String lookupName) throws SomeException {
 
        HashMap<String, String> props = new HashMap<String, String>();
        try {
            tcResultSet resultSet = lookupOps.getLookupValues(lookupName);
            int amRow = resultSet.getRowCount();
            if (amRow == 0) {
                logger.error("Lookup Code " + lookupName + " not found");
                throw new SomeException("Lookup Not Found");
            }
 
            for (int i = 0; i < resultSet.getRowCount(); i++) {
                resultSet.goToRow(i);
                String codeKeyfromResultSet = resultSet.getStringValue("Lookup Definition.Lookup Code Information.Code Key");
                String decodeValue = resultSet.getStringValue("Lookup Definition.Lookup Code Information.Decode");
                props.put(codeKeyfromResultSet, decodeValue);
 
            }
        } catch (tcAPIException e) {
            logger.error("tcAPIException ", e);
            throw new SomeException(e);
        } catch (tcInvalidLookupException e) {
            logger.error("tcInvalidLookupException ", e);
            throw new SomeException(e);
        } catch (tcColumnNotFoundException e) {
            logger.error("tcColumnNotFoundException ", e);
            throw new SomeException(e);
        }
 
        return props;
 
    }

Get a Map Containing the Name/Values from a Scheduled Job

public Map<String, String> someMethod(String taskName) throws SomeException {
 
        Map jobProps = new HashMap();
 
        try {
            //logger.debug("Get Job " + taskName);
            JobDetails jd = scheduleOps.getJobDetail(taskName);
 
            if (jd == null)
            {
                logger.error("Job Not Found for " + taskName);
                throw new SomeException ("Job Not Found for " + taskName);
            }
 
            Map<String,JobParameter> parms = jd.getAttributes();
 
            if (parms == null)
            {
                logger.debug("No Parms for " + taskName);
                return jobProps;
            }
            Set<String> keys = parms.keySet();
 
            for(String key : keys)
            {
                JobParameter jp = parms.get(key);
                //logger.debug("DataType " + jp.getDataType());
                //logger.debug("Name " + jp.getName());
                //logger.debug("Val " + jp.getValue());
                jobProps.put(jp.getName(),jp.getValue().toString());
 
            }
        } catch (SchedulerException ex) {
            logger.error("SchedulerException",ex);
            throw new SomeException("SchedulerException",ex);
        }
        return jobProps;
 
    }

Get a System Property Value

public String someMethod(String propName) throws SomeException {
        SystemProperty sysProp = null;
        String ptyValue = null;
 
        try {
            sysProp = confService.getSystemProperty(propName);
        } catch (SystemConfigurationServiceException SCSE) {
            logger.error("SystemConfigurationServiceException",SCSE);
            throw new SomeException("SystemConfigurationServiceException",SCSE);
        }
 
        if (sysProp != null) {
            ptyValue = sysProp.getPtyValue();
        }
 
        return ptyValue;
    }
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License