Search in sources :

Example 6 with EmailAddress

use of edu.stanford.bmir.protege.web.shared.user.EmailAddress in project webprotege by protegeproject.

the class EmailAddressReadConverterTestCase method convertShouldReturnEmailAddressWithAddressEqualToSuppliedAddress.

@Test
public void convertShouldReturnEmailAddressWithAddressEqualToSuppliedAddress() {
    EmailAddressReadConverter converter = new EmailAddressReadConverter();
    String suppliedAddress = "jane.doe@stanford.edu";
    EmailAddress convertedAddress = converter.convert(suppliedAddress);
    assertEquals(suppliedAddress, convertedAddress.getEmailAddress());
}
Also used : EmailAddress(edu.stanford.bmir.protege.web.shared.user.EmailAddress) Test(org.junit.Test)

Example 7 with EmailAddress

use of edu.stanford.bmir.protege.web.shared.user.EmailAddress 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

EmailAddress (edu.stanford.bmir.protege.web.shared.user.EmailAddress)7 Test (org.junit.Test)3 ApplicationSettings (edu.stanford.bmir.protege.web.shared.app.ApplicationSettings)2 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)2 Nonnull (javax.annotation.Nonnull)2 WebProtegeDialog (edu.stanford.bmir.protege.web.client.library.dlg.WebProtegeDialog)1 AccountCreationSetting (edu.stanford.bmir.protege.web.shared.app.AccountCreationSetting)1 ApplicationLocation (edu.stanford.bmir.protege.web.shared.app.ApplicationLocation)1 ProjectCreationSetting (edu.stanford.bmir.protege.web.shared.app.ProjectCreationSetting)1 ProjectUploadSetting (edu.stanford.bmir.protege.web.shared.app.ProjectUploadSetting)1 SetApplicationSettingsAction (edu.stanford.bmir.protege.web.shared.app.SetApplicationSettingsAction)1 SetEmailAddressAction (edu.stanford.bmir.protege.web.shared.mail.SetEmailAddressAction)1 SetEmailAddressResult (edu.stanford.bmir.protege.web.shared.mail.SetEmailAddressResult)1 Optional (java.util.Optional)1