Exemplo n.º 1
0
  private void startXmlElement(String s, jgl.HashMap hashmap) {
    boolean flag = false;
    java.util.Vector vector = null;
    xmlResponse.append("<" + s);
    if (hashmap != null) {
      java.util.Enumeration enumeration = hashmap.keys();
      while (enumeration.hasMoreElements()) {
        String s1 = enumeration.nextElement().toString();
        Object obj = hashmap.get(s1);
        if (obj instanceof String[]) {
          flag = true;
          if (vector == null) {
            vector = new Vector();
          }
          vector.addElement(s1);
        } else if (obj instanceof String) {
          if (com.dragonflow.Utils.I18N.isNullEncoding(obj.toString())) {
            xmlResponse.append(
                " "
                    + s1
                    + "=\""
                    + com.dragonflow.Utils.TextUtils.escapeHTML(
                        com.dragonflow.Utils.I18N.toDefaultEncoding(obj.toString()))
                    + "\"");
          } else {
            xmlResponse.append(
                " "
                    + s1
                    + "=\""
                    + com.dragonflow.Utils.TextUtils.escapeHTML(obj.toString())
                    + "\"");
          }
        }
      }
      xmlResponse.append(">\r\n");
      if (flag) {
        for (int i = 0; i < vector.size(); i++) {
          String s2 = (String) vector.elementAt(i);
          String as[] = (String[]) hashmap.get(s2);
          xmlResponse.append("<property>\r\n");
          xmlResponse.append(s2 + "\r\n");
          for (int j = 0; j < as.length; j++) {
            if (as[j] == null) {
              continue;
            }
            if (encodeValues) {
              String s3 = com.dragonflow.XmlApi.XmlApiRequestXML.escapeXML(as[j]);
              xmlResponse.append("<value>" + s3 + "</value>\r\n");
            } else {
              xmlResponse.append("<value>" + as[j] + "</value>\r\n");
            }
          }

          xmlResponse.append("</property>\r\n");
        }
      }
    }
  }
Exemplo n.º 2
0
  public static void saveMG(String groupId, Array data, String s, boolean flag, boolean flag1)
      throws Exception {

    Enumeration<?> enumeration = data.elements();
    while (enumeration.hasMoreElements()) {
      HashMap hashMap = (HashMap) enumeration.nextElement();

      // Object nextID =  hashMap.get("_nextID");
      // if (nextID == null) continue;
      saveGroup(groupId, FILENAME_EXT_MG, hashMap);
      break;
    }

    // enumeration = data.elements();
    List<String> subgroups = new ArrayList<String>();
    while (enumeration.hasMoreElements()) {
      HashMap hashMap = (HashMap) enumeration.nextElement();

      String _class = (String) hashMap.get("_class");
      if (_class == null) continue;
      if ("SubGroup".equals(_class)) {
        subgroups.add(TextUtils.getValue(hashMap, "_group"));
        continue;
      }
      Object id = getId(hashMap);
      if (id == null) continue;
      MonitorEntity.save(groupId, FILENAME_EXT_MG, (String) id, hashMap);
    }
    updateSubGroup(groupId, subgroups, FILENAME_EXT_MG);
  }
Exemplo n.º 3
0
 public String getUnitDisplayString(String s) {
   String s1 = (String) unitDisplayName.get(s);
   if (s1 == null) {
     return s;
   } else {
     return s1;
   }
 }
Exemplo n.º 4
0
 public Object getClassProperty(String s) {
   jgl.HashMap hashmap = getClassPropertyTable();
   if (hashmap == null) {
     return null;
   } else {
     return hashmap.get(s);
   }
 }
 public synchronized void resetFileTimeStamp(String s) {
   String s1 = (new File(s)).getAbsolutePath();
   Long long1 = (Long) fileNameMap.get(s1);
   if (long1 != null) {
     fileNameMap.remove(s1);
     fileNameMap.put(s1, new Long(0L));
   }
 }
