I am working on a custom After Operation Rule where I need to add “true” value to the isActive attribute and Concatenate the entitlements with the application name selected by ‘ - ‘
The approach you shared — are you going to implement it during aggregation to reflect within the ISC attribute, or during provisioning to reflect in the target system?
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
Map updatedMapInfo = new HashMap();
try {
if (processedResponseObject != null) {
List dataList = new ArrayList();
for (Map iterateMap : processedResponseObject) {
if (iterateMap != null) {
Map userMap = new HashMap();
userMap.put("userId", iterateMap.get("userId"));
userMap.put("firstName", iterateMap.get("firstName"));
userMap.put("lastName", iterateMap.get("lastName"));
userMap.put("isActive", "Test - true");
List applicationRoles = new ArrayList();
List<Map> apps = (List<Map>) iterateMap.get("applications");
if (apps != null) {
for (Map app : apps) {
String appName = (String) app.get("appName");
List<String> levels = (List<String>) app.get("accessLevels");
if (levels != null) {
for (String lvl : levels) {
if (appName != null && !appName.trim().isEmpty() &&
lvl != null && !lvl.trim().isEmpty()) {
applicationRoles.add(appName + " - " + lvl);
}
}
}
}
}
userMap.put("application-Role", applicationRoles);
dataList.add(userMap);
}
}
updatedMapInfo.put("data", dataList);
}
} catch (Exception e) {
log.error("Error in After Operation Rule: " + e.getMessage(), e);
updatedMapInfo.put("data", new ArrayList()); // fallback empty
}
return updatedMapInfo;
this is my code. I have attached the code to my source and ran the aggregation, after aggregation it’s not populating any value. it’s not taking the inputs from the code.
Did you change your response mapping in your UI for the source to Accounts/Identities list JSONPath:$.data[*]as in the code you are sending/updating/returning to updatedMapInfo.put(“data”, dataList);
return updatedMapInfo;
if the above is fine, then do the below to troubleshoot :
What i Would suggest is, throw a general execption after each step and see step by step where values are being poplated, and where issue might be..
for eg
are values like userid etc being populated into the usermap or not.
Eg : throw new GeneralException(“userMap” + String.valueOf(userMap));
Keeo doing that in all lines and run aggregatin and keep checking it if all details are being populated correctly and where issue might come up
No error is coming but the Accounts are 0 after the Aggregation.
they updated the api. now isActive is a String and we are fetching it directly from the JSON.
Now how to check the logs? I checked the logs but nothing was there, can you help me exactly which logs we have to check
This is the working code. When I run the aggregation and checked the log it is returning the expected output. But after the aggregation the accounts getting fetched was 0.
And in Aggregation HTTP operation if I give $ as a response information it’s returning the data in the logs, but if I give $.data as a response information the logs returning null data.
Can anyone please help me with this issue.
import java.util.*;
import org.json.JSONArray;
import org.json.JSONObject;
Map updatedMapInfo = new HashMap();
List newProcessedResponseObject = new ArrayList();
try {
if (processedResponseObject != null && processedResponseObject.size() > 0) {
for (Map iterateMap : processedResponseObject) {
if (iterateMap != null) {
Map currentMap = new HashMap();
currentMap.put("userld", iterateMap.get("userId"));
currentMap.put("firstName", iterateMap.get("firstName"));
currentMap.put("lastName", iterateMap.get("lastName"));
currentMap.put("isActive", "testActive");
List appList = new ArrayList();
// Get applications JSON string
Object appsObj = iterateMap.get("applications");
if (appsObj != null) {
String appsJson = appsObj.toString().trim();
// Parse JSON Array
JSONArray appsArray = new JSONArray(appsJson);
for (int i = 0; i < appsArray.length(); i++) {
JSONObject appObj = appsArray.getJSONObject(i);
String appName = appObj.optString("appName", "");
log.error("GMOX - Print appName" + appName);
JSONArray accessArr = appObj.optJSONArray("accessLevels");
if (accessArr != null && accessArr.length() > 0) {
for (int j = 0; j < accessArr.length(); j++) {
String access = accessArr.getString(j);
appList.add(appName + "-" + access);
log.error("GMOX - Print Concatenated" + appName + "$$$$$$$$$$$$$$$$$$$$$$$$" + access);
}
} else {
appList.add(appName);
}
}
}
currentMap.put("applications", appList);
log.error("GMOX - Print applications" + appList);
newProcessedResponseObject.add(currentMap);
}
}
}
updatedMapInfo.put("data",newProcessedResponseObject);
log.error("GMOX - Print Final Output" + updatedMapInfo);
} catch (Exception ex) {
log.error("Exception while parsing applications in After Operation Rule: " + ex.getMessage());
}
log.trace("GMOX - Print Exit Rule");
return updatedMapInfo;
Code looks good. If you are using processedResponseObject then you should have applications in response mapping. If “applications” is not part of response mapping then user rawresponseObject and build user object.
Excellent rule to construct entitlement. I would like to throw in some suggestions as well.
The issue could be how data is being configured in HTTP response mapping. Try aggregation after removing root path($.data) if configured and direct mapping in attribute path(schema attribute: User ID; attribute path: userId). I also see an lowercase “L“ instead of “I“ in your rule with line: -
I have same issue, updatedMap has correct data, but accounts not populated for source. Tried with root path : ($.data) and also tried after removing root path.