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());
}
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);
}
}
Aggregations