001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package org.libresource.web;
034:
035: import org.libresource.xml.ImportExportLogger;
036:
037: import javax.servlet.http.HttpServletResponse;
038:
039: public class WebImportExportLogger implements ImportExportLogger {
040: private HttpServletResponse response;
041:
042: public WebImportExportLogger(HttpServletResponse response) {
043: this .response = response;
044: }
045:
046: public void log(int type, String message) {
047: if (response != null) {
048: try {
049: switch (type) {
050: case ImportExportLogger.APPEND:
051: response.getWriter().println(message);
052: response.getWriter().flush();
053: response.flushBuffer();
054:
055: break;
056:
057: case ImportExportLogger.MESSAGE:
058: response.getWriter().println(
059: "<li>" + message + "</li>");
060:
061: for (int i = 0; i < 100; i++)
062: response
063: .getWriter()
064: .println(
065: " ");
066:
067: response.getWriter().flush();
068: response.flushBuffer();
069:
070: break;
071:
072: case ImportExportLogger.ERROR:
073: response.getWriter().println(
074: "<li style=\"color:red\">ERROR : "
075: + message + "</li>");
076:
077: for (int i = 0; i < 100; i++)
078: response
079: .getWriter()
080: .println(
081: " ");
082:
083: response.getWriter().flush();
084: response.flushBuffer();
085:
086: break;
087:
088: case ImportExportLogger.NOTICE:
089: response.getWriter().println(
090: "<li style=\"color:blue\">NOTICE : "
091: + message + "</li>");
092:
093: for (int i = 0; i < 100; i++)
094: response
095: .getWriter()
096: .println(
097: " ");
098:
099: response.getWriter().flush();
100: response.flushBuffer();
101:
102: break;
103: }
104: } catch (Exception e) {
105: //
106: }
107: }
108: }
109: }
|