import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import sailpoint.object.Filter;
import sailpoint.object.Identity;
import sailpoint.object.IdentitySnapshot;
import sailpoint.object.LinkSnapshot;
import sailpoint.object.ProvisioningPlan;
import sailpoint.object.ProvisioningPlan.AccountRequest;
import sailpoint.object.QueryOptions;
import sailpoint.tools.GeneralException;
public List<LinkSnapshot> getIdSnapshot(String identityName) throws GeneralException {
log.debug("Enter into the method : getIdSnapshot");
boolean checkSnapshot = false;
List<LinkSnapshot> linkSnap = new ArrayList<LinkSnapshot>();
QueryOptions qop = new QueryOptions();
qop.addFilter(Filter.eq("identityName", identityName));
qop.setOrderBy("created");
qop.setOrderAscending(false);
Iterator<IdentitySnapshot> it = context.search(IdentitySnapshot.class, qop);
checkSnapshot = it.hasNext();
if (checkSnapshot) {
IdentitySnapshot eachIdentitySnapshot = (IdentitySnapshot) it.next();
linkSnap = eachIdentitySnapshot.getLinks();
}
log.debug("Exiting from the method : getIdSnapshot");
return linkSnap;
}
public ProvisioningPlan buildPlanFromSnapshot(String identityName) throws GeneralException {
log.debug("Enter into the method : buildFromSnapshot");
ProvisioningPlan plan = new ProvisioningPlan();
Identity identity = context.getObjectByName(Identity.class, identityName);
if (plan != null) {
plan.setIdentity(identity);
}
List<LinkSnapshot> linkSnap = new ArrayList<LinkSnapshot>();
linkSnap = getIdSnapshot(identityName);
for (LinkSnapshot ls : linkSnap) {
if (ls.getAttributes().get("IIQDisabled") == null
|| ls.getAttributes().get("IIQDisabled").toString().equals("false")) {
AccountRequest accountRequest = new AccountRequest();
accountRequest.setApplication(ls.getApplicationName());
accountRequest.setInstance(ls.getInstance());
accountRequest.setNativeIdentity(ls.getNativeIdentity());
accountRequest.setOperation(AccountRequest.Operation.Create);
plan.add(accountRequest);
}
}
log.debug("Link plan : " + plan.toXml());
log.debug("Exiting from the method : buildPlanFromSnapshot");
return plan;
}