/**
  * @param name
  * @param conf
  * @throws IOException
  */
 public void replaceGlobalConfigurations(String name, SeleniumGlobalConfiguration conf)
     throws IOException {
   validateAdmin();
   removeGlobalConfigurations(name, false);
   configurations.add(conf);
   PluginImpl.getPlugin().save();
 }
 public HttpResponse doRestart() throws IOException, ServletException {
   validateAdmin();
   try {
     channel.call(new StopHubCallable());
   } catch (Exception e) {
     throw new IOException(e);
   }
   channel.close();
   try {
     startHub();
     waitForHubLaunch();
   } catch (Exception e) {
     throw new IOException(e);
   }
   return HttpResponses.forwardToPreviousPage();
 }
  /**
   * @param req StaplerRequest
   * @param rsp StaplerResponse to redirect with
   * @throws IOException if redirection goes wrong
   */
  public void doCreate(StaplerRequest req, StaplerResponse rsp) throws Exception {
    validateAdmin();
    SeleniumGlobalConfiguration conf =
        req.bindJSON(SeleniumGlobalConfiguration.class, req.getSubmittedForm());
    if (null == conf.getName() || conf.getName().trim().equals("")) {
      throw new Failure("You must specify a name for the configuration");
    }

    if (PluginImpl.getPlugin().hasGlobalConfiguration(conf.getName())) {
      throw new Failure(
          "The configuration name you have chosen is already taken, please choose a unique name.");
    }

    PluginImpl.getPlugin().getGlobalConfigurations().add(conf);
    PluginImpl.getPlugin().save();
    rsp.sendRedirect2("configurations");
  }
 /**
  * @param req StaplerRequest
  * @param rsp StaplerResponse to redirect with
  * @throws IOException if redirection goes wrong
  */
 public void doAddRedirect(StaplerRequest req, StaplerResponse rsp) throws IOException {
   validateAdmin();
   rsp.sendRedirect2("add");
 }