001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/report/I_CmsReport.java,v $
003: * Date : $Date: 2008-02-27 12:05:41 $
004: * Version: $Revision: 1.31 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.report;
033:
034: import org.opencms.i18n.CmsMessageContainer;
035:
036: import java.util.List;
037: import java.util.Locale;
038:
039: /**
040: * This is the interface for the report classes which are used for the output
041: * during operations that run on a spearate Thread in OpenCms,
042: * like publish, import, export etc.<p>
043: *
044: * @author Alexander Kandzior
045: * @author Jan Baudisch
046: * @author Peter Bonrad
047: *
048: * @version $Revision: 1.31 $
049: *
050: * @since 6.0.0
051: */
052: public interface I_CmsReport {
053:
054: /** Indicates default formatting. */
055: int FORMAT_DEFAULT = 0;
056:
057: /** Indicates error formatting. */
058: int FORMAT_ERROR = 5;
059:
060: /** Indicates headline formatting. */
061: int FORMAT_HEADLINE = 2;
062:
063: /** Indicates note formatting. */
064: int FORMAT_NOTE = 3;
065:
066: /** Indicates OK formatting. */
067: int FORMAT_OK = 4;
068:
069: /** Indicates warning formatting. */
070: int FORMAT_WARNING = 1;
071:
072: /** Request parameter value that this report should create an "extended" output. */
073: String REPORT_TYPE_EXTENDED = "extended";
074:
075: /** Request parameter value that this report should create a "simple" output. */
076: String REPORT_TYPE_SIMPLE = "simple";
077:
078: /**
079: * Adds an error object to the list of errors that occured during the report.<p>
080: *
081: * @param obj the error object
082: */
083: void addError(Object obj);
084:
085: /**
086: * Adds a warning object to the list of warnings that occured during the report.<p>
087: *
088: * @param obj the error object
089: */
090: void addWarning(Object obj);
091:
092: /**
093: * Formats the runtime formatted as "hh:mm:ss".<p>
094: *
095: * @return the runtime formatted as "hh:mm:ss"
096: */
097: String formatRuntime();
098:
099: /**
100: * Returns a list of all errors that occured during the report.<p>
101: *
102: * @return an error list that occured during the report
103: */
104: List getErrors();
105:
106: /**
107: * Returns the locale this report was initialized with.<p>
108: *
109: * @return the locale this report was initialized with
110: */
111: Locale getLocale();
112:
113: /**
114: * Updates this report, this processes all new output added since
115: * the last call to this method.<p>
116: *
117: * This is only required in case the output is written to a HTML page,
118: * if the shell output is used, this will just return an empty String.<p>
119: *
120: * @return new elements that have been added to the report and not yet processed.
121: */
122: String getReportUpdate();
123:
124: /**
125: * Returns the time this report has been running.<p>
126: *
127: * @return the time this report has been running
128: */
129: long getRuntime();
130:
131: /**
132: * Returns the original site root of the user who started this report,
133: * or <code>null</code> if the original site root has not been set.<p>
134: *
135: * @return the original site root of the user who started this report
136: */
137: String getSiteRoot();
138:
139: /**
140: * Returns a list of all warnings that occured during the report.<p>
141: *
142: * @return a warning list that occured during the report
143: */
144: List getWarnings();
145:
146: /**
147: * Returns if the report generated an error output.<p>
148: *
149: * @return true if the report generated an error, otherwise false
150: */
151: boolean hasError();
152:
153: /**
154: * Returns if the report generated a warning output.<p>
155: *
156: * @return true if the report generated a warning, otherwise false
157: */
158: boolean hasWarning();
159:
160: /**
161: * Prints a localized message to the report.<p>
162: *
163: * @param container the String to add
164: */
165: void print(CmsMessageContainer container);
166:
167: /**
168: * Prints a localized message to the report, using the indicated formatting.<p>
169: *
170: * Use the contants starting with <code>FORMAT</code> from this interface
171: * to indicate which formatting to use.<p>
172: *
173: * @param container the String to add
174: * @param format the formatting to use for the output
175: */
176: void print(CmsMessageContainer container, int format);
177:
178: /**
179: * Adds a line break to the report.<p>
180: */
181: void println();
182:
183: /**
184: * Prints a localized message to the report.<p>
185: *
186: * @param container the message container to add
187: */
188: void println(CmsMessageContainer container);
189:
190: /**
191: * Prints a localized message to the report, using the indicated formatting.<p>
192: *
193: * Use the contants starting with <code>FORMAT</code> from this interface
194: * to indicate which formatting to use.<p>
195: *
196: * @param container the message container to add
197: * @param format the formatting to use for the output
198: */
199: void println(CmsMessageContainer container, int format);
200:
201: /**
202: * Adds an Exception to the report, ensuring that the Exception content is
203: * processed to generate a valid output esp. for HTML pages.<p>
204: *
205: * The exception will be stored and the output will later be processed
206: * in a special way.<p>
207: *
208: * @param t the exception to add
209: */
210: void println(Throwable t);
211:
212: /**
213: * Prints a localized message followed by a parametera and dots to the report.<p>
214: *
215: * @param container the Message to add
216: * @param param the Parameter to add
217: */
218: void printMessageWithParam(CmsMessageContainer container,
219: Object param);
220:
221: /**
222: * Convenience method to print a localized message, followed by a parameter and dots to the report.<p>
223: *
224: * The output follows the pattern: ( 3 / 8 ) Deleting filename.txt ...
225: *
226: * @param m the number of the report output
227: * @param n the total number of report outputs
228: * @param container the Message to add
229: * @param param the Parameter to add
230: *
231: */
232: void printMessageWithParam(int m, int n,
233: CmsMessageContainer container, Object param);
234:
235: /**
236: * Removes the report site root prefix from the absolute path in the resource name,
237: * that is adjusts the resource name for the report site root.<p>
238: *
239: * If the site root for this report has not been set,
240: * or the resource name does not start with the report site root,
241: * the name it is left untouched.<p>
242: *
243: * @param resourcename the resource name (full path)
244: *
245: * @return the resource name adjusted for the report site root
246: *
247: * @see org.opencms.file.CmsRequestContext#removeSiteRoot(String)
248: */
249: String removeSiteRoot(String resourcename);
250:
251: /**
252: * Resets the runtime to 0 milliseconds.<p>
253: */
254: void resetRuntime();
255: }
|