Search in sources :

Example 6 with ApplicationSettings

use of edu.stanford.bmir.protege.web.shared.app.ApplicationSettings 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)

Example 7 with ApplicationSettings

use of edu.stanford.bmir.protege.web.shared.app.ApplicationSettings in project webprotege by protegeproject.

the class ApplicationPreferencesManager_TestCase method shouldGetAccountCreationNotAllowed.

@Test
public void shouldGetAccountCreationNotAllowed() {
    ApplicationSettings applicationSettings = manager.getApplicationSettings();
    assertThat(applicationSettings.getAccountCreationSetting(), is(ACCOUNT_CREATION_NOT_ALLOWED));
}
Also used : ApplicationSettings(edu.stanford.bmir.protege.web.shared.app.ApplicationSettings) Test(org.junit.Test)

Example 8 with ApplicationSettings

use of edu.stanford.bmir.protege.web.shared.app.ApplicationSettings in project webprotege by protegeproject.

the class ApplicationPreferencesManager_TestCase method shouldGetProjectCreationNotAllowed.

@Test
public void shouldGetProjectCreationNotAllowed() {
    ApplicationSettings applicationSettings = manager.getApplicationSettings();
    assertThat(applicationSettings.getProjectCreationSetting(), is(EMPTY_PROJECT_CREATION_NOT_ALLOWED));
}
Also used : ApplicationSettings(edu.stanford.bmir.protege.web.shared.app.ApplicationSettings) Test(org.junit.Test)

Example 9 with ApplicationSettings

use of edu.stanford.bmir.protege.web.shared.app.ApplicationSettings in project webprotege by protegeproject.

the class ApplicationPreferencesManager_TestCase method shouldGetProjectUploadAllowed.

@Test
public void shouldGetProjectUploadAllowed() {
    when(accessManager.hasPermission(forAnySignedInUser(), ApplicationResource.get(), BuiltInAction.UPLOAD_PROJECT)).thenReturn(true);
    ApplicationSettings applicationSettings = manager.getApplicationSettings();
    assertThat(applicationSettings.getProjectUploadSetting(), is(PROJECT_UPLOAD_ALLOWED));
}
Also used : ApplicationSettings(edu.stanford.bmir.protege.web.shared.app.ApplicationSettings) Test(org.junit.Test)

Aggregations

ApplicationSettings (edu.stanford.bmir.protege.web.shared.app.ApplicationSettings)9 Test (org.junit.Test)7 EmailAddress (edu.stanford.bmir.protege.web.shared.user.EmailAddress)2 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 Nonnull (javax.annotation.Nonnull)1