1 13 14 package org.ejbca.ui.web.admin.loginterface; 15 16 import java.rmi.RemoteException ; 17 import java.util.ArrayList ; 18 import java.util.Collection ; 19 import java.util.Collections ; 20 import java.util.HashMap ; 21 import java.util.Iterator ; 22 23 import org.ejbca.core.model.log.LogEntry; 24 import org.ejbca.ui.web.admin.rainterface.SortBy; 25 26 27 32 public class LogEntriesView implements java.io.Serializable { 33 34 35 public LogEntriesView(SubjectDNProxy dnproxy , String [] localinfoeventnames, String [] localerroreventnames, String [] localmodulenames, HashMap caidtonamemap) { 36 logentryviews = new ArrayList (); 37 sortby = new SortBy(SortBy.TIME, SortBy.DECENDING); 38 this.dnproxy = dnproxy; 39 this.localinfoeventnames=localinfoeventnames; 40 this.localerroreventnames=localerroreventnames; 41 this.localmodulenames=localmodulenames; 42 this.caidtonamemap=caidtonamemap; 43 } 44 45 47 53 public void sortBy(int sortby, int sortorder) { 54 this.sortby.setSortBy(sortby); 55 this.sortby.setSortOrder(sortorder); 56 57 Collections.sort(logentryviews); 58 } 59 60 67 public LogEntryView[] getEntries(int index, int size) { 68 int endindex; 69 LogEntryView[] returnval; 70 71 if(index > logentryviews.size()) index = logentryviews.size()-1; 72 if(index < 0) index =0; 73 74 endindex = index + size; 75 if(endindex > logentryviews.size()) endindex = logentryviews.size(); 76 77 returnval = new LogEntryView[endindex-index]; 78 79 int end = endindex - index; 80 for(int i = 0; i < end; i++){ 81 returnval[i] = (LogEntryView) logentryviews.get(index+i); 82 } 83 84 return returnval; 85 } 86 87 90 public void setEntries(Collection logentries) throws RemoteException { 91 LogEntryView logentryview; 92 Iterator i; 93 this.logentryviews.clear(); 94 if(logentries!=null && logentries.size() > 0){ 95 i=logentries.iterator(); 96 while(i.hasNext()){ 97 LogEntry nextentry = (LogEntry) i.next(); 98 logentryview = new LogEntryView(nextentry, dnproxy, localinfoeventnames, localerroreventnames, localmodulenames, caidtonamemap); 99 logentryview.setSortBy(this.sortby); 100 logentryviews.add(logentryview); 101 } 102 Collections.sort(logentryviews); 103 } 104 } 105 106 109 public int size(){ 110 return logentryviews.size(); 111 } 112 private ArrayList logentryviews; 114 private SortBy sortby; 115 private SubjectDNProxy dnproxy; 116 private String [] localinfoeventnames; 117 private String [] localerroreventnames; 118 private String [] localmodulenames; 119 private HashMap caidtonamemap; 120 } 121 | Popular Tags |