コード例 #1
0
    /** Returns the value in the proper format: "value". */
    protected String getValue(String strUser, String strValue) {

      ArrayList aListValues = WUtil.strToAList(strValue);
      String strNewValue = "";

      if (strValue == null || strValue.trim().length() <= 0) return "";

      String strPath =
          FileUtil.openPath("SYSPROF" + File.separator + strUser)
              + File.pathSeparator
              + FileUtil.openPath("USRPROF" + File.separator + strUser);
      HashMap hmUser = WFileUtil.getHashMap(strPath);

      for (int i = 0; i < aListValues.size(); i++) {
        strNewValue = (String) aListValues.get(i);
        if (strNewValue == null) strNewValue = "";

        // if the value is of the form: $home, then parse the value
        if (hmUser != null && strNewValue.indexOf('$') >= 0) {
          strValue = WFileUtil.parseValue(strNewValue, hmUser);
          if (strValue != null && strValue.trim().length() > 0) strNewValue = strValue;
        }
      }

      return strNewValue;
    }
コード例 #2
0
    protected void writeAuditTrail(String strPath, String strUser, StringBuffer sbValues) {
      BufferedReader reader = WFileUtil.openReadFile(strPath);
      String strLine;
      ArrayList aListData = WUtil.strToAList(sbValues.toString(), false, "\n");
      StringBuffer sbData = sbValues;
      String strPnl = (this instanceof DisplayTemplate) ? "Data Template " : "Data Dir ";
      if (reader == null) {
        Messages.postDebug("Error opening file " + strPath);
        return;
      }

      try {
        while ((strLine = reader.readLine()) != null) {
          // if the line in the file is not in the arraylist,
          // then that line has been deleted
          if (!aListData.contains(strLine))
            WUserUtil.writeAuditTrail(new Date(), strUser, "Deleted " + strPnl + strLine);

          // remove the lines that are also in the file or those which
          // have been deleted.
          aListData.remove(strLine);
        }

        // Traverse through the remaining new lines in the arraylist,
        // and write it to the audit trail
        for (int i = 0; i < aListData.size(); i++) {
          strLine = (String) aListData.get(i);
          WUserUtil.writeAuditTrail(new Date(), strUser, "Added " + strPnl + strLine);
        }
        reader.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }