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

nameclass, %method, %block, %line, %
TabWizardController.java100% (1/1)69%  (11/16)83%  (362/437)79%  (85.8/109)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TabWizardController100% (1/1)69%  (11/16)83%  (362/437)79%  (85.8/109)
afterPropertiesSet (): void 0%   (0/1)0%   (0/9)0%   (0/3)
handleInvalidSubmit (ActionRequest, ActionResponse): void 0%   (0/1)0%   (0/5)0%   (0/2)
processCancel (ActionRequest, ActionResponse, Object, BindException): void 0%   (0/1)0%   (0/5)0%   (0/2)
renderCancel (RenderRequest, RenderResponse, Object, BindException): ModelAnd... 0%   (0/1)0%   (0/7)0%   (0/2)
renderInvalidSubmit (RenderRequest, RenderResponse): ModelAndView 0%   (0/1)0%   (0/2)0%   (0/1)
parseExpressionHtml (WebTab): String 100% (1/1)13%  (5/39)18%  (2/11)
validatePage (Object, Errors, int, boolean): void 100% (1/1)72%  (23/32)75%  (9/12)
handleActionRequestInternal (ActionRequest, ActionResponse): void 100% (1/1)97%  (89/92)99%  (14.8/15)
handleRenderRequestInternal (RenderRequest, RenderResponse): ModelAndView 100% (1/1)99%  (95/96)96%  (22/23)
TabWizardController (): void 100% (1/1)100% (3/3)100% (1/1)
getInitialPage (PortletRequest, Object): int 100% (1/1)100% (33/33)100% (8/8)
getPublishingService (): PublishingService 100% (1/1)100% (3/3)100% (1/1)
initBinder (PortletRequest, PortletRequestDataBinder): void 100% (1/1)100% (28/28)100% (5/5)
processFinish (ActionRequest, ActionResponse, Object, BindException): void 100% (1/1)100% (36/36)100% (11/11)
renderFinish (RenderRequest, RenderResponse, Object, BindException): ModelAnd... 100% (1/1)100% (43/43)100% (10/10)
setPublishingService (PublishingService): void 100% (1/1)100% (4/4)100% (2/2)

