@SuppressWarnings("unchecked") public int run(ItemCollection adocumentContext, ItemCollection adocumentActivity) throws PluginException { String rtfItemResult; documentContext = adocumentContext; documentActivity = adocumentActivity; // Logtext aus Resultdocument lesen rtfItemResult = documentActivity.getItemValueString("rtfresultlog"); String aProtokoll = rtfItemResult; String sDatumsFormat = documentActivity.getItemValueString("keyLogDateFormat"); if (sDatumsFormat == null || "".equals(sDatumsFormat)) sDatumsFormat = "1"; String sZeitFormat = documentActivity.getItemValueString("keylogtimeformat"); if (sZeitFormat == null || "".equals(sZeitFormat)) sZeitFormat = "2"; logger.fine("[HistoryPlugin] logtimeformat=" + sZeitFormat); logger.fine("[HistoryPlugin] logdateformat=" + sDatumsFormat); // get Time Date format... int iDatumsFormat = -1; int iZeitFormat = -1; try { iDatumsFormat = Integer.parseInt(sDatumsFormat); iZeitFormat = Integer.parseInt(sZeitFormat); } catch (NumberFormatException nfe) { // invalid DateTime format found logger.fine("[HistoryPlugin] undefined logtimeformat " + nfe.toString()); } String sTim = ""; if ((iZeitFormat > -1) && (iDatumsFormat > -1)) { sTim = DateFormat.getDateTimeInstance(iDatumsFormat, iZeitFormat).format(new Date()); } else { if ((iZeitFormat == -1) && (iDatumsFormat > -1)) sTim = DateFormat.getDateInstance(iDatumsFormat).format(new Date()); else if ((iZeitFormat > -1) && (iDatumsFormat == -1)) sTim = DateFormat.getTimeInstance(iZeitFormat).format(new Date()); } // Check if a text was found. Protocol will only be added if text // was defined if (!"".equals(aProtokoll)) { String sDoppelpunkt = ""; if ((!"".equals(sTim)) && (!"".equals(aProtokoll))) sDoppelpunkt = " : "; aProtokoll = sTim + sDoppelpunkt + aProtokoll; aProtokoll = replaceDynamicValues(aProtokoll, documentContext); vOldProt = documentContext.getItemValue("txtworkflowhistorylog"); vOldProtRev = documentContext.getItemValue("txtworkflowhistorylogrev"); vOldProt.add(aProtokoll); vOldProtRev.add(0, aProtokoll); // check if maximum length of log is defined int iMaxLogLength = documentContext.getItemValueInteger("numworkflowhistoryLength"); if (iMaxLogLength > 0) { while (vOldProt.size() > iMaxLogLength) vOldProt.remove(0); while (vOldProtRev.size() > iMaxLogLength) vOldProtRev.remove(vOldProtRev.size() - 1); } } return Plugin.PLUGIN_OK; }