@NotNull private Iterator<String> internalListOrphanedIdentities() { try { Iterator<SyncedIdentity> it = handler.listIdentities(userMgr); return Iterators.filter(Iterators.transform(it, new Function<SyncedIdentity, String>() { @Nullable @Override public String apply(@Nullable SyncedIdentity syncedIdentity) { if (syncedIdentity != null && isMyIDP(syncedIdentity)) { ExternalIdentityRef ref = syncedIdentity.getExternalIdRef(); try { ExternalIdentity extId = (ref == null) ? null : idp.getIdentity(ref); if (extId == null) { return syncedIdentity.getId(); } } catch (ExternalIdentityException e) { log.error("Error while fetching external identity {}", syncedIdentity, e); } } return null; } }), Predicates.notNull()); } catch (RepositoryException e) { log.error("Error while listing orphaned users", e); return Collections.emptyIterator(); } }
@Override protected void runTest() throws Exception { JackrabbitSession s = ((JackrabbitSession) systemLogin()); try { UserManager userManager = s.getUserManager(); Iterator<SyncedIdentity> it = syncHandler.listIdentities(userManager); while (it.hasNext()) { it.next(); } } finally { s.logout(); } } }
/** * @see SynchronizationMBean#syncAllUsers(boolean) */ @NotNull String[] syncAllUsers(boolean purge) { try { List<String> list = new ArrayList<>(); context.setKeepMissing(!purge) .setForceGroupSync(true) .setForceUserSync(true); Iterator<SyncedIdentity> it = handler.listIdentities(userMgr); List<SyncResult> results = new ArrayList<>(batchSize); while (it.hasNext()) { SyncedIdentity id = it.next(); if (isMyIDP(id)) { results = syncUser(id.getId(), false, results, list); } } commit(list, results, NO_BATCH_SIZE); return list.toArray(new String[0]); } catch (RepositoryException e) { throw new IllegalStateException("Error retrieving users for syncing", e); } }