1 | package edu.iu.uis.sit.portal.portlet.admin.web; |
2 | |
3 | import org.springframework.validation.Errors; |
4 | import org.springframework.validation.ValidationUtils; |
5 | import org.springframework.validation.Validator; |
6 | |
7 | import edu.iu.uis.sit.portal.portlet.admin.domain.PortletMapping; |
8 | import edu.iu.uis.sit.portal.portlet.admin.services.AdminService; |
9 | |
10 | public class PortletMappingValidator implements Validator { |
11 | |
12 | private AdminService adminService; |
13 | |
14 | public boolean supports(Class candidate) { |
15 | return PortletMapping.class.isAssignableFrom(candidate); |
16 | } |
17 | |
18 | public void validate(Object obj, Errors errors) { |
19 | ValidationUtils.rejectIfEmptyOrWhitespace(errors, "portletType", "PORTLET_TYPE_REQUIRED", "Portlet Type is required."); |
20 | ValidationUtils.rejectIfEmptyOrWhitespace(errors, "edsType", "EDS_TYPE_REQUIRED", "EDS Type is required."); |
21 | ValidationUtils.rejectIfEmptyOrWhitespace(errors, "displayName", "DISPLAY_NAME_REQUIRED", "Display Name is required."); |
22 | } |
23 | |
24 | public AdminService getAdminService() { |
25 | return adminService; |
26 | } |
27 | |
28 | public void setAdminService(AdminService adminService) { |
29 | this.adminService = adminService; |
30 | } |
31 | |
32 | } |