java.lang.Object
net.i2p.router.web.helpers.ConfigRestartBean

public class ConfigRestartBeanextends Object
Simple helper to control restarts/shutdowns in the left hand nav.
  • Field Details

    • SET1

      private static final String[] SET1
      All these are tagged below so no need to _x them here. order is: form value, form class, display text.
    • SET2

      private static final String[] SET2
      Button labels shown to a basic-mode user.
    • SET3

      private static final String[] SET3
      Button labels shown to an advanced-mode user.
    • SET4

      private static final String[] SET4
      Button labels shown when the router may only stop.
    • PROP_ADVANCED

      private static final String PROP_ADVANCED
      Property selecting the advanced button set.
      See Also:
  • Constructor Details

    • ConfigRestartBean

      public ConfigRestartBean()
      Creates a bean; the container calls it with no arguments before rendering the nav.
  • Method Details

    • isAdvanced

      public static boolean isAdvanced()
      Check if advanced mode is enabled.
      Returns:
      true if advanced mode is enabled
    • renderStatus

      public static String renderStatus(String urlBase, String action, HttpSession session, String nextNonce, String nonce)
      This also initiates the restart/shutdown based on action.
      Parameters:
      urlBase - the base URL
      action - the action to perform
      session - the HTTP session
      nextNonce - the next nonce to output in the form
      nonce - the nonce to be validated for actions
      Returns:
      the rendered HTML
    • buttons

      private static void buttons(RouterContext ctx, StringBuilder buf, String url, String nonce, String[] s)
      Value,class,label,... triplets.
      Parameters:
      ctx - the router context used to translate the button labels
      buf - the HTML form is appended to
      url - the form's action URL
      nonce - the console nonce, added as a hidden field
      s - value,class,label,... triplets
    • isShuttingDown

      public static boolean isShuttingDown(RouterContext ctx)
      Check if the router is shutting down.
      Parameters:
      ctx - the router context
      Returns:
      true if shutting down
    • isRestarting

      public static boolean isRestarting(RouterContext ctx)
      Check if the router is restarting.
      Parameters:
      ctx - the router context
      Returns:
      true if restarting
    • getRestartTimeRemaining

      public static long getRestartTimeRemaining()
      This is for sidebar.jsp.
      Returns:
      the time remaining until restart
    • _t

      private static String _t(String s, RouterContext ctx)
      Translates a label using the router's language.
      Parameters:
      s - the text to translate
      ctx - the context holding the language
      Returns:
      the translated text
    • _t

      private static String _t(String s, Object o, RouterContext ctx)
      Translates a label with one argument substituted.
      Parameters:
      s - the text to translate
      o - the argument to substitute
      ctx - the context holding the language
      Returns:
      the translated text
    • ngettext

      private static String ngettext(String s, String p, int n, RouterContext ctx)
      Translate a string whose form depends on a count (ngettext).
      Parameters:
      s - the singular English text, also the lookup key
      p - the plural English text
      n - the count deciding which form is used
      ctx - the router context supplying the language
      Returns:
      the translated string for that count
    • formatDelay

      private static String formatDelay(int seconds)
      Format seconds as "1m 30s" or just "45s".
      Parameters:
      seconds - the delay to format, 0 or less is shown as "0s"
      Returns:
      the delay with an m and an s part, either omitted when it is zero