예제 #1
0
  void savePreferences() {
    String s = "";
    try {
      jgl.HashMap hashmap = getMasterConfig();
      // add by hailong.yi 2008/8/20
      jgl.HashMap hashmapSave = new jgl.HashMap();

      String s1 = com.dragonflow.Page.portalGeneralPrefsPage.getValue(hashmap, "_httpPort");
      String s2 = request.getValue("httpPort").trim();
      if (!s1.equals(s2) && s2.length() > 0) {
        int i = com.dragonflow.Properties.StringProperty.toInteger(s2);
        if (i == 0) {
          s = s + "\tHTTP Port must be a number greater than 0";
        } else {
          try {
            java.net.ServerSocket serversocket = new ServerSocket(i);
            serversocket.close();
          } catch (java.io.IOException ioexception1) {
            s = s + "\tPort " + i + " could not be opened: " + ioexception1.getMessage();
          }
        }
      }
      String s3 = request.getValue("authorizedIP");
      if (s3.length() > 0 && !com.dragonflow.Utils.TextUtils.onlyChars(s3, "0123456789,.*")) {
        s = s + "\tThe IP Address allowed access contained illegal characters";
      }
      if (s3.length() == 0 && request.getValue("checkAddressAndLogin").length() > 0) {
        s =
            s
                + "\tTo enable <B>Require both IP address and Login</B> you must fill in authorized IP address(es)";
      }
      String s4 = request.getValue("license").trim();

      if (!com.dragonflow.Utils.LUtils.setLicenseKey(s4, hashmap, hashmapSave))
      //            if(!com.dragonflow.Utils.LUtils.setLicenseKey(s4, hashmap))
      {
        s = s + com.dragonflow.Utils.LUtils.getLicenseErrorString(s4);
      }
      /*            hashmap.put("_httpPort", s2);
                  hashmap.put("_authorizedIP", s3);
                  hashmap.put("_checkAddressAndLogin", request.getValue("checkAddressAndLogin"));
                  hashmap.put("_localeEnabled", request.getValue("localeEnabled"));
      */
      hashmapSave.put("_httpPort", s2);
      hashmapSave.put("_authorizedIP", s3);
      hashmapSave.put("_checkAddressAndLogin", request.getValue("checkAddressAndLogin"));
      hashmapSave.put("_localeEnabled", request.getValue("localeEnabled"));
      if (s.length() == 0) {
        // saveMasterConfig(hashmap);
        Config.configPut(hashmapSave);
        if (!s1.equals(s2)) {
          byte byte0 = 15;
          String s5 =
              "Waiting 15 seconds for "
                  + com.dragonflow.SiteView.Platform.productName
                  + "'s web server to restart...";
          if (s2.length() == 0) {
            s5 = "";
            byte0 = 0;
          } else if (s1.length() == 0) {
            s5 =
                "Waiting 15 seconds for "
                    + com.dragonflow.SiteView.Platform.productName
                    + "'s web server to start...";
          }
          String s6 =
              com.dragonflow.Page.portalGeneralPrefsPage.getValue(hashmap, "_webserverAddress");
          String s7 = "http://" + s6 + ":" + s2 + "/";
          printPreferencesSaved(s7, "<H2>Preferences have been saved</H2><P>" + s5, byte0);
        } else {
          printPreferencesSaved();
        }
      } else {
        printErrorPage(s);
      }
    } catch (Exception ioexception) {
      printError(
          "The preferences could not be saved", "master.config file could not be saved", "10");
    }
  }