/* * The contents of this file are subject to the Mozilla Public License Version 1.1 * (the "License"); you may not use this file except in compliance with the License. * You may obtain a copy of the License at . * * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT * WARRANTY OF ANY KIND, either express or implied. See the License for the specific * language governing rights and limitations under the License. * * The Original Code is the Venice Web Communities System. * * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ package com.silverwrist.venice.servlets.format; import java.io.*; import java.util.*; import com.silverwrist.util.StringUtil; import com.silverwrist.venice.core.*; public class AuditDataViewer implements ContentRender { /*-------------------------------------------------------------------------------- * Attributes *-------------------------------------------------------------------------------- */ private List audit_list; private int offset; private int total_count; private int last_index; private String title; private String next_url; private String prev_url; /*-------------------------------------------------------------------------------- * Constructor *-------------------------------------------------------------------------------- */ public AuditDataViewer(VeniceEngine engine, List audit_list, int offset, int total_count, String title, String template_url) { this.audit_list = audit_list; this.offset = offset; this.total_count = total_count; int npage = engine.getNumAuditRecordsPerPage(); this.last_index = offset + npage; if (this.last_index>total_count) this.last_index = total_count; this.title = title; if (this.last_index0) this.prev_url = StringUtil.replaceAllInstances(template_url,"%",String.valueOf(offset-npage)); else this.prev_url = null; } // end constructor /*-------------------------------------------------------------------------------- * Implementations from interface VeniceContent *-------------------------------------------------------------------------------- */ public String getPageTitle(RenderData rdat) { return title; } // end getPageTitle /*-------------------------------------------------------------------------------- * Implementations from interface ContentRender *-------------------------------------------------------------------------------- */ public void renderHere(Writer out, RenderData rdat) throws IOException { rdat.writeContentHeader(out,title,null); // Write the informational and navigational table out.write("
" + rdat.getStdFontTag(null,2)); out.write("\nDisplaying records " + (offset+1) + " to " + last_index + " of " + total_count + "\n"); out.write("\n"); if (prev_url==null) out.write("\"\"\n"); else out.write("\"Previous\""); out.write(" "); if (next_url==null) out.write("\"\"\n"); else out.write("\"Next\""); out.write("\n
\n"); // Start writing the table containing the actual audit records. String tb_font = rdat.getStdFontTag(null,2); out.write("\n"); out.write("\n\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n\n"); Iterator it = audit_list.iterator(); while (it.hasNext()) { // display each record in turn AuditData dat = (AuditData)(it.next()); out.write("\n\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); for (int i=0; i" + tb_font); if (dat.getData(i)!=null) out.write(StringUtil.encodeHTML(dat.getData(i))); else out.write(" "); out.write("\n"); } // end for out.write("\n"); } // end while out.write("
" + tb_font + "Date/Time" + tb_font + "Description" + tb_font + "User" + tb_font + "SIG" + tb_font + "IP Address" + tb_font + "Additional Data
" + tb_font + rdat.formatDateForDisplay(dat.getDateTime()) + "" + tb_font + StringUtil.encodeHTML(dat.getDescription()) + "" + tb_font + StringUtil.encodeHTML(dat.getUserName()) + "" + tb_font + StringUtil.encodeHTML(dat.getSIGName()) + "" + tb_font + StringUtil.encodeHTML(dat.getIPAddress()) + "
\n"); } // end renderHere } // end class AuditDataViewer