Search in sources :

Example 1 with EmailAddress

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

the class ApplicationSettingsPresenter method applySettings.

private void applySettings() {
    ApplicationSettings applicationSettings = new ApplicationSettings(view.getApplicationName(), new EmailAddress(view.getSystemNotificationEmailAddress()), new ApplicationLocation(view.getScheme().name().toLowerCase(), getHostNameFromView(), getPathFromView(), getPortFromView()), view.isAccountCreationAllowed() ? ACCOUNT_CREATION_ALLOWED : ACCOUNT_CREATION_NOT_ALLOWED, Collections.emptyList(), view.isProjectCreationAllowed() ? EMPTY_PROJECT_CREATION_ALLOWED : EMPTY_PROJECT_CREATION_NOT_ALLOWED, Collections.emptyList(), view.isProjectUploadAllowed() ? PROJECT_UPLOAD_ALLOWED : PROJECT_UPLOAD_NOT_ALLOWED, Collections.emptyList(), view.isNotificationEmailsEnabled() ? SEND_NOTIFICATION_EMAILS : DO_NOT_SEND_NOTIFICATION_EMAILS, parseMaxUploadSize());
    dispatchServiceManager.execute(new SetApplicationSettingsAction(applicationSettings), result -> MessageBox.showMessage("Settings applied", "The application settings have successfully been applied"));
}
Also used : ApplicationSettings(edu.stanford.bmir.protege.web.shared.app.ApplicationSettings) SetApplicationSettingsAction(edu.stanford.bmir.protege.web.shared.app.SetApplicationSettingsAction) ApplicationLocation(edu.stanford.bmir.protege.web.shared.app.ApplicationLocation) EmailAddress(edu.stanford.bmir.protege.web.shared.user.EmailAddress)

Example 2 with EmailAddress

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

the class UserDetailsManagerImpl_TestCase method shouldGetUserIdByEmail.

@Test
public void shouldGetUserIdByEmail() {
    EmailAddress emailAddress = new EmailAddress(email);
    assertThat(userDetailsManagerImpl.getUserIdByEmailAddress(emailAddress), is(java.util.Optional.of(userId)));
}
Also used : EmailAddress(edu.stanford.bmir.protege.web.shared.user.EmailAddress) Test(org.junit.Test)

Example 3 with EmailAddress

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

the class EmailAddressWriteConverterTestCase method convertShoudldReturnStringEqualToSuppliedEmailAddress.

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

Example 4 with EmailAddress

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

the class ChangeEmailAddressPresenter method showDialog.

private void showDialog(Optional<EmailAddress> emailAddress) {
    final UserId userId = loggedInUserProvider.getCurrentUserId();
    ChangeEmailAddressDialogController controller = new ChangeEmailAddressDialogController();
    emailAddress.ifPresent(controller::setValue);
    controller.setDialogButtonHandler(DialogButton.OK, (data, closer) -> {
        if (data.isPresent()) {
            dispatchServiceManager.execute(new SetEmailAddressAction(userId, data.get().getEmailAddress()), result -> {
                if (result.getResult() == ADDRESS_ALREADY_EXISTS) {
                    MessageBox.showMessage("Address already taken", "The email address that you have specified is taken by another user.  " + "Please specify a different email address.");
                } else {
                    closer.hide();
                }
            });
        } else {
            MessageBox.showAlert("The specified email addresses do not match.");
        }
    });
    WebProtegeDialog<Optional<EmailAddress>> dlg = new WebProtegeDialog<Optional<EmailAddress>>(controller);
    dlg.setVisible(true);
}
Also used : Optional(java.util.Optional) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) WebProtegeDialog(edu.stanford.bmir.protege.web.client.library.dlg.WebProtegeDialog) SetEmailAddressAction(edu.stanford.bmir.protege.web.shared.mail.SetEmailAddressAction) EmailAddress(edu.stanford.bmir.protege.web.shared.user.EmailAddress)

Example 5 with EmailAddress

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

the class ApplicationSettingsManager method getApplicationSettings.

@Nonnull
public ApplicationSettings getApplicationSettings() {
    try {
        readLock.lock();
        ApplicationPreferences applicationPreferences = settingsStore.getApplicationPreferences();
        AccountCreationSetting accountCreationSetting;
        boolean canCreateAccounts = accessManager.hasPermission(forGuestUser(), ApplicationResource.get(), BuiltInAction.CREATE_ACCOUNT);
        if (canCreateAccounts) {
            accountCreationSetting = ACCOUNT_CREATION_ALLOWED;
        } else {
            accountCreationSetting = ACCOUNT_CREATION_NOT_ALLOWED;
        }
        ProjectCreationSetting projectCreationSetting;
        boolean canCreateEmptyProject = accessManager.hasPermission(forAnySignedInUser(), ApplicationResource.get(), CREATE_EMPTY_PROJECT);
        if (canCreateEmptyProject) {
            projectCreationSetting = EMPTY_PROJECT_CREATION_ALLOWED;
        } else {
            projectCreationSetting = EMPTY_PROJECT_CREATION_NOT_ALLOWED;
        }
        ProjectUploadSetting projectUploadSetting;
        boolean canUploadProject = accessManager.hasPermission(forAnySignedInUser(), ApplicationResource.get(), UPLOAD_PROJECT);
        if (canUploadProject) {
            projectUploadSetting = PROJECT_UPLOAD_ALLOWED;
        } else {
            projectUploadSetting = PROJECT_UPLOAD_NOT_ALLOWED;
        }
        return new ApplicationSettings(applicationPreferences.getApplicationName(), new EmailAddress(applicationPreferences.getSystemNotificationEmailAddress()), applicationPreferences.getApplicationLocation(), accountCreationSetting, ImmutableList.of(), projectCreationSetting, ImmutableList.of(), projectUploadSetting, ImmutableList.of(), SEND_NOTIFICATION_EMAILS, applicationPreferences.getMaxUploadSize());
    } finally {
        readLock.unlock();
    }
}
Also used : ProjectUploadSetting(edu.stanford.bmir.protege.web.shared.app.ProjectUploadSetting) ApplicationSettings(edu.stanford.bmir.protege.web.shared.app.ApplicationSettings) ProjectCreationSetting(edu.stanford.bmir.protege.web.shared.app.ProjectCreationSetting) EmailAddress(edu.stanford.bmir.protege.web.shared.user.EmailAddress) AccountCreationSetting(edu.stanford.bmir.protege.web.shared.app.AccountCreationSetting) 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