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