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.io.InputStream;
036:
037: import java.net.URL;
038:
039: import java.util.Set;
040: import java.util.Hashtable;
041: import java.util.Properties;
042: import java.util.Enumeration;
043:
044: import javax.portlet.PortletContext;
045: import javax.portlet.PortletRequestDispatcher;
046:
047: import com.knowgate.debug.*;
048:
049: /**
050: * @author Sergio Montoro Ten
051: * @version 0.1
052: */
053:
054: public class HipergatePortletContext implements PortletContext {
055:
056: private Hashtable oAttribs;
057: private Properties oParams;
058:
059: public HipergatePortletContext() {
060: oAttribs = new Hashtable();
061: oParams = new Properties();
062: }
063:
064: public Object getAttribute(String sAttributeName) {
065: return oAttribs.get(sAttributeName);
066: }
067:
068: public Enumeration getAttributeNames() {
069: return oAttribs.keys();
070: }
071:
072: public String getInitParameter(String sParameterName) {
073: return oParams.getProperty(sParameterName);
074: }
075:
076: public Enumeration getInitParameterNames() {
077: return oParams.keys();
078: }
079:
080: public int getMajorVersion() {
081: return 1;
082: }
083:
084: public int getMinorVersion() {
085: return 0;
086: }
087:
088: public String getMimeType(String sFile) {
089: throw new UnsupportedOperationException(
090: "Method getMimeType() not implemented by HipergatePortletContext");
091: }
092:
093: public PortletRequestDispatcher getNamedDispatcher(String sName) {
094: throw new UnsupportedOperationException(
095: "Method getNamedDispatcher() not implemented by HipergatePortletContext");
096: }
097:
098: public PortletRequestDispatcher getRequestDispatcher(String sPath) {
099: throw new UnsupportedOperationException(
100: "Method getRequestDispatcher() not implemented by HipergatePortletContext");
101: }
102:
103: public String getPortletContextName() {
104: throw new UnsupportedOperationException(
105: "Method getPortletContextName() not implemented by HipergatePortletContext");
106: }
107:
108: public String getRealPath(String sPath) {
109: throw new UnsupportedOperationException(
110: "Method getRealPath() not implemented by HipergatePortletContext");
111: }
112:
113: public URL getResource(String sPath) {
114: throw new UnsupportedOperationException(
115: "Method getResource() not implemented by HipergatePortletContext");
116: }
117:
118: public Set getResourcePaths(String sPath) {
119: throw new UnsupportedOperationException(
120: "Method getResourcePaths() not implemented by HipergatePortletContext");
121: }
122:
123: public InputStream getResourceAsStream(String sPath) {
124: throw new UnsupportedOperationException(
125: "Method getResourceAsStream() not implemented by HipergatePortletContext");
126: }
127:
128: public String getServerInfo() {
129: return "hipergate Portlet Container Emulator";
130: }
131:
132: public void log(String sMsg) {
133: DebugFile.writeln(sMsg);
134: }
135:
136: public void log(String sMsg, Throwable oXcpt) {
137: DebugFile.writeln(sMsg);
138: new ErrorHandler(oXcpt);
139: }
140:
141: public void removeAttribute(String sName) {
142: oAttribs.remove(sName);
143: }
144:
145: public void setAttribute(String sName, Object oAttr) {
146: oAttribs.put(sName, oAttr);
147: }
148: }
|