1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.service.impl;
17
18 import org.apache.log4j.Logger;
19 import org.kuali.rice.krad.exception.ExceptionIncident;
20 import org.kuali.rice.krad.exception.KualiExceptionIncident;
21 import org.kuali.rice.krad.service.KualiExceptionIncidentService;
22
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.Map;
26
27
28
29
30
31
32
33
34
35
36
37 public class KualiExceptionIncidentServiceImpl extends KualiFeedbackServiceImpl implements KualiExceptionIncidentService {
38 private Logger LOG=Logger.getLogger(KualiExceptionIncidentServiceImpl.class);
39
40
41
42
43 private String incidentMailingList;
44
45
46
47
48
49
50
51
52
53 public static final String REPORT_MAIL_LIST=String.format("%s.REPORT_MAIL_LIST", KualiExceptionIncidentServiceImpl.class.getSimpleName());
54
55 @Override
56 protected String getToAddressesPropertyName() {
57 return REPORT_MAIL_LIST;
58 }
59
60
61
62
63
64
65 @Override
66 public void report(KualiExceptionIncident exceptionIncident) throws Exception {
67 if (LOG.isTraceEnabled()) {
68 String lm=String.format("ENTRY %s",
69 (exceptionIncident==null)?"null":exceptionIncident.toString());
70 LOG.trace(lm);
71 }
72
73 emailReport(
74 exceptionIncident.getProperty(
75 KualiExceptionIncident.EXCEPTION_REPORT_SUBJECT),
76 exceptionIncident.getProperty(
77 KualiExceptionIncident.EXCEPTION_REPORT_MESSAGE));
78
79 if (LOG.isTraceEnabled()) {
80 String lm=String.format("EXIT");
81 LOG.trace(lm);
82 }
83
84 }
85
86
87
88
89
90
91
92
93
94
95 public List<String> split(String s, String token) {
96 if (LOG.isTraceEnabled()) {
97 String lm=String.format("ENTRY %s;%s", s, token);
98 LOG.trace(lm);
99 }
100
101 String[] sarray=s.split(token);
102 List<String> list=new ArrayList<String>();
103 for (int i=0; i<sarray.length && sarray[i].length() > 0; i++) {
104 list.add(sarray[i]);
105 }
106
107 if (LOG.isTraceEnabled()) {
108 String lm=String.format("EXIT %s", list.toString());
109 LOG.trace(lm);
110 }
111
112 return list;
113 }
114
115
116
117
118
119
120
121 @Override
122 public KualiExceptionIncident getExceptionIncident(Exception exception,
123 Map<String, String> properties) {
124 if ( exception == null ) {
125 return getExceptionIncident(properties);
126 }
127 if (LOG.isTraceEnabled()) {
128 String lm=String.format("ENTRY %s;%s", exception.getMessage(),
129 properties.toString());
130 LOG.trace(lm);
131 }
132
133 KualiExceptionIncident ei=new ExceptionIncident(exception, properties);
134
135 if (LOG.isTraceEnabled()) {
136 String lm=String.format("EXIT %s", ei.toProperties().toString());
137 LOG.trace(lm);
138 }
139
140 return ei;
141 }
142
143
144
145
146
147
148
149 @Override
150 public KualiExceptionIncident getExceptionIncident(Map<String, String> properties) {
151 if (LOG.isTraceEnabled()) {
152 String lm=String.format("ENTRY %s", properties.toString());
153 LOG.trace(lm);
154 }
155
156 ExceptionIncident ei=new ExceptionIncident(properties);
157
158 if (LOG.isTraceEnabled()) {
159 String lm=String.format("EXIT %s", ei.toProperties().toString());
160 LOG.trace(lm);
161 }
162
163 return ei;
164 }
165
166
167
168
169
170 public String getIncidentMailingList() {
171 return this.incidentMailingList;
172 }
173
174
175
176
177
178 public void setIncidentMailingList(String incidentMailingList) {
179 this.incidentMailingList = incidentMailingList;
180 }
181
182 }