import sailpoint.object.Filter;
import sailpoint.object.Identity;
import sailpoint.object.QueryOptions;
import sailpoint.tools.GeneralException;
import sailpoint.api.SailPointContext;
int count = 0;
String firstName = null;
String lastName = null;
String userName = null;
String email = null;
String domain = "@testMighty.com";
if (identity != null) {
if (identity.getFirstname() != null @and identity.getFirstname().equalsIgnoreCase("")
@and identity.getLastname() != null @and identity.getLastname().equalsIgnoreCase("")) {
firstName = identity.getFirstname();
lastName = identity.getLastname();
userName = firstName + "." + lastName;
email = userName + domain;
QueryOptions qo = new QueryOptions();
Filter filter = Filter.ignoreCase(Filter.like("email", email, Filter.MatchMode.START));
qo.addFilter(filter);
try {
count = context.countObjects(Identity.class, qo);
if (count != 0) {
email = userName + count + domain;
}
return email;
} catch (GeneralException e) {
System.out.println("GeneralException : " + e.getMessage());
}
} else {
System.out.println("Identity firstname is " + firstName);
System.out.println("Identity lastname is " + lastName);
}
} else {
System.out.println("Identity object is null");
}