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 [FragmentValidator.java]

nameclass, %method, %block, %line, %
FragmentValidator.java100% (1/1)64%  (7/11)26%  (73/282)29%  (20.1/69)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FragmentValidator100% (1/1)64%  (7/11)26%  (73/282)29%  (20.1/69)
getAclService (): AclService 0%   (0/1)0%   (0/3)0%   (0/1)
validatePage4 (WebFragment, Errors): void 0%   (0/1)0%   (0/1)0%   (0/1)
validateRSSPage1 (WebFragment, Errors): void 0%   (0/1)0%   (0/6)0%   (0/2)
validateURLPage1 (WebFragment, Errors): void 0%   (0/1)0%   (0/6)0%   (0/2)
validatePage3 (WebFragment, Errors): void 100% (1/1)5%   (10/189)9%   (4/43)
validate (Object, Errors): void 100% (1/1)68%  (30/44)61%  (6.1/10)
FragmentValidator (): 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)
validatePage2 (WebFragment, Errors): void 100% (1/1)100% (16/16)100% (4/4)
validateXMLPage1 (WebFragment, Errors): void 100% (1/1)100% (6/6)100% (2/2)

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 FragmentValidator implements Validator {
12 
13        private AclService aclService;
14 
15        public boolean supports(Class candidate) {
16                return WebFragment.class.isAssignableFrom(candidate);
17        }
18 
19        public void validate(Object obj, Errors errors) {
20                WebFragment webFragment = (WebFragment) obj;
21                if (Constants.RSS_TYPE.equals(webFragment.getFragment().getType())) {
22                        validateRSSPage1(webFragment, errors);
23                } else if (Constants.URL_TYPE.equals(webFragment.getFragment().getType())) {
24                        validateURLPage1(webFragment, errors);
25 
26                } else if (Constants.XML_TYPE.equals(webFragment.getFragment().getType())) {
27                        validateXMLPage1(webFragment, errors);
28                }
29                validatePage2(webFragment, errors);
30                validatePage3(webFragment, errors);
31        }
32 
33        public void validateRSSPage1(WebFragment webFragment, Errors errors) {
34                ValidationUtils.rejectIfEmpty(errors, "fragment.url", "URL_REQUIRED", "URL is required.");
35        }
36 
37        public void validateXMLPage1(WebFragment webFragment, Errors errors) {
38                ValidationUtils.rejectIfEmpty(errors, "fragment.fragmentText.text", "FRAGMENT_TEXT_REQUIRED", "XML is required.");
39        }
40 
41        public void validateURLPage1(WebFragment webFragment, Errors errors) {
42                ValidationUtils.rejectIfEmpty(errors, "fragment.url", "URL_REQUIRED", "URL is required.");
43        }
44 
45        public void validatePage2(WebFragment webFragment, Errors errors) {
46                ValidationUtils.rejectIfEmpty(errors, "fragment.title", "TITLE_REQUIRED", "Title is required.");
47                ValidationUtils.rejectIfEmpty(errors, "fragment.description", "DESCRIPTION_REQUIRED", "Description is required.");
48                ValidationUtils.rejectIfEmpty(errors, "fragment.contactEmail", "CONTACT_EMAIL_REQUIRED", "Email is required.");
49        }
50 
51        public void validatePage3(WebFragment webFragment, Errors errors) {
52                if (webFragment.isAddViewGroup()) {
53                        if (webFragment.getAclViewGroup() == null || "".equals(webFragment.getAclViewGroup())) {
54                                errors.rejectValue("aclViewGroup", "ACL_VIEW_GROUP_REQUIRED", "Group is required.");
55                        } else {
56                                if (getAclService().isValidGroup(webFragment.getAclViewGroup())) {
57                                        Acl acl = new Acl();
58                                        acl.setValue(webFragment.getAclViewGroup());
59                                        acl.setType(Constants.GROUP_VIEW);
60                                        acl.setKey(Constants.GROUP_KEY);
61                                        acl.setFragment(webFragment.getFragment());
62                                        webFragment.getFragment().getAcls().add(acl);
63                                        webFragment.setAclViewGroup("");
64                                } else {
65                                        errors.rejectValue("aclViewGroup", "ACL_VIEW_GROUP_INVALID", "Group is invalid.");
66                                }
67                        }
68                }
69                if (webFragment.isAddViewRole()) {
70                        if (webFragment.getAclViewRole() == null || "".equals(webFragment.getAclViewRole())) {
71                                errors.rejectValue("aclViewRole", "ACL_VIEW_ROLE_REQUIRED", "Role is required.");
72                        }
73                        if (webFragment.getAclViewRoleKey() == null || "".equals(webFragment.getAclViewRoleKey())) {
74                                errors.rejectValue("aclViewRoleKey", "ACL_VIEW_ROLE_KEY_REQUIRED", "Role Id is required.");
75                        }
76                        if (webFragment.getAclViewRole() != null && !"".equals(webFragment.getAclViewRole()) && webFragment.getAclViewRoleKey() != null && !"".equals(webFragment.getAclViewRoleKey())) {
77                                Acl acl = new Acl();
78                                acl.setValue(webFragment.getAclViewRole());
79                                acl.setType(Constants.ROLE_VIEW);
80                                acl.setKey(webFragment.getAclViewRoleKey());
81                                acl.setFragment(webFragment.getFragment());
82                                webFragment.getFragment().getAcls().add(acl);
83                                webFragment.setAclViewRole("");
84                                webFragment.setAclViewRoleKey("");
85                        }
86                }
87                if (webFragment.isAddPublishGroup()) {
88                        if (webFragment.getAclPublishGroup() == null || "".equals(webFragment.getAclPublishGroup())) {
89                                errors.rejectValue("aclPublishGroup", "ACL_PUBLISH_GROUP_REQUIRED", "Group is required.");
90                        } else {
91                                if (getAclService().isValidGroup(webFragment.getAclPublishGroup())) {
92                                        Acl acl = new Acl();
93                                        acl.setValue(webFragment.getAclPublishGroup());
94                                        acl.setType(Constants.GROUP_PUBLISH);
95                                        acl.setKey(Constants.GROUP_KEY);
96                                        acl.setFragment(webFragment.getFragment());
97                                        webFragment.getFragment().getAcls().add(acl);
98                                        webFragment.setAclPublishGroup("");
99                                } else {
100                                        errors.rejectValue("aclPublishGroup", "ACL_PUBLISH_GROUP_INVALID", "Group is invalid.");
101                                }
102                        }
103                }
104        }
105 
106    public void validatePage4(WebFragment webFragment, Errors errors) {
107        
108    }
109    
110        public AclService getAclService() {
111                return aclService;
112        }
113 
114        public void setAclService(AclService aclService) {
115                this.aclService = aclService;
116        }
117}

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