1 | |
package org.kuali.student.enrollment.class1.lpr.service.aspect; |
2 | |
|
3 | |
|
4 | |
import java.util.List; |
5 | |
|
6 | |
|
7 | |
import org.aspectj.lang.JoinPoint; |
8 | |
import org.kuali.student.common.exceptions.MissingParameterException; |
9 | |
import org.kuali.student.common.exceptions.OperationFailedException; |
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | 0 | public class ServiceAspects<T> { |
18 | |
|
19 | |
List<Throwable> includeThrowableClassList ; |
20 | |
|
21 | |
|
22 | |
public void setIncludeThrowableClassList(List <Throwable> serviceExceptionTypes) { |
23 | 0 | this.includeThrowableClassList = serviceExceptionTypes; |
24 | 0 | } |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
public void beforeInvokingService(JoinPoint join) throws Throwable{ |
30 | |
|
31 | 0 | Object[] argValues = join.getArgs(); |
32 | |
|
33 | 0 | for(Object argValue:argValues){ |
34 | |
|
35 | 0 | if(argValue==null){ |
36 | |
|
37 | 0 | throw new MissingParameterException("Input parameters cannot be null, one of the parameters had null value:"+argValue); |
38 | |
|
39 | |
} |
40 | |
} |
41 | 0 | } |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
public void handleExceptions(Throwable ex) throws OperationFailedException{ |
50 | |
|
51 | 0 | if (!includeThrowableClassList.contains(ex)) { |
52 | 0 | throw new OperationFailedException(ex.getMessage(), ex); |
53 | |
} |
54 | 0 | } |
55 | |
|
56 | |
} |
57 | |
|