Here a single plan contains two account request while it should contain only one (for delimited).
so here while getting the existing plan i need to delete its account request so that it should contain only delimited request.
public static ProvisioningPlan buildDelimitedCustomLeaverPlan(SailPointContext context, Workflow workflow){
Logger logger = Logger.getLogger("AIZRules");
logger.debug("ENTRY : Inside buildDelimitedCustomLeaverPlan");
String identityName=workflow.get("identityName");
logger.debug("identityName**"+identityName);
if (identityName==null || identityName == void) {
logger.debug("Workflow does not contain identity");
return null;
}
Identity previousIdentity = context.getObjectByName(Identity.class,identityName);
logger.debug("previousIdentity*** " + previousIdentity);
if (previousIdentity==null || previousIdentity == void) {
logger.debug("Identity not found in repo");
return null;
}
String previousIdentityName = previousIdentity.getName();
logger.debug("previousIdentityName :" + previousIdentityName);
ProvisioningPlan plan = workflow.get("plan");
logger.debug("existing plan in delimited connector: " + plan.toXml());
if (plan != null){
//plan = new ProvisioningPlan();
Identity requesterId = context.getObjectByName(Identity.class,"spadmin");
if (null!= requesterId){
plan.addRequester(requesterId);
}else{
logger.error("Could not find spadmin to set requester");
return null;
}
List accReqList = new ArrayList();
List previousIdentityAccounts = previousIdentity.getLinks();
Iterator accountsItr = previousIdentityAccounts.iterator();
List excludedApps = new ArrayList();
logger.debug("previousIdentityAccounts:" + previousIdentityAccounts);
//Read the custom object and store in above list
Custom obj = context.getObject( Custom.class, "SPCONF Leaver Mappings Custom" );
if (obj == null){
throw new Exception("Cannot find the custom class");
}
List excludedApps = obj.getList("ExcludedDisables");
logger.debug("excludedApps: " + excludedApps);
while(accountsItr.hasNext())
{
Link account=(Link)accountsItr.next();
if(!account.isDisabled()){
if (!excludedApps.contains(account.getApplicationName())){
String appType=account.getApplication().getType();
logger.debug("Print Seq buildDelimitedCustomLeaverPlan type of app " + appType);
if(appType !=null && !appType.equalsIgnoreCase("DelimitedFile")){
logger.debug("Removing non-delimited AccountRequest: " + accReq.toXml());
}
else{
logger.debug("Print Seq buildDelimitedCustomLeaverPlan name of app " + account.getApplicationName());
ProvisioningPlan.AccountRequest userAccount = new ProvisioningPlan.AccountRequest();
userAccount.setApplication(account.getApplicationName());
userAccount.setNativeIdentity(account.getNativeIdentity());
userAccount.setOperation(ProvisioningPlan.AccountRequest.Operation.Disable);
plan.add(userAccount);
}
}
}
}
logger.debug("accReqList: " + accReqList);
logger.debug("accReqList isEmpty : " + accReqList.isEmpty() );
}
logger.debug("AFTER MODDING " + plan.toXml());
logger.debug("EXITING buildDelimitedCutomLeaverPlan for: " + identityName);
//return null;
return plan;
}