While removing multiple Role its giving this 500 internal server error. but its working fine if i remove only one role at a time
Before Provisioning SCript
Log log = LogFactory.getLog("com.cof.rap.rule.Direct Branch.cofDirect BranchRule");
String appName ="Direct Branch";
QueryOptions qo = new QueryOptions();
List columns= new ArrayList();
Iterator applink = null;
List rolelist=new ArrayList();
if(plan!=null)
{
if(log.isDebugEnabled())
{
log.debug("COF Direct Branch BeforeProvisioning Rule:Initial Plan:"+plan);
}
Iterable accountRequests = Util.safeIterable(plan.getAccountRequests());
for (AccountRequest accReq : accountRequests)
{
if(accReq!=null && accReq.getApplicationName()!=null && appName.equals(accReq.getApplicationName()))
{
if (accReq.getOp() != null)
{
String strOp = accReq.getOp().toString();
if (strOp.equals("Modify"))
{
String nativeId=accReq.getNativeIdentity();
Identity identity=context.getObjectByName(Identity.class,nativeId);
columns.add("attributes");
qo.addFilter(sailpoint.object.Filter.eq("nativeIdentity",nativeId));
qo.addFilter(sailpoint.object.Filter.eq("application.name",appName));
applink = context.search(Link.class, qo, columns);
while(applink.hasNext())
{
Object[] objLink= (Object[]) applink.next();
attLink= (Attributes) objLink[0];
}
rolelist =attLink.get("roles");
List attRequests=accReq.getAttributeRequests();
List removalList=new ArrayList();
boolean isconvertDisable=false;
List attRequests=accReq.getAttributeRequests();
for(AttributeRequest attRequest:attRequests)
{
String strRequestName= attRequest.getName();
String strOperation= attRequest.getOp().toString();
if(attRequest.getName()!=null && strOperation!=null)
{
if("roles".equals(strRequestName) && "Add".equals(strOperation) )
{
isconvertDisable=false;
break; //No further Check required for Disable if any single Add request is present
}
else if( "roles".equals(strRequestName) && strOperation.equals("Remove") && !(rolelist.size() > 1) )
{
isconvertDisable=true;
}
}
}
if(isconvertDisable)
{
AccountRequest accReqNew=new AccountRequest();
accReqNew.setApplication(appName);
accReqNew.setNativeIdentity(accReq.getNativeIdentity());
accReqNew.setOperation(AccountRequest.Operation.Delete);//deleting account directly as per the direct branch application requirement
plan.remove(accReq);
plan.add(accReqNew);
}
}
else if(strOp.equalsIgnoreCase("Delete"))
{
AccountRequest accReqNew=new AccountRequest();
accReqNew.setApplication(appName);
accReqNew.setNativeIdentity(accReq.getNativeIdentity());
accReqNew.setOperation(AccountRequest.Operation.Disable);
plan.remove(accReq);
plan.add(accReqNew);
}
}
}
}
if(log.isDebugEnabled())
{
log.debug("COF Direct Branch BeforeProvisioning Rule:Final Plan:"+plan);
}
}