01: /* Copyright 2005 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.tools.checks;
07:
08: /**
09: * Object representing the result of a check. All CheckResults convey the result
10: * of a check.
11: * Additionally, CheckResults representing failures convey advice about how
12: * to remediate the failed check.
13: * @version $Revision: 35833 $ $Date: 2005-05-19 18:51:40 -0700 (Thu, 19 May 2005) $
14: * @since uPortal 2.5
15: */
16: public class CheckResult {
17:
18: /**
19: * True if this CheckResult represents a successful result.
20: * False if it represents a failure.
21: */
22: private final boolean success;
23:
24: /**
25: * A message describing the result of the check.
26: */
27: private final String message;
28:
29: /**
30: * In the case where the check failed, a String describing how to resolve
31: * the failure.
32: */
33: private final String remediationAdvice;
34:
35: private CheckResult(boolean success, String message,
36: String remediationAdvice) {
37: // constructor is private in order to
38: // require usage of the static factory methods
39: // which document the difference between a success and a failure.
40:
41: this .success = success;
42: this .message = message;
43: this .remediationAdvice = remediationAdvice;
44:
45: }
46:
47: /**
48: * Obtain a CheckResult representing a check that succeeded -- dependency
49: * for which you were checking was present, thing you asserted to be true
50: * actually was true, etc.
51: * @param message - a message describing the success of that check
52: * @return a CheckResult representing the success
53: */
54: public static CheckResult createSuccess(String message) {
55: return new CheckResult(true, message, null);
56: }
57:
58: /**
59: * Obtain a CheckResult representing a check that failed -- dependency for which
60: * you were checking was not present, thing you asserted to be true wasn't, etc.
61: * @param message - a message describing the failure of the check
62: * @param remediationAdvice - advice for the uPortal deployer about how to resolve this failure
63: * @return a CheckResult representing this failure
64: */
65: public static CheckResult createFailure(String message,
66: String remediationAdvice) {
67: return new CheckResult(false, message, remediationAdvice);
68: }
69:
70: /**
71: * @return Returns the message.
72: */
73: public String getMessage() {
74: return this .message;
75: }
76:
77: /**
78: * @return Returns the remediationAdvice.
79: */
80: public String getRemediationAdvice() {
81: return this .remediationAdvice;
82: }
83:
84: /**
85: * @return Returns the success.
86: */
87: public boolean isSuccess() {
88: return this.success;
89: }
90: }
|