Code Examples

 

  • Sailpoint API  classes like :

import sailpoint.api.SailPointContext;
import sailpoint.connector.JDBCConnector; 

import sailpoint.object.Attributes;  
import sailpoint.object.Custom; 
import sailpoint.object.Filter; 
import sailpoint.object.Identity; 
import sailpoint.object.QueryOptions; 
import sailpoint.object.Policy; 
import sailpoint.object.PolicyViolation; 
import sailpoint.object.Link;

import sailpoint.object.Application;
import sailpoint.object.ProvisioningPlan;
import sailpoint.object.ProvisioningPlan.AccountRequest;
import sailpoint.object.ProvisioningPlan.AttributeRequest;
import sailpoint.object.ProvisioningPlan.PermissionRequest;
import sailpoint.object.ProvisioningResult;
import sailpoint.object.Schema; 

import sailpoint.tools.GeneralException; 
import sailpoint.tools.Message; 

import sailpoint.tools.xml.XMLObjectFactory;
import sailpoint.tools.Util;

 buildEmployeeTerminationDisablePlan

public static String LLP_Salesforce="LLP Salesforce";

  else if(idenLink.getApplicationName().equalsIgnoreCase(LLP_Salesforce))         {

            log.error("Inside SNOW link : ");

            accountRequestDisable.setApplication(LLP_Salesforce);

            accountRequestDisable.setOperation(AccountRequest.Operation.Disable);

            if(idenLink!=null)            {

              accountRequestDisable.setNativeIdentity(idenLink.getNativeIdentity());            }

            employeeTermiantionDisablePlan.add(accountRequestDisable);          }


buildEmployeeRehirePlan

