001: /*
002: * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005:
006: package com.sun.portal.harness;
007:
008: import java.util.Hashtable;
009: import java.util.List;
010: import java.util.Map;
011: import java.util.Locale;
012: import java.util.Set;
013: import java.util.Collections;
014:
015: import java.io.File;
016:
017: import javax.servlet.http.HttpServletRequest;
018: import javax.servlet.http.HttpServletResponse;
019: import javax.servlet.http.Cookie;
020:
021: import com.sun.portal.desktop.context.DesktopContext;
022: import com.sun.portal.providers.context.ContainerProviderContext;
023: import com.sun.portal.desktop.context.SessionListener;
024: import com.sun.portal.desktop.context.UserListener;
025: import com.sun.portal.desktop.context.ContextException;
026: import com.sun.portal.desktop.context.ContextError;
027:
028: import com.sun.portal.providers.Provider;
029: import com.sun.portal.providers.ProviderException;
030:
031: import com.sun.portal.desktop.dp.DPRoot;
032:
033: import com.sun.portal.desktop.template.ParsedTagArray;
034:
035: public class HarnessDesktopContext implements DesktopContext {
036:
037: HarnessDesktopContext(HarnessProviderContext ctx) {
038: m_HCtx = ctx;
039: }
040:
041: public long getLastRequestTimeMillis() {
042: return System.currentTimeMillis();
043: }
044:
045: public long getLastAccess() {
046: return m_LastAccess;
047: }
048:
049: public void setLastAccess(long val) {
050: m_LastAccess = val;
051: }
052:
053: public ContainerProviderContext getContainerProviderContext() {
054: return m_HCtx;
055: }
056:
057: public String getContentType() {
058: return m_HCtx.getContentType();
059: }
060:
061: public String encodeURL(String url) {
062: return m_HCtx.encodeURL(url);
063: }
064:
065: public Set getAncestors(HttpServletRequest req, String channel) {
066: // not implemented here
067: return Collections.EMPTY_SET;
068: }
069:
070: public String getClientTypeProperty(String clientType, String key) {
071: return m_HCtx.getClientTypeProperty(clientType, key);
072: }
073:
074: public String getLogoutURL() {
075: return m_HCtx.getLogoutURL();
076: }
077:
078: public String getLoginURL() {
079: return getLogoutURL();
080: }
081:
082: public String getDefaultClientType() {
083: return m_HCtx.getDefaultClientType();
084: }
085:
086: public void setDebugLevel(short level) {
087: m_HCtx.setDebugLevel(level);
088: }
089:
090: public String getDesktopURL(HttpServletRequest req) {
091: return m_HCtx.getDesktopURL(req);
092: }
093:
094: public String getDesktopURL(HttpServletRequest req, Map m1, Map m2) {
095: // FIXME
096: return m_HCtx.getDesktopURL(req);
097: }
098:
099: public String getDesktopURL(HttpServletRequest req, String str) {
100: // FIXME
101: return m_HCtx.getDesktopURL(req);
102: }
103:
104: public String getContainerProviderContextClassName() {
105: throw new ContextError(
106: "Unexpected call to getContainerProviderContextClassName()");
107: }
108:
109: public String getEditProviderContainerName() {
110: throw new ContextError(
111: "Unexpected call to getEditProviderContainerName()");
112: }
113:
114: public String getTemplateBaseDir() {
115: return m_HCtx.getTemplateBaseDir();
116: }
117:
118: public String getConfigProperty(String key) {
119: return m_HCtx.getConfigProperty(key);
120: }
121:
122: public void debugMessage(Object o, Throwable t) {
123: m_HCtx.debugMessage(o, t);
124: }
125:
126: public void addSessionListener(SessionListener sl) {
127: m_HCtx.addSessionListener(sl);
128: }
129:
130: public boolean isDebugMessageEnabled() {
131: return m_HCtx.isDebugMessageEnabled();
132: }
133:
134: public String getUserID() {
135: return m_HCtx.getUserID();
136: }
137:
138: public StringBuffer getRequestServer(HttpServletRequest req) {
139: StringBuffer buf = new StringBuffer();
140: buf.append(req.getRequestURI());
141: return buf;
142: }
143:
144: public void debugWarning(Object o) {
145: m_HCtx.debugWarning(o);
146: }
147:
148: public boolean isDebugErrorEnabled() {
149: return m_HCtx.isDebugErrorEnabled();
150: }
151:
152: public void debugMessage(Object o) {
153: m_HCtx.debugMessage(o);
154: }
155:
156: /**
157: * Validates user session.
158: * communicating with session
159: */
160: public boolean validateSession(HttpServletRequest req) {
161: return true;
162: }
163:
164: public void refresh() {
165: }
166:
167: public boolean getIsStale() {
168: return false;
169: }
170:
171: public File getTemplatePath(String app, String provider, String file) {
172: return m_HCtx.getTemplatePath(app, file);
173: }
174:
175: public File getTemplatePath(String desktopType, String locale,
176: String app, String provider, String clientType,
177: String file, String baseDir) {
178: return m_HCtx.getTemplatePath(desktopType, locale, app,
179: clientType, file, baseDir);
180:
181: }
182:
183: public File getTemplateMostSpecificPath(String app,
184: String provider, String file) {
185: return getTemplatePath(app, provider, file);
186: }
187:
188: public File getTemplateMostSpecificPath(String desktopType,
189: String locale, String app, String provider,
190: String clientType, String file, String baseDir) {
191: return getTemplatePath(desktopType, locale, app, provider,
192: clientType, file, baseDir);
193: }
194:
195: public String getJSPCompilerWARClassPath() {
196: return m_HCtx.getJSPCompilerWARClassPath();
197: }
198:
199: public boolean isDebugEnabled() {
200: return m_HCtx.isDebugEnabled();
201: }
202:
203: public short getDebugLevel() {
204: return m_HCtx.getDebugLevel();
205: }
206:
207: public StringBuffer getTemplate(String app, String provider,
208: String file, Hashtable table) {
209: return m_HCtx.getTemplate(app, file, table);
210: }
211:
212: public StringBuffer getTemplate(String desktopType, String locale,
213: String app, String provider, String clientType,
214: String file, Hashtable table, String baseDir) {
215: return m_HCtx.getTemplate(desktopType, locale, app, clientType,
216: file, table, baseDir);
217: }
218:
219: public String getClientProperty(String key) {
220: return m_HCtx.getClientProperty(key);
221: }
222:
223: public String getClientTypeProperty(String key) {
224: return m_HCtx.getClientTypeProperty(key);
225: }
226:
227: public Set getClientTypeProperties(String clientType, String key) {
228: // FIXME
229: return null;
230: }
231:
232: public File[] getTemplatePaths(String app, String provider,
233: String file) {
234: return m_HCtx.getTemplatePaths(app, file);
235: }
236:
237: public DPRoot getDPRoot() {
238: throw new ContextError("Unexpected call to getDPRoot()");
239: }
240:
241: public void init(HttpServletRequest req) {
242: }
243:
244: /**
245: * Gets the property stored in this session.
246: * @param name The property name.
247: * @return The property value in String format. If property is
248: * not not found, return null.
249: * there are errors in getting the property.
250: */
251: public Object getSessionProperty(String name) {
252: return m_HCtx.getSessionProperty(name);
253: }
254:
255: public ParsedTagArray getTemplate(String app, String provider,
256: String file) {
257: return new ParsedTagArray(m_HCtx.getTemplate(app, file));
258: }
259:
260: public ParsedTagArray getTemplate(String desktopType,
261: String locale, String app, String provider,
262: String clientType, String file, String baseDir) {
263: return new ParsedTagArray(m_HCtx.getTemplate(desktopType,
264: locale, app, clientType, file, baseDir));
265: }
266:
267: /**
268: * Sets a property for this session.
269: * @param name The property name
270: * @param obj The property value
271: * there are errors in setting the property name and value
272: */
273: public void setSessionProperty(String name, Object obj) {
274: m_HCtx.setSessionProperty(name, obj);
275: }
276:
277: public void setClientProperty(String name, String str) {
278: m_HCtx.setClientProperty(name, str);
279: }
280:
281: public String getJSPScratchDir() {
282: return m_HCtx.getJSPScratchDir();
283: }
284:
285: /**
286: * Write out any modified data to the persistent store, if necessary.
287: */
288: public void store() {
289: }
290:
291: public void debugError(Object o, Throwable t) {
292: m_HCtx.debugError(o, t);
293: }
294:
295: public void addUserReference() {
296: }
297:
298: public void addUserListener(UserListener sl) {
299: }
300:
301: public String getClientPath() {
302: return m_HCtx.getClientPath();
303: }
304:
305: public short getCookieSupport() {
306: return m_HCtx.getCookieSupport();
307: }
308:
309: public String getEncoderClassName() {
310: return m_HCtx.getEncoderClassName();
311: }
312:
313: public void debugError(Object o) {
314: m_HCtx.debugError(o);
315: }
316:
317: public Provider getProvider(HttpServletRequest req, String name) {
318: throw new ContextError("Unexpected call to getProvider()");
319: }
320:
321: public String getLocaleString() {
322: return m_HCtx.getLocaleString();
323: }
324:
325: public String getStaticContentPath() {
326: return m_HCtx.getStaticContentPath();
327: }
328:
329: public void debugWarning(Object o, Throwable t) {
330: m_HCtx.debugWarning(o, t);
331: }
332:
333: /*
334: public String getSystemIDPath() {
335: return m_HCtx.getSystemIDPath();
336: }
337: */
338:
339: public String getClientType() {
340: return m_HCtx.getClientType();
341: }
342:
343: public boolean isPasContextActivated() {
344: return false;
345: }
346:
347: public boolean isDebugWarningEnabled() {
348: return m_HCtx.isDebugWarningEnabled();
349: }
350:
351: public String getSessionID() {
352: return m_HCtx.getSessionID();
353: }
354:
355: public boolean isAuthless(HttpServletRequest req) {
356: return m_HCtx.isAuthless(req);
357: }
358:
359: public boolean isWSRP(HttpServletRequest req) {
360: return false; //tmp - Cathy
361: }
362:
363: public String getAuthenticationType() {
364: return "harness";
365: }
366:
367: //
368: // client properties
369: //
370: public Cookie getClientProperties() {
371: return null;
372: }
373:
374: /**
375: * Gets the attribute. 'Attributes' are settings that are not
376: * channel-related (i.e. not stored in display profile)
377: * @param name The attribute name.
378: * @return The attribute value in String format. If property is
379: * not not found, return null.
380: */
381: public String getStringAttribute(String name) {
382: return m_HCtx.getStringAttribute(name);
383: }
384:
385: public String getStringAttribute(String name, Locale locale) {
386: return getStringAttribute(name);
387: }
388:
389: public Map getContent(HttpServletRequest req,
390: HttpServletResponse res, List providers, int timeout)
391: throws ContextException, ProviderException {
392: throw new ContextError("Unexpected call to getContent()");
393: }
394:
395: public String getCharset() {
396: return m_HCtx.getCharset();
397: }
398:
399: public StringBuffer getContent(HttpServletRequest req,
400: HttpServletResponse res, String name)
401: throws ContextException, ProviderException {
402: throw new ContextError("Unexpected call to getContent()");
403: }
404:
405: public void setLastRequestTimeMillis(long lastRequest) {
406: }
407:
408: public String getDesktopType() {
409: return m_HCtx.getDesktopType();
410: }
411:
412: public String getProviderClassBaseDir() {
413: return m_HCtx.getProviderClassBaseDir();
414: }
415:
416: public Locale getLocale() {
417: return m_HCtx.getLocale();
418: }
419:
420: public String getPropertiesContextClassName() {
421: return m_HCtx.getPropertiesContextClassName();
422: }
423:
424: public Set getRoles() {
425: return null;
426: }
427:
428: public void setStringAttribute(String name, String val) {
429: m_HCtx.setStringAttribute(name, val);
430: }
431:
432: public void setDPRootCustomized(boolean val) {
433: m_DPRootCustomized = val;
434: }
435:
436: public boolean isDPRootCustomized() {
437: return m_DPRootCustomized;
438: }
439:
440: public String getDefaultChannelName() {
441: return m_DefaultChannelName;
442: }
443:
444: public void setDefaultChannelName(String nm) {
445: m_DefaultChannelName = nm;
446: }
447:
448: public String getTopChannelName(HttpServletRequest req) {
449: throw new ContextError("Unexpected call to getTopChannelName()");
450: }
451:
452: public void setTopChannelName(HttpServletRequest req, String channel) {
453: throw new ContextError("Unexpected call to setTopChannelName()");
454: }
455:
456: public void setIsStale(boolean stale) {
457: throw new ContextError("Unexpected call to setIsStale()");
458: }
459:
460: private HarnessProviderContext m_HCtx;
461: private long m_LastAccess = 0;
462: private boolean m_DPRootCustomized = false;
463: private String m_DefaultChannelName;
464: }
|