Exemplo n.º 6
0
 jgl.Array getCustomCache(String s) {
   jgl.Array array = (jgl.Array) customCaches.get(s);
   if (array == null) {
     array = new Array();
     customCaches.put(s, array);
   }
   return array;
 }
Exemplo n.º 7
0
 static void resolveTemplateReferences(HashMap hashmap) {
   if (hashmap != null) {
     HashMap hashmap1;
     for (Enumeration enumeration = hashmap.keys();
         enumeration.hasMoreElements();
         resolveTemplateReferences(hashmap, hashmap1, 0, hashmap.size()))
       hashmap1 = (HashMap) hashmap.get(enumeration.nextElement());
   }
 }
Exemplo n.º 8
0
 protected void addToMonitorList(Monitor monitor, Array array, HashMap hashmap) {
   if (monitor == this) {
     return;
   }
   String s = monitor.getProperty(pGroupID) + " " + monitor.getProperty(pID);
   if (hashmap.get(s) == null) {
     hashmap.put(s, monitor);
     array.add(monitor);
   }
 }
Exemplo n.º 9
0
 public void flush() {
   flushsafe(logStatementCache, logCache);
   flushsafe(linkStatementCache, linkCache);
   for (Enumeration enumeration = customStatements.keys(); enumeration.hasMoreElements(); ) {
     String s = (String) enumeration.nextElement();
     java.sql.PreparedStatement preparedstatement =
         (java.sql.PreparedStatement) customStatements.get(s);
     jgl.Array array = (jgl.Array) customCaches.get(s);
     try {
       flushsafe(preparedstatement, array);
       COM.dragonflow.Log.LogManager.log("RunMonitor", "jdbc logger, flushed " + s);
     } catch (java.lang.Exception exception) {
       COM.dragonflow.Log.LogManager.log(
           "RunMonitor", "jdbc logger error, closing " + s + ", " + exception);
       COM.dragonflow.Log.LogManager.log(
           "Error", "jdbc logger error: closing " + s + ", " + exception);
     }
   }
 }
Exemplo n.º 10
0
  private void updateMaster(HashMap hashmap) {
    SiteViewGroup siteviewgroup = SiteViewGroup.currentSiteView();
    String s;
    for (Enumeration enumeration = hashmap.keys();
        enumeration.hasMoreElements();
        siteviewgroup.setProperty(s, (String) hashmap.get(s))) {
      s = (String) enumeration.nextElement();
    }

    siteviewgroup.saveSettings();
  }
Exemplo n.º 11
0
 public String getDisplayUnits() {
   if (displayUnits != null) {
     return displayUnits;
   }
   String s = (String) defaultDisplayUnits.get(units);
   if (s != null) {
     return s;
   } else {
     return units;
   }
 }
Exemplo n.º 12
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;
    }
  }
Exemplo n.º 13
0
  /**
   * CAUTION: Decompiled by hand.
   *
   * @param hashmap
   * @param hashmap1
   * @param i
   * @param j
   */
  static void resolveTemplateReferences(HashMap hashmap, HashMap hashmap1, int i, int j) {
    if (i > j) {
      LogManager.log("Error", "Loop detected in templates.config");
      return;
    }
    for (Enumeration enumeration = hashmap1.values("__template"); enumeration.hasMoreElements(); ) {
      String s = (String) enumeration.nextElement();
      HashMap hashmap2 = (HashMap) hashmap.get(s);
      if (hashmap2 != null) {
        resolveTemplateReferences(hashmap, hashmap2, i + 1, j);
        Enumeration enumeration1 = hashmap2.keys();
        while (enumeration1.hasMoreElements()) {
          String s1 = (String) enumeration1.nextElement();
          if (hashmap1.get(s1) == null) hashmap1.put(s1, hashmap2.get(s1));
        }
      }
    }

    hashmap1.remove("__template");
  }
Exemplo n.º 14
0
 public String convertValue(String s, String s1, String s2) throws IllegalConversionException {
   if (!s1.equals(s2)) {
     float f = StringProperty.toFloat(s);
     Float float1 = (Float) unitConversionTable.get(s1 + " to " + s2);
     if (float1 != null) {
       s = String.valueOf(f * float1.floatValue());
     } else {
       throw new IllegalConversionException();
     }
   }
   return s;
 }
