01: /**
02: * $Id: WSRPWindowRequestReader.java,v 1.7 2005/10/18 18:57:37 jtb Exp $
03: * Copyright 2003 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.wsrp.consumer.wsrpwindow;
14:
15: import java.util.HashMap;
16: import java.util.Map;
17: import java.util.Iterator;
18: import javax.servlet.http.HttpServletRequest;
19: import com.sun.portal.providers.window.WindowRequestReader;
20: import com.sun.portal.providers.window.WindowProvider;
21: import com.sun.portal.providers.window.util.PortalConstants;
22: import com.sun.portal.desktop.DesktopRequest;
23: import com.sun.portal.container.ChannelMode;
24: import com.sun.portal.container.WindowState;
25: import com.sun.portal.wsrp.common.WSRPToContainerMap;
26:
27: public class WSRPWindowRequestReader implements WindowRequestReader {
28:
29: public ChannelMode readNewChannelMode(HttpServletRequest request) {
30: String newChannelMode = request
31: .getParameter(WSRPWindowChannelURL.NEW_CHANNEL_MODE);
32:
33: if (newChannelMode != null && newChannelMode.length() > 0) {
34: ChannelMode channelMode = WSRPToContainerMap
35: .mapChannelModeToContainer(newChannelMode);
36:
37: return channelMode;
38: }
39: return null;
40: }
41:
42: public WindowState readNewWindowState(HttpServletRequest request) {
43: String newWindowState = request
44: .getParameter(WSRPWindowChannelURL.NEW_WINDOW_STATE);
45:
46: if (newWindowState != null && newWindowState.length() > 0) {
47:
48: WindowState windowState = WSRPToContainerMap
49: .mapWindowStateToContainer(newWindowState);
50: return windowState;
51: }
52: return null;
53: }
54:
55: public String readURLType(HttpServletRequest request) {
56: String urlType = request
57: .getParameter(WSRPWindowChannelURL.PORTLET_ACTION);
58: if (urlType != null) {
59: return WSRPToContainerMap.mapURLTypeToContainer(urlType);
60: } else {
61: throw new RuntimeException("Bad WSRP URL");
62: }
63: }
64:
65: public Map readParamsMap(HttpServletRequest request) {
66: Map parameterMap = ((DesktopRequest) request)
67: .getDesktopPortletRequest().getParameterMap();
68:
69: Map parsedMap = new HashMap();
70: Iterator keyIterator = parameterMap.keySet().iterator();
71: while (keyIterator.hasNext()) {
72: String key = (String) keyIterator.next();
73: parsedMap.put(key, (String[]) parameterMap.get(key));
74: }
75: return parsedMap;
76: }
77:
78: }
|