1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.student.r2.common.exceptions; |
18 | |
|
19 | |
import java.io.PrintStream; |
20 | |
import java.io.PrintWriter; |
21 | |
import java.util.List; |
22 | |
|
23 | |
import javax.xml.ws.WebFault; |
24 | |
|
25 | |
import org.apache.log4j.Logger; |
26 | |
import org.kuali.student.r2.common.exceptions.DataValidationErrorException; |
27 | |
import org.kuali.student.r2.common.dto.ValidationResultInfo; |
28 | |
|
29 | |
@WebFault(faultBean="org.kuali.student.r2.common.exceptions.jaxws.DataValidationErrorExceptionBean") |
30 | |
public class DataValidationErrorException |
31 | |
extends Exception { |
32 | |
|
33 | 0 | private static final Logger LOG = Logger.getLogger(DataValidationErrorException.class); |
34 | |
|
35 | |
private static final long serialVersionUID = 1L; |
36 | |
|
37 | |
private List<ValidationResultInfo> validationResults; |
38 | |
|
39 | |
|
40 | 0 | public DataValidationErrorException() { |
41 | 0 | } |
42 | |
|
43 | |
public DataValidationErrorException(String message, List<ValidationResultInfo> validationResults) { |
44 | 0 | this(message, validationResults, null); |
45 | 0 | } |
46 | |
|
47 | |
public DataValidationErrorException(String message, List<ValidationResultInfo> validationResults, Throwable cause) { |
48 | 0 | super(message, cause); |
49 | 0 | this.validationResults = validationResults; |
50 | 0 | } |
51 | |
|
52 | |
public DataValidationErrorException(String message, Throwable cause) { |
53 | 0 | super(message, cause); |
54 | 0 | } |
55 | |
|
56 | |
public DataValidationErrorException(String message) { |
57 | 0 | super(message); |
58 | 0 | } |
59 | |
|
60 | |
public DataValidationErrorException(Throwable cause) { |
61 | 0 | super(cause); |
62 | 0 | } |
63 | |
|
64 | |
public List<ValidationResultInfo> getValidationResults() { |
65 | 0 | return validationResults; |
66 | |
} |
67 | |
|
68 | |
@Override |
69 | |
public void printStackTrace(PrintStream s) { |
70 | 0 | super.printStackTrace(s); |
71 | 0 | logValidationResults(); |
72 | 0 | } |
73 | |
|
74 | |
@Override |
75 | |
public void printStackTrace(PrintWriter s) { |
76 | 0 | super.printStackTrace(s); |
77 | 0 | logValidationResults(); |
78 | 0 | } |
79 | |
|
80 | |
@Override |
81 | |
public String toString() { |
82 | 0 | StringBuilder sb = new StringBuilder(); |
83 | 0 | sb.append(super.getMessage()).append("\n"); |
84 | |
|
85 | 0 | if (validationResults != null) { |
86 | 0 | sb.append("Validation Results: \n"); |
87 | 0 | for (ValidationResultInfo info:validationResults) { |
88 | 0 | sb.append(info).append("\n"); |
89 | |
} |
90 | |
} else { |
91 | 0 | sb.append("Validation Results: None set."); |
92 | |
} |
93 | 0 | return sb.toString(); |
94 | |
} |
95 | |
|
96 | |
private void logValidationResults() { |
97 | 0 | LOG.debug(toString()); |
98 | 0 | } |
99 | |
} |