Exemplo n.º 15
0
  void closeConnection() {
    COM.dragonflow.Log.LogManager.log("RunMonitor", "jdbc log, closing database connection");
    if (logStatementCache != null) {
      try {
        logStatementCache.close();
        logStatementCache = null;
      } catch (java.lang.Exception exception) {
        COM.dragonflow.Log.LogManager.log(
            "RunMonitor", "jdbc logger error: closing statement, " + exception);
        COM.dragonflow.Log.LogManager.log(
            "Error", "jdbc logger error: closing statement, " + exception);
      }
    }
    if (linkStatementCache != null) {
      try {
        linkStatementCache.close();
        linkStatementCache = null;
      } catch (java.lang.Exception exception1) {
        COM.dragonflow.Log.LogManager.log(
            "RunMonitor", "jdbc logger error: closing link statement, " + exception1);
        COM.dragonflow.Log.LogManager.log(
            "Error", "jdbc logger error: closing link statement, " + exception1);
      }
    }
    for (Enumeration enumeration = customStatements.keys(); enumeration.hasMoreElements(); ) {
      String s = (String) enumeration.nextElement();
      java.sql.PreparedStatement preparedstatement =
          (java.sql.PreparedStatement) customStatements.get(s);
      try {
        preparedstatement.close();
        customStatements.remove(s);
        COM.dragonflow.Log.LogManager.log("RunMonitor", "jdbc logger, closed " + s);
      } catch (java.lang.Exception exception3) {
        COM.dragonflow.Log.LogManager.log(
            "RunMonitor", "jdbc logger error, closing " + s + ", " + exception3);
        COM.dragonflow.Log.LogManager.log(
            "Error", "jdbc logger error: closing " + s + ", " + exception3);
      }
    }

    if (connection != null) {
      try {
        connection.close();
        connection = null;
      } catch (java.lang.Exception exception2) {
        COM.dragonflow.Log.LogManager.log(
            "RunMonitor", "jdbc logger error: closing, " + exception2);
        COM.dragonflow.Log.LogManager.log("Error", "jdbc logger error: closing, " + exception2);
      }
    }
    COM.dragonflow.Log.LogManager.log("RunMonitor", "jdbc log, closed");
  }
Exemplo n.º 16
0
 public Array getProperties(StringProperty stringproperty) throws NullPointerException {
   jgl.Array array = new Array();
   jgl.HashMap hashmap = findTable(stringproperty);
   if (hashmap != null) {
     Object obj = hashmap.get(stringproperty);
     if (obj != null && (obj instanceof Array)) {
       array = (Array) obj;
     } else if (obj != null) {
       array.add(obj);
     }
   }
   return array;
 }
Exemplo n.º 17
0
 void printForm(String s, jgl.Array array, jgl.HashMap hashmap) throws Exception {
   String s1 = "";
   String s2 = getMachineID();
   String s3 = com.dragonflow.Page.remoteBase.getSubmitName(s);
   String s4 = request.getValue("storeID");
   jgl.HashMap hashmap1;
   if (s.equals("Edit")) {
     hashmap1 = findMachine(array, s2);
     s1 = s3 + " Remote Server : " + hashmap1.get("_name");
   } else {
     hashmap1 = new HashMap();
     String s5 = request.getValue("host");
     hashmap1.put("_host", s5);
     s1 = s3 + " Remote Server";
   }
   printBodyHeader(s1);
   printButtonBar(getHelpPage(), "");
   outputStream.println("<p><H2>" + s1 + "</H2>\n");
   outputStream.println(getPagePOST(getPage(), s));
   outputStream.println(
       "<input type=hidden name=backURL value=\""
           + request.getValue("backURL")
           + "\">\n"
           + "<input type=hidden name=backLabel value=\""
           + request.getValue("backLabel")
           + "\">");
   if (s.equals("Edit")) {
     outputStream.println("<input type=hidden name=" + getIDName() + " value=" + s2 + ">");
   }
   outputStream.println(getReturnLink(true, s4));
   outputStream.println("<TABLE>");
   boolean flag = displayFormTable(hashmap1, s);
   outputStream.println("</TABLE>");
   if (flag) {
     outputStream.println(
         "<TABLE WIDTH=100%><TR><TD>"
             + getReturnLink(true, s4)
             + "<input type=submit value=\""
             + s3
             + "\"> "
             + getPrintFormSubmit()
             + "\n"
             + "</TD></TR></TABLE>");
   } else {
     printBackLink();
   }
   printFooter(outputStream);
 }
