1 | package edu.iu.uis.sit.portal.portlet.admin.web; |
2 | |
3 | import java.util.ArrayList; |
4 | import java.util.Iterator; |
5 | import java.util.List; |
6 | |
7 | import javax.portlet.PortletRequest; |
8 | |
9 | import org.springframework.web.portlet.ModelAndView; |
10 | import org.springframework.web.portlet.mvc.SimpleFormController; |
11 | |
12 | import edu.iu.uis.sit.portal.portlet.admin.domain.PortalSupport; |
13 | import edu.iu.uis.sit.portal.portlet.admin.services.AdminService; |
14 | import edu.iu.uis.sit.portal.portlet.utility.Constants; |
15 | |
16 | public class WindowStateController extends SimpleFormController { |
17 | private AdminService adminService; |
18 | |
19 | protected void onSubmitAction(Object command) throws Exception { |
20 | WebPortalConfig webPortalConfig = (WebPortalConfig) command; |
21 | getAdminService().savePortalSupport(webPortalConfig.getPortalConfig(), webPortalConfig.getPortalSupport()); |
22 | } |
23 | |
24 | protected ModelAndView onSubmitRender(Object command) throws Exception { |
25 | ModelAndView modelAndView = new ModelAndView("displayWindowStates"); |
26 | List windowStates = new ArrayList(); |
27 | for (Iterator iter = getAdminService().getPortalConfig().getPortalSupports().iterator(); iter.hasNext();) { |
28 | PortalSupport support = (PortalSupport) iter.next(); |
29 | if (Constants.WINDOW_STATE_SUPPORT.equals(support.getSupportType())) { |
30 | windowStates.add(support); |
31 | } |
32 | } |
33 | modelAndView.addObject("windowStates", windowStates); |
34 | return modelAndView; |
35 | } |
36 | |
37 | protected Object formBackingObject(PortletRequest request) throws Exception { |
38 | WebPortalConfig webPortalConfig = new WebPortalConfig(getAdminService().getPortalConfig()); |
39 | if (request.getParameter("portalSupportId") != null) { |
40 | for (Iterator iter = webPortalConfig.getPortalConfig().getPortalSupports().iterator(); iter.hasNext();) { |
41 | PortalSupport support = (PortalSupport) iter.next(); |
42 | if (support.getPortalSupportId().longValue() == Long.parseLong(request.getParameter("portalSupportId"))) { |
43 | webPortalConfig.setPortalSupport(support); |
44 | } |
45 | } |
46 | } |
47 | webPortalConfig.getPortalSupport().setSupportType(Constants.WINDOW_STATE_SUPPORT); |
48 | return webPortalConfig; |
49 | } |
50 | |
51 | public AdminService getAdminService() { |
52 | return adminService; |
53 | } |
54 | |
55 | public void setAdminService(AdminService adminService) { |
56 | this.adminService = adminService; |
57 | } |
58 | } |