Search in sources :

Example 51 with DwrPermission

use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.

the class MiscDwr method acknowledgeEvent.

@DwrPermission(anonymous = true)
public int acknowledgeEvent(int eventId) {
    User user = Common.getHttpUser();
    if (user != null) {
        Common.eventManager.acknowledgeEventById(eventId, Common.timer.currentTimeMillis(), user, null);
        resetLastAlarmLevelChange();
    }
    return eventId;
}
Also used : User(com.serotonin.m2m2.vo.User) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 52 with DwrPermission

use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.

the class MiscDwr method toggleUserMuted.

@DwrPermission(anonymous = true)
public boolean toggleUserMuted() {
    User user = Common.getHttpUser();
    if (user != null) {
        user.setMuted(!user.isMuted());
        UserDao.instance.saveMuted(user.getId(), user.isMuted());
        return user.isMuted();
    }
    return false;
}
Also used : User(com.serotonin.m2m2.vo.User) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 53 with DwrPermission

use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.

the class ModulesDwr method toggleDeletion.

@DwrPermission(admin = true)
public boolean toggleDeletion(String moduleName) {
    Module module = ModuleRegistry.getModule(moduleName);
    module.setMarkedForDeletion(!module.isMarkedForDeletion());
    return module.isMarkedForDeletion();
}
Also used : Module(com.serotonin.m2m2.module.Module) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 54 with DwrPermission

use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.

the class ModulesDwr method versionCheck.

@DwrPermission(admin = true)
public ProcessResult versionCheck() {
    ProcessResult result = new ProcessResult();
    if (UPGRADE_DOWNLOADER != null) {
        result.addData("error", Common.translate("modules.versionCheck.occupied"));
        return result;
    }
    try {
        JsonValue jsonResponse = getAvailableUpgrades();
        if (jsonResponse instanceof JsonString)
            result.addData("error", jsonResponse.toString());
        else {
            JsonObject root = jsonResponse.toJsonObject();
            result.addData("upgrades", root.get("upgrades").toNative());
            result.addData("newInstalls", root.get("newInstalls").toNative());
            if (root.containsKey("upgradesError"))
                result.addData("upgradesError", root.getString("upgradesError"));
            if (root.containsKey("updates")) {
                result.addData("updates", root.get("updates").toNative());
                result.addData("newInstalls-oldCore", root.get("newInstalls-oldCore").toNative());
            }
            if (root.containsKey("missingModules"))
                result.addData("missingModules", root.getJsonArray("missingModules").toNative());
        }
    } catch (UnknownHostException e) {
        LOG.error("", e);
        result.addData("unknownHost", e.getMessage());
    } catch (Exception e) {
        LOG.error("", e);
        result.addData("error", e.getMessage());
    }
    return result;
}
Also used : UnknownHostException(java.net.UnknownHostException) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) JsonValue(com.serotonin.json.type.JsonValue) JsonObject(com.serotonin.json.type.JsonObject) JsonString(com.serotonin.json.type.JsonString) JsonException(com.serotonin.json.JsonException) HttpException(org.apache.http.HttpException) ShouldNeverHappenException(com.serotonin.ShouldNeverHappenException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 55 with DwrPermission

use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.

the class ModulesDwr method monitorDownloads.

@DwrPermission(admin = true)
public static ProcessResult monitorDownloads() {
    ProcessResult result = new ProcessResult();
    synchronized (UPGRADE_DOWNLOADER_LOCK) {
        if (UPGRADE_DOWNLOADER == null && stage == UpgradeState.IDLE) {
            result.addGenericMessage("modules.versionCheck.notRunning");
            return result;
        }
        result.addData("finished", finished);
        result.addData("cancelled", cancelled);
        result.addData("restart", restart);
        if (error != null)
            result.addData("error", error);
        result.addData("stage", stage);
        result.addData("results", getUpgradeResults(Common.getTranslations()));
        if (finished)
            stage = UpgradeState.IDLE;
    }
    return result;
}
Also used : ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) 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