Beispiel #1
0
 public static Array createHealthGroup() throws SiteViewParameterException {
   String s = Platform.getRoot() + File.separator + "groups" + File.separator + "__Health__.mg";
   File file = new File(s);
   Array array = null;
   if (!file.exists()) {
     array = new Array();
     HashMap hashmap = new HashMap();
     hashmap.put("_encoding", I18N.getDefaultEncoding());
     hashmap.put("_health", "true");
     hashmap.put("_dependsCondition", "good");
     hashmap.put("_fileEncoding", I18N.getDefaultEncoding());
     hashmap.put("_name", "Health");
     hashmap.put("_nextID", "1");
     array.add(hashmap);
     try {
       FrameFile.writeToFile(s, array);
     } catch (IOException ioexception1) {
       String as[] = {"__Health__.mg", ioexception1.getMessage()};
       throw new SiteViewParameterException(SiteViewErrorCodes.ERR_OP_SS_HEALTH_CANNOT_WRITE, as);
     }
   } else {
     try {
       array = FrameFile.readFromFile(s);
     } catch (IOException ioexception) {
       LogManager.log(
           "error", "Couldn't read the Health group. Got Error: " + ioexception.getMessage());
     }
   }
   return array;
 }
Beispiel #2
0
  public String update(HashMap hashmap, String s) throws SiteViewException {
    String s1 = (String) hashmap.get("_healthTemplateSet");
    String s2 = "";
    String s3 = "";
    int i = Machine.getOS("");
    String s4 = i != 1 ? "Unix" : "NT";
    if (!Platform.isStandardAccount(s)) {
      s2 =
          Platform.getRoot()
              + File.separator
              + "accounts"
              + File.separator
              + s
              + File.separator
              + "templates.health";
      if (!(new File(s2)).exists()) {
        s2 = Platform.getRoot() + File.separator + "templates.health";
      }
      s3 =
          Platform.getRoot()
              + File.separator
              + "accounts"
              + File.separator
              + s
              + File.separator
              + "groups";
      if (!(new File(s3)).exists()) {
        s3 = Platform.getRoot() + File.separator + "groups";
      }
    } else {
      s2 = Platform.getRoot() + File.separator + "templates.health";
      s3 = Platform.getRoot() + File.separator + "groups";
    }
    if (s1 != null && s1.length() > 0) {
      File file = new File(s2);
      String as[] = file.list();
      Array array = null;
      try {
        array = FrameFile.readFromFile(s3 + "/" + "__Health__.mg");
      } catch (IOException ioexception) {
      }
      if (array == null || array.size() == 0) {
        array = createHealthGroup();
        APISiteView.forceConfigurationRefresh();
      }
      Array array1 = null;
      try {
        array1 = FrameFile.readFromFile(s2 + "/" + s4 + s1);
      } catch (IOException ioexception1) {
        String as1[] = {ioexception1.getMessage()};
        throw new SiteViewParameterException(
            SiteViewErrorCodes.ERR_OP_SS_HEALTH_NO_TEMPLATE_FILE, as1);
      }
      if (array != null && array1 != null) {
        HashMap hashmap1 = (HashMap) array.at(0);
        String s5 = (String) hashmap1.get("_nextID");
        for (int j = 1; j < array1.size(); j++) {
          HashMap hashmap2 = (HashMap) array1.at(j);
          HashMap hashmap3 = new HashMap();
          hashmap3.put("_id", s5);
          String s6;
          for (Enumeration enumeration = hashmap2.keys();
              enumeration.hasMoreElements();
              hashmap3.put(s6, hashmap2.get(s6))) {
            s6 = (String) enumeration.nextElement();
          }

          array.add(hashmap3);
          s5 = TextUtils.increment(s5);
        }

        hashmap1.put("_nextID", s5);
        try {
          FrameFile.writeToFile(s3 + "/" + "__Health__.mg", array);
        } catch (IOException ioexception2) {
          String as2[] = {"__Health__.mg", ioexception2.getMessage()};
          throw new SiteViewParameterException(
              SiteViewErrorCodes.ERR_OP_SS_HEALTH_CANNOT_WRITE, as2);
        }
      }
      hashmap.remove("_healthTemplateSet");
      updateMaster(hashmap);
      APIGroup.forceConfigurationRefresh();
      return s1;
    } else {
      hashmap.remove("_healthTemplateSet");
      updateMaster(hashmap);
      APIGroup.forceConfigurationRefresh();
      return "";
    }
  }