Webservice After operation rule to clear processedResponseObject?

Hi All,

I have an scenario where I need to clear the processedResponseObject from the operation and pass the value to the processedResponseObject like the entitlement value ent 1, ent 2, etc…

I have tried this code but when I aggregate the entitlement it returns nothing. Can anyone help me with that..

import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Map

Map processedResponseObject = new HashMap();
String[] values = { "ent 1", "ent 2", "ent 3", "ent 4" };

// Step 3: Create list of maps
List<Map<String, String>> nameEntries = new ArrayList();

for (int i = 0; i < values.length; i++) {
    Map<String, String> entry = new HashMap();
    entry.put("name", values[i]);
    nameEntries.add(entry);
}

// Step 4: Add to processedResponseObject
processedResponseObject.put("data", nameEntries);

// Step 5: Return
return processedResponseObject;

Thanks,
Shantha Kumar

Hi @Santhakumar ,

Try below:

import java.util.*;

public Map<String, Object> buildProcessedResponse() {
Map<String, Object> processedResponseObject = new HashMap<>();

// Step 1: Initialize string array
String[] values = { "ent 1", "ent 2", "ent 3", "ent 4" };

// Step 2: Create list of maps
List<Map<String, String>> nameEntries = new ArrayList<>();

for (int i = 0; i < values.length; i++) {
    Map<String, String> entry = new HashMap<>();
    entry.put("name", values[i]);
    nameEntries.add(entry);
}

// Step 3: Add list to processedResponseObject
processedResponseObject.put("data", nameEntries);

// Step 4: Return
return processedResponseObject;

}

buildProcessedResponse();

its working for me:

If you want to completely ‘ignore’ what came out of the prosessedResponseObject (i.e. clear all values and add your own), you can also do this:

import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;

log.error(application.getName() + ": start");

Map dummyEntitlementMap = new HashMap();
List dummyEntitlementList = new ArrayList();
Map returnEntilementMap = new HashMap();

dummyEntitlementMap.put("displayName","account");
dummyEntitlementMap.put("value","account");
dummyEntitlementMap.put("description","Dummy entitlement to enforce the account creation");

dummyEntitlementList.add(dummyEntitlementMap);

returnEntilementMap.put("data", dummyEntitlementList);
log.error(application.getName() + returnEntilementMap);
return returnEntilementMap;

Of course this is only pushing in one value for an entitlement, you will indeed have do do a small loop based on an array if you want multiple values.

The entitlement schema i have only the attribute called name is it okay or need to add some.

Tried but when i aggregate the entitlement it returns nothing

Your schema must have name, value and preferably description as well.

In my schema i have only name and description is it ok right. Also did we need to populate anything in Response Mapping and Response Information???

If possible can you share the full working code :grinning_face:

No, your entitlement schema must have a value attribute as this is what ultimately triggers ISC to provision. If it doesn’t show up, make sure you have your group schema like this:

{
    "nativeObjectType": "group",
    "identityAttribute": "value",
    "displayAttribute": "displayName",
    "hierarchyAttribute": null,
    "includePermissions": false,
    "features": [],
    "configuration": {
        "cloudGoverned": false
    },
    "attributes": [
        {
            "name": "displayName",
            "type": "STRING",
            "schema": null,
            "description": "displayName",
            "isMulti": false,
            "isEntitlement": false,
            "isGroup": false
        },
        {
            "name": "value",
            "type": "STRING",
            "schema": null,
            "description": "value",
            "isMulti": false,
            "isEntitlement": false,
            "isGroup": false
        },
        {
            "name": "description",
            "type": "STRING",
            "schema": null,
            "description": "description",
            "isMulti": false,
            "isEntitlement": false,
            "isGroup": false
        }
    ],
    "name": "group"
}

Tried with the same schema but not able to get the entitlements it was returning nothing

Which after rule have you been using?

This one I’m trying to get the single value first

import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;

log.error(application.getName() + ": start");

Map dummyEntitlementMap = new HashMap();
List dummyEntitlementList = new ArrayList();
Map returnEntilementMap = new HashMap();

dummyEntitlementMap.put("displayName","account");
dummyEntitlementMap.put("value","account");
dummyEntitlementMap.put("description","Dummy entitlement to enforce the account creation");

dummyEntitlementList.add(dummyEntitlementMap);

returnEntilementMap.put("data", dummyEntitlementList);
log.error(application.getName() + returnEntilementMap);
return returnEntilementMap;

Also i have tried this simple rule

import java.util.HashMap;

import java.util.List;

import java.util.ArrayList;

import java.util.Map;

List entlist = new ArrayList();

entlist.add("ent 1");

entlist.add("ent 2");

entlist.add("ent 3");

processedResponseObject.clear();

Map updateInfo = new HashMap();

updateInfo.put("data",entlist);

processedResponseObject.add(updateInfo);

return processedResponseObject;

Are you sure you attached the rule to the HTTP operation?

Can you share the source / HTTP operation JSON?

I think your Map object variable name processedResponseObject is overlapping with input param. can you use a different name and try once. Otherwise the code looks fine and it should work.

I have resolved the issue will share the code when i available.

Thanks all for the inputs.