Source Code Cross Referenced for OasisCatalogConfigurationWrapper.java in  » GIS » GeoTools-2.4.1 » org » geotools » data » complex » config » 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 » GIS » GeoTools 2.4.1 » org.geotools.data.complex.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.geotools.data.complex.config;
002:
003:        import java.io.File;
004:        import java.io.IOException;
005:        import java.net.MalformedURLException;
006:        import java.net.URI;
007:        import java.net.URISyntaxException;
008:        import java.util.Iterator;
009:        import java.util.logging.Level;
010:        import java.util.logging.Logger;
011:
012:        import org.apache.xml.resolver.Catalog;
013:        import org.eclipse.xsd.XSDSchema;
014:        import org.eclipse.xsd.util.XSDSchemaLocationResolver;
015:        import org.geotools.xml.BindingConfiguration;
016:        import org.geotools.xml.Configuration;
017:
018:        public class OasisCatalogConfigurationWrapper extends Configuration {
019:
020:            private static final Logger LOGGER = org.geotools.util.logging.Logging
021:                    .getLogger(OasisCatalogConfigurationWrapper.class
022:                            .getPackage().getName());
023:
024:            private Catalog catalog;
025:
026:            private Configuration configuration;
027:
028:            public OasisCatalogConfigurationWrapper(final Catalog catalog,
029:                    final Configuration configuration) {
030:                this .catalog = catalog;
031:                this .configuration = configuration;
032:                addWrappedDepencencies();
033:            }
034:
035:            private void addWrappedDepencencies() {
036:                Configuration dependency;
037:                for (Iterator it = configuration.allDependencies().iterator(); it
038:                        .hasNext();) {
039:                    dependency = (Configuration) it.next();
040:                    addDependency(dependency);
041:                }
042:            }
043:
044:            public BindingConfiguration getBindingConfiguration() {
045:                return configuration.getBindingConfiguration();
046:            }
047:
048:            public String getNamespaceURI() {
049:                return configuration.getNamespaceURI();
050:            }
051:
052:            public String getSchemaFileURL() {
053:                String schemaFileURL = configuration.getSchemaFileURL();
054:                try {
055:                    String resolvedLocation = catalog
056:                            .resolveSystem(schemaFileURL);
057:                    if (resolvedLocation != null) {
058:                        schemaFileURL = resolvedLocation;
059:                    }
060:                } catch (MalformedURLException e) {
061:                    LOGGER.log(Level.SEVERE, "Illegal schema URL: "
062:                            + schemaFileURL, e);
063:                    throw new RuntimeException(e);
064:                } catch (IOException e) {
065:                    LOGGER.log(Level.SEVERE, "Error reading Oasis Catalog: "
066:                            + e.getMessage(), e);
067:                    throw new RuntimeException(e);
068:                }
069:                return schemaFileURL;
070:            }
071:
072:            public XSDSchemaLocationResolver getSchemaLocationResolver() {
073:                final XSDSchemaLocationResolver resolver = configuration
074:                        .getSchemaLocationResolver();
075:                final XSDSchemaLocationResolver lastResortCatalogResolver;
076:                lastResortCatalogResolver = new CatalogSchemaLocationResolverWrapper(
077:                        catalog, resolver);
078:                return lastResortCatalogResolver;
079:            }
080:
081:            private static class CatalogSchemaLocationResolverWrapper implements 
082:                    XSDSchemaLocationResolver {
083:
084:                private Catalog catalog;
085:
086:                private XSDSchemaLocationResolver resolver;
087:
088:                public CatalogSchemaLocationResolverWrapper(
089:                        final Catalog catalog,
090:                        final XSDSchemaLocationResolver resolver) {
091:                    this .catalog = catalog;
092:                    this .resolver = resolver;
093:                }
094:
095:                /**
096:                 * @param schema
097:                 *            the schema being resolved
098:                 * @param uri
099:                 *            the namespace being resolved. If its an empty string (i.e.
100:                 *            the location refers to an include, and thus the uri to the
101:                 *            same one than the schema), the schema one is used.
102:                 * @param location
103:                 *            the xsd location, either of <code>schema</code>, an
104:                 *            import or an include, for which to try resolving it as a
105:                 *            relative path of the <code>schema</code> location.
106:                 * @return
107:                 * 
108:                 */
109:                public String resolveSchemaLocation(final XSDSchema schema,
110:                        final String url, final String location) {
111:                    String schemaLocation = resolver.resolveSchemaLocation(
112:                            schema, url, location);
113:                    if (schemaLocation == null) {
114:                        try {
115:                            LOGGER.finest("resolving " + location);
116:                            schemaLocation = catalog.resolveSystem(location);
117:                            if (schemaLocation != null) {
118:                                LOGGER
119:                                        .finer("Verifying existence of catalog resolved location "
120:                                                + schemaLocation);
121:                                File f;
122:                                try {
123:                                    f = new File(new URI(schemaLocation));
124:                                    if (!f.exists()) {
125:                                        LOGGER.info("Cannot locate "
126:                                                + schemaLocation);
127:                                        schemaLocation = null;
128:                                    }
129:                                } catch (URISyntaxException e) {
130:                                    schemaLocation = null;
131:                                    LOGGER.log(Level.WARNING,
132:                                            "Exception resolving "
133:                                                    + schemaLocation, e);
134:                                }
135:                            }
136:                        } catch (MalformedURLException e) {
137:                            e.printStackTrace();
138:                        } catch (IOException e) {
139:                            e.printStackTrace();
140:                        }
141:                    }
142:                    return schemaLocation;
143:                }
144:            }
145:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.