// TODO: The same method exists in EventFactory, find a common place for it private UserIdentity toUserIdentity(final PersonIdent who) { final UserIdentity u = new UserIdentity(); u.setName(who.getName()); u.setEmail(who.getEmailAddress()); u.setDate(new Timestamp(who.getWhen().getTime())); u.setTimeZone(who.getTimeZoneOffset()); // If only one account has access to this email address, select it // as the identity of the user. // final Set<Account.Id> a = byEmailCache.get(u.getEmail()); if (a.size() == 1) { u.setAccount(a.iterator().next()); } return u; }