Esempio n. 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;
 }
Esempio n. 2
0
 public static void readExtraItems(String s, ArrayList array) throws IOException {
   File file = new File(Platform.getRoot() + File.separator + "templates.view");
   if (!file.exists()) {
     return;
   }
   String as[] = file.list();
   if (as == null) {
     return;
   }
   for (int i = 0; i < as.length; i++) {
     File file1 = new File(file, as[i]);
     if (!file1.isDirectory()) {
       continue;
     }
     File file2 = new File(file1, s);
     if (!file2.exists()) {
       continue;
     }
     ArrayList array1 = FrameFile.readFromFile(file2.getAbsolutePath());
     for (int j = 0; j < array1.size(); j++) {
       HashMap hashmap = (HashMap) array1.get(j);
       String s1 = TextUtils.getValue(hashmap, "_id");
       s1 = file1.getName() + "-" + s1;
       hashmap.put("_id", s1);
       hashmap.put("_package", as[i]);
       array.add(hashmap);
     }
   }
 }
Esempio n. 3
0
  void loadAllPortalSiteViews() {
    Object obj = null;
    try {
      ArrayList array = FrameFile.readFromFile(PORTAL_SERVERS_CONFIG_PATH);
      for (int i = 1; i < array.size(); i++) {
        HashMap hashmap = (HashMap) array.get(i);
        loadPortalSiteView(hashmap);
      }

    } catch (IOException ioexception) {
      LogManager.log("Error", "Could not load portal servers file: " + PORTAL_SERVERS_CONFIG_PATH);
    }
  }
Esempio n. 4
0
  private static void refreshCache(String s, File file, ArrayList array) {
    try {
      ArrayList array1 = FrameFile.readFromFile(file.getAbsolutePath());
      for (int i = 1; i < array1.size(); i++) {
        HashMap hashmap = (HashMap) array1.get(i);
        array.add(hashmap);
      }

      readExtraItems(s, array);
    } catch (IOException ioexception) {
      LogManager.log("Error", "Error reading file: " + ioexception.getMessage());
    }
  }
Esempio n. 5
0
  private static void createHealthGroupList(String s) {
    if (groupIDsInHealth.contains(s)) {
      return;
    }
    groupIDsInHealth.add(s);
    String s1 = Platform.getRoot() + "/groups/";
    try {
      Array array = FrameFile.readFromFile(s1 + s + ".mg");
      for (int i = 1; i < array.size(); i++) {
        HashMap hashmap = (HashMap) array.at(i);
        String s2 = (String) hashmap.get("_class");
        if (s2 != null && s2.equals("SubGroup")) {
          createHealthGroupList((String) hashmap.get("_group"));
        }
      }

    } catch (IOException ioexception) {
      return;
    }
  }
Esempio n. 6
0
 /** CAUTION: Decompiled by hand. */
 private static void insureMinHealth() {
   try {
     Array array = FrameFile.readFromFile(Health.CheckCreateHealth());
     if (array.size() > 1) {
       return;
     } else {
       HashMap hashmap = new HashMap();
       String as[] = Health.getHealth().getTemplateList("administrator");
       if (as != null && as.length > 0 && as[0].length() > 0) {
         hashmap.put("_healthTemplateSet", as[0]);
         hashmap.put("_healthDisableLogging", "");
         getHealth().update(hashmap, "administrator");
       }
     }
   } catch (Exception exception) {
     LogManager.log(
         "error",
         "Couldn't add default health monitors to the Health subsystem. Got Error: "
             + exception.getMessage());
   }
 }
Esempio n. 7
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 "";
    }
  }