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


001:        /* Copyright 2001, 2005 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.channels;
007:
008:        import javax.xml.parsers.DocumentBuilderFactory;
009:        import javax.xml.parsers.ParserConfigurationException;
010:
011:        import org.jasig.portal.ChannelCacheKey;
012:        import org.jasig.portal.GeneralRenderingException;
013:        import org.jasig.portal.ICacheable;
014:        import org.jasig.portal.IChannel;
015:        import org.jasig.portal.PortalException;
016:        import org.jasig.portal.i18n.LocaleManager;
017:        import org.jasig.portal.utils.ResourceLoader;
018:        import org.jasig.portal.utils.XSLT;
019:        import org.w3c.dom.Document;
020:        import org.w3c.dom.Element;
021:        import org.xml.sax.ContentHandler;
022:
023:        /** <p>A simple channel which renders an image along with an optional
024:         * caption and subcaption.</p>
025:         * <p>Channel parameters:</p>
026:         *   <table>
027:         *     <tr><th>Name</th><th>Description</th><th>Example</th><th>Required</th></tr>
028:         *     <tr><td>img-uri</td><td>The URI of the image to display</td><td>http://webcam.its.hawaii.edu/uhmwebcam/image01.jpg</td><td>yes</td></tr>
029:         *     <tr><td>img-width</td><td>The width of the image to display</td><td>320</td><td>no</td></tr>
030:         *     <tr><td>img-height</td><td>The height of the image to display</td><td>240</td><td>no</td></tr>
031:         *     <tr><td>img-border</td><td>The border of the image to display</td><td>0</td><td>no</td></tr>
032:         *     <tr><td>img-link</td><td>A URI to be used as an href for the image</td><td>http://www.hawaii.edu/visitor/#webcams</td><td>no</td></tr>
033:         *     <tr><td>caption</td><td>A caption of the image to display</td><td>Almost Live Shot of Hamilton Library Front Entrance</td><td>no</td></tr>
034:         *     <tr><td>subcaption</td><td>The subcaption of the image to display</td><td>Updated Once per Minute During Daylight Hours</td><td>no</td></tr>
035:         *     <tr><td>alt-text</td><td>Text to include as the 'alt' attribute of the img tag</td><td>Almost live shot of Hamilton library front enterance</td><td>no, but highly recommended in support of non-visual browsers</td></tr>
036:         *   </table>
037:         * @author Ken Weiner, kweiner@unicon.net
038:         * @version $Revision: 36835 $
039:         */
040:        public class CImage extends BaseChannel implements  ICacheable, IChannel {
041:            public static final String ALT_TEXT_CHANNEL_PARAM_NAME = "alt-text";
042:
043:            private static final String sslLocation = "CImage/CImage.ssl";
044:
045:            /**
046:             * Output channel content to the portal
047:             * @param out a sax content handler
048:             * @throws org.jasig.portal.PortalException
049:             */
050:            public void renderXML(ContentHandler out) throws PortalException {
051:                // Get the static data
052:                String sImageUri = staticData.getParameter("img-uri");
053:                String sImageWidth = staticData.getParameter("img-width");
054:                String sImageHeight = staticData.getParameter("img-height");
055:                String sImageBorder = staticData.getParameter("img-border");
056:                String sImageLink = staticData.getParameter("img-link");
057:                String sCaption = staticData.getParameter("caption");
058:                String sSubCaption = staticData.getParameter("subcaption");
059:                String sAltText = staticData
060:                        .getParameter(ALT_TEXT_CHANNEL_PARAM_NAME);
061:
062:                Document doc = null;
063:                try {
064:                    doc = DocumentBuilderFactory.newInstance()
065:                            .newDocumentBuilder().newDocument();
066:                } catch (ParserConfigurationException pce) {
067:                    log.error("Error getting a Document", pce);
068:                    throw new GeneralRenderingException(pce);
069:                }
070:
071:                // Create XML doc
072:                Element contentE = doc.createElement("content");
073:
074:                // Add image tag src, width, height, border, and link
075:                Element imageE = doc.createElement("image");
076:                imageE.setAttribute("src", sImageUri);
077:                if (exists(sImageWidth))
078:                    imageE.setAttribute("width", sImageWidth);
079:                if (exists(sImageWidth))
080:                    imageE.setAttribute("height", sImageHeight);
081:                if (exists(sImageWidth))
082:                    imageE.setAttribute("border", sImageBorder);
083:                if (exists(sImageWidth))
084:                    imageE.setAttribute("link", sImageLink);
085:                if (exists(sAltText)) {
086:                    imageE.setAttribute("alt-text", sAltText);
087:                }
088:                contentE.appendChild(imageE);
089:
090:                // Add a caption if it is specified
091:                if (exists(sCaption)) {
092:                    Element captionE = doc.createElement("caption");
093:                    captionE.appendChild(doc.createTextNode(sCaption));
094:                    contentE.appendChild(captionE);
095:                }
096:
097:                // Add a subcaption if it is specified
098:                if (exists(sSubCaption)) {
099:                    Element subcaptionE = doc.createElement("subcaption");
100:                    subcaptionE.appendChild(doc.createTextNode(sSubCaption));
101:                    contentE.appendChild(subcaptionE);
102:                }
103:
104:                doc.appendChild(contentE);
105:
106:                XSLT xslt = XSLT.getTransformer(this , runtimeData.getLocales());
107:                xslt.setXML(doc);
108:                xslt.setXSL(sslLocation, runtimeData.getBrowserInfo());
109:                xslt.setTarget(out);
110:                xslt.setStylesheetParameter("baseActionURL", runtimeData
111:                        .getBaseActionURL());
112:                xslt.transform();
113:            }
114:
115:            private static boolean exists(String s) {
116:                return (s != null && s.length() > 0);
117:            }
118:
119:            // ICachable methods...
120:
121:            public ChannelCacheKey generateKey() {
122:                ChannelCacheKey key = new ChannelCacheKey();
123:                key.setKey(getKey());
124:                key.setKeyScope(ChannelCacheKey.SYSTEM_KEY_SCOPE);
125:                key.setKeyValidity(null);
126:                return key;
127:            }
128:
129:            public boolean isCacheValid(Object validity) {
130:                return true;
131:            }
132:
133:            private String getKey() {
134:                StringBuffer sbKey = new StringBuffer(1024);
135:                sbKey.append("org.jasig.portal.channels.CImage").append(": ");
136:                sbKey.append("xslUri:");
137:                try {
138:                    String sslUrl = ResourceLoader.getResourceAsURLString(this 
139:                            .getClass(), sslLocation);
140:                    sbKey.append(
141:                            XSLT.getStylesheetURI(sslUrl, runtimeData
142:                                    .getBrowserInfo())).append(", ");
143:                } catch (PortalException pe) {
144:                    sbKey.append("Not available, ");
145:                }
146:                sbKey.append("staticData:").append(staticData.toString());
147:                sbKey.append("locales:").append(
148:                        LocaleManager.stringValueOf(runtimeData.getLocales()));
149:
150:                return sbKey.toString();
151:            }
152:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.