Source Code Cross Referenced for AbstractNavigationalState.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » container » state » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » jetspeed 2.1.3 » org.apache.jetspeed.container.state.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.jetspeed.container.state.impl;
018:
019:        import java.io.UnsupportedEncodingException;
020:        import java.util.Collections;
021:        import java.util.Iterator;
022:        import java.util.Map;
023:
024:        import javax.portlet.PortletMode;
025:        import javax.portlet.WindowState;
026:
027:        import org.apache.jetspeed.JetspeedActions;
028:        import org.apache.jetspeed.cache.JetspeedContentCache;
029:        import org.apache.jetspeed.container.state.MutableNavigationalState;
030:        import org.apache.jetspeed.om.common.portlet.PortletApplication;
031:        import org.apache.pluto.om.window.PortletWindow;
032:
033:        /**
034:         * BaseNavigationalState
035:         *
036:         * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
037:         * @version $Id: AbstractNavigationalState.java 554926 2007-07-10 13:12:26Z ate $
038:         */
039:        public abstract class AbstractNavigationalState implements 
040:                MutableNavigationalState {
041:            private NavigationalStateCodec codec;
042:            private PortletWindowRequestNavigationalStates requestStates;
043:            protected JetspeedContentCache cache;
044:            protected JetspeedContentCache decorationCache;
045:
046:            public AbstractNavigationalState(NavigationalStateCodec codec,
047:                    JetspeedContentCache cache) {
048:                this (codec, cache, null);
049:            }
050:
051:            public AbstractNavigationalState(NavigationalStateCodec codec,
052:                    JetspeedContentCache cache,
053:                    JetspeedContentCache decorationCache) {
054:                this .codec = codec;
055:                this .cache = cache;
056:                this .decorationCache = decorationCache;
057:            }
058:
059:            public void init(String encodedState, String characterEncoding)
060:                    throws UnsupportedEncodingException {
061:                if (requestStates == null) {
062:                    requestStates = codec.decode(encodedState,
063:                            characterEncoding);
064:                }
065:            }
066:
067:            protected PortletWindowRequestNavigationalStates getPortletWindowRequestNavigationalStates() {
068:                return requestStates;
069:            }
070:
071:            public void setState(PortletWindow window, WindowState windowState) {
072:                if (windowState != null) {
073:                    if (!JetspeedActions.getStandardWindowStates().contains(
074:                            windowState)) {
075:                        PortletApplication pa = (PortletApplication) window
076:                                .getPortletEntity().getPortletDefinition()
077:                                .getPortletApplicationDefinition();
078:                        windowState = pa.getMappedWindowState(windowState);
079:                    }
080:                    String windowId = window.getId().toString();
081:                    PortletWindowRequestNavigationalState state = requestStates
082:                            .getPortletWindowNavigationalState(windowId);
083:                    if (state != null
084:                            && (state.getWindowState() == null || !state
085:                                    .getWindowState().equals(windowState))) {
086:                        state.setWindowState(windowState);
087:                    } else {
088:                        state = new PortletWindowRequestNavigationalState(
089:                                windowId);
090:                        requestStates.addPortletWindowNavigationalState(
091:                                windowId, state);
092:                        state.setWindowState(windowState);
093:                    }
094:                    if (windowState.equals(WindowState.MAXIMIZED)) {
095:                        requestStates.setMaximizedWindow(window);
096:                    }
097:                }
098:            }
099:
100:            public void setMode(PortletWindow window, PortletMode portletMode) {
101:                if (portletMode != null) {
102:                    if (!JetspeedActions.getStandardPortletModes().contains(
103:                            portletMode)) {
104:                        PortletApplication pa = (PortletApplication) window
105:                                .getPortletEntity().getPortletDefinition()
106:                                .getPortletApplicationDefinition();
107:                        portletMode = pa.getMappedPortletMode(portletMode);
108:                    }
109:                    String windowId = window.getId().toString();
110:                    PortletWindowRequestNavigationalState state = requestStates
111:                            .getPortletWindowNavigationalState(windowId);
112:                    if (state != null
113:                            && (state.getPortletMode() == null || !state
114:                                    .getPortletMode().equals(portletMode))) {
115:                        state.setPortletMode(portletMode);
116:                    } else {
117:                        state = new PortletWindowRequestNavigationalState(
118:                                windowId);
119:                        requestStates.addPortletWindowNavigationalState(
120:                                windowId, state);
121:                        state.setPortletMode(portletMode);
122:                    }
123:                }
124:            }
125:
126:            public WindowState getMappedState(String windowId) {
127:                WindowState windowState = null;
128:                PortletWindowRequestNavigationalState state = requestStates
129:                        .getPortletWindowNavigationalState(windowId);
130:                if (state != null) {
131:                    windowState = state.getWindowState();
132:                }
133:                return windowState != null ? windowState : WindowState.NORMAL;
134:            }
135:
136:            /**
137:             * @deprecated
138:             */
139:            public WindowState getState(String windowId) {
140:                return getMappedState(windowId);
141:            }
142:
143:            public WindowState getState(PortletWindow window) {
144:                WindowState state = getMappedState(window.getId().toString());
145:                if (state != null
146:                        && !JetspeedActions.getStandardWindowStates().contains(
147:                                state)) {
148:                    PortletApplication pa = (PortletApplication) window
149:                            .getPortletEntity().getPortletDefinition()
150:                            .getPortletApplicationDefinition();
151:                    state = pa.getCustomWindowState(state);
152:                }
153:                return state;
154:            }
155:
156:            public WindowState getMappedState(PortletWindow window) {
157:                return getMappedState(window.getId().toString());
158:            }
159:
160:            public PortletMode getMappedMode(String windowId) {
161:                PortletMode portletMode = null;
162:                PortletWindowRequestNavigationalState state = requestStates
163:                        .getPortletWindowNavigationalState(windowId);
164:                if (state != null) {
165:                    portletMode = state.getPortletMode();
166:                }
167:                return portletMode != null ? portletMode : PortletMode.VIEW;
168:            }
169:
170:            /**
171:             * @deprecated
172:             */
173:            public PortletMode getMode(String windowId) {
174:                return getMappedMode(windowId);
175:            }
176:
177:            public PortletMode getMode(PortletWindow window) {
178:                PortletMode mode = getMappedMode(window.getId().toString());
179:                if (mode != null
180:                        && !JetspeedActions.getStandardPortletModes().contains(
181:                                mode)) {
182:                    PortletApplication pa = (PortletApplication) window
183:                            .getPortletEntity().getPortletDefinition()
184:                            .getPortletApplicationDefinition();
185:                    mode = pa.getCustomPortletMode(mode);
186:                }
187:                return mode;
188:            }
189:
190:            public PortletMode getMappedMode(PortletWindow window) {
191:                return getMappedMode(window.getId().toString());
192:            }
193:
194:            public PortletWindow getMaximizedWindow() {
195:                return requestStates.getMaximizedWindow();
196:            }
197:
198:            public Iterator getParameterNames(PortletWindow window) {
199:                PortletWindowRequestNavigationalState state = requestStates
200:                        .getPortletWindowNavigationalState(window.getId()
201:                                .toString());
202:                if (state != null && state.getParametersMap() != null) {
203:                    return state.getParametersMap().keySet().iterator();
204:                } else {
205:                    return Collections.EMPTY_LIST.iterator();
206:                }
207:            }
208:
209:            public String[] getParameterValues(PortletWindow window,
210:                    String parameterName) {
211:                PortletWindowRequestNavigationalState state = requestStates
212:                        .getPortletWindowNavigationalState(window.getId()
213:                                .toString());
214:                if (state != null && state.getParametersMap() != null) {
215:                    return (String[]) state.getParametersMap().get(
216:                            parameterName);
217:                } else {
218:                    return null;
219:                }
220:            }
221:
222:            public PortletWindow getPortletWindowOfAction() {
223:                return requestStates.getActionWindow();
224:            }
225:
226:            public PortletWindow getPortletWindowOfResource() {
227:                return requestStates.getResourceWindow();
228:            }
229:
230:            public String encode(PortletWindow window, Map parameters,
231:                    PortletMode mode, WindowState state, boolean action)
232:                    throws UnsupportedEncodingException {
233:                if (mode != null || state != null) {
234:                    PortletApplication pa = null;
235:                    if (mode != null
236:                            && !JetspeedActions.getStandardPortletModes()
237:                                    .contains(mode)) {
238:                        pa = (PortletApplication) window.getPortletEntity()
239:                                .getPortletDefinition()
240:                                .getPortletApplicationDefinition();
241:                        mode = pa.getMappedPortletMode(mode);
242:                    }
243:                    if (state != null
244:                            && !JetspeedActions.getStandardWindowStates()
245:                                    .contains(state)) {
246:                        if (pa == null) {
247:                            pa = (PortletApplication) window.getPortletEntity()
248:                                    .getPortletDefinition()
249:                                    .getPortletApplicationDefinition();
250:                        }
251:                        state = pa.getMappedWindowState(state);
252:                    }
253:                }
254:                return codec.encode(requestStates, window, parameters, mode,
255:                        state, action, isNavigationalParameterStateFull(),
256:                        isRenderParameterStateFull());
257:            }
258:
259:            public String encode(PortletWindow window, PortletMode mode,
260:                    WindowState state) throws UnsupportedEncodingException {
261:                if (mode != null || state != null) {
262:                    PortletApplication pa = null;
263:                    if (mode != null
264:                            && !JetspeedActions.getStandardPortletModes()
265:                                    .contains(mode)) {
266:                        pa = (PortletApplication) window.getPortletEntity()
267:                                .getPortletDefinition()
268:                                .getPortletApplicationDefinition();
269:                        mode = pa.getMappedPortletMode(mode);
270:                    }
271:                    if (state != null
272:                            && !JetspeedActions.getStandardWindowStates()
273:                                    .contains(state)) {
274:                        if (pa == null) {
275:                            pa = (PortletApplication) window.getPortletEntity()
276:                                    .getPortletDefinition()
277:                                    .getPortletApplicationDefinition();
278:                        }
279:                        state = pa.getMappedWindowState(state);
280:                    }
281:                }
282:                String encodedState = null;
283:                Map currentWindowStates = null;
284:                PortletWindowExtendedNavigationalState windowNavState = null;
285:                PortletMode targetMode = mode;
286:                WindowState targetState = state;
287:                if (this  instanceof  SessionNavigationalState) {
288:                    currentWindowStates = ((SessionNavigationalState) this )
289:                            .getCurrentPageWindowStates();
290:                    if (currentWindowStates != null) {
291:                        windowNavState = (PortletWindowExtendedNavigationalState) currentWindowStates
292:                                .get(window.getId().toString());
293:                        if (windowNavState != null) {
294:                            if (targetMode == null) {
295:                                targetMode = windowNavState.getPortletMode();
296:                            }
297:                            if (targetState == null) {
298:                                targetState = windowNavState.getWindowState();
299:                            }
300:                            encodedState = windowNavState
301:                                    .getDecoratorActionEncoding(targetMode,
302:                                            targetState);
303:                        }
304:                    }
305:                }
306:                if (encodedState == null) {
307:                    encodedState = codec.encode(requestStates, window, mode,
308:                            state, isNavigationalParameterStateFull(),
309:                            isRenderParameterStateFull());
310:                    if (currentWindowStates != null) {
311:                        if (windowNavState == null) {
312:                            windowNavState = new PortletWindowExtendedNavigationalState();
313:                            currentWindowStates.put(window.getId().toString(),
314:                                    windowNavState);
315:                        }
316:                        windowNavState.setDecoratorActionEncoding(targetMode,
317:                                targetState, encodedState);
318:                    }
319:                }
320:                return encodedState;
321:            }
322:
323:            public String encode() throws UnsupportedEncodingException {
324:                return codec.encode(requestStates,
325:                        isNavigationalParameterStateFull(),
326:                        isRenderParameterStateFull());
327:            }
328:
329:            public Iterator getWindowIdIterator() {
330:                return requestStates.getWindowIdIterator();
331:            }
332:
333:            public void clearParameters(PortletWindow window) {
334:                PortletWindowRequestNavigationalState state = requestStates
335:                        .getPortletWindowNavigationalState(window.getId()
336:                                .toString());
337:                if (state != null) {
338:                    Map map = state.getParametersMap();
339:                    if (map != null) {
340:                        map.clear();
341:                        state.setClearParameters(true);
342:                    }
343:                }
344:            }
345:
346:            public void removeState(PortletWindow window) {
347:                requestStates.removePortletWindowNavigationalState(window
348:                        .getId().toString());
349:            }
350:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.