EMMA Coverage Report (generated Fri Sep 15 10:32:43 EDT 2006)
[all classes][edu.iu.uis.sit.portal.portlet.publishing.web]

COVERAGE SUMMARY FOR SOURCE FILE [TabValidator.java]

nameclass, %method, %block, %line, %
TabValidator.java100% (1/1)88%  (7/8)23%  (54/236)31%  (18/58)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TabValidator100% (1/1)88%  (7/8)23%  (54/236)31%  (18/58)
getAclService (): AclService 0%   (0/1)0%   (0/3)0%   (0/1)
validatePage2 (WebTab, Errors): void 100% (1/1)5%   (10/189)9%   (4/43)
TabValidator (): void 100% (1/1)100% (3/3)100% (1/1)
setAclService (AclService): void 100% (1/1)100% (4/4)100% (2/2)
supports (Class): boolean 100% (1/1)100% (4/4)100% (1/1)
validate (Object, Errors): void 100% (1/1)100% (16/16)100% (5/5)
validatePage1 (WebTab, Errors): void 100% (1/1)100% (16/16)100% (4/4)
validatePage3 (WebTab, Errors): void 100% (1/1)100% (1/1)100% (1/1)

1package edu.iu.uis.sit.portal.portlet.publishing.web;
2 
3import org.springframework.validation.Errors;
4import org.springframework.validation.ValidationUtils;
5import org.springframework.validation.Validator;
6 
7import edu.iu.uis.sit.portal.portlet.publishing.domain.Acl;
8import edu.iu.uis.sit.portal.portlet.utility.Constants;
9import edu.iu.uis.sit.portal.user.service.AclService;
10 
11public class TabValidator implements Validator {
12 
13        private AclService aclService;
14 
15        public boolean supports(Class candidate) {
16                return WebTab.class.isAssignableFrom(candidate);
17        }
18 
19        public void validate(Object obj, Errors errors) {
20                WebTab webTab = (WebTab) obj;
21 
22                validatePage1(webTab, errors);
23                validatePage2(webTab, errors);
24                validatePage3(webTab, errors);
25        }
26 
27        public void validatePage1(WebTab webTab, Errors errors) {
28                ValidationUtils.rejectIfEmpty(errors, "tab.name", "NAME_REQUIRED", "Name is required.");
29                ValidationUtils.rejectIfEmpty(errors, "tab.description", "DESCRIPTION_REQUIRED", "Description is required.");
30                ValidationUtils.rejectIfEmpty(errors, "tab.contactEmail", "CONTACT_EMAIL_REQUIRED", "Email is required.");
31        }
32 
33        public void validatePage2(WebTab webTab, Errors errors) {
34                if (webTab.isAddViewGroup()) {
35                        if (webTab.getAclViewGroup() == null || "".equals(webTab.getAclViewGroup())) {
36                                errors.rejectValue("aclViewGroup", "ACL_VIEW_GROUP_REQUIRED", "Group is required.");
37                        } else {
38                                if (getAclService().isValidGroup(webTab.getAclViewGroup())) {
39                                        Acl acl = new Acl();
40                                        acl.setValue(webTab.getAclViewGroup());
41                                        acl.setType(Constants.GROUP_VIEW);
42                                        acl.setKey(Constants.GROUP_KEY);
43                                        acl.setTab(webTab.getTab());
44                                        webTab.getTab().getAcls().add(acl);
45                                        webTab.setAclViewGroup("");
46                                } else {
47                                        errors.rejectValue("aclViewGroup", "ACL_VIEW_GROUP_INVALID", "Group is invalid.");
48                                }
49                        }
50                }
51                if (webTab.isAddViewRole()) {
52                        if (webTab.getAclViewRole() == null || "".equals(webTab.getAclViewRole())) {
53                                errors.rejectValue("aclViewRole", "ACL_VIEW_ROLE_REQUIRED", "Role is required.");
54                        }
55                        if (webTab.getAclViewRoleKey() == null || "".equals(webTab.getAclViewRoleKey())) {
56                                errors.rejectValue("aclViewRoleKey", "ACL_VIEW_ROLE_KEY_REQUIRED", "Role Id is required.");
57                        }
58                        if (webTab.getAclViewRole() != null && !"".equals(webTab.getAclViewRole()) && webTab.getAclViewRoleKey() != null && !"".equals(webTab.getAclViewRoleKey())) {
59                                Acl acl = new Acl();
60                                acl.setValue(webTab.getAclViewRole());
61                                acl.setType(Constants.ROLE_VIEW);
62                                acl.setKey(webTab.getAclViewRoleKey());
63                                acl.setTab(webTab.getTab());
64                                webTab.getTab().getAcls().add(acl);
65                                webTab.setAclViewRole("");
66                                webTab.setAclViewRoleKey("");
67                        }
68                }
69                if (webTab.isAddPublishGroup()) {
70                        if (webTab.getAclPublishGroup() == null || "".equals(webTab.getAclPublishGroup())) {
71                                errors.rejectValue("aclPublishGroup", "ACL_PUBLISH_GROUP_REQUIRED", "Group is required.");
72                        } else {
73                                if (getAclService().isValidGroup(webTab.getAclPublishGroup())) {
74                                        Acl acl = new Acl();
75                                        acl.setValue(webTab.getAclPublishGroup());
76                                        acl.setType(Constants.GROUP_PUBLISH);
77                                        acl.setKey(Constants.GROUP_KEY);
78                                        acl.setTab(webTab.getTab());
79                                        webTab.getTab().getAcls().add(acl);
80                                        webTab.setAclPublishGroup("");
81                                } else {
82                                        errors.rejectValue("aclPublishGroup", "ACL_PUBLISH_GROUP_INVALID", "Group is invalid.");
83                                }
84                        }
85                }
86        }
87 
88        public void validatePage3(WebTab webTab, Errors errors) {
89 
90        }
91 
92        public AclService getAclService() {
93                return aclService;
94        }
95 
96        public void setAclService(AclService aclService) {
97                this.aclService = aclService;
98        }
99}

[all classes][edu.iu.uis.sit.portal.portlet.publishing.web]
EMMA 2.0.5312 (C) Vladimir Roubtsov