Hi,
I am working on webservice connector. I am facing some difficulty duting account aggregation. Th use case is below-
First API call- Give user info such as id, firstname, lastname, email etc.
Second API call- Give user group details based on id.
I need the users only when their email ends with some “@xyz.com” in accounts. I have wriiten a after rule in which I am calling the Second API when email contains @xyz.com. But this code is pulling correct accounts from first page but once it go to to second page , it starts pulling all other records as well where email does not contain @xyz.com. Any thoughts?
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
import sailpoint.connector.webservices.Endpoint;
import sailpoint.connector.webservices.WebServicesClient;
import sailpoint.object.Application;
import java.util.ArrayList;
Map roleMap = new HashMap();
List finalList = new ArrayList();
Map map = (Map) requestEndPoint.getHeader();
String baseurl =(String) application.getAttributeValue("genericWebServiceBaseUrl");
List allowedStatuses = new ArrayList();
allowedStatuses.add("2**");
if (processedResponseObject!= null)
{
for(Map data : processedResponseObject)
{
String email = (String) data.get("login");
String id = (String) data.get("id");
if(email != null && email.contains("@xyz.com"))
{
String url1 = baseurl + "/users/" + id + "/memberships";
String roleData = null;
roleData = restClient.executeGet(url1, map, allowedStatuses);
if (roleData != null) {
try {
JSONObject jsonObject = new JSONObject(roleData);
JSONArray array = (JSONArray) jsonObject.get("entries");
List roleList = new ArrayList();
for (int i = 0; i < array.length(); i++) {
JSONObject obj = (JSONObject) array.get(i);
String roleName = (String) obj.getJSONObject("group").get("name");
roleList.add(roleName);
}
data.put("Groups", roleList);
} catch (Exception e) {
log.info("Error while adding groups");
}
}
roleMap.put(id, data);
}
}
for (Map consolidatedMap : roleMap.values()) {
finalList.add(consolidatedMap);
}
}
Map updatedMapInfo = new HashMap();
updatedMapInfo.put("data", finalList);
return updatedMapInfo;