Tuesday 19 December 2017

OIM API - Code snippet to get IT Resource Key by Application Instance Name.

public String getItResourceKey(String applicationInstanceName) {
    String methodName = "getItResourceKey()";
    System.out.println(methodName + " :: Enter");
    String itrKey = null;
    ApplicationInstance appInst = null;
   
    //get application instance service
    ApplicationInstanceService appService = Platform.getService(ApplicationInstanceService.class);
   
    if(!applicationInstanceName.trim().isEmpty() && applicationInstanceName.trim() != null) {
        System.out.println(methodName + " :: Fetching IT Resource Key for application [" + applicationInstanceName + "]");
        try {
            appInst = appService.findApplicationInstanceByName(applicationInstanceName);
            itrKey = String.valueOf(appInst.getItResourceKey());

            System.out.println("itrKey :: " + itrKey);
        } catch (Exception e) {
            System.out.println(methodName + " :: Exception occured :" + e);
        }
    } else {
        System.out.println(methodName + " :: Appliction Instance Name is null or empty");
    }
    System.out.println(methodName + " :: Exit");
    return itrKey;
}

1 comment: