Web Services After Operation Rule
The After Operation Rule is used to calculate attributes after a web service operation call.
It is used by the Web Services connector to update parsed resource objects and save connectorStateMap values. Create List of Objects converts to Resource objects and the connectorStateMap
values are updated in the application object permanently. The returned map holds data keys for the resource object list and the connectorStateMap
key for updated attributes that must be saved in the application.
Input Objects
Objects |
Type |
Description |
application |
|
Application whose data file is being processed. |
requestEndPoint |
|
Current request information. It contains the header, body, context URL, method type, response attribute map, successful response code. |
processedResponseObject |
|
This object is List of Map (account/group). The map contains key as identityAttribute of the application schema and value is all the account/group attributes (schema) passed by the connector after parsing the respective API response. |
rawResponseObject |
String |
String object which holds the raw response returned from the target system which can be in JSON or XML form. |
restClient |
|
A Web Services Client (HTTP Client) object that enables you to call the Web Services API target system. |
Return Objects
The Map
object returned from the After Operation Rule may contain any or all of the following:
-
Updated list of account / group resource objects; identified by key
data
-
Attribute values to be updated into application via connector state map; identified by key
connectorStateMap
Each resource (account/group) object is a Map
-type object which contains key-value pairs, where key represents the schema attribute name and value represents the account/ group attribute value.
Examples for After Operation Rules
The following example displays the After Operation Rule used to update accounts, groups, and application attribute values after execution of the endpoint:
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Iterator;
//We can parse the response(rawResponseObject) to fetch from the respective executed Endpoint operation.
Map updatedMapInfo = new HashMap();
if (processedResponseObject != null){
for (Map iterateMap : processedResponseObject) {
if (iterateMap != null ) {
Set keySet = iterateMap.keySet();
for (String s : keySet) {
if (s.equals("given_name")) {
String forStr = (String) iterateMap.get("given_name");
forStr = "TEST"+ forStr;
iterateMap.put("given_name", forStr);
}
}
}
}
updatedMapInfo.put("data", processedResponseObject);
}
Map connectorStateMap = new HashMap();
connectorStateMap.put("refresh_token","refreshTokenGeneratedInAfterRuleScript");
updatedInfoMap.put("connectorStateMap",connectorStateMap);
return updatedMapInfo;
The following example displays the After Operation Rule being used by the Web Services connector to update the resource object:
<![CDATA[
import connector.common.JsonUtil;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.PrintStream;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import sailpoint.tools.GeneralException;
Map updatedMapInfo = new HashMap();
List list = new ArrayList();
ArrayList<String> Roles = new ArrayList<String>();
Map response = (Map) JsonUtil.toMap(rawResponseObject);
int RoleSize = 0;
String newName;
List Finallist = new ArrayList();
List workspace = new ArrayList();
log.error("RULEWS response at start" + response);
if (response.get("data") != null) {
list = (ArrayList) response.get("data");
for(int d = 0; d < list.size(); d++ ){
Map responseMap = (Map) list.get(d);
if (responseMap.get("attributes") != null) {
Map newmap = new HashMap();
Map data = (Map) responseMap.get("attributes");
newmap.put("firstName", data.get("firstName"));
newmap.put("lastName",data.get("lastName"));
newmap.put("displayName",data.get("displayName"));
newmap.put("userName",data.get("userName"));
newmap.put("email",data.get("email"));
if (data.get("workspaceMemberships") != null) {
ArrayList Workspacedetail = (ArrayList) data.get("workspaceMemberships");
for (int i = 0; i < Workspacedetail.size(); i++) {
Map work = (Map) Workspacedetail.get(i);
for (int w = 0; w < work.size(); w++) {
if (work.get("workspaceName") != null) {
workspace.add(work.get("workspaceName"));
Roles = (ArrayList) work.get("workspaceRoles");
for (int r = 0; r < Roles.size(); r++) {
if (Roles.get(r) != null) {
newName = Roles.get(r).toString() + " - " + work.get("workspaceName");
if(newName != null) {
Roles.set(r, newName);
newmap.put("workspaceRoles", Roles);
}
}
}
}
break;
}
}
}
Finallist.add(newmap);
}
}
}
log.error("RULEWS newmap at end" + newmap);
log.error("RULEWS Finallist at end" + Finallist);
log.error("RULEWS processedResponseObject Before is " + processedResponseObject);
updatedMapInfo.put("data", Finallist);
log.error("RULEWS updatedMapInfo is " + updatedMapInfo);
return updatedMapInfo;
log.error("RULEWS processedResponseObject after is " + processedResponseObject);
]]