Search in sources :

Example 1 with ApplicationLocation

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

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

the class ApplicationSettingsChecker method getConfigurationErrors.

/**
 * Gets a list of configuration error messages.
 * @return A list of configuration error messages.  If there are no configuration errors
 * then the list will be empty.
 */
@Nonnull
public List<String> getConfigurationErrors() {
    List<String> configurationErrors = new ArrayList<>();
    if (settings.getApplicationName().isEmpty()) {
        configurationErrors.add("Application name is not specified");
    }
    if (settings.getSystemNotificationEmailAddress().isEmpty()) {
        configurationErrors.add("System notification email address is not specified");
    }
    ApplicationLocation location = settings.getApplicationLocation();
    if (location.getHost().trim().isEmpty()) {
        configurationErrors.add("Application host is not specified");
    }
    if (location.getScheme().trim().isEmpty()) {
        configurationErrors.add("Application scheme (http(s)) is not specified");
    }
    try {
        placeUrl.getApplicationUrl();
    } catch (Exception e) {
        configurationErrors.add(String.format("Cannot construct well-formed application URL. (%s)", e.getMessage()));
    }
    try {
        placeUrl.getProjectUrl(ProjectId.get(UUID.randomUUID().toString()));
    } catch (Exception e) {
        configurationErrors.add(String.format("Cannot construct well-formed project URLs. (%s)", e.getMessage()));
    }
    try {
        placeUrl.getEntityUrl(ProjectId.get(UUID.randomUUID().toString()), DataFactory.getOWLThing());
    } catch (Exception e) {
        configurationErrors.add(String.format("Cannot construct well-formed OWL Entity URLs. (%s)", e.getMessage()));
    }
    configurationErrors.forEach(e -> logger.warn(e));
    return configurationErrors;
}
Also used : ArrayList(java.util.ArrayList) ApplicationLocation(edu.stanford.bmir.protege.web.shared.app.ApplicationLocation) Nonnull(javax.annotation.Nonnull)

Aggregations

ApplicationLocation (edu.stanford.bmir.protege.web.shared.app.ApplicationLocation)2 ApplicationSettings (edu.stanford.bmir.protege.web.shared.app.ApplicationSettings)1 SetApplicationSettingsAction (edu.stanford.bmir.protege.web.shared.app.SetApplicationSettingsAction)1 EmailAddress (edu.stanford.bmir.protege.web.shared.user.EmailAddress)1 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1