1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.student.r2.core.service.util; |
18 | |
|
19 | |
|
20 | |
|
21 | |
import java.util.List; |
22 | |
|
23 | |
import org.kuali.student.r2.common.datadictionary.DataDictionaryValidator; |
24 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
25 | |
import org.kuali.student.r2.common.dto.ValidationResultInfo; |
26 | |
import org.kuali.student.r2.common.exceptions.InvalidParameterException; |
27 | |
import org.kuali.student.r2.common.exceptions.MissingParameterException; |
28 | |
import org.kuali.student.r2.common.exceptions.OperationFailedException; |
29 | |
import org.kuali.student.r2.common.exceptions.PermissionDeniedException; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | 0 | public class ValidationUtils { |
37 | |
|
38 | |
public static List<ValidationResultInfo> validateInfo( DataDictionaryValidator validator, |
39 | |
String validationType, |
40 | |
Object info, |
41 | |
ContextInfo context) |
42 | |
throws OperationFailedException, MissingParameterException, InvalidParameterException { |
43 | 0 | if (null == validator) { |
44 | 0 | throw new InvalidParameterException("DataDictionaryValidator parameter cannot be null"); |
45 | |
} |
46 | |
|
47 | |
List<ValidationResultInfo> errors; |
48 | |
try { |
49 | 0 | errors = validator.validate(DataDictionaryValidator.ValidationType.fromString(validationType), info, context); |
50 | 0 | } catch (PermissionDeniedException ex) { |
51 | 0 | throw new OperationFailedException("Validation failed due to permission exception", ex); |
52 | 0 | } |
53 | 0 | return errors; |
54 | |
} |
55 | |
|
56 | |
} |