01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.module.tools;
11:
12: import org.mmbase.util.logging.Logger;
13: import org.mmbase.util.logging.Logging;
14:
15: /**
16: * Contains the status after installing an MMBase 'application'. I.e. whether is was successful, and
17: * a newline separated message String containing the reason(s).
18: * @version $Id: ApplicationResult.java,v 1.4 2007/10/02 12:15:14 michiel Exp $
19: */
20: class ApplicationResult {
21:
22: private static final Logger log = Logging
23: .getLoggerInstance(ApplicationResult.class);
24:
25: protected final StringBuilder resultMessage;
26: protected boolean success;
27:
28: public ApplicationResult() {
29: resultMessage = new StringBuilder();
30: success = true;
31: }
32:
33: public String getMessage() {
34: return resultMessage.toString();
35: }
36:
37: public boolean isSuccess() {
38: return success;
39: }
40:
41: private void addMessage(String message) {
42: if (resultMessage.length() > 0) {
43: resultMessage.append('\n');
44: }
45: resultMessage.append(message);
46: }
47:
48: /**
49: * Adds a message and logs it as an error, and sets the success status to false.
50: */
51: public boolean error(String message) {
52: success = false;
53: log.error(message);
54: addMessage(message);
55: return false;
56: }
57:
58: /**
59: * Adds a message and logs it as an warning, and sets the success status to false.
60: */
61: public boolean warn(String message) {
62: success = false;
63: log.warn(message);
64: addMessage(message);
65: return false;
66: }
67:
68: /**
69: * Adds a message and sets the success status to true.
70: */
71: public boolean success(String message) {
72: success = true;
73: addMessage(message);
74: return true;
75: }
76:
77: }
|