Search in sources :

Example 6 with IMangoLifecycle

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

the class ModulesDwr method scheduleRestart.

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

Example 7 with IMangoLifecycle

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

the class CommonDataInterceptor method preHandle.

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
    request.setAttribute("availableLanguages", Common.getLanguages());
    request.setAttribute("lang", ControllerUtils.getLocale(request).getLanguage());
    // If database isn't ready we can't do this
    // TODO Maybe do this differently?
    IMangoLifecycle lifecycle = Providers.get(IMangoLifecycle.class);
    if (lifecycle.getStartupProgress() >= 100f) {
        request.setAttribute("instanceDescription", SystemSettingsDao.getValue(SystemSettingsDao.INSTANCE_DESCRIPTION));
        // Only output the site analytics if we are NOT on the system settings page
        if (!request.getRequestURL().toString().endsWith(ModuleRegistry.SYSTEM_SETTINGS_URL)) {
            request.setAttribute("siteAnalyticsHead", SystemSettingsDao.getValue(SystemSettingsDao.SITE_ANALYTICS_HEAD));
            request.setAttribute("siteAnalyticsBody", SystemSettingsDao.getValue(SystemSettingsDao.SITE_ANALYTICS_BODY));
        }
    }
    request.setAttribute("NEW_ID", Common.NEW_ID);
    request.setAttribute("lastUpgrade", Common.lastUpgrade);
    return true;
}
Also used : IMangoLifecycle(com.serotonin.m2m2.IMangoLifecycle)

Aggregations

IMangoLifecycle (com.serotonin.m2m2.IMangoLifecycle)7 ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)3 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)3 JsonException (com.serotonin.json.JsonException)1 JsonWriter (com.serotonin.json.JsonWriter)1 LicenseViolatedException (com.serotonin.m2m2.LicenseViolatedException)1 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 HashMap (java.util.HashMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 RequestDispatcher (javax.servlet.RequestDispatcher)1 ServletException (javax.servlet.ServletException)1 WebContext (org.directwebremoting.WebContext)1