1 16 package org.apache.pluto.portlet.admin.controller; 17 18 import java.io.IOException ; 19 20 import javax.portlet.ActionRequest; 21 import javax.portlet.ActionResponse; 22 import javax.portlet.PortletException; 23 import javax.portlet.PortletMode; 24 import javax.portlet.PortletSession; 25 import javax.portlet.RenderRequest; 26 import javax.portlet.RenderResponse; 27 28 import org.apache.pluto.portlet.admin.PlutoAdminConstants; 29 import org.apache.pluto.portlet.admin.bean.PageTO; 30 import org.apache.pluto.portlet.admin.bean.PortletMessage; 31 import org.apache.pluto.portlet.admin.bean.PortletMessageType; 32 import org.apache.pluto.portlet.admin.services.DeployWarService; 33 34 35 42 public class DeployWarPortlet extends ControllerPortlet { 43 private DeployWarService service = null; 44 45 46 protected void doEdit(RenderRequest request, RenderResponse response) 47 throws PortletException, IOException { 48 super.doEdit(request, response); 49 } 50 51 54 protected void doView(RenderRequest request, RenderResponse response) 55 throws PortletException, IOException { 56 super.doView(request, response); 57 } 58 59 62 public void init() throws PortletException { 63 super.init(); 64 service = new DeployWarService(); 65 } 66 67 70 protected void doHelp(RenderRequest request, RenderResponse response) 71 throws PortletException, IOException { 72 super.doHelp(request, response); 73 } 74 75 public void processAction(ActionRequest request, ActionResponse response) 76 throws PortletException, IOException 77 { 78 try { 79 String action = request.getParameter("action"); 80 log("Action param == " + action); 81 82 if (action == null) { 83 String fileName = service.processFileUpload(request,response); 85 86 int index = fileName.indexOf(".war"); 88 String name = null; 89 if ( index != -1) { 90 name = fileName.substring(0, index); 91 } else { 92 name = fileName; 93 } 94 service.addToPortletContexts(name); 96 97 PageTO oPage = new PageTO(); 99 oPage.setName(name); 100 request.getPortletSession().setAttribute(PlutoAdminConstants.PAGE_ATTR, oPage); 101 102 _incView = "/portlets/admin/PageRegistryAdd.jsp"; 104 response.setPortletMode(PortletMode.VIEW); 105 106 } else if (action.equals("showhome")) { 107 108 _incView = "/portlets/admin/DeployWarView.jsp"; 109 response.setPortletMode(PortletMode.VIEW); 110 111 } else if (action.equals("showpagelayout")) { 112 113 PortletSession session = request.getPortletSession(); 114 PageTO page = (PageTO)session.getAttribute(PlutoAdminConstants.PAGE_ATTR); 115 String name = ""; 116 if (page != null) { 117 name = page.getName(); 118 } 119 if (page != null && !service.pageExists(name)) { 120 service.setPage(request); 121 _incView = "/portlets/admin/PageRegistryAdd2.jsp"; 123 } else { 124 session.setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("Page '" + name + "' already exists in pageregistry.xml", PortletMessageType.INFO)); 125 _incView = "/portlets/admin/DeployWarView.jsp"; 126 } 127 response.setPortletMode(PortletMode.VIEW); 128 129 } else if (action.equals("savepagelayout")) { 130 131 service.savePageLayout(request); 132 request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("Deployment successful. Please restart the Pluto portal.", PortletMessageType.SUCCESS)); 134 _incView = "/portlets/admin/DeployWarView.jsp"; 135 response.setPortletMode(PortletMode.VIEW); 136 } 137 138 } catch (Throwable e) { 139 log("Error! ", e); 140 request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("A problem has occurred: " + e.getMessage() + ". Please check the servlet container's error log.", PortletMessageType.ERROR)); 141 } 142 } 143 144 } 145 | Popular Tags |