Source Code Cross Referenced for CSnoop.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, 2006 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 java.util.Locale;
009:        import java.util.ResourceBundle;
010:
011:        import javax.servlet.http.HttpServletRequest;
012:
013:        import org.jasig.portal.ChannelRuntimeData;
014:        import org.jasig.portal.ChannelRuntimeProperties;
015:        import org.jasig.portal.ChannelStaticData;
016:        import org.jasig.portal.IPrivilegedChannel;
017:        import org.jasig.portal.PortalControlStructures;
018:        import org.jasig.portal.PortalEvent;
019:        import org.jasig.portal.PortalException;
020:        import org.jasig.portal.i18n.LocaleManager;
021:        import org.jasig.portal.utils.DocumentFactory;
022:        import org.jasig.portal.utils.XSLT;
023:        import org.w3c.dom.Document;
024:        import org.w3c.dom.Element;
025:        import org.xml.sax.ContentHandler;
026:
027:        /**
028:         * <p>A channel which displays HTTP request and HTML header info.
029:         * This channel implements IPrivilegedChannel rather than
030:         * IChannel because it needs access to the HttpServletRequest object.</p>
031:         * <p>This channel was partially developed at Columbia University
032:         * as an exercise.</p>
033:         * @author Ken Weiner, kweiner@unicon.net
034:         * @version $Revision: 36688 $
035:         */
036:        public class CSnoop implements  IPrivilegedChannel {
037:            private PortalControlStructures pcs;
038:            private ChannelRuntimeData runtimeData;
039:
040:            private static final String sslLocation = "CSnoop/CSnoop.ssl";
041:            private static final String bundleLocation = "/org/jasig/portal/channels/CSnoop/CSnoop";
042:
043:            /**
044:             * No-argument constructor for CSnoop.
045:             */
046:            public CSnoop() {
047:                this .runtimeData = new ChannelRuntimeData();
048:            }
049:
050:            /**
051:             * Sends portal control structures to the portal, i.e. HttpServletRequest,
052:             * HttpServletResponse, UserPreferencesManager, etc.
053:             * @param pcs the portal control structures
054:             */
055:            public void setPortalControlStructures(PortalControlStructures pcs) {
056:                this .pcs = pcs;
057:            }
058:
059:            /**
060:             * Returns channel runtime properties.
061:             * @return handle to runtime properties
062:             */
063:            public ChannelRuntimeProperties getRuntimeProperties() {
064:                // Channel will always render, so the default values are ok
065:                return new ChannelRuntimeProperties();
066:            }
067:
068:            /**
069:             * Processes layout-level events coming from the portal
070:             * @param ev a portal layout event
071:             */
072:            public void receiveEvent(PortalEvent ev) {
073:                // no events for this channel
074:            }
075:
076:            /**
077:             * Receive static channel data from the portal
078:             * @param sd static channel data
079:             */
080:            public void setStaticData(ChannelStaticData sd) {
081:            }
082:
083:            /**
084:             * Receives channel runtime data from the portal and processes actions
085:             * passed to it.  The names of these parameters are entirely up to the channel.
086:             * @param rd handle to channel runtime data
087:             */
088:            public void setRuntimeData(ChannelRuntimeData rd) {
089:                this .runtimeData = rd;
090:            }
091:
092:            /**
093:             * Output channel content to the portal
094:             * @param out a sax document handler
095:             */
096:            public void renderXML(ContentHandler out) throws PortalException {
097:                HttpServletRequest request = pcs.getHttpServletRequest();
098:                Document doc = DocumentFactory.getNewDocument();
099:
100:                // <snooper>
101:                Element snooperE = doc.createElement("snooper");
102:
103:                // <request-info>
104:                Element requestInfoE = doc.createElement("request-info");
105:
106:                addInfo(requestInfoE, "request-protocol", request.getProtocol());
107:                addInfo(requestInfoE, "request-method", request.getMethod());
108:                addInfo(requestInfoE, "server-name", request.getServerName());
109:                addInfo(requestInfoE, "server-port", String.valueOf(request
110:                        .getServerPort()));
111:                addInfo(requestInfoE, "request-uri", request.getRequestURI());
112:                addInfo(requestInfoE, "context-path", request.getContextPath());
113:                addInfo(requestInfoE, "servlet-path", request.getServletPath());
114:                addInfo(requestInfoE, "query-string", request.getQueryString());
115:                addInfo(requestInfoE, "path-info", request.getPathInfo());
116:                addInfo(requestInfoE, "path-translated", request
117:                        .getPathTranslated());
118:                addInfo(requestInfoE, "content-length", String.valueOf(request
119:                        .getContentLength()));
120:                addInfo(requestInfoE, "content-type", request.getContentType());
121:                addInfo(requestInfoE, "remote-user", request.getRemoteUser());
122:                addInfo(requestInfoE, "remote-address", request.getRemoteAddr());
123:                addInfo(requestInfoE, "remote-host", request.getRemoteHost());
124:                addInfo(requestInfoE, "authorization-scheme", request
125:                        .getAuthType());
126:                addInfo(requestInfoE, "locale", request.getLocale().toString());
127:
128:                // <headers>
129:                Element headersE = doc.createElement("headers");
130:                java.util.Enumeration enum1 = request.getHeaderNames();
131:                while (enum1.hasMoreElements()) {
132:                    String name = (String) enum1.nextElement();
133:                    String value = request.getHeader(name);
134:                    Element headerE = doc.createElement("header");
135:                    headerE.setAttribute("name", name);
136:                    headerE.appendChild(doc.createTextNode(value));
137:                    headersE.appendChild(headerE);
138:                }
139:                requestInfoE.appendChild(headersE);
140:                snooperE.appendChild(requestInfoE);
141:
142:                // <channel-runtime-data>
143:                Element channelRuntimeDataE = doc
144:                        .createElement("channel-runtime-data");
145:
146:                // <locales>
147:                Locale[] locales = runtimeData.getLocales();
148:                if (locales == null) { // Take this out if locales are guaranteed
149:                    locales = new Locale[] { Locale.getDefault() };
150:                }
151:                Element localesE = LocaleManager.xmlValueOf(locales)
152:                        .getDocumentElement();
153:                channelRuntimeDataE.appendChild(doc.importNode(localesE, true));
154:
155:                snooperE.appendChild(channelRuntimeDataE);
156:
157:                doc.appendChild(snooperE);
158:
159:                ResourceBundle l18n = ResourceBundle.getBundle(bundleLocation,
160:                        runtimeData.getLocales()[0]);
161:                // Now perform the transformation
162:                XSLT xslt = XSLT.getTransformer(this );
163:                xslt.setResourceBundle(l18n);
164:                xslt.setXML(doc);
165:                xslt.setXSL(sslLocation, runtimeData.getBrowserInfo());
166:                xslt.setTarget(out);
167:                xslt.transform();
168:            }
169:
170:            /**
171:             * Adds a text node with the given name and value. If the value is null then no text node
172:             * is added to the new node, but the new node is still added to parentElement
173:             * @param parentElement parent of the node to be added
174:             * @param name name of the node to add
175:             * @param value String value of the node to add
176:             */
177:            private void addInfo(Element parentElement, String name,
178:                    String value) {
179:                Document doc = parentElement.getOwnerDocument();
180:                Element e = doc.createElement(name);
181:                if (value != null) {
182:                    e.appendChild(doc.createTextNode(value));
183:                }
184:                parentElement.appendChild(e);
185:            }
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.