use of edu.stanford.bmir.protege.web.shared.mail.SetEmailAddressResult in project webprotege by protegeproject.
the class SetEmailAddressActionHandler method execute.
@Nonnull
@Override
public SetEmailAddressResult execute(@Nonnull SetEmailAddressAction action, @Nonnull ExecutionContext executionContext) {
String emailAddress = action.getEmailAddress();
Optional<UserId> userId = userDetailsManager.getUserIdByEmailAddress(new EmailAddress(emailAddress));
if (userId.isPresent()) {
if (userId.get().equals(action.getUserId())) {
// Same user, same address
return new SetEmailAddressResult(ADDRESS_UNCHANGED);
} else {
// Already exists
return new SetEmailAddressResult(ADDRESS_ALREADY_EXISTS);
}
} else {
userDetailsManager.setEmail(action.getUserId(), emailAddress);
return new SetEmailAddressResult(ADDRESS_CHANGED);
}
}
Aggregations