private void syncUser(@Nonnull ExternalUser user) throws SyncException {
SyncContext context = null;
try {
Root root = getRoot();
if (root == null) {
throw new SyncException("Cannot synchronize user. root == null");
}
UserManager userManager = getUserManager();
if (userManager == null) {
throw new SyncException("Cannot synchronize user. userManager == null");
}
DebugTimer timer = new DebugTimer();
context = syncHandler.createContext(idp, userManager, root);
context.sync(user);
timer.mark("sync");
root.commit();
timer.mark("commit");
if (log.isDebugEnabled()) {
log.debug("syncUser({}) {}", user.getId(), timer.getString());
}
} catch (CommitFailedException e) {
throw new SyncException("User synchronization failed during commit.", e);
} finally {
if (context != null) {
context.close();
}
}