1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.pluto.portalImpl.core;
21
22 import java.util.Enumeration;
23 import java.util.HashMap;
24 import java.util.Vector;
25
26 import javax.portlet.PortletMode;
27 import javax.portlet.WindowState;
28
29 import org.apache.pluto.portalImpl.services.config.Config;
30 import org.apache.pluto.services.information.PortalContextProvider;
31 import org.apache.pluto.Environment;
32
33 /***
34
35 *
36 * To change this generated comment edit the template variable "typecomment":
37 * Window>Preferences>Java>Templates.
38 * To enable and disable the creation of type comments go to
39 * Window>Preferences>Java>Code Generation.
40 */
41 public class PortalContextProviderImpl implements PortalContextProvider {
42
43
44 /*** Portal information */
45 private String info = null;
46
47 /*** supported portlet modes by this portal */
48 private Vector modes;
49
50 /*** supported window states by this portal */
51 private Vector states;
52
53 /*** portal properties */
54 private HashMap properties = new HashMap();
55
56
57 public PortalContextProviderImpl()
58 {
59
60 modes = getDefaultModes();
61
62 states = getDefaultStates();
63
64 info = Config.getParameters().getString("portaldriver.info");
65 }
66
67
68
69 public java.lang.String getProperty(java.lang.String name)
70 {
71 if (name == null) {
72 throw new IllegalArgumentException("Property name == null");
73 }
74
75 return(String) properties.get(name);
76 }
77
78
79 public java.util.Collection getPropertyNames()
80 {
81 return properties.keySet();
82 }
83
84
85 public java.util.Collection getSupportedPortletModes()
86 {
87 return modes;
88 }
89
90
91 public java.util.Collection getSupportedWindowStates()
92 {
93 return states;
94 }
95
96
97 public String getPortalInfo()
98 {
99 return info;
100 }
101
102
103
104 private Vector getDefaultModes()
105 {
106
107 Vector m = new Vector();
108
109 String[] supportedModes = Config.getParameters().getStrings("supported.portletmode");
110
111 for (int i=0; i<supportedModes.length; i++) {
112 m.add(new PortletMode(supportedModes[i].toString().toLowerCase()));
113 }
114
115 return m;
116 }
117
118 private Vector getDefaultStates()
119 {
120 Vector s = new Vector();
121
122 String[] supportedStates = Config.getParameters().getStrings("supported.windowstate");
123
124 for (int i=0; i<supportedStates.length; i++) {
125 s.add(new WindowState(supportedStates[i].toString().toLowerCase()));
126 }
127
128 return s;
129 }
130
131
132
133
134
135 public void setProperty(String name, String value)
136 {
137 if (name == null) {
138 throw new IllegalArgumentException("Property name == null");
139 }
140
141 properties.put(name, value);
142 }
143
144
145
146 public void setSupportedPortletModes(Enumeration portletModes)
147 {
148 Vector v = new Vector();
149 while (portletModes.hasMoreElements()) {
150 v.add(portletModes.nextElement());
151 }
152 modes = v;
153 }
154
155
156 public void setSupportedWindowStates(Enumeration windowStates)
157 {
158 Vector v = new Vector();
159 while (windowStates.hasMoreElements()) {
160 v.add(windowStates.nextElement());
161 }
162 states = v;
163 }
164
165 /***
166 * reset all values to default portlet modes and window states;
167 * delete all properties and set the given portlet information
168 * as portlet info string.
169 *
170 * @param portalInfo portal information string that will be returned
171 * by the <code>getPortalInfo</code> call.
172 */
173 public void reset(String portalInfo)
174 {
175 info = new String(portalInfo);
176
177
178 modes = getDefaultModes();
179
180 states = getDefaultStates();
181
182 properties.clear();
183 }
184
185
186
187 }