1package edu.iu.uis.sit.portal.portlet.publishing.web;
2 
3import java.sql.Timestamp;
4import java.text.NumberFormat;
5import java.util.ArrayList;
6import java.util.Iterator;
7import java.util.List;
8 
9import javax.portlet.ActionRequest;
10import javax.portlet.ActionResponse;
11import javax.portlet.PortletRequest;
12import javax.portlet.RenderRequest;
13import javax.portlet.RenderResponse;
14 
15import org.springframework.beans.propertyeditors.CustomNumberEditor;
16import org.springframework.beans.propertyeditors.StringTrimmerEditor;
17import org.springframework.validation.BindException;
18import org.springframework.validation.Errors;
19import org.springframework.web.portlet.ModelAndView;
20import org.springframework.web.portlet.bind.PortletRequestDataBinder;
21import org.springframework.web.portlet.mvc.AbstractWizardFormController;
22 
23import edu.iu.uis.sit.portal.portlet.publishing.domain.Acl;
24import edu.iu.uis.sit.portal.portlet.publishing.domain.Tab;
25import edu.iu.uis.sit.portal.portlet.publishing.services.PublishingService;
26import edu.iu.uis.sit.portal.portlet.utility.Constants;
27 
28public class TabWizardController extends AbstractWizardFormController {
29 
30        private PublishingService publishingService;
31 
32        public void afterPropertiesSet() throws Exception {
33                if (getPublishingService() == null) {
34                        throw new IllegalArgumentException("A PublishingService is required");
35                }
36        }
37 
38        protected void handleActionRequestInternal(ActionRequest request, ActionResponse response) throws Exception {
39                WebTab webTab = (WebTab) getCommand(request);
40                webTab.setAddPublishGroup(request.getParameter("addPublishGroup") != null);
41                webTab.setAddViewGroup(request.getParameter("addViewGroup") != null);
42                webTab.setAddViewRole(request.getParameter("addViewRole") != null);
43 
44                if (request.getParameter("removeAclValue") != null && !"".equals(request.getParameter("removeAclValue"))) {
45                        for (Iterator iter = webTab.getTab().getAcls().iterator(); iter.hasNext();) {
46                                Acl acl = (Acl) iter.next();
47                                if (acl.getKey().equals(request.getParameter("removeAclKey")) && acl.getType().equals(request.getParameter("removeAclType")) && acl.getValue().equals(request.getParameter("removeAclValue"))) {
48                                        iter.remove();
49                                        break;
50                                }
51                        }
52                }
53                String attributeName = getFormSessionAttributeName();
54                request.getPortletSession().setAttribute(attributeName, (Object) webTab);
55                super.handleActionRequestInternal(request, response);
56        }
57 
58        protected ModelAndView handleRenderRequestInternal(RenderRequest request, RenderResponse response) throws Exception {
59                ModelAndView modelAndView = super.handleRenderRequestInternal(request, response);
60                try {
61                        WebTab webTab = (WebTab) getRenderCommand(request);
62                        List groupViews = new ArrayList();
63                        List roleViews = new ArrayList();
64                        List groupPublishs = new ArrayList();
65                        for (Iterator iter = webTab.getTab().getAcls().iterator(); iter.hasNext();) {
66                                Acl acl = (Acl) iter.next();
67                                if (Constants.GROUP_PUBLISH.equals(acl.getType())) {
68                                        groupPublishs.add(acl);
69                                } else if (Constants.GROUP_VIEW.equals(acl.getType())) {
70                                        groupViews.add(acl);
71                                } else if (Constants.ROLE_VIEW.equals(acl.getType())) {
72                                        roleViews.add(acl);
73                                }
74                        }
75                        modelAndView.addObject("roleViews", roleViews);
76                        modelAndView.addObject("groupPublishs", groupPublishs);
77                        modelAndView.addObject("groupViews", groupViews);
78                } catch (Exception e) {
79 
80                }
81                if (request.getParameter("updateTab") != null) {
82                        modelAndView.addObject("page", 4);
83                        modelAndView.setViewName("tabPage4");
84                }
85                return modelAndView;
86        }
87 
88        protected void processFinish(ActionRequest request, ActionResponse response, Object command, BindException errors) throws Exception {
89                Timestamp now = new Timestamp(System.currentTimeMillis());
90                WebTab webTab = (WebTab) command;
91                Tab tab = webTab.getTab();
92                tab.setLastUpdateDate(now);
93                if (tab.getTabId() == null) {
94                        tab.setCreateDate(now);
95                }
96 
97                if (tab.getTabId() == null) {
98                        response.setRenderParameter("new", "new");
99                }
100                String xml = parseExpressionHtml(webTab);
101                getPublishingService().saveTab(tab);
102        }
103 
104        private String parseExpressionHtml(WebTab webTab) {
105        if (webTab.getWebAclExpression() == null) {
106            return "";
107        }
108        String xml = webTab.getWebAclExpression();
109                System.out.println(xml);
110                xml = xml.replaceAll("<script.*script>", "");
111                xml = xml.replaceAll("<input.*type=\"radio\">", "");
112                System.out.println(xml);
113                xml = xml.replaceAll("<a href.*>remove", "");
114                xml = xml.replaceAll("</a>", "");
115                System.out.println(xml);
116                return xml;
117        }
118 
119        protected void processCancel(ActionRequest request, ActionResponse response, Object command, BindException errors) throws Exception {
120                response.setRenderParameter("action", "addTab");
121        }
122 
123        protected void validatePage(Object command, Errors errors, int page, boolean finish) {
124                if (finish) {
125                        this.getValidator().validate(command, errors);
126                        return;
127                }
128                WebTab webTab = (WebTab) command;
129                TabValidator tabValidator = (TabValidator) getValidator();
130                switch (page) {
131                case 0:
132                        tabValidator.validatePage1(webTab, errors);
133                        break;
134                case 1:
135                        tabValidator.validatePage2(webTab, errors);
136                        break;
137                case 2:
138                        tabValidator.validatePage3(webTab, errors);
139                        break;
140                }
141        }
142 
143        protected void initBinder(PortletRequest request, PortletRequestDataBinder binder) throws Exception {
144                NumberFormat nf = NumberFormat.getInstance();
145                binder.registerCustomEditor(Integer.class, new CustomNumberEditor(Integer.class, nf, true));
146                binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, nf, true));
147                binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
148        }
149 
150        protected ModelAndView renderCancel(RenderRequest request, RenderResponse response, Object command, BindException errors) throws Exception {
151                ModelAndView modelAndView = new ModelAndView("start");
152                return modelAndView;
153        }
154 
155        protected ModelAndView renderFinish(RenderRequest request, RenderResponse response, Object command, BindException errors) throws Exception {
156                if (request.getParameter("new") != null) {
157                        ModelAndView modelAndView = new ModelAndView("message");
158                        modelAndView.addObject("message", "Saved successfully");
159                        return modelAndView;
160                }
161                ModelAndView modelAndView = new ModelAndView("tabPage4");
162                modelAndView.addObject("webTab", ((WebTab) command));
163                modelAndView.addObject("page", 4);
164                String attributeName = getFormSessionAttributeName();
165 
166                request.getPortletSession().setAttribute(attributeName, command);
167                return modelAndView;
168        }
169 
170        protected int getInitialPage(PortletRequest request, Object command) {
171                WebTab webTab = (WebTab) command;
172 
173                if (request.getParameter("tabId") != null) {
174                        Tab found = getPublishingService().findTabById(new Long(request.getParameter("tabId")));
175                        if (found != null) {
176                                webTab.setTab(found);
177                        }
178                } else {
179                        webTab.getTab().getAclExpression().setAclExpressionType(Constants.OR);
180                }
181                return super.getInitialPage(request, webTab);
182        }
183 
184        protected ModelAndView renderInvalidSubmit(RenderRequest request, RenderResponse response) throws Exception {
185                return null;
186        }
187 
188        protected void handleInvalidSubmit(ActionRequest request, ActionResponse response) throws Exception {
189                response.setRenderParameter("action", "addTab");
190        }
191 
192        public PublishingService getPublishingService() {
193                return publishingService;
194        }
195 
196        public void setPublishingService(PublishingService publishingService) {
197                this.publishingService = publishingService;
198        }
199 
200}

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