Exemplo n.º 18
0
  public static void saveDYN(String groupId, Array data, String s, boolean flag, boolean flag1)
      throws Exception {
    Enumeration<?> enumeration = data.elements();

    while (enumeration.hasMoreElements()) {
      HashMap hashMap = (HashMap) enumeration.nextElement();

      String id = (String) hashMap.get("id");
      if (id == null) continue;
      if (id.equals("-1")) {
        saveGroup(groupId, FILENAME_EXT_DYN, hashMap);
      } else {
        MonitorEntity.save(groupId, FILENAME_EXT_DYN, (String) id, hashMap);
      }
    }
  }
Exemplo n.º 19
0
 private static String getId(HashMap hashmap) {
   Object id = hashmap.get("_id");
   if (id != null) return (String) id;
   Enumeration<?> enumeration = hashmap.keys();
   while (enumeration.hasMoreElements()) {
     Object obj = enumeration.nextElement();
     if (obj instanceof StringProperty) {
       String key = ((StringProperty) obj).getName();
       if (key.equals("_id")) {
         Enumeration<?> enumeration1 = hashmap.values(obj);
         while (enumeration1.hasMoreElements()) {
           Object obj1 = enumeration1.nextElement();
           return (String) obj1;
         }
       }
     }
   }
   return null;
 }
Exemplo n.º 20
0
  public HashMap getTemplateTable() {
    if (templateID != null && templateTableLastUpdate < templateCacheLastUpdate) {
      templateTable = null;
      if (templateID.length() > 0) {
        if (templateCache == null) {
          templateCache = new HashMap();
          String s = "";
          Array array = getTemplateConfigFileList();
          for (int i = 0; i < array.size(); i++)
            try {
              s = (String) array.at(i);
              HashMap hashmap2 = new HashMap();
              Array array1 = FrameFile.readFromFile(s);
              templateCacheLastUpdate = Platform.timeMillis();
              for (int j = 1; j < array1.size(); j++) {
                HashMap hashmap3 = (HashMap) array1.at(j);
                hashmap2.put(TextUtils.getValue(hashmap3, "__id"), hashmap3);
              }

              resolveTemplateReferences(hashmap2);
              templateCache.add(s, hashmap2);
            } catch (IOException ioexception) {
              LogManager.log("Error", "Could not read template file " + s);
            }
        }
        if (templateCache != null) {
          String s1 = getTemplateConfigFilePath();
          HashMap hashmap = null;
          hashmap = (HashMap) templateCache.get(s1);
          if (hashmap != null) {
            HashMap hashmap1 = (HashMap) hashmap.get(templateID);
            if (hashmap1 != null) {
              templateTable = new HashMapOrdered(true);
              initializeValuesTable(hashmap1, templateTable, true);
            }
          }
        }
      }
      templateTableLastUpdate = Platform.timeMillis();
    }
    return templateTable;
  }
Exemplo n.º 21
0
 public void preprocessValuesTable(HashMap hashmap) {
   String s = "_machine";
   String s1 = (String) hashmap.get(s);
   if (s1 != null) {
     StringProperty stringproperty = getPropertyObject(s);
     if (stringproperty != null) {
       String s2 = TextUtils.getValue(hashmap, "__portalServerID");
       String s3 = s1;
       if (s2.length() > 0) {
         s3 = s3 + "@" + s2;
         if (!s3.endsWith(":")) {
           s3 = s3 + ":";
         }
       }
       os = Machine.getOS(s3);
       valuesTable.add(stringproperty, s1);
     }
     hashmap.remove(s);
   }
   super.preprocessValuesTable(hashmap);
 }
