1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.services.information;
18
19 import java.util.Iterator;
20 import java.util.HashSet;
21 import javax.servlet.ServletConfig;
22 import javax.servlet.http.HttpServletRequest;
23 import javax.portlet.WindowState;
24 import javax.portlet.PortletMode;
25
26 import org.apache.pluto.services.information.DynamicInformationProvider;
27 import org.apache.pluto.services.information.PortletActionProvider;
28 import org.apache.pluto.services.information.ResourceURLProvider;
29 import org.apache.pluto.om.window.PortletWindow;
30 import org.apache.pluto.services.information.PortletURLProvider;
31 import org.apache.jetspeed.container.state.MutableNavigationalState;
32 import org.apache.jetspeed.container.state.NavigationalState;
33 import org.apache.jetspeed.engine.core.PortletActionProviderImpl;
34 import org.apache.jetspeed.request.RequestContext;
35 import org.apache.jetspeed.request.RequestContextComponent;
36 import org.apache.jetspeed.Jetspeed;
37
38 /***
39 * Provides dynamic information to Pluto Container:
40 *
41 * 1. getPortletURL
42 * 2. getRequestMimetype
43 * 3. getResponseMimetype
44 * 4. getResponseMimetypes
45 * 5. getPortletMode
46 * 6. getPreviousPortletMode
47 * 7. getWindowState
48 * 8. getPreviousWindowState
49 * 9. isPortletModeAllowed
50 * 10. isWindowStateAllowed
51 * 11. getSupportedPortletModes
52 * 12. getSupportedWindowStates
53 * 13. getAllParameters
54 *
55 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
56 * @version $Id: DynamicInformationProviderImpl.java 517719 2007-03-13 15:05:48Z ate $
57 */
58 public class DynamicInformationProviderImpl implements DynamicInformationProvider
59 {
60 HttpServletRequest request = null;
61 ServletConfig config = null;
62
63 RequestContext context;
64
65 public DynamicInformationProviderImpl(HttpServletRequest request,
66 ServletConfig config)
67 {
68 this.request = request;
69 this.config = config;
70
71
72 RequestContextComponent rcc = (RequestContextComponent)Jetspeed.getComponentManager().getComponent(RequestContextComponent.class);
73 this.context = rcc.getRequestContext(request);
74 }
75
76 public PortletURLProvider getPortletURLProvider(PortletWindow portletWindow)
77 {
78 return new PortletURLProviderImpl(this.context, portletWindow);
79 }
80
81 public String getRequestContentType()
82 {
83 return context.getMimeType().toString();
84 }
85
86 public String getResponseContentType()
87 {
88 return context.getMimeType().toString();
89 }
90
91 public Iterator getResponseContentTypes()
92 {
93 HashSet responseMimeTypes = new HashSet(NumberOfKnownMimetypes);
94
95 responseMimeTypes.add("text/html");
96
97 return responseMimeTypes.iterator();
98 }
99
100 public PortletMode getPortletMode(PortletWindow portletWindow)
101 {
102 NavigationalState navState = context.getPortalURL().getNavigationalState();
103 return navState.getMode(portletWindow);
104 }
105
106 public WindowState getWindowState(PortletWindow portletWindow)
107 {
108 NavigationalState navState = context.getPortalURL().getNavigationalState();
109 return navState.getState(portletWindow);
110 }
111
112 public boolean isPortletModeAllowed(PortletMode mode)
113 {
114 return Jetspeed.getContext().isPortletModeAllowed(mode);
115 }
116
117 public boolean isWindowStateAllowed(WindowState state)
118 {
119 return Jetspeed.getContext().isWindowStateAllowed(state);
120 }
121
122 public String getBasePortalURL()
123 {
124 return context.getPortalURL().getBaseURL();
125 }
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165 private final static int NumberOfKnownMimetypes = 15;
166
167
168 /***
169 * <p>
170 * getPortletActionProvider
171 * </p>
172 *
173 * @see org.apache.pluto.services.information.DynamicInformationProvider#getPortletActionProvider(org.apache.pluto.om.window.PortletWindow)
174 * @param arg0
175 * @return
176 */
177 public PortletActionProvider getPortletActionProvider(PortletWindow window)
178 {
179 return new PortletActionProviderImpl((MutableNavigationalState)context.getPortalURL().getNavigationalState(), window);
180 }
181
182 /***
183 * <p>
184 * getResourceURLProvider
185 * </p>
186 *
187 * @see org.apache.pluto.services.information.DynamicInformationProvider#getResourceURLProvider(org.apache.pluto.om.window.PortletWindow)
188 * @param arg0
189 * @return
190 */
191 public ResourceURLProvider getResourceURLProvider(PortletWindow window)
192 {
193
194 return new ResourceURLProviderImpl(this.context, window);
195 }
196
197 }