Search in sources :

Example 96 with DwrPermission

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;
}
Also used : ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) SystemSettingsDao(com.serotonin.m2m2.db.dao.SystemSettingsDao) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 97 with DwrPermission

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());
}
Also used : DataPurge(com.serotonin.m2m2.rt.maint.DataPurge) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 98 with DwrPermission

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;
}
Also used : ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) SystemSettingsDao(com.serotonin.m2m2.db.dao.SystemSettingsDao) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 99 with DwrPermission

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;
}
Also used : User(com.serotonin.m2m2.vo.User) HashMap(java.util.HashMap) MangoEmailContent(com.serotonin.m2m2.email.MangoEmailContent) TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage) Translations(com.serotonin.m2m2.i18n.Translations) InvalidArgumentException(com.serotonin.InvalidArgumentException) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 100 with DwrPermission

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());
    }
}
Also used : StringStringPair(com.serotonin.db.pair.StringStringPair) SystemSettingsDao(com.serotonin.m2m2.db.dao.SystemSettingsDao) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Aggregations

DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)220 ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)126 User (com.serotonin.m2m2.vo.User)56 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)47 ArrayList (java.util.ArrayList)35 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)24 HashMap (java.util.HashMap)21 StringStringPair (com.serotonin.db.pair.StringStringPair)11 SystemSettingsDao (com.serotonin.m2m2.db.dao.SystemSettingsDao)11 DuplicateKeyException (org.springframework.dao.DuplicateKeyException)10 IOException (java.io.IOException)9 DateTime (org.joda.time.DateTime)9 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)9 AbstractVO (com.serotonin.m2m2.vo.AbstractVO)8 AnonymousUser (com.serotonin.m2m2.vo.AnonymousUser)8 LinkedHashMap (java.util.LinkedHashMap)8 PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)7 ShareUser (com.serotonin.m2m2.view.ShareUser)7 ResultsWithTotal (com.serotonin.m2m2.db.dao.ResultsWithTotal)6 ReportVO (com.serotonin.m2m2.reports.vo.ReportVO)6