Getting error : While iterating getApplications() method result from Bundle

Hi All,

I am getting error While iterating getApplications() method result from Bundle. i.e. applicationsList in my case. Please help.

How to iterate applicationsList

Error : An unexpected error occurred: The application script threw an exception: java.lang.ClassCastException: Cannot cast java.util.HashSet to java.lang.String BSF info: SLF_Policy_Violation_Asia Group Insurance System SLOCPI at line: 0 column: columnNo

List applicationsList = new ArrayList();

for (Bundle role : allrequestedRoles) {
if (role.getApplications() != null) {

  applicationsList.add(role.getApplications());

  /*  if (applicationsList.getName().equals(targetApplication)){
    applicationRoles.add(role);
  }*/

}

}

log.error(“Applications List:”+applicationsList);
log.error(“Applications List Size:”+applicationsList.size());

List finalappName = new ArrayList();
for (String app : applicationsList) {
if(app.getName().equals(targetApplication)){
finalappName.add(app);
}
}

Can you try below code?

List finalAppName = new ArrayList();
			for (Bundle role : reqRoles){
              
               Set applicationsList = role.getApplications(); // getApplications() return type java.util.Set<Application>
         
               if (applicationsList != null @and applicationsList.size() > 0){
               
                  Iterator it = applicationsList.iterator();
                  
                  while (it.hasNext()){
                     Application app = it.next();
                     String appName = app.getName();
						
                     if (!finalAppName.contains(appName)){
                        finalAppName.add(appName);
                     }
                  }
				  sailpoint.tools.Util.flushIterator(it);   
               }
1 Like

Can you try replacing the following line in you code with suggestion below:

applicationsList.add(role.getApplications());

try this instead

applicationsList.addAll(role.getApplications());

1 Like