Exemplo n.º 22
0
  /**
   * CAUTION: Decompiled by hand.
   *
   * @param s
   * @return
   * @throws NullPointerException
   */
  public Array getProperties(String s) throws NullPointerException {
    StringProperty stringproperty = getPropertyObject(s);
    if (stringproperty != null) {
      return getProperties(stringproperty);
    }
    jgl.Array array = new Array();
    Object obj = null;
    jgl.HashMap hashmap = findTable(s);
    if (hashmap != null) {
      obj = hashmap.get(s);
    }

    if (obj == null) {
      return array;
    }

    if (obj instanceof String) {
      array.add(obj);
    } else if (obj instanceof Array) {
      array = (Array) obj;
    }
    return array;
  }
Exemplo n.º 23
0
  public String getProperty(StringProperty stringproperty) throws NullPointerException {
    String s = null;
    HashMap hashmap = findTable(stringproperty);
    if (hashmap != null) {
      Object obj = hashmap.get(stringproperty);
      if (obj != null && (obj instanceof Array)) {
        s = "";
        Array array = (Array) obj;
        for (Enumeration enumeration = array.elements(); enumeration.hasMoreElements(); ) {
          if (s.length() != 0) {
            s = s + stringproperty.multiLineDelimiter + " ";
          }
          s = s + enumeration.nextElement();
        }

      } else {
        s = (String) obj;
      }
    }
    if (s == null && stringproperty != null) {
      s = stringproperty.defaultValue;
    }
    return s;
  }
Exemplo n.º 24
0
  /**
   * CAUTION: Decompiled by hand.
   *
   * @param s
   * @return
   * @throws NullPointerException
   */
  public String getProperty(String s) throws NullPointerException {
    StringProperty stringproperty = getPropertyObject(s);
    if (stringproperty != null) {
      return getProperty(stringproperty);
    }

    Object obj = null;
    String s1 = null;
    jgl.HashMap hashmap = findTable(s);
    if (hashmap != null) {
      obj = hashmap.get(s);
    }

    if (obj == null) {
      s1 = "";
    } else if (obj instanceof String) {
      s1 = (String) obj;
    } else if (obj instanceof Array) {
      s1 = (String) ((Array) obj).at(0);
    } else {
      s1 = "";
    }
    return s1;
  }
