001: /*
002: * Copyright 2002 Sun Microsystems, Inc. All
003: * rights reserved. Use of this product is subject
004: * to license terms. Federal Acquisitions:
005: * Commercial Software -- Government Users
006: * Subject to Standard License Terms and
007: * Conditions.
008: *
009: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010: * are trademarks or registered trademarks of Sun Microsystems,
011: * Inc. in the United States and other countries.
012: */
013:
014: package com.sun.portal.portletcontainercommon;
015:
016: import javax.servlet.http.HttpServletRequest;
017: import java.util.List;
018: import java.util.Map;
019: import java.util.Locale;
020:
021: import javax.portlet.PortletPreferences;
022:
023: import com.sun.portal.container.ContainerRequest;
024: import com.sun.portal.container.WindowState;
025: import com.sun.portal.container.ChannelMode;
026: import com.sun.portal.container.ChannelURLFactory;
027:
028: import com.iplanet.sso.SSOToken;
029:
030: /**
031: * <code>PortletContainerRequest</code> encapsulates the request sent by the
032: * portlet container to PAE. Portlet container is responsible to use the
033: * set methods to set the informtaion that is necessary for the PAE to process
034: * the request. PAE then can use the get methods to get the request
035: * information.
036: **/
037: public class PortletContainerRequest {
038:
039: // key for PortletContainerRequest object in http request attribute
040: public static final String PORTLET_CONTAINER_REQUEST = "portlet_container_request";
041:
042: private ContainerRequest _req = null;
043:
044: private PortletPreferences _preferences = null;
045: private Map _renderParams = null;
046: private Map _userInfo = null;
047: private List _actions = null;
048: private String _portletName = null;
049: private String _channelName = null;
050: private Locale _locale = null;
051: private SSOToken _token = null;
052: private String responseContentType = null;
053:
054: public PortletContainerRequest(ContainerRequest req) {
055: _req = req;
056: }
057:
058: /**
059: * Returns the <code>PortletPreferences</code>
060: *
061: * @return the <code>PortletPreferences</code>
062: * @see javax.portlet.PortletPreferences
063: **/
064: public PortletPreferences getPortletPreferences() {
065: return _preferences;
066: }
067:
068: /**
069: * Sets the <code>PortletPreferences</code>
070: *
071: * @param preferences the <code>PortletPreferences</code> to set to
072: * @see javax.portlet.PortletPreferences
073: */
074: public void setPortletPreferences(PortletPreferences preferences) {
075: _preferences = preferences;
076: }
077:
078: /**
079: * Returns the <code>UserInfo</code>
080: *
081: * @return the <code>UserInfo</code> Map
082: **/
083: public Map getUserInfo() {
084: return _req.getUserInfo();
085: }
086:
087: /**
088: * Sets the <code>UserInfo</code> Map
089: *
090: * @param userInfo the <code>UserInfo</code> to set to
091: */
092: public void setUserInfo(Map userInfo) {
093: // not used any more should remove sometime
094: _userInfo = userInfo;
095: }
096:
097: /**
098: * Returns action list that describes what PAE needs to do.
099: * Valid actions are ISCACHEVALID, PREPARE, RENDER, ACTION.
100: *
101: * @return the action list
102: * @see com.sun.portal.portletcontainercommon.PortletAction
103: **/
104: public List getActions() {
105: return _actions;
106: }
107:
108: /**
109: * Sets the action list that describes what PAE needs to do
110: * Valid actions are ISCACHEVALID, PREPARE, RENDER, ACTION.
111: *
112: * @param attributes the request attributes to set to
113: * @see com.sun.portal.portletcontainercommon.PortletAction
114: */
115: public void setActions(List actions) {
116: _actions = actions;
117: }
118:
119: /**
120: * Returns the portlet name
121: *
122: * @return the portlet name
123: **/
124: public String getPortletName() {
125: return _portletName;
126: }
127:
128: /**
129: * Sets the portlet name
130: *
131: * @param portletName the portlet name to set to
132: */
133: public void setPortletName(String portletName) {
134: _portletName = portletName;
135: }
136:
137: /**
138: * Returns the channel name
139: *
140: * @return the channel name
141: **/
142: public String getChannelName() {
143: return _channelName;
144: }
145:
146: /**
147: * Sets the channel name
148: *
149: * @param channelName the channel name to set to
150: */
151: public void setChannelName(String channelName) {
152: _channelName = channelName;
153: }
154:
155: /**
156: * Returns the HttpServletRequest.
157: *
158: * @return the HttpServletRequest
159: **/
160: public HttpServletRequest getHttpServletRequest() {
161: return _req.getHttpServletRequest();
162: }
163:
164: /**
165: * Returns the current window state of the channel.
166: *
167: * @return current window state
168: **/
169: public WindowState getWindowState() {
170: return _req.getWindowState();
171: }
172:
173: /**
174: * Returns the current mode of the channel.
175: *
176: * @return the current channel mode
177: **/
178: public ChannelMode getChannelMode() {
179: return _req.getChannelMode();
180: }
181:
182: /**
183: * Returns the entityID of the channel that this request is directed to.
184: *
185: * @return the entity ID
186: **/
187: public String getEntityID() {
188: return _req.getEntityID();
189: }
190:
191: /**
192: * Returns the ChannelURLFactory class.
193: *
194: * @return the ChannelURLFactory class.
195: **/
196: public ChannelURLFactory getChannelURLFactory() {
197: return _req.getChannelURLFactory();
198: }
199:
200: /**
201: * Returns the ID of the current user.
202: *
203: * @return the ID of the current user.
204: **/
205: public String getUserID() {
206: return _req.getUserID();
207: }
208:
209: /**
210: * Returns a <code>List</code> of all the
211: * roles of the current user. Each value in the list is a String
212: * representation of a role value.
213: *
214: * @return the roles of the current user
215: **/
216: public List getRoles() {
217: return _req.getRoles();
218: }
219:
220: /**
221: * Returns a <code>List</code> of all the
222: * allowable window states for the current channel to be changed to in
223: * this user request. Each value in the list is a <code>WindowState
224: * </code> object.
225: *
226: * @return the allowable window states
227: **/
228: public List getAllowableWindowState() {
229: return _req.getAllowableWindowState();
230: }
231:
232: /**
233: * Returns a <code>List</code> of all the
234: * allowable channel modes for the current channel to be changed to in
235: * this user request. Each value in the list is a <code>ChannelMode
236: * </code> object.
237: *
238: * @return the allowable channel modes
239: **/
240: public List getAllowableChannelMode() {
241: return _req.getAllowableChannelMode();
242: }
243:
244: /**
245: * Returns a <code>List</code> of all the
246: * allowable content type for the current channel.
247: *
248: * @return the allowable content types
249: **/
250: public List getAllowableContentType() {
251: return _req.getAllowableContentType();
252: }
253:
254: /**
255: * Sets the user locale
256: *
257: * @param Locale the user locale
258: */
259: public void setLocale(Locale locale) {
260: _locale = locale;
261: }
262:
263: /**
264: * Returns the user locale.
265: *
266: * @return current user locale.
267: **/
268: public Locale getLocale() {
269: return _locale;
270: }
271:
272: /**
273: * Sets the sso token
274: *
275: * @param SSOToken the sso token
276: */
277: public SSOToken getSSOToken() {
278: return _token;
279: }
280:
281: /**
282: * Returns the sso token.
283: *
284: * @return sso token for the current session.
285: **/
286: public void setSSOToken(SSOToken token) {
287: _token = token;
288: }
289:
290: public void setResponseContentType(String responseContentType) {
291: this .responseContentType = responseContentType;
292: }
293:
294: public String getResponseContentType() {
295: return responseContentType;
296: }
297: }
|