01: /*
02: * Copyright 2002 Sun Microsystems, Inc. All
03: * rights reserved. Use of this product is subject
04: * to license terms. Federal Acquisitions:
05: * Commercial Software -- Government Users
06: * Subject to Standard License Terms and
07: * Conditions.
08: *
09: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
10: * are trademarks or registered trademarks of Sun Microsystems,
11: * Inc. in the United States and other countries.
12: */
13: package com.sun.portal.providers.portletwindowprocess;
14:
15: import java.net.URL;
16:
17: import javax.servlet.http.HttpServletRequest;
18: import javax.servlet.http.HttpServletResponse;
19:
20: import com.sun.portal.providers.Provider;
21: import com.sun.portal.providers.ProviderException;
22: import com.sun.portal.providers.ProviderAdapter;
23: import com.sun.portal.providers.context.ContainerProviderContext;
24: import com.sun.portal.providers.window.WindowProvider;
25:
26: /**
27: * This class is a hack and would allow the processing of the
28: * portlets even when isEditable property is set to false for portlets
29: * and extends <code>ProviderAdapter</code>
30: *
31: */
32: public class PortletWindowProcessProvider extends ProviderAdapter {
33:
34: /**
35: * Delegates the process action to the target portlet
36: *
37: * @return The URL that the iPS desktop will re-direct to. A value
38: * of null should indicate to the client that it should return to its
39: * default view.
40: *
41: * @param request An HttpServletRequest that contains
42: * information related to this
43: * request for content.
44: *
45: * @param response An HttpServletResponse that allows the
46: * provider to influence the
47: * overall response for the desktop page (besides generating the content).
48: *
49: * @exception ProviderException If there was an error processing
50: * the edit form. How this exception is handled is up to the client of the
51: * provider object.
52: *
53: * @return The URL that the iPS desktop will re-direct to. A value
54: * of null should indicate to the client that it should return to its
55: * default view.
56: *
57: * @see com.sun.portal.providers.Provider#getEdit
58: * @see com.sun.portal.providers.Provider#isEditable
59: * @see com.sun.portal.providers.InvalidEditFormDataException
60: * @see com.sun.portal.desktop.DesktopServlet
61: */
62: public URL processEdit(HttpServletRequest req,
63: HttpServletResponse res) throws ProviderException {
64: ContainerProviderContext cpc = (ContainerProviderContext) getProviderContext();
65: String targetPortletChannel = req
66: .getParameter(WindowProvider.TARGET_PORTLET_CHANNEL_KEY);
67: if (targetPortletChannel == null
68: || targetPortletChannel.length() == 0) {
69: throw new ProviderException(
70: "target portlet channel was null or of zero length");
71: }
72: Provider p = cpc.getProvider(req, null, targetPortletChannel);
73: if (p == null) {
74: throw new ProviderException("no such portlet: "
75: + targetPortletChannel);
76: }
77:
78: URL redirectURL = p.processEdit(req, res);
79: return redirectURL;
80: }
81:
82: }
|