Exemplo n.º 25
0
 public static Object getClassPropertyByObject(String s, String s1) {
   HashMap hashmap = (HashMap) cClassValues.get(s);
   return hashmap.get(s1);
 }
  public synchronized boolean execute() {
    try {
      SiteViewGroup siteviewgroup = SiteViewGroup.currentSiteView();
      Array array = new Array();
      Array array1 = new Array();
      Array array2 = new Array();
      Array array3 = siteviewgroup.getGroupFiles();
      Enumeration enumeration = array3.elements();
      File file = null;
      File file1 = null;
      File file2 = null;
      File file3 = null;
      HashSet hashset = new HashSet();
      for (Enumeration enumeration1 = fileNameMap.keys();
          enumeration1.hasMoreElements();
          hashset.add(enumeration1.nextElement())) {}
      String s;
      for (; enumeration.hasMoreElements(); hashset.remove(s)) {
        File file4 = (File) enumeration.nextElement();
        s = file4.getAbsolutePath();
        Long long1 = (Long) fileNameMap.get(s);
        if (long1 == null) {
          if (file4.getName().equals("history.config")) {
            file = file4;
          } else if (file4.getName().equals("dynamic.config")) {
            file2 = file4;
          } else {
            array.add(file4);
          }
        } else if (long1.longValue() != file4.lastModified()) {
          if (file4.getName().equals("history.config")) {
            file1 = file4;
          } else if (file4.getName().equals("dynamic.config")) {
            file3 = file4;
          } else {
            array1.add(file4);
            if (file4.getAbsolutePath().endsWith(".mg")) {
              //                            TopazConfigurator.checkModified(file4);
            }
          }
        }
        long1 = new Long(file4.lastModified());
        fileNameMap.put(s, long1);
      }

      if (file2 != null) {
        array.add(file2);
      }
      if (file3 != null) {
        array1.add(file3);
      }
      if (file != null) {
        array.add(file);
      }
      if (file1 != null) {
        array1.add(file1);
      }
      String s1;
      for (Iterator iterator = hashset.iterator();
          iterator.hasNext();
          LogManager.log("Debug", "group deleted: " + s1)) {
        s1 = (String) iterator.next();
        fileNameMap.remove(s1);
        File file5 = new File(s1);
        array2.add(file5);
        if (file5.getAbsolutePath().endsWith(".mg")) {
          //                    TopazConfigurator.checkDeleted(file5);
        }
      }

      HashMap hashmap = new HashMap();
      siteviewgroup.adjustGroups(array, array1, array2, hashmap);
      for (HashMapIterator hashmapiterator = hashmap.begin();
          !hashmapiterator.atEnd();
          hashmapiterator.advance()) {
        fileNameMap.put(hashmapiterator.key(), hashmapiterator.value());
      }

    } catch (Exception exception) {
      LogManager.log("Error", "Error loading configuration: " + exception);
      LogManager.log("Error", "  detail: " + FileUtils.stackTraceText(exception));
    }
    clearConfigChangeFlag();
    return true;
  }
Exemplo n.º 27
0
  void printAddForm(String s) throws Exception {
    jgl.Array array = getFrames();
    if (request.isPost()) {
      if (dependentCheck()) {
        return;
      }
      String s1 = null;
      Object obj = null;
      jgl.HashMap hashmap1 = null;
      int i = -1;
      jgl.Array array1 = parseHosts(request.getValue("host"));
      boolean flag = array1.size() > 1;
      for (int j = 0; j < array1.size(); j++) {
        jgl.HashMap hashmap;
        if (s.equals("Add")) {
          if (hashmap1 == null) {
            hashmap1 = getMasterConfig();
          }
          s1 = getNextMachineID(hashmap1);
          hashmap = new HashMap();
          if (s1.length() == 0) {
            s1 = "10";
          }
          // hashmap1.put(getNextMachineName(),
          //        com.dragonflow.Utils.TextUtils.increment(s1));
          Config.configPut(getNextMachineName(), com.dragonflow.Utils.TextUtils.increment(s1));
        } else {
          s1 = getMachineID();
          hashmap = findMachine(array, s1);
          i = getIndex(array, hashmap);
          array.remove(hashmap);
        }
        hashmap.put("_host", array1.at(j).toString().trim());
        if (request.getValue("title").length() == 0) {
          hashmap.put("_name", hashmap.get("_host"));
        } else if (flag) {
          hashmap.put("_name", request.getValue("title") + " - " + hashmap.get("_host"));
        } else {
          hashmap.put("_name", request.getValue("title"));
        }
        saveAddProperties(s, hashmap, s1);
        if (s.equals("Add")) {
          array.add(hashmap);
        } else {
          array.insert(i, hashmap);
        }
      }

      saveMachines(array, getRemoteName());
      String s2 = "";
      if (request.getValue("addtest").indexOf("add") != -1 || array1.size() > 1) {
        s2 =
            getPageLink(getPage(), "List")
                + "&"
                + getIDName()
                + "="
                + s1
                + "&backURL="
                + request.getValue("backURL")
                + "&backLabel="
                + java.net.URLEncoder.encode(request.getValue("backLabel"))
                + "&backDescription="
                + java.net.URLEncoder.encode(request.getValue("backDescription"))
                + getReturnLink(false, request.getValue("storeID"));
      } else {
        s2 =
            getPageLink(getPage(), "Test")
                + "&"
                + getIDName()
                + "="
                + s1
                + "&backURL="
                + request.getValue("backURL")
                + "&backLabel="
                + java.net.URLEncoder.encode(request.getValue("backLabel"))
                + "&backDescription="
                + java.net.URLEncoder.encode(request.getValue("backDescription"))
                + getReturnLink(false, request.getValue("storeID"));
      }
      autoFollowPortalRefresh = false;
      printRefreshPage(s2, 0);
    } else {
      printForm(s, array, new HashMap());
    }
  }
