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(); } }
/** * Gets the list of the vnmrj users(operators) for the current unix user logged in * * @return the list of vnmrj users */ protected Object[] getOperators() { String strUser = System.getProperty("user.name"); User user = LoginService.getDefault().getUser(strUser); ArrayList<String> aListOperators = user.getOperators(); if (aListOperators == null || aListOperators.isEmpty()) aListOperators = new ArrayList<String>(); Collections.sort(aListOperators); if (aListOperators.contains(strUser)) aListOperators.remove(strUser); aListOperators.add(0, strUser); return (aListOperators.toArray()); }