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
32 public class PortalContextProviderImpl implements PortalContextProvider {
33
34
35 /*** Portal information */
36 private String info;
37
38 /*** supported portlet modes by this portal */
39 private Vector modes;
40
41 /*** supported window states by this portal */
42 private Vector states;
43
44 /*** portal properties */
45 private HashMap properties = new HashMap();
46
47
48 public PortalContextProviderImpl()
49 {
50
51 modes = getDefaultModes();
52
53 states = getDefaultStates();
54
55 info = Config.getParameters().getString("portaldriver.info");
56 }
57
58
59
60 public java.lang.String getProperty(java.lang.String name)
61 {
62 if (name == null) {
63 throw new IllegalArgumentException("Property name == null");
64 }
65
66 return(String) properties.get(name);
67 }
68
69
70 public java.util.Collection getPropertyNames()
71 {
72 return properties.keySet();
73 }
74
75
76 public java.util.Collection getSupportedPortletModes()
77 {
78 return modes;
79 }
80
81
82 public java.util.Collection getSupportedWindowStates()
83 {
84 return states;
85 }
86
87
88 public String getPortalInfo()
89 {
90 return info;
91 }
92
93
94
95 private Vector getDefaultModes()
96 {
97
98 Vector m = new Vector();
99
100 String[] supportedModes = Config.getParameters().getStrings("supported.portletmode");
101
102 for (int i=0; i<supportedModes.length; i++) {
103 m.add(new PortletMode(supportedModes[i].toString().toLowerCase()));
104 }
105
106 return m;
107 }
108
109 private Vector getDefaultStates()
110 {
111 Vector s = new Vector();
112
113 String[] supportedStates = Config.getParameters().getStrings("supported.windowstate");
114
115 for (int i=0; i<supportedStates.length; i++) {
116 s.add(new WindowState(supportedStates[i].toString().toLowerCase()));
117 }
118
119 return s;
120 }
121
122
123
124
125
126 public void setProperty(String name, String value)
127 {
128 if (name == null) {
129 throw new IllegalArgumentException("Property name == null");
130 }
131
132 properties.put(name, value);
133 }
134
135
136
137 public void setSupportedPortletModes(Enumeration portletModes)
138 {
139 Vector v = new Vector();
140 while (portletModes.hasMoreElements()) {
141 v.add(portletModes.nextElement());
142 }
143 modes = v;
144 }
145
146
147 public void setSupportedWindowStates(Enumeration windowStates)
148 {
149 Vector v = new Vector();
150 while (windowStates.hasMoreElements()) {
151 v.add(windowStates.nextElement());
152 }
153 states = v;
154 }
155
156 /***
157 * reset all values to default portlet modes and window states;
158 * delete all properties and set the given portlet information
159 * as portlet info string.
160 *
161 * @param portalInfo portal information string that will be returned
162 * by the <code>getPortalInfo</code> call.
163 */
164 public void reset(String portalInfo)
165 {
166 info = new String(portalInfo);
167
168
169 modes = getDefaultModes();
170
171 states = getDefaultStates();
172
173 properties.clear();
174 }
175
176
177
178 }