bjarcilla
(Bill Joseph Arcilla)
1
Have you encountered this error? This is working before and the error specifically points from <
Full Code
import sailpoint.object.Identity;
import sailpoint.object.Link;
import sailpoint.object.ProvisioningPlan;
import sailpoint.object.ProvisioningPlan.AccountRequest;
import sailpoint.object.ProvisioningPlan.AttributeRequest;
import sailpoint.object.ProvisioningPlan.Operation;
import sailpoint.tools.GeneralException;
import sailpoint.tools.Util;
import sailpoint.api.IdentityService;
import sailpoint.api.SailPointContext;
import org.apache.log4j.Logger;
Logger logger = Logger.getLogger("com.company.rule");
if(logger.isDebugEnabled()) {
logger.debug("-------------Started Before Provisioning Rule-------------");
}
try{
String requesterName=null;
List ars = plan.getAccountRequests();
for(int i = 0; i < ars.size(); i++){
AccountRequest ar = ars.get(i);
if (!AccountRequest.Operation.Delete.equals(ar.getOperation())) {
continue;
}
Identity identity = plan.getIdentity();
IdentityService idService = new IdentityService(context);
if(identity==null){
continue;
}
List applicationLinks = idService.getLinks(identity,application);
if (applicationLinks.isEmpty()) {
continue;
}
Link applicationLink = applicationLinks.get(0);
if(applicationLink==null || (!applicationLink.getApplicationName().equals(application.getName()) && applicationLink.getAttribute("entitlement")==null)){
continue;
}
requesterName = plan.get("requester");
ar.add(new AttributeRequest("requester",ProvisioningPlan.Operation.Add,plan.get("requester")));
ar.add(new AttributeRequest("entitlement",ProvisioningPlan.Operation.Remove,applicationLink.getAttribute("entitlement")));
break;
}
}
catch (IOException exception) {
logger.debug("Exception In Before Provisioning Rule: " + exception.getMessage());
throw exception;
}
logger.debug("-------------Exited Before Provisioning Rule-------------");
Hi @bjarcilla,
can you try this?
import sailpoint.object.Identity;
import sailpoint.object.Link;
import sailpoint.object.ProvisioningPlan;
import sailpoint.object.ProvisioningPlan.AccountRequest;
import sailpoint.object.ProvisioningPlan.AttributeRequest;
import sailpoint.object.ProvisioningPlan.Operation;
import sailpoint.tools.GeneralException;
import sailpoint.tools.Util;
import sailpoint.api.IdentityService;
import sailpoint.api.SailPointContext;
import org.apache.log4j.Logger;
Logger logger = Logger.getLogger("com.company.rule");
if(logger.isDebugEnabled()) {
logger.debug("-------------Started Before Provisioning Rule-------------");
}
try{
for(AccountRequest ar : plan.getAccountRequests()){
if (!AccountRequest.Operation.Delete.equals(ar.getOperation())) {
continue;
}
Identity identity = plan.getIdentity();
if(identity==null){
continue;
}
IdentityService idService = new IdentityService(context);
List applicationLinks = idService.getLinks(identity,application);
if (applicationLinks.isEmpty()) {
continue;
}
Link applicationLink = applicationLinks.get(0);
if(applicationLink==null || (!applicationLink.getApplicationName().equals(application.getName()) && applicationLink.getAttribute("entitlement")==null)){
continue;
}
ar.add(new AttributeRequest("requester",ProvisioningPlan.Operation.Add,plan.get("requester")));
ar.add(new AttributeRequest("entitlement",ProvisioningPlan.Operation.Remove,applicationLink.getAttribute("entitlement")));
break;
}
}
catch (Exception exception) {
logger.debug("Exception In Before Provisioning Rule: " + exception.getMessage());
}
logger.debug("-------------Exited Before Provisioning Rule-------------");
or this:
import sailpoint.object.Link;
import sailpoint.object.ProvisioningPlan;
import sailpoint.object.ProvisioningPlan.AccountRequest;
import sailpoint.object.ProvisioningPlan.AttributeRequest;
import sailpoint.object.ProvisioningPlan.Operation;
import sailpoint.tools.GeneralException;
import sailpoint.tools.Util;
import org.apache.log4j.Logger;
Logger logger = Logger.getLogger("com.company.rule");
if(logger.isDebugEnabled()) {
logger.debug("-------------Started Before Provisioning Rule-------------");
}
try{
for(AccountRequest ar : plan.getAccountRequests()){
if (!AccountRequest.Operation.Delete.equals(ar.getOperation())) {
continue;
}
Link lnk = context.getUniqueObject(Link.class,Filter.and(Filter.eq("application.name",application.getName()),Filter.eq("nativeIdentity",ar.getNativeIdentity())));
if(lnk == null && lnk.getAttribute("entitlement") == null){
continue;
}
ar.add(new AttributeRequest("requester",ProvisioningPlan.Operation.Add,plan.get("requester")));
ar.add(new AttributeRequest("entitlement",ProvisioningPlan.Operation.Remove,lnk.getAttribute("entitlement")));
break;
}
}
catch (Exception exception) {
logger.debug("Exception In Before Provisioning Rule: " + exception.getMessage());
}
logger.debug("-------------Exited Before Provisioning Rule-------------");
ps why dont you use a provisioning form on delete operation?
Why can’t you use enhanced for loop instead of regular legacy loop at line 27 just like
for (AccountRequest ar : ars) {
// user your ar for your code.
}
bjarcilla
(Bill Joseph Arcilla)
4
Hi, turns out the actual code is working, and the code that is causing the error is not updated in sailpoint. Anyway, thank you for your inputs!
1 Like
system
(system)
Closed
5
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.