Friday, February 16, 2024

Sample Before Rule

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import org.apache.commons.logging.Log;

import org.apache.log4j.Logger;

import sailpoint.api.SailPointContext;

import sailpoint.connectorDependencies.EndPoint;

import sailpoint.object.Custom;

import sailpoint.object.ProvisioningPlan;

import sailpoint.object.ProvisioningPlan.AccountRequest;

import sailpoint.object.ProvisioningPlan.AttributeRequest;

import sailpoint.tools.Util;

import connector.common.JsonUtil;


String roleType = "";

String roleId = "";

List<String> securityGroup = new ArrayList<String>();

String secretAccountIndicator = "";

String phone = null;


String bcomSecGroupReqType = "";

List<String> bcomSecurityGroup = new ArrayList<String>();

List<String> ipccRoleId = new ArrayList<String>();

String ipccPhone = "";

String roleChangeReqType = "";

List<String> roleChangeRoleID = new ArrayList<String>();


String primasRole = "";

String primasPhone = "";


String secAccIndicator = "";

String bcomAccSecretAccountIndicator = "";


Custom custom = null;

AttributeRequest attributeRequest = null;

Map<String, Object> formMap = new HashMap<String, Object>();

List<AccountRequest> accountRequests = null;


custom = context.getObjectByName(Custom.class, "Mighty - Payload Details");


Map body = requestEndPoint.getBody();

String jsonBody = body.get("jsonBody").toString().trim();

log.error("jsonBody : " + jsonBody);


Map jsonMap = JsonUtil.toMap(jsonBody);

log.error("jsonMap : " + jsonMap);


accountRequests = provisioningPlan.getAccountRequests();

log.error("accountRequests : " + accountRequests);


for (AccountRequest accountRequest : accountRequests) {

if (Util.isNotNullOrEmpty(accountRequest.getApplicationName())

&& accountRequest.getApplicationName().toString().trim().equalsIgnoreCase("BCOM")) {


formMap = provisioningPlan.getArguments().getMap();

log.error("formMap : " + formMap);


if (accountRequest.getAttributeRequest("rolesIds") != null) {

attributeRequest = accountRequest.getAttributeRequest("rolesIds");

log.error("attributeRequest : " + attributeRequest);

if (attributeRequest.getName().equalsIgnoreCase("IPCC")) {

if (formMap.get("Role ID") != null) {

ipccRoleId = (List<String>) formMap.get("Role ID");

log.error("ipccRoleId : " + ipccRoleId);

}

if (formMap.get("Phone") != null) {

phone = formMap.get("Phone").toString().trim();

log.error("phone : " + phone);

}

if (Util.isNotNullOrEmpty(phone)) {

jsonMap.put("phoneNo", phone);

}

// To - Do

// Map postBodyMap = (Map) requestEndPoint.getBody();


}

if (attributeRequest.getName().equalsIgnoreCase("IPCC update Roles")) {

if (formMap.get("Request Type") != null) {

roleChangeReqType = formMap.get("Request Type").toString().trim();

log.error("roleChangeReqType : " + roleChangeReqType);

}

if (formMap.get("Role ID") != null) {

roleChangeRoleID = (List<String>) formMap.get("Role ID");

log.error("roleChangeRoleID : " + roleChangeRoleID);

}


// To - Do

}

if (attributeRequest.getName().equalsIgnoreCase("BCOM update Security Group")) {


if (formMap.get("Request Type") != null) {

bcomSecGroupReqType = formMap.get("Request Type").toString();

log.error("bcomSecGroupReqType : " + bcomSecGroupReqType);

}

if (formMap.get("Security Group") != null) {

bcomSecurityGroup = (List<String>) formMap.get("Security Group");

log.error("bcomSecurityGroup : " + bcomSecurityGroup);

}


// To - Do

}

if (attributeRequest.getName().equalsIgnoreCase("BCOM")) {


if (formMap.get("Role ID") != null) {

roleId = formMap.get("Role ID").toString();

}

if (formMap.get("Security Group") != null) {

securityGroup = (List) formMap.get("Security Group");

}

if (formMap.get("Secret Account Indicator") != null) {

secretAccountIndicator = formMap.get("Secret Account Indicator").toString().trim();

}

if (formMap.get("Phone") != null) {

phone = formMap.get("Phone").toString().trim();

}


// To - Do


}

if (attributeRequest.getName().equalsIgnoreCase("PRIMAS")) {

if (formMap.get("Role ID") != null) {

primasRole = formMap.get("Role ID").toString();

if (formMap.get("PRIMAS") != null) {

roleType = custom.getString("PRIMAS");

log.error("roleType : " + roleType);

}

}

if (formMap.get("Phone") != null) {

primasPhone = formMap.get("Phone").toString().trim();

log.error("primasPhone : " + primasPhone);

}

// To - Do


if (Util.isNotNullOrEmpty(primasPhone)) {

jsonMap.put("phoneNo", primasPhone);

}

}

if (attributeRequest.getName().equalsIgnoreCase("BCOM update Account Indicator")) {

if (formMap.get("Secret Account Indicator") != null) {

secretAccountIndicator = formMap.get("Secret Account Indicator").toString().trim();

log.error("secretAccountIndicator : " + secretAccountIndicator);


if (secretAccountIndicator.equalsIgnoreCase("Normal Account")) {

secAccIndicator = custom.getString("Normal Account");

log.error("secAccIndicator : " + secretAccountIndicator);

}

if (secretAccountIndicator.equalsIgnoreCase("Confidential and Normal Account")) {

secAccIndicator = custom.getString("Confidential and Normal Account");

log.error("secAccIndicator : " + secretAccountIndicator);

}

}

// To - Do

if (Util.isNotNullOrEmpty(secAccIndicator)) {

jsonMap.put("secretAccountIndicator", secAccIndicator);

}

}

}

}

}


No comments:

Post a Comment

Fetch Members from Workgroup

  import java.util.ArrayList;   import java.util.Iterator;   import java.util.List;   import sailpoint.api.ObjectUtil;   import sailpoint.ob...