WebServicesAfterOperationRule

This rule is used to calculate attributes after a web-service operation call.

This rule is used by the Web Services Connector to update parsed resource object and save connectorStateMap values. Create List of Objects would later be converted to Resource object and save connectorStateMap values to the application object permanently.

The returned map will hold data key for resource object list and connectorStateMap key for updated attribute that must be saved in the application.

Input Objects

Objects

Type

Description

application>

sailpoint.object.Application

Application whose data file is being processed.

requestEndPoint

sailpoint.connector.webservices.

EndPoint

Current request information; contains the header, body, context url, method type, response attribute map, successful response code.

processedResponseObject

List<Map<String, Object>>

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

sailpoint.connector.webservices.

WebServicesClient

A WebServicesClient (HttpClient) object that would enable the user to call the Web Services API target system.

Return Objects

Type

Purpose

java.util.Map

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 of type Map which contains key-value pair, where key represents the schema attribute name and value represents the account/ group attribute value.

Examples for After Operation Rules

Following example displays after operation rule that can be used to update the accounts/groups and application attributes value after execution of the endpoint:

Copy
import java.util.*;
            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;

Following example displays the after operation rule that can be used in Web Services connector for updating the resource object:

Copy
<![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);

        ]]