Search in sources :

Example 1 with SetEmailAddressResult

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);
    }
}
Also used : UserId(edu.stanford.bmir.protege.web.shared.user.UserId) EmailAddress(edu.stanford.bmir.protege.web.shared.user.EmailAddress) SetEmailAddressResult(edu.stanford.bmir.protege.web.shared.mail.SetEmailAddressResult) Nonnull(javax.annotation.Nonnull)

Aggregations

SetEmailAddressResult (edu.stanford.bmir.protege.web.shared.mail.SetEmailAddressResult)1 EmailAddress (edu.stanford.bmir.protege.web.shared.user.EmailAddress)1 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)1 Nonnull (javax.annotation.Nonnull)1