Search in sources :

Example 56 with ProcessResult

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

Example 57 with ProcessResult

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;
}
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 58 with ProcessResult

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

Example 59 with ProcessResult

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

Example 60 with ProcessResult

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

Aggregations

ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)165 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)132 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)31 User (com.serotonin.m2m2.vo.User)31 ArrayList (java.util.ArrayList)28 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)27 JsonException (com.serotonin.json.JsonException)21 TranslatableJsonException (com.serotonin.m2m2.i18n.TranslatableJsonException)20 JsonObject (com.serotonin.json.type.JsonObject)13 HashMap (java.util.HashMap)12 DuplicateKeyException (org.springframework.dao.DuplicateKeyException)11 StringStringPair (com.serotonin.db.pair.StringStringPair)9 RestProcessResult (com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult)9 IOException (java.io.IOException)9 ShouldNeverHappenException (com.serotonin.ShouldNeverHappenException)8 ProcessMessage (com.serotonin.m2m2.i18n.ProcessMessage)8 AbstractVO (com.serotonin.m2m2.vo.AbstractVO)8 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)8 SystemSettingsDao (com.serotonin.m2m2.db.dao.SystemSettingsDao)7 PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)7