Source Code Cross Referenced for JetspeedContentCacheKey.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » cache » 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.cache.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:
018:        package org.apache.jetspeed.cache.impl;
019:
020:        import java.io.Serializable;
021:        import java.util.Iterator;
022:        import java.util.List;
023:
024:        import org.apache.jetspeed.cache.ContentCacheKey;
025:        import org.apache.jetspeed.desktop.JetspeedDesktop;
026:        import org.apache.jetspeed.request.RequestContext;
027:
028:        /**
029:         * The content cache key holds an immutable cache key definition.
030:         * Cache key definitions are based on the following required properties:
031:         * <ul>
032:         * <li>username</li>
033:         * <li>windowid</li>
034:         * <li>pipeline</li>
035:         * </ul>
036:         * and the following optional properties:
037:         * <ul>
038:         * <li>sessionid</li>
039:         * <li></li>
040:         * <li>request.{parameter}</li>
041:         * <li>session.{attribute}</li>
042:         * </ul>
043:         * The string representation of this key is calculated once upon construction.
044:         * 
045:         * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
046:         * @version $Id: $
047:         */
048:        public class JetspeedContentCacheKey implements  ContentCacheKey,
049:                Serializable {
050:            private String username = null;
051:            private String pipeline = null;
052:            private String windowId = null;
053:            private String sessionId = null;
054:            private String requestParameter = null;
055:            private String sessionAttribute = null;
056:            private String key = "";
057:
058:            public JetspeedContentCacheKey(List segments,
059:                    RequestContext context, String windowId) {
060:                boolean first = true;
061:                Iterator si = segments.iterator();
062:                while (si.hasNext()) {
063:                    String segment = (String) si.next();
064:                    if (segment.equals("username")) {
065:                        this .username = context.getUserPrincipal().getName();
066:                        key = (first) ? this .username
067:                                : key
068:                                        + EhPortletContentCacheElementImpl.KEY_SEPARATOR
069:                                        + this .username;
070:                    } else if (segment.equals("windowid")) {
071:                        this .windowId = windowId;
072:                        key = (first) ? this .windowId
073:                                : key
074:                                        + EhPortletContentCacheElementImpl.KEY_SEPARATOR
075:                                        + this .windowId;
076:                    } else if (segment.equals("sessionid")) {
077:                        this .sessionId = context.getRequest().getSession()
078:                                .getId();
079:                        key = (first) ? this .sessionId
080:                                : key
081:                                        + EhPortletContentCacheElementImpl.KEY_SEPARATOR
082:                                        + this .sessionId;
083:                    } else if (segment.equals("pipeline")) {
084:                        String encoder = context
085:                                .getRequestParameter(JetspeedDesktop.DESKTOP_ENCODER_REQUEST_PARAMETER);
086:                        if (encoder != null
087:                                && encoder
088:                                        .equals(JetspeedDesktop.DESKTOP_ENCODER_REQUEST_PARAMETER_VALUE)) {
089:                            this .pipeline = "desktop";
090:                        } else {
091:                            this .pipeline = "portal";
092:                        }
093:                        key = (first) ? this .pipeline
094:                                : key
095:                                        + EhPortletContentCacheElementImpl.KEY_SEPARATOR
096:                                        + this .pipeline;
097:                    } else if (segment.startsWith("request")) {
098:                        int pos = segment.indexOf(".");
099:                        if (pos > -1) {
100:                            String parameterName = segment.substring(pos);
101:                            this .requestParameter = context
102:                                    .getRequestParameter(parameterName);
103:                            if (this .requestParameter != null) {
104:                                key = (first) ? this .requestParameter
105:                                        : key
106:                                                + EhPortletContentCacheElementImpl.KEY_SEPARATOR
107:                                                + this .requestParameter;
108:                            }
109:                        }
110:                    } else if (segment.startsWith("session")) {
111:                        int pos = segment.indexOf(".");
112:                        if (pos > -1) {
113:                            String attributeName = segment.substring(pos);
114:                            this .sessionAttribute = (String) context
115:                                    .getSessionAttribute(attributeName);
116:                            if (this .sessionAttribute != null) {
117:                                key = (first) ? this .sessionAttribute
118:                                        : key
119:                                                + EhPortletContentCacheElementImpl.KEY_SEPARATOR
120:                                                + this .sessionAttribute;
121:                            }
122:                        }
123:                    }
124:                    first = false;
125:                }
126:                //System.out.println("*** CACHE KEY IS [" + key + "]");
127:            }
128:
129:            public JetspeedContentCacheKey() {
130:            }
131:
132:            public void createFromUser(String username, String pipeline,
133:                    String windowId) {
134:                this .setUsername(username);
135:                this .setPipeline(pipeline);
136:                this .setWindowId(windowId);
137:                this .key = this .getUsername()
138:                        + EhPortletContentCacheElementImpl.KEY_SEPARATOR
139:                        + this .getPipeline()
140:                        + EhPortletContentCacheElementImpl.KEY_SEPARATOR
141:                        + this .getWindowId();
142:            }
143:
144:            public void createFromSession(String sessionId, String pipeline,
145:                    String windowId) {
146:                this .setSessionId(sessionId);
147:                this .setPipeline(pipeline);
148:                this .setWindowId(windowId);
149:                this .key = this .getSessionId()
150:                        + EhPortletContentCacheElementImpl.KEY_SEPARATOR
151:                        + this .getPipeline()
152:                        + EhPortletContentCacheElementImpl.KEY_SEPARATOR
153:                        + this .getWindowId();
154:            }
155:
156:            public String getKey() {
157:                return this .key;
158:            }
159:
160:            public String getPipeline() {
161:                return this .pipeline;
162:            }
163:
164:            public String getRequestParameter() {
165:                return this .requestParameter;
166:            }
167:
168:            public String getSessionAttribute() {
169:                return this .sessionAttribute;
170:            }
171:
172:            public String getSessionId() {
173:                return this .sessionId;
174:            }
175:
176:            public String getUsername() {
177:                return this .username;
178:            }
179:
180:            public String getWindowId() {
181:                return this .windowId;
182:            }
183:
184:            public void setPipeline(String pipeline) {
185:                this .pipeline = pipeline;
186:            }
187:
188:            public void setRequestParameter(String requestParameter) {
189:                this .requestParameter = requestParameter;
190:            }
191:
192:            public void setSessionAttribute(String sessionAttribute) {
193:                this .sessionAttribute = sessionAttribute;
194:            }
195:
196:            public void setSessionId(String sessionId) {
197:                this .sessionId = sessionId;
198:            }
199:
200:            public void setUsername(String username) {
201:                this .username = username;
202:            }
203:
204:            public void setWindowId(String windowId) {
205:                this.windowId = windowId;
206:            }
207:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.