Exemplo n.º 28
0
  public static void saveGroup(String groupId, String stype, HashMap hashMap) throws Exception {

    EntityCondition whereCondition =
        EntityCondition.makeCondition(
            UtilMisc.toList(
                EntityCondition.makeCondition("id", EntityOperator.EQUALS, groupId),
                EntityCondition.makeCondition("stype", EntityOperator.EQUALS, stype)),
            EntityOperator.AND);

    List<GenericValue> groups =
        getDelegator()
            .findList("SvGroup", whereCondition, null, UtilMisc.toList("idx"), null, false);
    if (!(groups.size() > 0)) {
      GenericValue group = getDelegator().makeValue("SvGroup");
      group.set("id", groupId);
      String[] splits = groupId.split("\\.");
      if (splits.length > 1) {
        group.set("parent", splits[0]);
      }
      group.set("stype", stype);
      group.create();
    }

    whereCondition =
        EntityCondition.makeCondition(
            UtilMisc.toList(
                EntityCondition.makeCondition("groupId", EntityOperator.EQUALS, groupId),
                EntityCondition.makeCondition("stype", EntityOperator.EQUALS, stype)),
            EntityOperator.AND);
    List<GenericValue> groupValue =
        getDelegator()
            .findList("SvGroupValue", whereCondition, null, UtilMisc.toList("idx"), null, false);
    long maxIdx = 0;
    try {
      int index = groupValue.size() - 1;
      GenericValue val = groupValue.get(index);
      maxIdx = val.getInteger("idx");
    } catch (Exception e) {
    }

    for (GenericValue val : groupValue) {
      String key = val.getString("attrName");
      if (key == null) continue;
      boolean bExist = false;
      Enumeration<?> enumKeys = hashMap.keys();
      while (enumKeys.hasMoreElements()) {
        Object obj = enumKeys.nextElement();
        String keyi = null;
        if (obj instanceof StringProperty) {
          keyi = ((StringProperty) obj).getName();
        } else {
          keyi = (String) obj;
        }
        if (key.equals(keyi)) {
          bExist = true;
        }
      }
      if (!bExist) {
        val.remove();
      }
    }

    Enumeration<?> enumeration = hashMap.keys();
    while (enumeration.hasMoreElements()) {
      Object obj = enumeration.nextElement();
      String key = null;
      if (obj instanceof StringProperty) {
        key = ((StringProperty) obj).getName();
      } else {
        key = (String) obj;
      }
      if (key == null) continue;

      String value = null;
      if (obj instanceof StringProperty) {
        value = ((StringProperty) obj).getValue();
      } else if (obj instanceof Array) {

      } else if (obj instanceof String) {
        value = "" + hashMap.get(key);
      }
      value = "".equals(value) ? null : value;
      boolean bExist = false;

      for (GenericValue val : groupValue) {
        if (key.equals(val.getString("attrName"))) {
          if (value == null) {
            val.remove();
          } else {
            val.set("attrValue", value);
            val.store();
          }
          bExist = true;
        }
      }
      if (!bExist && value != null) {
        GenericValue val = getDelegator().makeValue("SvGroupValue");
        val.set("groupId", groupId);
        val.set("stype", stype);
        maxIdx++;
        val.set("idx", maxIdx);
        val.set("attrName", key);
        val.set("attrValue", value);
        val.create();
      }
    }
  }
Exemplo n.º 29
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 "";
    }
  }
Exemplo n.º 30
0
 public static Object getPropertyMapByObject(String s, String s1) {
   HashMap hashmap = (HashMap) cPropertyMap.get(s);
   return hashmap.get(s1);
 }