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


001:        /* Copyright 2002 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.webproxy;
007:
008:        import org.jasig.portal.ChannelRuntimeData;
009:        import org.jasig.portal.PortalException;
010:        import org.jasig.portal.utils.SAX2FilterImpl;
011:        import org.xml.sax.Attributes;
012:        import org.xml.sax.ContentHandler;
013:        import org.xml.sax.helpers.AttributesImpl;
014:
015:        /**
016:         * Rewrites URLs for CWebProxy.
017:         * @author Sarah Arnott, sarnott@mun.ca
018:         * @version $Revision: 42283 $
019:         */
020:        public abstract class CWebProxyURLFilter extends SAX2FilterImpl {
021:
022:            protected ChannelRuntimeData runtimeData;
023:            protected String baseUrl;
024:
025:            /**
026:             * A constructor which receives a ContentHandler to which
027:             * filtered SAX events are passed. 
028:             * @param handler the ContentHandler to which filtered SAX events are passed
029:             */
030:            protected CWebProxyURLFilter(ContentHandler handler) {
031:                super (handler);
032:            }
033:
034:            /**
035:             * A factory method that uses mimeType to determine 
036:             * which type of CWebProxyURLFilter to return.
037:             * There are currently two types of markup supported: XHTML and WML.
038:             * @param handler the ContentHandler used to pass along filtered SAX events
039:             * @param runtimeData the CWebProxy channel runtime data 
040:             */
041:            public static final CWebProxyURLFilter newCWebProxyURLFilter(
042:                    String mimeType, ChannelRuntimeData runtimeData,
043:                    ContentHandler handler) throws PortalException {
044:                // Create a CWebProxyURLFilter, depending on mime type
045:                CWebProxyURLFilter filter = null;
046:                if (mimeType != null) {
047:                    if (mimeType.equals("text/html"))
048:                        filter = new CWebProxyXHTMLURLFilter(handler);
049:                    else if (mimeType.equals("text/vnd.wap.wml"))
050:                        filter = new CWebProxyWMLURLFilter(handler);
051:                    else
052:                        throw new PortalException(
053:                                "CWebProxyURLFilter.newCWebProxyURLFilter(): Unable to locate CWebProxyURLFilter for mime type '"
054:                                        + mimeType + "'");
055:                } else {
056:                    throw new PortalException(
057:                            "CWebProxyURLFilter.newCWebProxyURLFilter(): Unable to create CWebProxyURLFilter. Mime type is null.");
058:                }
059:
060:                // Set CWebProxyURLFilter properties
061:                filter.runtimeData = runtimeData;
062:                filter.baseUrl = (String) runtimeData.get("cw_xml");
063:
064:                return filter;
065:            }
066:
067:            /**
068:             * A helper method which rewrites an attribute that has a URL value
069:             * for CWebProxy.  The URL rewriting is dependant upon the values
070:             * of runtime data parameters (see CWebProxy documentation).
071:             *
072:             * @param elementName the element name containing an attribute of name attName
073:             * @param attName the name of the attribute of elementName
074:             * @param qName the name of the current element
075:             * @param attsImpl the attributes implementation to contain the new attribute value
076:             */
077:            protected final void rewriteURL(String elementName, String attName,
078:                    String qName, Attributes atts, AttributesImpl attsImpl) {
079:                if (qName.equalsIgnoreCase(elementName)) {
080:                    String passThrough = (String) runtimeData
081:                            .get("cw_passThrough");
082:                    if (passThrough != null
083:                            && (passThrough.equals("all")
084:                                    || passThrough.equals("application") || passThrough
085:                                    .equals("marked"))) {
086:                        String attValue = atts.getValue(attName);
087:                        if (attValue != null
088:                                && (attValue.startsWith("http://") || attValue
089:                                        .startsWith("https://"))) {
090:                            String query = getQueryString(attValue);
091:                            String base = getBase(attValue);
092:
093:                            // determine the actionURL
094:                            String actionURL;
095:                            if (attValue.indexOf("cw_download=") != -1)
096:                                actionURL = (String) runtimeData
097:                                        .get("downloadActionURL");
098:                            else
099:                                actionURL = (String) runtimeData
100:                                        .get("baseActionURL");
101:
102:                            String xmlUri = (String) runtimeData.get("cw_xml");
103:
104:                            // rewrite URL when required
105:                            if (passThrough.equals("marked")) {
106:                                if (attValue.indexOf("cw_inChannelLink=") != -1) {
107:                                    if ((attValue.trim().equals("") || xmlUri
108:                                            .equals(base)))
109:                                        attValue = actionURL + query;
110:                                    else if (!query.equals(""))
111:                                        attValue = actionURL + query
112:                                                + "&cw_xml=" + base;
113:                                    else
114:                                        attValue = actionURL + "?cw_xml="
115:                                                + base;
116:                                }
117:                            } else if (passThrough.equals("application")) {
118:                                if (attValue.trim().equals("")
119:                                        || xmlUri.equals(base))
120:                                    attValue = actionURL + query;
121:                            } else if (passThrough.equals("all")) {
122:                                if (attValue.trim().equals("")
123:                                        || xmlUri.equals(base))
124:                                    attValue = actionURL + query;
125:                                else if (!query.equals(""))
126:                                    attValue = actionURL + query + "&cw_xml="
127:                                            + base;
128:                                else
129:                                    attValue = actionURL + "?cw_xml="
130:                                            + attValue;
131:                            }
132:
133:                            int index = atts.getIndex(attName);
134:                            attsImpl.setAttribute(index, atts.getURI(index),
135:                                    atts.getLocalName(index), attName, atts
136:                                            .getType(index), attValue);
137:                        }
138:                    }
139:                }
140:            }
141:
142:            /**
143:             * Returns the portion of the URL without the query string.
144:             * @param url A String representing the absolute URL.
145:             */
146:            protected String getBase(String url) {
147:                if (url.indexOf("?") != -1)
148:                    return url.substring(0, url.indexOf("?"));
149:                else
150:                    return url;
151:            }
152:
153:            /**
154:             * Returns the query string portion of the URL.
155:             * @param url A String representing the absolute URL.
156:             */
157:            protected String getQueryString(String url) {
158:                if (url.indexOf("?") != -1)
159:                    return url.substring(url.indexOf("?"));
160:                else
161:                    return "";
162:            }
163:
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.