use of com.serotonin.m2m2.db.dao.SystemSettingsDao in project ma-core-public by infiniteautomation.
the class SystemSettingsDwr method saveEmailSettings.
@DwrPermission(admin = true)
public ProcessResult saveEmailSettings(String host, int port, String from, String name, boolean auth, String username, String password, boolean tls, int contentType) {
ProcessResult response = new ProcessResult();
SystemSettingsDao systemSettingsDao = SystemSettingsDao.instance;
if (port < 0)
response.addContextualMessage(SystemSettingsDao.EMAIL_SMTP_PORT, "validate.cannotBeNegative");
if (!emailPattern.matcher(from).matches())
response.addContextualMessage(SystemSettingsDao.EMAIL_FROM_ADDRESS, "validate.invalidValue");
// If valid then save all
if (!response.getHasMessages()) {
systemSettingsDao.setValue(SystemSettingsDao.EMAIL_SMTP_HOST, host);
systemSettingsDao.setIntValue(SystemSettingsDao.EMAIL_SMTP_PORT, port);
systemSettingsDao.setValue(SystemSettingsDao.EMAIL_FROM_ADDRESS, from);
systemSettingsDao.setValue(SystemSettingsDao.EMAIL_FROM_NAME, name);
systemSettingsDao.setBooleanValue(SystemSettingsDao.EMAIL_AUTHORIZATION, auth);
systemSettingsDao.setValue(SystemSettingsDao.EMAIL_SMTP_USERNAME, username);
systemSettingsDao.setValue(SystemSettingsDao.EMAIL_SMTP_PASSWORD, password);
systemSettingsDao.setBooleanValue(SystemSettingsDao.EMAIL_TLS, tls);
systemSettingsDao.setIntValue(SystemSettingsDao.EMAIL_CONTENT_TYPE, contentType);
}
return response;
}
Aggregations