Source Code Cross Referenced for DlmIntroChannel.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » layout » dlm » channels » guide » 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 » uPortal_rel 2 6 1 GA » org.jasig.portal.layout.dlm.channels.guide 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2003 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal.layout.dlm.channels.guide;
007:
008:        import java.io.File;
009:        import java.util.HashMap;
010:        import java.util.Map;
011:
012:        import javax.xml.parsers.DocumentBuilder;
013:        import javax.xml.parsers.DocumentBuilderFactory;
014:
015:        import org.jasig.portal.ChannelCacheKey;
016:        import org.jasig.portal.ChannelRuntimeData;
017:        import org.jasig.portal.ICacheable;
018:        import org.jasig.portal.PortalEvent;
019:        import org.jasig.portal.PortalException;
020:        import org.jasig.portal.ResourceMissingException;
021:        import org.jasig.portal.channels.CAbstractXslt;
022:        import org.jasig.portal.utils.DTDResolver;
023:        import org.jasig.portal.utils.ResourceLoader;
024:        import org.w3c.dom.Document;
025:
026:        /**
027:         * A simple channel for introducing the capabilities of DLM in the portal. This
028:         * channel gets its content from a file, "dlmIntro.html", included with the
029:         * channel's source.
030:         * 
031:         * @author mboyd@sungardsct.com
032:         */
033:        public class DlmIntroChannel extends CAbstractXslt implements 
034:                ICacheable {
035:            private Map cacheKeys = new HashMap();
036:            private String mediaBase = null;
037:            private static final String CONTENT_FILE = "dlmIntro.xml";
038:            private static final String STYLESHEET_FILE = "dlmIntro.xsl";
039:            private String currentSection = "1";
040:
041:            /**
042:             * Create a globally shared cache key for a section with the validity
043:             * object being a string of the long value representing the last time
044:             * that the content file was updated.
045:             * 
046:             * @return
047:             */
048:            private ChannelCacheKey initKey(String id) {
049:                ChannelCacheKey key = new ChannelCacheKey();
050:                key.setKeyScope(ChannelCacheKey.INSTANCE_KEY_SCOPE);
051:                key.setKey(this .getClass().getName() + ":" + id);
052:
053:                try {
054:                    File contentFile = ResourceLoader.getResourceAsFile(this 
055:                            .getClass(), CONTENT_FILE);
056:                    long contentModified = contentFile.lastModified();
057:                    File stylesheetFile = ResourceLoader.getResourceAsFile(this 
058:                            .getClass(), STYLESHEET_FILE);
059:                    long stylesheetModified = stylesheetFile.lastModified();
060:                    if (contentModified > stylesheetModified)
061:                        key.setKeyValidity("" + contentModified);
062:                    else
063:                        key.setKeyValidity("" + stylesheetModified);
064:                } catch (ResourceMissingException e) {
065:                    // if we can't tell when the file was modified then it will 
066:                    // force rendering everytime. This should never happen but 
067:                    // handles that scenario if it does occur.
068:                    key.setKeyValidity("1");
069:                }
070:                return key;
071:            }
072:
073:            /**
074:             * Return our cache key which is a system cache key so all users share 
075:             * the same output and it never changes meaning that it never regenerates.
076:             * 
077:             * @see org.jasig.portal.ICacheable#generateKey()
078:             */
079:            public ChannelCacheKey generateKey() {
080:                ChannelCacheKey key = (ChannelCacheKey) this .cacheKeys
081:                        .get(currentSection);
082:                if (key == null) // haven't asked for this section yet
083:                    key = initKey(currentSection);
084:
085:                return key;
086:            }
087:
088:            public boolean isCacheValid(Object validity) {
089:                try {
090:                    long lastRefreshed = Long.parseLong((String) validity);
091:                    File contentFile = ResourceLoader.getResourceAsFile(this 
092:                            .getClass(), CONTENT_FILE);
093:                    File stylesheetFile = ResourceLoader.getResourceAsFile(this 
094:                            .getClass(), STYLESHEET_FILE);
095:                    long contentModified = contentFile.lastModified();
096:                    // TODO remove stylesheet checking after development done since
097:                    // it gets cached and regular users can't purge the cache.
098:                    long stylesheetModified = stylesheetFile.lastModified();
099:
100:                    if (contentModified > lastRefreshed
101:                            || stylesheetModified > lastRefreshed)
102:                        return false;
103:                    return true;
104:                } catch (ResourceMissingException e) {
105:                    // exception can't be thrown from here so toss this to force it to
106:                    // look again for the file in renderCharacters and toss the 
107:                    // exception there where it will be seen in the portal.
108:                    return false;
109:                }
110:            }
111:
112:            /**
113:             * Sets up the base media URL if not done already and determines which
114:             * section is desired by the user if any.
115:             */
116:            @Override
117:            protected void runtimeDataSet() throws PortalException {
118:                ChannelRuntimeData crd = getRuntimeData();
119:                // get an appropriate media path for this channel's images
120:                if (mediaBase == null) {
121:                    mediaBase = crd.getBaseMediaURL(this );
122:                    String cls = getClass().getName();
123:                    String pkg = cls.substring(0, cls.lastIndexOf('.'));
124:                    mediaBase = mediaBase + pkg.replace('.', '/') + '/';
125:                }
126:                String section = crd.getParameter("section");
127:
128:                if (section == null || section.equals(""))
129:                    currentSection = "1";
130:                else
131:                    currentSection = section;
132:            }
133:
134:            public void receiveEvent(PortalEvent ev) {
135:                // do nothing on events
136:            }
137:
138:            @Override
139:            protected Map getStylesheetParams() throws Exception {
140:                // TODO Auto-generated method stub
141:
142:                Map<String, String> paramMap = new HashMap<String, String>();
143:                paramMap.put("baseActionUrl", this .getRuntimeData()
144:                        .getBaseActionURL(true));
145:                paramMap.put("baseMediaUrl", mediaBase);
146:                paramMap.put("selectedSection", currentSection);
147:                return paramMap;
148:            }
149:
150:            @Override
151:            protected Document getXml() throws Exception {
152:
153:                File contents = ResourceLoader.getResourceAsFile(this 
154:                        .getClass(), CONTENT_FILE);
155:
156:                DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
157:                        .newInstance();
158:                docBuilderFactory.setNamespaceAware(true);
159:                DocumentBuilder docBuilder = docBuilderFactory
160:                        .newDocumentBuilder();
161:                DTDResolver dtdResolver = new DTDResolver();
162:                docBuilder.setEntityResolver(dtdResolver);
163:                Document dom = docBuilder.parse(contents);
164:                return dom;
165:            }
166:
167:            @Override
168:            protected String getXsltUri() throws Exception {
169:                return STYLESHEET_FILE;
170:            }
171:        }
w__ww.__j___a__v__a_2___s_.__c__o___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.