for (String externalId: externalIds) {
ExternalIdentityRef ref = ExternalIdentityRef.fromString(externalId);
try {
ExternalIdentity id = idp.getIdentity(ref);
if (id != null) {
SyncResult r = context.sync(id);
systemSession.save();
list.add(getJSONString(r));
} else {
SyncResult r = new SyncResultImpl(
new SyncedIdentityImpl("", ref, false, -1),
SyncResult.Status.NO_SUCH_IDENTITY
);
list.add(getJSONString(r));
}