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;
}
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;
}
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();
}
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;
}
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;
}
Aggregations