else if(idenLink.getApplicationName().equalsIgnoreCase(LLP_Salesforce))        {

          if(idenLink.isDisabled())             {

            log.error("SNOW link disbled");

            accountRequestRehire.setNativeIdentity(idenLink.getNativeIdentity());

            accountRequestRehire.setApplication(LLP_Salesforce);

            accountRequestRehire.setOperation(AccountRequest.Operation.Enable);

            accountReqListRehire.add(accountRequestRehire);       }       }                                                                                                                                                                                                                                     

  String groupName = "CN=G_LLP_ECM-Users_HR_NL,OU=Groups,OU=ECM,OU=PRD,OU=Applications,OU=Central,DC=ds,DC=LLP,DC=com";

  QueryOptions queryOptions = new QueryOptions();

  Filter valueFilter = Filter.eq("value", groupName);

  Filter applicationFilter = Filter.eq("application.name", "LLP Active Directory");

  Filter combineFilter  = Filter.and(valueFilter, applicationFilter );

  queryOptions.addFilter(combineFilter);

  Iterator iterator = context.search(ManagedAttribute.class,queryOptions);

  if( null != iterator && iterator.hasNext()){

    ManagedAttribute accountGroup = (ManagedAttribute)iterator.next();

    accountGroup.setRequestable(false); 

    context.saveObject(accountGroup);

    context.commitTransaction();

  }

           List spUserList = new ArrayList();

    String appName = API_APP_ACTIVE_DIR;

  Application app = context.getObjectByName(Application.class, appName);

  QueryOptions queryOption = new QueryOptions();

  queryOption.addFilter(Filter.eq("application",app));

  Iterator it = context.search(Link.class,queryOption);

  if(it !=null)    {

    while(it.hasNext())       {

      Link link = (Link) it.next();

      if(link.getIdentity()!=null)         {

        if(link.getIdentity().getName()!=null)         {

          String userName =  link.getIdentity().getName();

          Identity identity = context.getObjectByName(Identity.class, userName);

          boolean inactive=identity.getAttribute("inactive");

          String lifecycleState=identity.getAttribute("API_LC_STATE");

          String termDate=identity.getAttribute("API_TERMINATIONDATE");

        

      boolean linkStatus = link.getAttribute(IIQDisabled);

              if(linkStatus)           {

                String daydiff = dateDiffForInactive(termDate);

                if(daydiff>0)                 {

                  spUserList.add(userName);

                  //setLifecycleState("INACTIVE", identity);

                  //launchWorkflow("API WF Lifecycle Inactive", identity.getName());                  }

Identity identity = context.getObjectByName(Identity.class, "E57491");

  boolean inactive=identity.getAttribute("inactive");

  String lifecycleState=identity.getAttribute("API_LC_STATE");

  String termDate=identity.getAttribute("API_TERMINATIONDATE");

//identity.setAttribute("name","SP10688");

  //context.saveObject(identity);

  //context.commitTransaction();

Link apiAD = identity.getLink(context.getObjectByName(Application.class, API_APP_ACTIVE_DIR));

   Logger logger = Logger.getLogger("com.LLP.api.iga.API WF Rule Library.provisionToAD");

/*public List getContractorBirthRightRole(Identity identity)    {

    List appLinks=identity.getLinks();

    log.error("Print identity app links: "+appLinks);

    String contractorLincenses;

    List contractorBirthRightGroupList=new ArrayList();

    contractorBirthRightGroupList.add(LLP_AD_O365_GROUP);

    for(Link idenLink : appLinks)      {

      log.error("Print identity links for idenity :"+idenLink);

      if(idenLink.getApplicationName().equalsIgnoreCase(LLP_CONTRACTOR_PORTAL))        {

        log.error("Inside contractor's contractor portal link");

        String title=idenLink.getAttribute("u_title");

        log.error("Print contractor title from CP app "+title);

        if(title!=null)

  

 <?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">

<Rule created="164580540" id="d1378c157e30403a5" language="beanshell" modified="16672153" name="Test Rule ">

  <ReferencedRules>

    <Reference class="sailpoint.object.Rule" id="d1378c1579111f0e817913512d260340" name="LLP Rule Library"/>

    <Reference class="sailpoint.object.Rule" id="d1378c1478ad13388178ad03d2e8004a" name="LLP Constants"/>

    <Reference class="sailpoint.object.Rule" id="d1378c1579a71c188179a78afe83007b" name="LLP Active Directory Rule Library"/>

  </ReferencedRules>

  <Source>

  import java.util.*;

  import sailpoint.object.*;

  import sailpoint.object.Identity;

  import sailpoint.object.Application;

  import sailpoint.object.Link;

  import sailpoint.object.Custom;

  import sailpoint.object.ProvisioningPlan;

  import sailpoint.object.ProvisioningPlan.AccountRequest;

  import sailpoint.object.ProvisioningPlan.AttributeRequest;

  import sailpoint.object.ProvisioningProject;

  import sailpoint.object.ProvisioningResult;

  import sailpoint.object.Filter;

  import sailpoint.object.QueryOptions;

  import sailpoint.object.ObjectConfig;

  import sailpoint.object.AttributeTarget;

import sailpoint.object.*;

  import sailpoint.api.*;

  import sailpoint.tools.*;

  import java.util.*;

  import java.lang.*;

  import org.apache.log4j.Logger;

EmailTemplate template = context.getObjectByName(EmailTemplate.class, tplName);
  System.out.println("Testingsys logs");
  if (null == template) {
    log.error("ERROR: could not find email template [ " + tplName + "]");
    return;     }

<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">

<Rule created="1389881057582" id="835181f9439af34401439b5de11f003a" language="beanshell" modified="1389958433279" name="JdbcProvRule" type="JDBCProvision">

  <Description>This rule is used by the JDBC connector to do provisioning of the data .</Description>

  <Signature returnType="ProvisioningResult">

    <Inputs>

      <Argument name="log">

        <Description>

          The log object associated with the SailPointContext.

        </Description>

 </Signature>

  <Source>

import java.util.Date;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.Statement;

if ( plan != null ) {

List accounts = plan.getAccountRequests();

System.out.println("accounts = accounts::"+accounts);

System.out.println("accounts = accounts size ::"+accounts.size());

if ( ( accounts != null ) &amp;&amp; ( accounts.size() > 0 ) ) {

for ( AccountRequest account : accounts ) {


if (AccountRequest.Operation.Create.equals(account.getOperation())) { //

System.out.println("Account Request Operation = Create");

// Here userID, first , last variable name should correspond to the Schema attributes of the application.

PreparedStatement statement = connection.prepareStatement("insert into USERTAB (USER_ID,FIRST_NAME,LAST_NAME,MGR) values (?,?,?,?)");

statement.setString(1, (String) account.getNativeIdentity());

statement.setString(2, getAttributeRequestValue(account, "FIRST_NAME"));

statement.setString(3, getAttributeRequestValue(account, "LAST_NAME"));

// in provisioning policy  return identity.getManager().displayName;

statement.setObject(4, getAttributeRequestValue(account, "MGR"));

System.out.println("Preparing to execute: " + statement);

statement.executeUpdate();

// Sucessful Create, so mark result as COMMITTED

result.setStatus(ProvisioningResult.STATUS_COMMITTED);


      <?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE Workflow PUBLIC "sailpoint.dtd" "sailpoint.dtd">

<Workflow  explicitTransitions="true"  libraries="Identity"  name="Birthright_WF_ldap" type="IdentityLifecycle">

    <Variable input="true" name="trigger"/>

<Variable input="true" name="event"/>      

    <Variable input="true" name="identityName"/>a

    <Variable initializer="string:AccountsRequest" input="true" name="flow"/>     

     <Variable initializer="string:LCM" input="true" name="source">

</Variable>

    <Variable name="plan"/>

    <Variable initializer="string:true" input="true" name="trace"/>     

    <Variable name="project"/> 

  <Variable initializer="script:(identityDisplayName != void) ? identityDisplayName : resolveDisplayName(identityName)" input="true" name=   "identityDisplayName">      

    </Variable>

<Step  name="Start" posX="2 8 " posY="10" wait="1">

   <Script>

      <Source>

       import org.apache.log4j.Logger;

        import org.apache.log4j.Level;

        import sailpoint.tools.Util;

Logger log = Logger.getLogger("Enter Birthright Plan* start step 333333333333333333333 :::::::::::::");

log.info("  Welcome Birthright Plan  ******start*********");

 </Source>

  </Script>

   <Transition to="Create Birthright Plan"/>

</Step>

<Step  name="Create Birthright Plan" posX="174" posY="9" resultVariable="plan">      

<Script>

      <Source>


         import sailpoint.object.ProvisioningPlan;

         import sailpoint.object.ProvisioningPlan.AccountRequest;

         import sailpoint.object.ProvisioningPlan.AttributeRequest;

         import java.util.List;

         import java.util.ArrayList;

         import sailpoint.object.Application;

         import sailpoint.object.Link;

import sailpoint.object.Attributes;

import org.apache.log4j.Logger;

        import org.apache.log4j.Level;

        import sailpoint.tools.Util;

Logger log = Logger.getLogger("Create Birthright Plan* :::");

log.info("  Create Birthright Plan  ***************");

         ProvisioningPlan plan = new ProvisioningPlan();

         Identity identityObject = context.getObjectByName(Identity.class, identityName);

if (identityObject.getAttribute("buid").equals("114560")) {

         System.out.println("obj..............."+identityObject);

log.info("obj..............."+identityObject);

System.out.println("name........."+identityName);

log.info("name....BR....."+identityName);

         List accountRequests = new ArrayList();

         AccountRequest accountRequest = new AccountRequest();

         accountRequest.setOperation(AccountRequest.Operation.Create);

         accountRequest.setApplication("UserInfo App");

         Link link = identityObject.getLink(context.getObjectByName(Application.class, "HRApp"));

         String buid = link.getAttribute("buid");

         String ssoId = link.getAttribute("ssoId");

         String firstName = link.getAttribute("firstName");

         String lastName = link.getAttribute("lastName");

         System.out.println("buid:............from birthright..... " +buid);

         System.out.println("ssoId:..." +ssoId);

         System.out.println("firstName......:" +firstName);

           log.info("buid:............from birthright..... " +buid);

           log.info("ssoId:..." +ssoId);

           log.info("firstName......:" +firstName);

            log.info("lastName......:" +lastName);    

        // accountRequest.add(new AttributeRequest("FIRST_NAME",event.getObject().getFirstname()));

       //  accountRequest.add(new AttributeRequest("sn",event.getObject().getLastname()));

         accountRequest.add(new AttributeRequest("FIRST_NAME",firstName));

         accountRequest.add(new AttributeRequest("USER_ID",ssoId));

         accountRequest.add(new AttributeRequest("LAST_NAME",lastName));

        // accountRequest.add(new AttributeRequest("mail",identityObject.getEmail()));     

         accountRequest.setNativeIdentity(ssoId);

          accountRequests.add(accountRequest);

         plan.setAccountRequests(accountRequests);

         plan.setIdentity(identityObject);

         //System.out.println("givenName"+event.getObject().getFirstname());

         //System.out.println("DN:...." +DN);

         System.out.println("obj..............."+identityObject);

         System.out.println("View PLAN    " + plan.toXml());

  log.info("View PLAN ****************************************           " + plan.toXml());

   log.debug("Plan = " + plan.toXml());  } 

   else {  

   log.debug("No Birth right ... NOP.");       }

         return plan;

    </Source>

  </Script>

    <Transition to="Compile Project"/>

  </Step>

  <Step action="call:compileProvisioningProject" name="Compile Project" posX="406" posY="10" resultVariable="project">

<Arg name="identityName" value="ref:identityName"/>

<Arg name="plan" value="ref:plan"/>

<Arg name="requester" value="string:spadmin"/>

<Arg name="source" value="string:UI"/>

<Arg name="optimisticProvisioning" value="string:false"/>

<Arg name="requireCreateTemplates" value="string:false"/>

<Arg name="noApplicationTemplates" value="string:true"/>

  <Transition to="Provision"/>

</Step>

<Step action="call:provisionProject" icon="Provision" name="Provision" posX="682" posY="10">

<Arg name="background" value="string:true"/>

<Arg name="project" value="ref:project"/>

<Description>Provision the project.</Description>

<Transition to="end"/>

</Step>

<Step  name="end" />

</Workflow>

   

   public ProvisioningPlan buildEmployeeTermiantionDisablePlan(String identityName)

  {

    log.error("Entering buildEmployeeTermiantionDisablePlan() for:" + identityName);

    ProvisioningPlan employeeTermiantionDisablePlan = new ProvisioningPlan();

    Identity identity=context.getObjectByName(Identity.class,identityName);

    List linkLists=new ArrayList();

    List accountReqListDisable = new ArrayList();

    String getDate;

    Date contractorTerminationDate = null;

    String DATE_FORMAT = "yyyy-MM-dd";

    long terminationDateLong;

Custom sapCustObj=context.getObjectByName(Custom.class,"LLP SAP Config Custom Object");


  if(identity!=null)
    {
      linkLists=identity.getLinks();
      log.error("Print links : "+linkLists);
      if(linkLists!=null)
      {
        for(Link idenLink:linkLists)
        {
          AccountRequest accountRequestDisable = new AccountRequest();
          log.error("Print link "+idenLink);


          if(idenLink.getApplicationName().equalsIgnoreCase(SERVICENOW_BPT))
          {
            log.error("Inside SNOW link : ");
            accountRequestDisable.setApplication(SERVICENOW_BPT);
            accountRequestDisable.setOperation(AccountRequest.Operation.Disable);
            if(idenLink!=null)
            {
              accountRequestDisable.setNativeIdentity(idenLink.getNativeIdentity());
            }
            employeeTermiantionDisablePlan.add(accountRequestDisable);

if(idenLink.getApplicationName().equalsIgnoreCase(AD_COKCCE))

          {

            log.error("disable ad cokecce");

            // log.error("disable operation for all ADs  : ");

            accountRequestDisable.setApplication(AD_COKCCE);

            accountRequestDisable.setOperation(AccountRequest.Operation.Disable);

            log.error("Print cokecce dn : "+idenLink.getAttribute("distinguishedName"));

            if(idenLink!=null)

            {

              accountRequestDisable.setNativeIdentity(idenLink.getNativeIdentity());

            }

            accountRequestDisable.add(new AttributeRequest("useraccountcontrol","514"));

            accountRequestDisable.add(new AttributeRequest("IIQDisabled","true"));

            accountRequestDisable.add(new AttributeRequest("accountExpires",dateInMillis));

            employeeTermiantionDisablePlan.add(accountRequestDisable);


 Link snowLinkIden= identity.getLink(context.getObjectByName(Application.class, SERVICENOW_BPT));

    Link LLPAdLinkIden= identity.getLink(context.getObjectByName(Application.class, LLP_ACTIVE_DIRECTORY));

    log.error("Print snow link of rehire identity: "+snowLinkIden);

    log.error("Print LLP ad link of rehire identity: "+LLPAdLinkIden);

    if(snowLinkIden==null)       {

      log.error("SNOw link is null");

      Map joinerMap = new HashMap();

      Map parentProvDetails = new HashMap();   

      String idenCountry=identity.getAttribute("country");

      String type=identity.getAttribute("type");   

 public String getApplicationAttribute(String identityName, String applicationName, String attributeName){

    log.trace("Entering getApplicationAttribute()");

    Identity identity = context.getObjectByName(Identity.class,identityName);

    if(null == identity){

      log.error("Identity:"+identityName+" not found");

      return null;    }

    Application application = context.getObjectByName(Application.class,applicationName);

    if(null == application){

      log.error("Application:"+applicationName+" not found");

      return null;    }

    IdentityService identityService = new IdentityService(context);

    List links = identityService.getLinks(identity, application);

    if(null == links || links.isEmpty()){

      log.error(applicatioName+ " account not found for "+identityName);

      return null;       }

    Link link = links.get(0);

    log.trace("Exiting getApplicationAttribute()");

    return link.getAttribute(attributeName);    }

public List getLLPAmatilBirthRightAdGroups(Identity identity)  {

    log.error("****Inside amatil LLP ad groups");

    List adAmatilBirthRightGroupList=new ArrayList();

    if(identity!=null)    {

      String idenLegacyRegion=identity.getAttribute(IDENTITY_AMATIL_COHORT);

      String idenCountry=identity.getAttribute("country");

      log.error("Print country :"+idenCountry);

      if(idenCountry!=null &amp;&amp; idenLegacyRegion!=null)      {

        log.error("identity country not null");

        String countrySpecAdGroup;

        Custom adGroupCustObj= context.getObjectByName(Custom.class,"LLP Country Specific LLP AD Groups Custom Object");

        if(adGroupCustObj!=null)        {

          countrySpecAdGroup=adGroupCustObj.get(idenCountry);

 adAmatilBirthRightGroupList.add(countrySpecAdGroup);
      
        adAmatilBirthRightGroupList.add("CN=G_LLP_AzureAssignment--API,OU=Groups,OU=Central,DC=ds,DC=LLP,DC=com");

        log.error("Print group list"+adAmatilBirthRightGroupList);
      }
    }
    return adAmatilBirthRightGroupList;


 public Link getIdentityAppLink(Identity identity, String applicationName)
  {
    List idenLinkLists=identity.getLinks();
    Link appLink;
    log.error("Identity name: "+identity);
    log.error("App name: "+applicationName);
    if(idenLinkLists!=null)    {
      for(Link idenLink : idenLinkLists)      {
        if(idenLink.getApplicationName().equalsIgnoreCase(applicationName))        {
          appLink=idenLink;
          break;          }      }
      return appLink;     }    }
 WorkflowLaunch wflaunch = new WorkflowLaunch();
        //Workflow wf = (Workflow) context.getObjectByName(Workflow.class,"LLP User Termination Disable Lifecycle Event Workflow");
        //Workflow wf = (Workflow) context.getObjectByName(Workflow.class,"LLP User Termination Deletion Lifecycle Event Workflow");
 wflaunch.setWorkflowName(wf.getName());
        wflaunch.setWorkflowRef(wf.getName());
        //wflaunch.setCaseName("Delete Amatil");
        wflaunch.setCaseName("Identity");
 Workflower workflower = new Workflower(context);
        WorkflowLaunch launch = workflower.launch(wflaunch);

 public static String provisionToAD(String strIdentity) 
  {
    Logger logger = Logger.getLogger("com.LLP.api.iga.API WF Rule Library.provisionToAD");


    String result;

    try {
      Identity identity = context.getObjectByName(Identity.class, strIdentity);
      ProvisioningPlan plan = new ProvisioningPlan();
      plan.setNativeIdentity(strIdentity);
      plan.setIdentity(identity);
      plan.setSourceName("spadmin");
       Link LLP_AD = identity.getLink(context.getObjectByName(Application.class, "LLP Active Directory"));
      AccountRequest accountRequest = new AccountRequest();
     //accountRequest.setApplication("API AD - CCAMATIL");
      accountRequest.setApplication("LLP Active Directory");
      accountRequest.setOperation(AccountRequest.Operation.Modify);
      accountRequest.setNativeIdentity(LLP_AD.getNativeIdentity());
      accountRequest.add(new AttributeRequest("sAMAccountName",ProvisioningPlan.Operation.Set,"SPE00004135"));
      accountRequest.add(new AttributeRequest("AC_NewName",ProvisioningPlan.Operation.Set,"SPE00004135"));
      plan.add(accountRequest);

      Provisioner provisioner = new Provisioner(context);
      provisioner.compile(plan);
      provisioner.execute();

      result = "SUCCESS";
    }
    catch (Exception e){
      logger.warn("Exception while provisioning to AD", e);
      result = "NULL";
    }

    logger.debug("exit: " + result);
    return result;
  }
  return provisionToAD("SP0004135");


 Identity identity = context.getObjectByName(Identity.class, "E50007491");
  boolean inactive=identity.getAttribute("inactive");
  String lifecycleState=identity.getAttribute("API_LC_STATE");
  String termDate=identity.getAttribute("API_TERMINATIONDATE");

  if(inactive!=null &amp;&amp; lifecycleState!=null &amp;&amp; termDate!=null)
  {
    if(inactive &amp;&amp; (lifecycleState.equalsIgnoreCase(API_EMP_STATUS_TERMINATED) ||lifecycleState.equalsIgnoreCase(API_EMP_STATUS_WITHDRAWN) ||lifecycleState.equalsIgnoreCase(API_EMP_STATUS_LEAVE) ||lifecycleState.equalsIgnoreCase(API_EMP_STATUS_NONACTIVE) ||lifecycleState.equalsIgnoreCase(API_EMP_STATUS_INACTIVE)))
    {
      Link apiAD = identity.getLink(context.getObjectByName(Application.class, API_APP_ACTIVE_DIR));
      if(apiAD!=null)
      {
        boolean linkStatus = apiAD.getAttribute(IIQDisabled);
        if(!linkStatus)
        {
          String daydiff = dateDiffForInactive(termDate);
          if(daydiff>0)
          {
            //setLifecycleState("INACTIVE", identity);
            launchWorkflow("API WF Lifecycle Inactive", identity.getName());             }

   IdentityRequest idReq = context.getObjectById(IdentityRequest.class, idReqId);
       logger.error("-----idReq----------"+idReq);


      identityRequestItemList = idReq.getItems();
        logger.error("-----identityRequestItemList----------"+identityRequestItemList);
      Iterator identityRequestItemListItr = identityRequestItemList.iterator();


      while(identityRequestItemListItr.hasNext()){
          logger.error("-----identityRequestItemListItr-------");

        IdentityRequestItem identityRequestItem = identityRequestItemListItr.next();


 import sailpoint.object.IdentityRequest;
  import sailpoint.api.SailPointContext;
  import sailpoint.object.Filter;
  import sailpoint.object.Custom;
  import sailpoint.object.QueryOptions;
  import sailpoint.object.ApprovalItem;
  import sailpoint.object.ApprovalSet;
  import sailpoint.object.Comment;
  import sailpoint.object.IdentityRequestItem;
  import sailpoint.object.WorkflowSummary.ApprovalSummary;
  import sailpoint.object.TaskResult;
  import sailpoint.object.Identity;
  import sailpoint.object.Attributes;
  import sailpoint.tools.Message;
  import sailpoint.tools.Util;
  import sailpoint.tools.GeneralException;
  import sailpoint.api.IdIterator;
  import java.util.List;
  import java.util.ArrayList;
  import java.util.Map;
  import java.util.HashMap;

  Logger logger = Logger.getLogger("LLP.rule.TEST");
  logger.error("---------IN----------------");
  /*
  List identityRequestItemList = new ArrayList();
  List accountRequestList = new ArrayList();

  QueryOptions qo = new QueryOptions();
  qo.add(Filter.eq("IdentityRequest.source", "LCM")); // All Identity Requests created from 'ServiceNow Service Portal Integration' will have source set to 'Service-Now'
 //qo.add(Filter.like("IdentityRequest.executionStatus", "Completed"));

  Iterator idReqs = context.search(IdentityRequest.class, qo, "id");
  System.out.println("-----------------------------");
  logger.error("-----idReqs----------"+idReqs);
  IdIterator itrIdReqs = new IdIterator(context, idReqs);
   logger.error("-----itrIdReqs----------"+itrIdReqs);

  if(itrIdReqs != null){

    while(itrIdReqs.hasNext()){

      String idReqId = (String) itrIdReqs.next();   

    logger.error("-----idReqId----------"+idReqId);

sp-init-custom.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE sailpoint PUBLIC 'sailpoint.dtd' 'sailpoint.dtd'>
<sailpoint>
  <ImportAction name='include' value='custom\Applications\Application-DDEP-SAP-BWP.xml'/>
  <ImportAction name='include' value='custom\Applications\Application-DDEP-SAP-CRP.xml'/> <ImportAction name='include' value='custom\Bundle\Bundle-DDEP-Portugal-Dynamic-DL-All-Portugal-Employees-BR.xml'/>
  <ImportAction name='include' value='custom\Rules\Rule-API-IGA-Constants.xml'/>
  <ImportAction name='include' value='custom\Rules\Rule-API-WF-Rule-Library.xml'/>
  <ImportAction name='include' value='custom\Rules\Rule-DDEP-Active-Directory-Rule-Library.xml'/>


 Identity managerIdentity = identity.getManager();
      if(null != managerIdentity){
        attributeValue = managerIdentity.getStringAttribute(attributeName);

public void sendProvisioningFailureNotification(String identityName, String appName, String errorMessage, String toAddress){

    log.error("Entering sendProvisioningFailureNotification()");
    String templateName = LLP_PROVISIOING_FAILURE_NOTIFICATION_TEMPLATE;
    Map args = new HashMap();
    List toAddresses = new ArrayList();

    args.put("identityName",identityName);
    args.put("appName",appName);
    args.put("errorMessage",errorMessage);
    args.put("identityRequestId",identityRequestId);
    toAddresses.add(toAddress);

    log.error("Print args: "+args);
    sendEmailFromRule(toAddresses,templateName,args); //Call method to send email
    log.error("Exiting sendProvisioningFailureNotification()");     }

 public void setJmlStatus(String identityName, String status)
  {
    log.error("Entering SetJmlStatus() for:" + identityName);
    Identity identity = context.getObjectByName(Identity.class,identityName);
    log.error("Print identity:" +identity);
    if(identity!=null)      {
      identity.setAttribute(IDENTITY_JML_STATUS,status);
      context.saveObject(identity);
      context.commitTransaction(); 
      log.trace("Exiting SetJmlStatus()");       }
    return;     }

public String getBusinessFunctionCodeName(String businessFuncVal)    {
    log.trace("Entering getBusinessFunctionCodeName for:"+ businessFuncVal);
    String businessFunctioncode="";
    Custom businessFncCustomObject = context.getObjectByName(Custom.class,"LLP Business function and Sub function Custom Object");
    if(businessFncCustomObject!=null)      {
      log.error("Print business func custom object: "+businessFncCustomObject);
      if(businessFncCustomObject.getList("BusinessUnit").get(0).get(businessFuncVal)!=null)      {
        businessFunctioncode= businessFncCustomObject.getList("BusinessUnit").get(0).get(businessFuncVal);

        log.trace("Business function code value: "+businessFunctioncode);        }
    }
    return businessFunctioncode;    }
/*Method to check provisioning Status is commited
  *
  *
  */
  public boolean isProvisioningCommitted(String applicationName){

    log.trace("Entering isProvisioningCommited() for:"+ applicationName);

    boolean committed = false;
    ProvisioningResult provisioningResult = getProvisioningResult(applicationName); //Get provisioning result from the project for specified application
    if(null != provisioningResult){
      String result  = provisioningResult.getStatus();
      if(result.equalsIgnoreCase(PROVISIONING_COMMITTED_STATUS)){ //Check if the committed status is true
        committed = true;
      }
    }

    log.trace("Exiting isProvisioningCommited()");
    return committed;
  }

 /*Method to check if an Identity has a link or account in a particular application
  *
  *
  */
  public boolean ifAccountExist(String identityName, String applicationName)
  {

    log.trace("Entering ifAccountExist(),identity:"+identityName+",Application:"+applicationName);
    boolean result = false;
    Filter filter = Filter.and(Filter.eq("identity.name",identityName),Filter.eq("application.name",applicationName));
    QueryOptions qo = new QueryOptions();
    qo.add(filter);

    Iterator it = context.search(Link.class,qo,"id");//Do context search to get the iterator
    if(it!=null)
    {
      if(it.hasNext()){
        result = true;
      }
      Util.flushIterator(it);
      log.trace("Exiting ifAccountExist(), result:"+result);
      return result;
    }
  }
 public String getDepartmentName(String departmentCode)
  {
    log.error("Inside department calculation method getDepartmentName ");
    String departmentName="";
    Custom departmentValueCustObj = context.getObjectByName(Custom.class,"LLP Department Custom Object");
    if(departmentValueCustObj!=null)
    {
      log.error("Print custom obj for department :"+departmentValueCustObj);
      if(departmentValueCustObj.get(departmentCode)!=null)
      {

        departmentName= departmentValueCustObj.get(departmentCode);
        log.error("Print dept name obtained : "+departmentName);
      }
    }

    return departmentName;
  }
public ProvisioningPlan buildEmployeeTermiantionDeletionPlan(String identityName)
  {

    log.error("Entering buildEmployeeTermiantionDeletionPlan() for:" + identityName);

    ProvisioningPlan employeeTermiantionDeletionPlan = new ProvisioningPlan();
    List accountReqListDelete = new ArrayList();
    //employeeTermiantionDeletionPlan.setNativeIdentity(identityName);

    Identity identity = context.getObjectByName(Identity.class,identityName);
    List idenLinkList=new ArrayList();

    idenLinkList=identity.getLinks();
    log.error("Print identity all links in delete plan");

    for(Link idenLink : idenLinkList)
    {
      AccountRequest accountRequestDelete = new AccountRequest();
      log.error("Print identity links inside deletion method : "+idenLink);
      log.error("Print iden links application type for deletion method: "+idenLink.getApplication().getType());
      if(idenLink.getApplication().getType().equalsIgnoreCase("Active Directory - Direct") &amp;&amp; !(idenLink.getApplicationName().equalsIgnoreCase(API_AD_AMATIL)))
      {

        log.error("Identity links are of AD type");
        String userAccControl=idenLink.getAttribute("userAccountControl");
        log.error("Print uer account control of the link : "+userAccControl);
        String idenTermDate=identity.getAttribute(IDENTITY_TERMINATION_DATE);
        log.error("Print iden termed date : "+idenTermDate);
        if(idenTermDate!=null &amp;&amp; userAccControl!=null &amp;&amp; (userAccControl.equalsIgnoreCase("514")||userAccControl.equalsIgnoreCase("546")))
        {

          log.error("iden term date not null and user account control is 514");
          String adDistinguishedName=getAdDn(identity,idenLink.getApplicationName());
          log.error("Print ad dns : "+adDistinguishedName);
          accountRequestDelete.setApplication(idenLink.getApplicationName());
          accountRequestDelete.setOperation(AccountRequest.Operation.Delete);
          accountRequestDelete.setNativeIdentity(idenLink.getNativeIdentity());
          accountReqListDelete.add(accountRequestDelete);

        }
      }

    }
    employeeTermiantionDeletionPlan.setIdentity(identity);
    employeeTermiantionDeletionPlan.setAccountRequests(accountReqListDelete);
    log.error("Print Delete plan ***"+employeeTermiantionDeletionPlan.toXml());
    log.error("Exiting employeeTermiantionDeletionPlan()");

    return employeeTermiantionDeletionPlan;
  }
public ProvisioningPlan buildEmployeeMoverPlan(String identityName)
  {


    log.trace("Entering buildEmployeeMoverPlan() for:" + identityName);
    ProvisioningPlan employeeMoverPlan = new ProvisioningPlan();
    List accountReqListMover = new ArrayList();
    List linkLists=new ArrayList();
List newLLPAdGrp=new ArrayList();

    //employeeMoverPlan.setNativeIdentity(identityName);
    // AccountRequest accountRequestMover = new AccountRequest();
    Identity identity = context.getObjectByName(Identity.class,identityName);
    log.error("Print identity : "+identity);

    if(identity!=null)
    {
      log.error("Identity not null");

      linkLists=identity.getLinks();
      log.error("Print links : "+linkLists);
      if(linkLists!=null)
      {
        for(Link idenLink:linkLists)
        {
          AccountRequest accountRequestMover = new AccountRequest();
          log.error("Print link "+idenLink);
          if(idenLink.getApplicationName().equalsIgnoreCase(AD_LLPCOKE))
          {
            //uncomment for Prod move
            String newIdenCokeCceAdOu=%%LLP_MOVER_COKECCE_DN%%;
            log.error("Print new identity cokecce OU : "+newIdenCokeCceAdOu);

            String oldIdenCokeCceAdOu=getAdDn(identity,AD_LLPCOKE);
            log.error("Print old LLP DN: "+oldIdenCokeCceAdOu);
            accountRequestMover.setNativeIdentity(oldIdenCokeCceAdOu);
            accountRequestMover.setApplication(AD_LLPCOKE);
            accountRequestMover.setOperation(AccountRequest.Operation.Modify);

            accountRequestMover.add(new AttributeRequest("AC_NewParent",ProvisioningPlan.Operation.Set,newIdenCokeCceAdOu));
            accountReqListMover.add(accountRequestMover);
          }
          else if(idenLink.getApplicationName().equalsIgnoreCase(AD_IBERIA))
          {
            //uncomment for Prod move
            String newIdenIberiaAdOu=%%LLP_MOVER_IBERIA_DN%%;
            log.error("Print new identity Iberia OU : "+newIdenIberiaAdOu);
            log.error("Identity has iberian link");

            String oldIdenIberiaAdOu=getAdDn(identity,AD_IBERIA);
            log.error("Print old iberia DN: "+oldIdenIberiaAdOu);
            accountRequestMover.setNativeIdentity(oldIdenIberiaAdOu);
            accountRequestMover.setApplication(AD_IBERIA);
            accountRequestMover.setOperation(AccountRequest.Operation.Modify);

            accountRequestMover.add(new AttributeRequest("AC_NewParent",ProvisioningPlan.Operation.Set,newIdenIberiaAdOu));
            accountReqListMover.add(accountRequestMover);
            log.error("Print iberia access request : "+accountRequestMover);
            log.error("Print iberia access request list  : "+accountReqListMover);
          }
          else if(idenLink.getApplicationName().equalsIgnoreCase(AD_GERMANY))
          {
            //uncomment for Prod move
            String newIdenGermanAdOu=%%LLP_MOVER_GERMANY_DN%%;
            log.error("Print new identity Germany OU : "+newIdenGermanAdOu);

            String oldIdenGermanAdOu=getAdDn(identity,AD_GERMANY);
            log.error("Print old German DN: "+oldIdenGermanAdOu);
            accountRequestMover.setNativeIdentity(oldIdenGermanAdOu);
            accountRequestMover.setApplication(AD_GERMANY);
            accountRequestMover.setOperation(AccountRequest.Operation.Modify);

            accountRequestMover.add(new AttributeRequest("AC_NewParent",ProvisioningPlan.Operation.Set,newIdenGermanAdOu));
            accountReqListMover.add(accountRequestMover);
          }

          else if(idenLink.getApplicationName().equalsIgnoreCase(AD_ICELAND))
          {
            //uncomment for Prod move
             String newIceLandAdOu=%%LLP_MOVER_ICELAND_DN%%;
            log.error("Print new identity Iceland OU : "+newIceLandAdOu);

            String oldIdenIceLandAdOu=getAdDn(identity,AD_ICELAND);
            log.error("Print old Iceland DN: "+oldIdenIceLandAdOu);
            accountRequestMover.setNativeIdentity(oldIdenIceLandAdOu);
            accountRequestMover.setApplication(AD_ICELAND);
            accountRequestMover.setOperation(AccountRequest.Operation.Modify);

            accountRequestMover.add(new AttributeRequest("AC_NewParent",ProvisioningPlan.Operation.Set,newIdenIceLandAdOu));
            accountReqListMover.add(accountRequestMover);
          }
          else if(idenLink.getApplicationName().equalsIgnoreCase(LLP_ACTIVE_DIRECTORY))
          {
            log.error(identityName+"has LLP ad account");

newLLPAdGrp=getNewBirthRightGroupOnMover(identityName);

            String newIdenLLPAdDn=%%LLP_MOVER_LLP_DN%%;
            log.error("Print inside mover LLP AD, new identity dn generated : "+newIdenLLPAdOu);
String newIdenLLPAdOu=newIdenLLPAdDn.substring(newIdenLLPAdDn.indexOf(",")+1);
            String oldIdenLLPAdOu=getAdDn(identity,LLP_ACTIVE_DIRECTORY);
            log.error("Print old LLP DN: "+oldIdenLLPAdOu);
            accountRequestMover.setNativeIdentity(oldIdenLLPAdOu);
            accountRequestMover.setApplication(LLP_ACTIVE_DIRECTORY);
            accountRequestMover.setOperation(AccountRequest.Operation.Modify);

            accountRequestMover.add(new AttributeRequest("AC_NewParent",ProvisioningPlan.Operation.Set,newIdenLLPAdOu));
  if(newLLPAdGrp!=null)
            {
              accountRequestMover.add(new AttributeRequest("memberOf",ProvisioningPlan.Operation.Set,newLLPAdGrp));
            }
            accountReqListMover.add(accountRequestMover);
          }
        }

        if(log.isDebugEnabled())
        {
          log.debug("Employee Mover Plan:"+employeeMoverPlan.toXml());
        }
        log.trace("Exiting buildEmployeeMoverPlan()");
        employeeMoverPlan.setIdentity(identity);
        employeeMoverPlan.setAccountRequests(accountReqListMover);

        log.error("Print Mover plan ***"+employeeMoverPlan.toXml());
        log.trace("Exiting buildEmployeeMoverPlan()");
        return employeeMoverPlan;
      }
    }

  }
linkLists=identity.getLinks();
    log.error("Print links : "+linkLists);
    if(linkLists!=null)
    {
      log.error("Inside if, link list not null, Rehire plan build");
      for(Link idenLink:linkLists)
      {

        log.error("Rehire plan build print idenLink: "+idenLink);
        AccountRequest accountRequestRehire = new AccountRequest();
        log.error("Print idenLink inside rehire plan: "+idenLink);
        if(idenLink.getApplicationName().equalsIgnoreCase(SERVICENOW_BPT))
        {
          if(idenLink.isDisabled())
          {
            log.error("SNOW link disbled");
            accountRequestRehire.setNativeIdentity(idenLink.getNativeIdentity());

            accountRequestRehire.setApplication(SERVICENOW_BPT);
            accountRequestRehire.setOperation(AccountRequest.Operation.Enable);
            accountReqListRehire.add(accountRequestRehire);
          }

        }

else if(idenLink.getApplicationName().equalsIgnoreCase(LLP_Salesforce))
        {
          if(idenLink.isDisabled())
          {
            log.error("SNOW link disbled");
            accountRequestRehire.setNativeIdentity(idenLink.getNativeIdentity());

            accountRequestRehire.setApplication(LLP_Salesforce);
            accountRequestRehire.setOperation(AccountRequest.Operation.Enable);
            accountReqListRehire.add(accountRequestRehire);
          }
        }
   else if(idenLink.getApplicationName().equalsIgnoreCase(LLP_ACTIVE_DIRECTORY))
        {
          if(idenLink.isDisabled())
          {
            String LLPDn=getAdDn(identity,LLP_ACTIVE_DIRECTORY);
            log.error("Print LLP ad current dN"+LLPDn);
            accountRequestRehire.setNativeIdentity(idenLink.getNativeIdentity());
            accountRequestRehire.setApplication(LLP_ACTIVE_DIRECTORY);
            accountRequestRehire.setOperation(AccountRequest.Operation.Enable);
            accountRequestRehire.add(new AttributeRequest("password",password));
            accountRequestRehire.add(new AttributeRequest("useraccountcontrol","512"));
            accountRequestRehire.add(new AttributeRequest("IIQDisabled","false"));
            accountRequestRehire.add(new AttributeRequest("accountExpires","0000000000000000"));
            accountReqListRehire.add(accountRequestRehire);
          }
        }



public ProvisioningPlan buildEmployeeTermiantionDisablePlan(String identityName)
  {
    log.error("Entering buildEmployeeTermiantionDisablePlan() for:" + identityName);
    ProvisioningPlan employeeTermiantionDisablePlan = new ProvisioningPlan();
    Identity identity=context.getObjectByName(Identity.class,identityName);
    List linkLists=new ArrayList();
    List accountReqListDisable = new ArrayList();
    String getDate;
    Date contractorTerminationDate = null;
    String DATE_FORMAT = "yyyy-MM-dd";
    long terminationDateLong;
    String dateInMillis;

    Custom sapCustObj=context.getObjectByName(Custom.class,"LLP SAP Config Custom Object");


    // String adAcctExpires=getADAccountExpires();
    log.error("Print current date : "+calculateCurrentDate());
    if(calculateCurrentDate()!=null)
    {
      log.error("date nt null");
      getDate=(String)calculateCurrentDate();
      log.error("Print current date inside employee termination disable plan: "+getDate);

    }
    //log.error("Print ad account expires : "+adAcctExpires);
    log.error("Print identity termination date outside if condition : "+getDate);
    SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT);
    contractorTerminationDate = (null != getDate &amp;&amp; !getDate.isEmpty()) ? formatter.parse(getDate) : null;
    log.error("Print term date parsed: "+contractorTerminationDate);
    if(null != contractorTerminationDate)
    {
      terminationDateLong=contractorTerminationDate.getTime();
      terminationDateLong = (terminationDateLong * 10000L) + 116444736000000000L;
      dateInMillis = String.valueOf(terminationDateLong);
      log.error("print date in miiie sec: "+dateInMillis);
    }
    log.error("print date in miiie sec: outside if condition: "+dateInMillis);

    if(identity!=null)
    {
      linkLists=identity.getLinks();
      log.error("Print links : "+linkLists);
      if(linkLists!=null)
      {
        for(Link idenLink:linkLists)
        {
          AccountRequest accountRequestDisable = new AccountRequest();
          log.error("Print link "+idenLink);


          if(idenLink.getApplicationName().equalsIgnoreCase(SERVICENOW_BPT))
          {
            log.error("Inside SNOW link : ");
            accountRequestDisable.setApplication(SERVICENOW_BPT);
            accountRequestDisable.setOperation(AccountRequest.Operation.Disable);
            if(idenLink!=null)
            {
              accountRequestDisable.setNativeIdentity(idenLink.getNativeIdentity());
            }
            employeeTermiantionDisablePlan.add(accountRequestDisable);
          }
    else if(idenLink.getApplicationName().equalsIgnoreCase(LLP_Salesforce))
          {
            log.error("Inside SNOW link : ");
            accountRequestDisable.setApplication(LLP_Salesforce);
            accountRequestDisable.setOperation(AccountRequest.Operation.Disable);
            if(idenLink!=null)
            {
              accountRequestDisable.setNativeIdentity(idenLink.getNativeIdentity());
            }
            employeeTermiantionDisablePlan.add(accountRequestDisable);
          }
  

          // if((idenLink.getApplication().getType().equalsIgnoreCase("Active Directory - Direct"))&amp;&amp; (!(idenLink.getApplicationName().equalsIgnoreCase(LLP_CONTRACTOR_PORTAL))))
          else if(idenLink.getApplicationName().equalsIgnoreCase(AD_LLPCOKE))
          {
            log.error("disable ad cokecce");
            // log.error("disable operation for all ADs  : ");
            accountRequestDisable.setApplication(AD_LLPCOKE);
            accountRequestDisable.setOperation(AccountRequest.Operation.Disable);
            log.error("Print cokecce dn : "+idenLink.getAttribute("distinguishedName"));
            if(idenLink!=null)
            {
              accountRequestDisable.setNativeIdentity(idenLink.getNativeIdentity());
            }
            accountRequestDisable.add(new AttributeRequest("useraccountcontrol","514"));
            accountRequestDisable.add(new AttributeRequest("IIQDisabled","true"));
            accountRequestDisable.add(new AttributeRequest("accountExpires",dateInMillis));
            employeeTermiantionDisablePlan.add(accountRequestDisable);
          }
          else if(idenLink.getApplicationName().equalsIgnoreCase(AD_IBERIA))
          {
            log.error("disable ad iberia");
            // log.error("disable operation for all ADs  : ");
            accountRequestDisable.setApplication(AD_IBERIA);
            accountRequestDisable.setOperation(AccountRequest.Operation.Disable);
            log.error("Print cokecce dn : "+idenLink.getAttribute("distinguishedName"));
            if(idenLink!=null)
              accountRequestDisable.setNativeIdentity(idenLink.getNativeIdentity());
            accountRequestDisable.add(new AttributeRequest("useraccountcontrol","514"));
            accountRequestDisable.add(new AttributeRequest("IIQDisabled","true"));
            accountRequestDisable.add(new AttributeRequest("accountExpires",dateInMillis));
            employeeTermiantionDisablePlan.add(accountRequestDisable);
          }

          else if(idenLink.getApplicationName().equalsIgnoreCase(AD_GERMANY))
          {
            log.error("disable ad cokecce");
            // log.error("disable operation for all ADs  : ");
            accountRequestDisable.setApplication(AD_GERMANY);
            accountRequestDisable.setOperation(AccountRequest.Operation.Disable);
            log.error("Print cokecce dn : "+idenLink.getAttribute("distinguishedName"));
            if(idenLink!=null)
            {
              accountRequestDisable.setNativeIdentity(idenLink.getNativeIdentity());
            }
            accountRequestDisable.add(new AttributeRequest("useraccountcontrol","514"));
            accountRequestDisable.add(new AttributeRequest("IIQDisabled","true"));
            accountRequestDisable.add(new AttributeRequest("accountExpires",dateInMillis));
            employeeTermiantionDisablePlan.add(accountRequestDisable);
          }

          else if(idenLink.getApplicationName().equalsIgnoreCase(AD_ICELAND))
          {
            log.error("disable ad cokecce");
            // log.error("disable operation for all ADs  : ");
            accountRequestDisable.setApplication(AD_ICELAND);
            accountRequestDisable.setOperation(AccountRequest.Operation.Disable);
            log.error("Print cokecce dn : "+idenLink.getAttribute("distinguishedName"));
            if(idenLink!=null)
              accountRequestDisable.setNativeIdentity(idenLink.getNativeIdentity());
            accountRequestDisable.add(new AttributeRequest("useraccountcontrol","514"));
            accountRequestDisable.add(new AttributeRequest("IIQDisabled","true"));
            accountRequestDisable.add(new AttributeRequest("accountExpires",dateInMillis));
            employeeTermiantionDisablePlan.add(accountRequestDisable);
          }
          else if(idenLink.getApplicationName().equalsIgnoreCase(LLP_ACTIVE_DIRECTORY))
          {
            log.error("disable ad cokecce");
            // log.error("disable operation for all ADs  : ");
            accountRequestDisable.setApplication(LLP_ACTIVE_DIRECTORY);
            accountRequestDisable.setOperation(AccountRequest.Operation.Disable);
            log.error("Print cokecce dn : "+idenLink.getAttribute("distinguishedName"));
            if(idenLink!=null)
            {
              accountRequestDisable.setNativeIdentity(idenLink.getNativeIdentity());
            }
            accountRequestDisable.add(new AttributeRequest("useraccountcontrol","514"));
            accountRequestDisable.add(new AttributeRequest("IIQDisabled","true"));
            accountRequestDisable.add(new AttributeRequest("accountExpires",dateInMillis));
            employeeTermiantionDisablePlan.add(accountRequestDisable);
          }

          else if(sapCustObj.get("REMOVE_ROLES").get(idenLink.getApplicationName())!=null)
          {
            log.error("SAP app disable");
            accountRequestDisable.setApplication(idenLink.getApplicationName());
            accountRequestDisable.setOperation(AccountRequest.Operation.Disable);
            accountRequestDisable.setNativeIdentity(idenLink.getNativeIdentity());
            employeeTermiantionDisablePlan.add(accountRequestDisable);
          }




        }
        AccountRequest accountRequestDisableIIQ = new AccountRequest();
        if(getDate!=null)
        {
          accountRequestDisableIIQ.setApplication("IIQ");
          accountRequestDisableIIQ.setOperation(AccountRequest.Operation.Modify);
          accountRequestDisableIIQ.setNativeIdentity(identityName);
          accountRequestDisableIIQ.add(new AttributeRequest(IDENTITY_TERMINATION_DATE,getDate));
          employeeTermiantionDisablePlan.add(accountRequestDisableIIQ);
        }


      }

      for (EntitlementGroup entGroup : identity.getExceptions())
      {
        String sapAppNameExists=sapCustObj.get("REMOVE_ROLES").get(entGroup.getApplicationName());
        if(sapAppNameExists!=null)
        {
          AccountRequest acctReqEnt = new AccountRequest(AccountRequest.Operation.Modify, entGroup.getApplicationName(), null, entGroup.getNativeIdentity());
          for (String attribute :entGroup.getAttributeNames())
          {
            AttributeRequest attReq = new AttributeRequest(attribute, ProvisioningPlan.Operation.Remove, entGroup.getAttributes().get(attribute));
            acctReqEnt.add(attReq);
          }
          employeeTermiantionDisablePlan.add(acctReqEnt);
        }

      }

      for (Bundle idenRole : identity.getBundles())
      {
        employeeTermiantionDisablePlan.add("IIQ", identityName, "assignedRoles", ProvisioningPlan.Operation.Remove, idenRole.getDisplayName());
      }
      employeeTermiantionDisablePlan.setIdentity(identity);
      //employeeTermiantionDisablePlan.setAccountRequests(accountReqListDisable);
      //  log.error("Print identity termination date : "+identity.getAttribute(IDENTITY_TERMINATION_DATE));
      return employeeTermiantionDisablePlan;
    }
  }
/*public List getContractorBirthRightRole(Identity identity)
  {
    List appLinks=identity.getLinks();
    log.error("Print identity app links: "+appLinks);
    String contractorLincenses;
    List contractorBirthRightGroupList=new ArrayList();
    contractorBirthRightGroupList.add(LLP_AD_O365_GROUP);
    for(Link idenLink : appLinks)
    {
      log.error("Print identity links for idenity :"+idenLink);
      if(idenLink.getApplicationName().equalsIgnoreCase(LLP_CONTRACTOR_PORTAL))
      {
        log.error("Inside contractor's contractor portal link");
        String title=idenLink.getAttribute("u_title");
        log.error("Print contractor title from CP app "+title);

        if(title!=null)
        {
          if(title.equalsIgnoreCase("Frontline Work"))
          {
            contractorLincenses="CN=G_LLP_AzureLicenseAssignment-MS3-Users,OU=Groups,OU=Central,DC=ds,DC=LLP,DC=com";

          }
          else if(title.equalsIgnoreCase("Factory Worker"))
          {
            contractorLincenses="CN=G_LLP_AzureLicenseAssignment-MS3-Users,OU=Groups,OU=Central,DC=ds,DC=LLP,DC=com";
          }
          else if(title.equalsIgnoreCase("Knowledge Worker"))
          {
            assetLicense="CN=G_LLP_AzureLicenseAssignment-MS3-Users,OU=Groups,OU=Central,DC=ds,DC=LLP,DC=com";
          }
        }

        log.error("Print assetLicense : "+assetLicense);
      }
    }
    contractorBirthRightGroupList.add(assetLicense);
    return contractorBirthRightGroupList;
  }*/

import sailpoint.api.Aggregator;
  import sailpoint.api.IdentityService;
  import sailpoint.tools.GeneralException;
  import sailpoint.tools.Util;
  import sailpoint.api.Workflower;

  import java.util.Date;
  import java.text.SimpleDateFormat;
  import java.sql.Connection;
  import java.sql.Statement;
  import java.sql.ResultSet;
  import javax.naming.ldap.*;
  import java.util.*;
  import java.lang.*;
  import sailpoint.object.Link;
  import java.text.SimpleDateFormat;
  import java.util.Date;
  import sailpoint.api.IdentityService;
  import java.util.Arrays;
  import java.lang.Object;
  import java.text.DateFormat;

public String calculateCurrentDate()
  {
    log.error("Method calculate current date");
    DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
    LocalDateTime now = LocalDateTime.now();
    return dtf.format(now);
    // log.error("Print current date calculated : "+date);
    // return date;
  }