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 PortletModeDeleteController extends SimpleFormController { |
17 | |
18 | private AdminService adminService; |
19 | |
20 | protected void onSubmitAction(Object command) throws Exception { |
21 | PortalSupport portalSupport = (PortalSupport) command; |
22 | getAdminService().deletePortalSupport(portalSupport); |
23 | } |
24 | |
25 | protected ModelAndView onSubmitRender(Object command) throws Exception { |
26 | ModelAndView modelAndView = new ModelAndView("displayPortletModes"); |
27 | List portletModes = new ArrayList(); |
28 | for (Iterator iter = getAdminService().getPortalConfig().getPortalSupports().iterator(); iter.hasNext();) { |
29 | PortalSupport support = (PortalSupport) iter.next(); |
30 | if (Constants.PORTLET_MODE_SUPPORT.equals(support.getSupportType())) { |
31 | portletModes.add(support); |
32 | } |
33 | } |
34 | modelAndView.addObject("portletModes", portletModes); |
35 | return modelAndView; |
36 | } |
37 | |
38 | protected Object formBackingObject(PortletRequest request) throws Exception { |
39 | if (request.getParameter("portalSupportId") != null) { |
40 | return getAdminService().findPortalSupportById(Long.parseLong(request.getParameter("portalSupportId"))); |
41 | } |
42 | return new PortalSupport(); |
43 | } |
44 | |
45 | public AdminService getAdminService() { |
46 | return adminService; |
47 | } |
48 | |
49 | public void setAdminService(AdminService adminService) { |
50 | this.adminService = adminService; |
51 | } |
52 | |
53 | } |