01: /*
02: * (C) Copyright 2000 - 2005 Nabh Information Systems, Inc.
03: *
04: * This program is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU General Public License
06: * as published by the Free Software Foundation; either version 2
07: * of the License, or (at your option) any later version.
08: *
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: *
18: */
19: package com.nabhinc.portlet.portletadmin;
20:
21: import java.io.IOException;
22:
23: import javax.portlet.ActionRequest;
24: import javax.portlet.ActionResponse;
25: import javax.portlet.PortletException;
26: import javax.servlet.http.HttpServletRequest;
27: import javax.servlet.http.HttpServletResponse;
28:
29: import com.nabhinc.portal.container.PortletRequestImpl;
30: import com.nabhinc.portal.container.PortletResponseImpl;
31: import com.nabhinc.portal.core.PortalServlet;
32: import com.nabhinc.portlet.portletadmin.PortletUtil;
33: import com.nabhinc.portlet.mvcportlet.core.ActionConfig;
34: import com.nabhinc.portlet.mvcportlet.core.ActionProcessor;
35: import com.nabhinc.portlet.mvcportlet.core.BaseRequestProcessor;
36:
37: /**
38: *
39: *
40: * @author Padmanabh Dabke
41: * (c) 2005 Nabh Information Systems, Inc. All Rights Reserved.
42: * @since 2.4.1
43: */
44: public class PortletLoader extends BaseRequestProcessor implements
45: ActionProcessor {
46:
47: /*
48: * Loads or reloads a portlet
49: */
50: public String process(ActionRequest request,
51: ActionResponse response, ActionConfig actionConfig)
52: throws PortletException, IOException {
53: String action = request.getParameter("request_type");
54: try {
55: HttpServletRequest req = ((PortletRequestImpl) request)
56: .getHttpServletRequest();
57: HttpServletResponse res = ((PortletResponseImpl) response)
58: .getHttpServletResponse();
59: response.setRenderParameter("action", action);
60: if ("LoadPortlet".equals(action)) {
61: PortalServlet.getInstance().loadPortletNamed(
62: request.getParameter("pname"), req, res);
63: } else if ("DeletePortlet".equals(action)) {
64: PortalServlet.getInstance().deletePortlet(
65: request.getParameter("pname"), req, res);
66: PortalServlet.getInstance().savePortletConfiguration();
67: } else if ("UnloadPortlet".equals(action)) {
68: PortalServlet.getInstance().unloadPortlet(
69: request.getParameter("pname"), req, res);
70: }
71: return "success";
72: } catch (Exception ex) {
73: response.setRenderParameter("error", PortletUtil
74: .getErrorStackTrace(ex));
75: return "load-error";
76: }
77: }
78:
79: }
|