use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.
the class SystemSettingsDwr method saveChartSettings.
/**
* Save the Backup Settings to the DB.
*
* @param backupFileLocation
* @param backupPeriod
*/
@DwrPermission(admin = true)
public ProcessResult saveChartSettings(boolean allowAnonymousChartView) {
ProcessResult result = new ProcessResult();
SystemSettingsDao systemSettingsDao = SystemSettingsDao.instance;
systemSettingsDao.setBooleanValue(SystemSettingsDao.ALLOW_ANONYMOUS_CHART_VIEW, allowAnonymousChartView);
return result;
}
use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.
the class SystemSettingsDwr method purgeNow.
@DwrPermission(admin = true)
public void purgeNow() {
DataPurge dataPurge = new DataPurge();
dataPurge.execute(Common.timer.currentTimeMillis());
}
use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.
the class SystemSettingsDwr method saveThreadPoolSettings.
@DwrPermission(admin = true)
public ProcessResult saveThreadPoolSettings(int highPriorityCorePoolSize, int highPriorityMaxPoolSize, int medPriorityCorePoolSize, int lowPriorityCorePoolSize) {
ProcessResult response = new ProcessResult();
SystemSettingsDao systemSettingsDao = SystemSettingsDao.instance;
if (highPriorityCorePoolSize > 0) {
systemSettingsDao.setIntValue(SystemSettingsDao.HIGH_PRI_CORE_POOL_SIZE, highPriorityCorePoolSize);
} else {
response.addContextualMessage(SystemSettingsDao.HIGH_PRI_CORE_POOL_SIZE, "validate.greaterThanZero");
}
if (highPriorityMaxPoolSize < BackgroundProcessing.HIGH_PRI_MAX_POOL_SIZE_MIN) {
response.addContextualMessage(SystemSettingsDao.HIGH_PRI_MAX_POOL_SIZE, "validate.greaterThanOrEqualTo", BackgroundProcessing.HIGH_PRI_MAX_POOL_SIZE_MIN);
} else if (highPriorityMaxPoolSize < highPriorityCorePoolSize) {
response.addContextualMessage(SystemSettingsDao.HIGH_PRI_MAX_POOL_SIZE, "systemSettings.threadPools.validate.maxPoolMustBeGreaterThanCorePool");
} else {
systemSettingsDao.setIntValue(SystemSettingsDao.HIGH_PRI_MAX_POOL_SIZE, highPriorityMaxPoolSize);
}
// core pool thread is available
if (medPriorityCorePoolSize >= BackgroundProcessing.MED_PRI_MAX_POOL_SIZE_MIN) {
// Due to the pool type we should set these to the same values
systemSettingsDao.setIntValue(SystemSettingsDao.MED_PRI_CORE_POOL_SIZE, medPriorityCorePoolSize);
} else {
response.addContextualMessage(SystemSettingsDao.MED_PRI_CORE_POOL_SIZE, "validate.greaterThanOrEqualTo", BackgroundProcessing.MED_PRI_MAX_POOL_SIZE_MIN);
}
if (lowPriorityCorePoolSize >= BackgroundProcessing.LOW_PRI_MAX_POOL_SIZE_MIN) {
systemSettingsDao.setIntValue(SystemSettingsDao.LOW_PRI_CORE_POOL_SIZE, lowPriorityCorePoolSize);
} else {
response.addContextualMessage(SystemSettingsDao.LOW_PRI_CORE_POOL_SIZE, "validate.greaterThanOrEqualTo", BackgroundProcessing.LOW_PRI_MAX_POOL_SIZE_MIN);
}
return response;
}
use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.
the class SystemSettingsDwr method sendTestEmail.
@DwrPermission(admin = true)
public Map<String, Object> sendTestEmail(String host, int port, String from, String name, boolean auth, String username, String password, boolean tls, int contentType) {
// Save the settings
saveEmailSettings(host, port, from, name, auth, username, password, tls, contentType);
// Get the web context information
User user = Common.getHttpUser();
Map<String, Object> result = new HashMap<>();
try {
Translations translations = getTranslations();
Map<String, Object> model = new HashMap<>();
model.put("message", new TranslatableMessage("systemSettings.testEmail"));
MangoEmailContent cnt = new MangoEmailContent("testEmail", model, translations, translations.translate("ftl.testEmail"), Common.UTF8);
EmailWorkItem.queueEmail(user.getEmail(), cnt);
result.put("message", new TranslatableMessage("common.testEmailSent", user.getEmail()));
} catch (Exception e) {
result.put("exception", e.getMessage());
}
return result;
}
use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.
the class SystemSettingsDwr method saveSystemPermissions.
@DwrPermission(admin = true)
public void saveSystemPermissions(String datasource, List<StringStringPair> modulePermissions) {
SystemSettingsDao systemSettingsDao = SystemSettingsDao.instance;
systemSettingsDao.setValue(SystemSettingsDao.PERMISSION_DATASOURCE, datasource);
for (StringStringPair p : modulePermissions) {
// Don't allow saving the superadmin permission as it doesn't do anything it's hard coded
if (!p.getKey().equals(SuperadminPermissionDefinition.PERMISSION))
systemSettingsDao.setValue(p.getKey(), p.getValue());
}
}
Aggregations