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


001:        /* Copyright 2001 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.utils;
007:
008:        import java.io.FileInputStream;
009:        import java.io.FileNotFoundException;
010:        import java.io.InputStream;
011:        import java.net.MalformedURLException;
012:        import java.net.URISyntaxException;
013:        import java.net.URL;
014:
015:        import org.apache.commons.logging.Log;
016:        import org.apache.commons.logging.LogFactory;
017:        import org.jasig.portal.ChannelRegistryManager;
018:        import org.jasig.portal.PortalSessionManager;
019:        import org.xml.sax.EntityResolver;
020:        import org.xml.sax.InputSource;
021:
022:        /**
023:         * Provides a means to resolve uPortal DTDs
024:         * @author Peter Kharchenko, pkharchenko@unicon.net
025:         * @author Ken Weiner, kweiner@unicon.net
026:         * @author Dave Wallace, dwallace@udel.edu modifications
027:         * @version $Revision: 36727 $
028:         */
029:        public class DTDResolver implements  EntityResolver {
030:
031:            private static final Log log = LogFactory.getLog(DTDResolver.class);
032:
033:            private static final String dtdPath = "dtd";
034:
035:            private static class PublicId {
036:                public String publicId;
037:                public String dtdFile;
038:
039:                public PublicId(final String publicId, final String dtdFile) {
040:                    this .publicId = publicId;
041:                    this .dtdFile = dtdPath + "/" + dtdFile;
042:                }
043:            }
044:
045:            private static final PublicId[] publicIds = new PublicId[] {
046:                    new PublicId(
047:                            "-//Netscape Communications//DTD RSS 0.91//EN",
048:                            "rss-0.91.dtd"),
049:                    new PublicId("-//uPortal//Tables/EN", "tables.dtd"),
050:                    new PublicId("-//uPortal//PersonDirs/EN", "PersonDirs.dtd"),
051:                    new PublicId("-//uPortal//Channel Publishing/EN",
052:                            "channelPublishingDocument.dtd"),
053:                    new PublicId("-//uPortal//Data/EN", "data.dtd"),
054:                    new PublicId("-//uPortal//PAGSGroupStore/EN",
055:                            "PAGSGroupStore.dtd"),
056:                    new PublicId("-//uPortal//LDAPGroupStore/EN",
057:                            "LDAPGroupStore.dtd") };
058:            private String dtdName = null;
059:
060:            /**
061:             * Constructor for DTDResolver
062:             */
063:            public DTDResolver() {
064:            }
065:
066:            /**
067:             * Constructor for DTDResolver
068:             * @param dtdName the name of the dtd
069:             */
070:            public DTDResolver(String dtdName) {
071:                this .dtdName = dtdName;
072:            }
073:
074:            /**
075:             * Sets up a new input source based on the dtd specified in the xml document
076:             * @param publicId the public ID
077:             * @param systemId the system ID
078:             * @return an input source based on the dtd specified in the xml document
079:             *               or null if we don't have a dtd that matches systemId or publicId
080:             */
081:            public InputSource resolveEntity(String publicId, String systemId) {
082:                InputStream inStream = null;
083:
084:                // Check for a match on the systemId
085:                if (systemId != null) {
086:                    if (dtdName != null && systemId.indexOf(dtdName) != -1) {
087:                        inStream = getResourceAsStream(dtdPath + "/" + dtdName);
088:                    } else if (systemId
089:                            .trim()
090:                            .equalsIgnoreCase(
091:                                    "http://my.netscape.com/publish/formats/rss-0.91.dtd")) {
092:                        inStream = getResourceAsStream(dtdPath
093:                                + "/rss-0.91.dtd");
094:                    }
095:
096:                    if (null != inStream) {
097:                        return new InputSource(inStream);
098:                    }
099:                }
100:
101:                // Check for a match on the public id
102:                if (publicId != null) {
103:                    publicId = publicId.trim();
104:                    for (int i = 0; i < publicIds.length; i++) {
105:                        if (publicId.equalsIgnoreCase(publicIds[i].publicId)) {
106:                            inStream = getResourceAsStream(publicIds[i].dtdFile);
107:                            if (null != inStream) {
108:                                return new InputSource(inStream);
109:                            }
110:                            break;
111:                        }
112:                    }
113:                }
114:
115:                // Return null to let the parser handle this entity
116:                return null;
117:            }
118:
119:            public InputStream getResourceAsStream(String resource) {
120:                if (PortalSessionManager.isServletContext()) {
121:                    return PortalSessionManager.getResourceAsStream(resource);
122:                } else {
123:                    try {
124:                        final URL root = DTDResolver.class.getResource("/");
125:                        return new FileInputStream(root.toURI().getPath()
126:                                + "../../" + resource);
127:                    } catch (FileNotFoundException e) {
128:                        log.error("Unable to find path to dtd " + resource, e);
129:                    } catch (URISyntaxException e) {
130:                        log.error("Unable to find path to dtd " + resource, e);
131:                    }
132:                    return null;
133:                }
134:            }
135:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.