use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.
the class MailingListsDwr method saveMailingList.
@DwrPermission(admin = true)
public ProcessResult saveMailingList(int id, String xid, String name, int receiveAlarmEmails, List<RecipientListEntryBean> entryBeans, List<Integer> inactiveIntervals) {
ProcessResult response = new ProcessResult();
MailingListDao mailingListDao = MailingListDao.instance;
// Validate the given information. If there is a problem, return an appropriate error message.
MailingList ml = createMailingList(id, xid, name, receiveAlarmEmails, entryBeans);
ml.getInactiveIntervals().addAll(inactiveIntervals);
if (StringUtils.isBlank(xid))
response.addContextualMessage("xid", "validate.required");
else if (!mailingListDao.isXidUnique(xid, id))
response.addContextualMessage("xid", "validate.xidUsed");
ml.validate(response);
if (!response.getHasMessages()) {
// Save the mailing list
mailingListDao.saveMailingList(ml);
response.addData("mlId", ml.getId());
}
if (!AlarmLevels.CODES.isValidId(receiveAlarmEmails))
response.addContextualMessage("receiveAlarmEmails", "validate.invalidValue");
return response;
}
use of com.serotonin.m2m2.i18n.ProcessResult 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.i18n.ProcessResult 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;
}
use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.
the class AbstractBasicDwr method get.
/**
* Get a VO
* @param id
* @return
*/
@DwrPermission(user = true)
public ProcessResult get(int id) {
VO vo = dao.get(id);
ProcessResult response = new ProcessResult();
response.addData("vo", vo);
return response;
}
use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.
the class AbstractBasicDwr method dojoQuery.
/**
* Load a list of VOs
* @return
*/
@DwrPermission(user = true)
public ProcessResult dojoQuery(Map<String, String> query, List<SortOption> sort, Integer start, Integer count, boolean or) {
ProcessResult response = new ProcessResult();
ResultsWithTotal results = dao.dojoQuery(query, sort, start, count, or);
response.addData("list", results.getResults());
response.addData("total", results.getTotal());
return response;
}
Aggregations