001: /*
002: Copyright (C) 2003-2006 Know Gate S.L. All rights reserved.
003: C/Oņa, 107 1š2 28050 Madrid (Spain)
004:
005: Redistribution and use in source and binary forms, with or without
006: modification, are permitted provided that the following conditions
007: are met:
008:
009: 1. Redistributions of source code must retain the above copyright
010: notice, this list of conditions and the following disclaimer.
011:
012: 2. The end-user documentation included with the redistribution,
013: if any, must include the following acknowledgment:
014: "This product includes software parts from hipergate
015: (http://www.hipergate.org/)."
016: Alternately, this acknowledgment may appear in the software itself,
017: if and wherever such third-party acknowledgments normally appear.
018:
019: 3. The name hipergate must not be used to endorse or promote products
020: derived from this software without prior written permission.
021: Products derived from this software may not be called hipergate,
022: nor may hipergate appear in their name, without prior written
023: permission.
024:
025: This library is distributed in the hope that it will be useful,
026: but WITHOUT ANY WARRANTY; without even the implied warranty of
027: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
028:
029: You should have received a copy of hipergate License with this code;
030: if not, visit http://www.hipergate.org or mail to info@hipergate.org
031: */
032:
033: package com.knowgate.http.portlets;
034:
035: import java.util.Hashtable;
036: import java.util.Enumeration;
037: import java.util.Properties;
038: import java.util.Map;
039: import java.util.Locale;
040:
041: import java.security.Principal;
042:
043: import javax.portlet.*;
044:
045: import javax.servlet.http.HttpServletRequest;
046:
047: /**
048: * @author Sergio Montoro Ten
049: * @version 1.0
050: */
051:
052: public class HipergateRenderRequest implements RenderRequest {
053:
054: private HttpServletRequest oSrvltReq;
055: private Properties oProps;
056: private Hashtable oAttrs;
057: private WindowState oWinState;
058:
059: public HipergateRenderRequest(HttpServletRequest oServletReq) {
060: oAttrs = new Hashtable();
061: oProps = new Properties();
062: oSrvltReq = oServletReq;
063: oWinState = WindowState.NORMAL;
064: }
065:
066: public boolean isWindowStateAllowed(WindowState state) {
067: return state == WindowState.NORMAL;
068: }
069:
070: public boolean isPortletModeAllowed(PortletMode mode) {
071: return mode == PortletMode.VIEW;
072: }
073:
074: public PortletMode getPortletMode() {
075: return PortletMode.VIEW;
076: }
077:
078: public WindowState getWindowState() {
079: return oWinState;
080: }
081:
082: public void setWindowState(String state) {
083: if (state.equalsIgnoreCase("NORMAL"))
084: oWinState = WindowState.NORMAL;
085: else if (state.equalsIgnoreCase("MINIMIZED"))
086: oWinState = WindowState.MINIMIZED;
087: else if (state.equalsIgnoreCase("MAXIMIZED"))
088: oWinState = WindowState.MAXIMIZED;
089: }
090:
091: public void setWindowState(WindowState state) {
092: oWinState = state;
093: }
094:
095: public PortletPreferences getPreferences() {
096: return null;
097: }
098:
099: public PortletSession getPortletSession() {
100: return null;
101: }
102:
103: public PortletSession getPortletSession(boolean create) {
104: return null;
105: }
106:
107: public String getProperty(String name) {
108: return oProps.getProperty(name);
109: }
110:
111: public void setProperty(String name, String value) {
112: oProps.put(name, value);
113: }
114:
115: public void setProperties(Properties props) {
116: oProps = props;
117: }
118:
119: public Enumeration getProperties(String name) {
120: return (Enumeration) oProps;
121: }
122:
123: public Enumeration getPropertyNames() {
124: return oProps.keys();
125: }
126:
127: public PortalContext getPortalContext() {
128: return null;
129:
130: }
131:
132: public String getAuthType() {
133: return null;
134: }
135:
136: public String getContextPath() {
137: return oSrvltReq.getContextPath();
138: }
139:
140: public String getRemoteUser() {
141: return oSrvltReq.getRemoteUser();
142: }
143:
144: public Principal getUserPrincipal() {
145: return oSrvltReq.getUserPrincipal();
146: }
147:
148: public boolean isUserInRole(String role) {
149: return false;
150: }
151:
152: public Object getAttribute(String name) {
153: return oAttrs.get(name);
154: }
155:
156: public Enumeration getAttributeNames() {
157: return oAttrs.keys();
158: }
159:
160: public String getParameter(String name) {
161: return oSrvltReq.getParameter(name);
162: }
163:
164: public Enumeration getParameterNames() {
165: return oSrvltReq.getParameterNames();
166: }
167:
168: public String[] getParameterValues(String name) {
169: return oSrvltReq.getParameterValues(name);
170: }
171:
172: public Map getParameterMap() {
173: return oSrvltReq.getParameterMap();
174: }
175:
176: public boolean isSecure() {
177: return false;
178: }
179:
180: public void setAttribute(String name, Object o) {
181: if (oAttrs.containsKey(name))
182: oAttrs.remove(name);
183: oAttrs.put(name, o);
184: }
185:
186: public void removeAttribute(String name) {
187: oAttrs.remove(name);
188: }
189:
190: public String getRequestedSessionId() {
191: return oSrvltReq.getRequestedSessionId();
192: }
193:
194: public boolean isRequestedSessionIdValid() {
195: return oSrvltReq.isRequestedSessionIdValid();
196: }
197:
198: public String getResponseContentType() {
199: throw new UnsupportedOperationException(
200: "getResponseContentType() not implemented at HipergateRenderRequest");
201: }
202:
203: public Enumeration getResponseContentTypes() {
204: throw new UnsupportedOperationException(
205: "getResponseContentTypes() not implemented HipergateRenderRequest");
206: }
207:
208: public Locale getLocale() {
209: return oSrvltReq.getLocale();
210: }
211:
212: public Enumeration getLocales() {
213: return oSrvltReq.getLocales();
214: }
215:
216: public String getScheme() {
217: return oSrvltReq.getScheme();
218: }
219:
220: public String getServerName() {
221: return oSrvltReq.getServerName();
222: }
223:
224: public int getServerPort() {
225: return oSrvltReq.getServerPort();
226: }
227: }
|