Hi Team,
I am facing issue while validating identity attribute rule as below
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Rule name="PopulateLCS" type="IdentityAttribute">
<Description>Calculates LCS based on start and end dates.</Description>
<Source><![CDATA[
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;
import sailpoint.tools.GeneralException;
import java.util.Iterator;
import sailpoint.object.*;
import java.util.ArrayList;
import sailpoint.api.*;
import sailpoint.object.*;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang.StringUtils;
String orgID = identity.getAttribute("originalId");
String empNumber = identity.getAttribute("identificationNumber");
if (orgID != null && empNumber != null){
if (orgID != empNumber){
//String samAccount = idn.getIdentityById("orgID").getSamaccountname();
sailpoint.rule.Identity foundIdentity = idn.getIdentityById("orgID");
String samaccount = foundIdentity.getSamaccountname();
if (samAccount == null && samAccount.isEmpty()){
return prehire;
}
else
{
return prehire-conversion;
}
}
}
// Date format we expect dates to be in (ISO8601)
SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");
if (identity.getAttribute("onLeave").equals("1")) {
return "loa";
}
// Parse the start date from the identity, and put in a Date object.
Date startDate = null;
if (identity.getAttribute("startDate") != null || !(identity.getAttribute("startDate").isEmpty())) {
startDate = dateFormat.parse(identity.getAttribute("startDate"));
} else return "inactive";
// Define a date for today
Date today = new Date();
// Calculate 7 days before start date
Calendar cal = Calendar.getInstance();
cal.setTime(startDate);
cal.add(Calendar.DAY_OF_YEAR, -7);
Date prehireDate = cal.getTime();
if (identity.getAttribute("endDate") == null || identity.getAttribute("endDate").isEmpty()) {
if ((today.equals(prehireDate)) || today.after(prehireDate) && today.before(startDate)) {
return "prehire";
} else if (today.equals(startDate) || today.after(startDate)) {
return "active";
}
return "inactive";
}
// Parse the end date from the identity, and put in a Date object.
Date endDate = null;
if (identity.getAttribute("endDate") != null) {
endDate = dateFormat.parse(identity.getAttribute("endDate"));
}
// Calculate 91 days after end date
cal.setTime(endDate);
cal.add(Calendar.DAY_OF_YEAR, 91);
Date deleteDate = cal.getTime();
// Calculate lifecycle state based on the attributes.
if ((today.equals(prehireDate)) || today.after(prehireDate) && today.before(startDate)) {
return "prehire";
} else if ((today.equals(endDate)) || (today.equals(startDate)) || (today.after(startDate) && today.before(endDate))) {
return "active";
} else if ((today.after(endDate) && today.before(deleteDate))) {
return "disabled";
} else if (identity.getAttribute("legalHold").equals("Y") || identity.getAttribute("cloudLifecycleState").equals("immediatetermination")){
return identity.getAttribute("cloudLifecycleState");
} else if (today.equals(deleteDate) || today.after(deleteDate)) {
return "delete";
}
// If we haven't calculated a state already, return inactive.
return "inactive";
]]></Source>
</Rule>
Can anyone suggest me how to fix this issue