package com.consili; import java.util.HashMap; import java.util.Map; import java.util.Vector; import com.ibm.xsp.extlib.util.ExtLibUtil; import lotus.domino.Database; import lotus.domino.Document; import lotus.domino.NotesException; import lotus.domino.Session; import lotus.domino.View; import lotus.domino.ViewEntry; import lotus.domino.ViewEntryCollection; public class AgentLogViewer { public String getUniqueAgentsFromLog() throws NotesException{ Session session = ExtLibUtil.getCurrentSession(); Database dbx = session.getDatabase("Domino/Acme","log.nsf"); View vv = dbx.getView("Miscellaneous Events"); ViewEntryCollection nvec = vv.getAllEntries(); Document d; String rowstr = ""; String agentName = ""; String kw = "Start executing agent"; ViewEntry entry = nvec.getFirstEntry(); Map<String,String[]> rowMap = new HashMap<String,String[]>(); while(entry!=null){ if(entry.isDocument()){ d = entry.getDocument(); Vector<String> v = d.getItemValue("EventList"); for(int i=0;i<v.size();i++){ rowstr = v.get(i); if(kw!=null){ if(rowstr.contains(kw)){ agentName = extractSubstring(rowstr); if (rowMap.containsKey(agentName)) { String[] existingData = rowMap.get(agentName); String[] newData = new String[existingData.length + 1]; System.arraycopy(existingData, 0, newData, 0, existingData.length); newData[newData.length - 1] = rowstr; rowMap.put(agentName, newData); } else { String[] newData = {rowstr}; rowMap.put(agentName, newData); } } } } ViewEntry tmp = entry; entry = nvec.getNextEntry(entry); tmp.recycle(); } } StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String[]> mapentry : rowMap.entrySet()) { String key = mapentry.getKey(); String[] data = mapentry.getValue(); sb.append("<b>" + key + "</b><br><br>" + String.join("<br>",data) + "<br><br>"); } return sb.toString(); } public static String extractSubstring(String input) { String startPhrase = "AMgr: Start executing agent '"; String endPhrase = "' in"; int startIndex = input.indexOf(startPhrase); int endIndex = input.indexOf(endPhrase); if (startIndex != -1 && endIndex != -1) { startIndex += startPhrase.length(); return input.substring(startIndex, endIndex); } return null; } } Xpage <?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core"> <div class="container"> <div class="row"> <div class="col-sm"> <h3>Agents</h3> </div> </div> <div class="row"> <div class="col-sm"> <xp:text value="#{javascript:LogViewer.getUniqueAgentsFromLog()}" escape="false" id="computedField4" tagName="div" style="" styleClass="small"> </xp:text> </div> </div> </div> </xp:view> FacesConfig <?xml version="1.0" encoding="UTF-8"?> <faces-config> <managed-bean> <managed-bean-name>LogViewer</managed-bean-name> <managed-bean-class>com.consili.AgentLogViewer</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> </faces-config>