Search in sources :

Example 81 with ProcessResult

use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.

the class ModulesDwr method scheduleShutdown.

@DwrPermission(admin = true)
public static ProcessResult scheduleShutdown() {
    ProcessResult result = new ProcessResult();
    synchronized (SHUTDOWN_TASK_LOCK) {
        if (SHUTDOWN_TASK == null) {
            long timeout = Common.getMillis(Common.TimePeriods.SECONDS, 10);
            // Ensure our lifecycle state is set to PRE_SHUTDOWN
            IMangoLifecycle lifecycle = Providers.get(IMangoLifecycle.class);
            SHUTDOWN_TASK = lifecycle.scheduleShutdown(timeout, false, Common.getHttpUser());
            // Get the redirect page
            result.addData("shutdownUri", "/shutdown.htm");
        } else {
            result.addData("message", Common.translate("modules.shutdownAlreadyScheduled"));
        }
    }
    return result;
}
Also used : ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) IMangoLifecycle(com.serotonin.m2m2.IMangoLifecycle) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 82 with ProcessResult

use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.

the class PublisherEditDwr method trySave.

protected ProcessResult trySave(PublisherVO<? extends PublishedPointVO> p) {
    ProcessResult response = new ProcessResult();
    p.validate(response);
    if (!response.getHasMessages()) {
        Common.runtimeManager.savePublisher(p);
        response.addData("id", p.getId());
    }
    return response;
}
Also used : ProcessResult(com.serotonin.m2m2.i18n.ProcessResult)

Example 83 with ProcessResult

use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.

the class PublisherListDwr method togglePublisher.

@DwrPermission(admin = true)
public ProcessResult togglePublisher(int publisherId) {
    ProcessResult response = new ProcessResult();
    PublisherVO<? extends PublishedPointVO> publisher = Common.runtimeManager.getPublisher(publisherId);
    publisher.setEnabled(!publisher.isEnabled());
    publisher.validate(response);
    if (!response.getHasMessages())
        Common.runtimeManager.savePublisher(publisher);
    else
        publisher.setEnabled(!publisher.isEnabled());
    response.addData("enabled", publisher.isEnabled());
    response.addData("id", publisherId);
    return response;
}
Also used : ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 84 with ProcessResult

use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.

the class StartupDwr method getStartupProgress.

@DwrPermission(anonymous = true)
public ProcessResult getStartupProgress(long since) {
    ProcessResult result = new ProcessResult();
    IMangoLifecycle lifecycle = Providers.get(IMangoLifecycle.class);
    float progress = lifecycle.getStartupProgress();
    float shutdownProgress = lifecycle.getShutdownProgress();
    List<String> messages = LoggingConsoleRT.instance.getMessagesSince(since);
    StringBuilder builder = new StringBuilder();
    for (String message : messages) {
        builder.append(message);
        builder.append("</br>");
    }
    result.addData("message", builder.toString());
    result.addData("startupProgress", progress);
    result.addData("shutdownProgress", shutdownProgress);
    result.addData("state", getLifecycleStateMessage(lifecycle.getLifecycleState()));
    if ((progress >= 100) && (shutdownProgress == 0)) {
        WebContext ctx = WebContextFactory.get();
        result.addData("startupUri", DefaultPagesDefinition.getLoginUri(ctx.getHttpServletRequest(), ctx.getHttpServletResponse()));
    }
    // Add the message to describe what process we are in
    if ((progress < 100) && (shutdownProgress == 0)) {
        result.addData("processMessage", this.translations.translate("startup.startingUp"));
    } else if ((shutdownProgress > 0) && (lifecycle.isRestarting())) {
        result.addData("processMessage", this.translations.translate("shutdown.restarting"));
    } else if (shutdownProgress > 0) {
        result.addData("processMessage", this.translations.translate("shutdown.shuttingDown"));
    }
    if ((progress == 100) && (shutdownProgress == 0)) {
        result.addData("processMessage", this.translations.translate("startup.state.running"));
    }
    return result;
}
Also used : WebContext(org.directwebremoting.WebContext) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) IMangoLifecycle(com.serotonin.m2m2.IMangoLifecycle) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 85 with ProcessResult

use of com.serotonin.m2m2.i18n.ProcessResult 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)

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