Source Code Cross Referenced for GML3OutputFormat.java in  » GIS » GeoServer » org » geoserver » wfs » xml » 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 » GeoServer » org.geoserver.wfs.xml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002:         * This code is licensed under the GPL 2.0 license, availible at the root
003:         * application directory.
004:         */
005:        package org.geoserver.wfs.xml;
006:
007:        import net.opengis.wfs.FeatureCollectionType;
008:        import net.opengis.wfs.GetFeatureType;
009:
010:        import net.opengis.wfs.BaseRequestType;
011:        import org.geoserver.ows.util.RequestUtils;
012:        import org.geoserver.ows.util.ResponseUtils;
013:        import org.geoserver.platform.Operation;
014:        import org.geoserver.platform.ServiceException;
015:        import org.geoserver.wfs.WFS;
016:        import org.geoserver.wfs.WFSException;
017:        import org.geoserver.wfs.WFSGetFeatureOutputFormat;
018:        import org.geoserver.wfs.xml.v1_1_0.WFSConfiguration;
019:        import org.geotools.feature.FeatureCollection;
020:        import org.geotools.feature.FeatureType;
021:        import org.geotools.xml.Encoder;
022:        import org.vfny.geoserver.global.Data;
023:        import org.vfny.geoserver.global.FeatureTypeInfo;
024:        import org.xml.sax.SAXException;
025:        import java.io.IOException;
026:        import java.io.OutputStream;
027:        import java.util.Arrays;
028:        import java.util.HashMap;
029:        import java.util.HashSet;
030:        import java.util.Iterator;
031:        import java.util.List;
032:        import java.util.Map;
033:        import java.util.Set;
034:
035:        public class GML3OutputFormat extends WFSGetFeatureOutputFormat {
036:            WFS wfs;
037:            Data catalog;
038:            WFSConfiguration configuration;
039:
040:            public GML3OutputFormat(WFS wfs, Data catalog,
041:                    WFSConfiguration configuration) {
042:                super (new HashSet(Arrays.asList(new Object[] { "gml3",
043:                        "text/xml; subtype=gml/3.1.1" })));
044:
045:                this .wfs = wfs;
046:                this .catalog = catalog;
047:                this .configuration = configuration;
048:            }
049:
050:            public String getMimeType(Object value, Operation operation) {
051:                return "text/xml; subtype=gml/3.1.1";
052:            }
053:
054:            public String getCapabilitiesElementName() {
055:                return "GML3";
056:            }
057:
058:            protected void write(FeatureCollectionType results,
059:                    OutputStream output, Operation getFeature)
060:                    throws ServiceException, IOException {
061:                List featureCollections = results.getFeature();
062:
063:                //round up the info objects for each feature collection
064:                HashMap /*<String,Set>*/ns2metas = new HashMap();
065:
066:                for (Iterator fc = featureCollections.iterator(); fc.hasNext();) {
067:                    FeatureCollection features = (FeatureCollection) fc.next();
068:                    FeatureType featureType = features.getSchema();
069:
070:                    //load the metadata for the feature type
071:                    String namespaceURI = featureType.getNamespace().toString();
072:                    FeatureTypeInfo meta = catalog.getFeatureTypeInfo(
073:                            featureType.getTypeName(), namespaceURI);
074:
075:                    if (meta == null)
076:                        throw new WFSException("Could not find feature type "
077:                                + namespaceURI + ":"
078:                                + featureType.getTypeName()
079:                                + " in the GeoServer catalog");
080:
081:                    //add it to the map
082:                    Set metas = (Set) ns2metas.get(namespaceURI);
083:
084:                    if (metas == null) {
085:                        metas = new HashSet();
086:                        ns2metas.put(namespaceURI, metas);
087:                    }
088:
089:                    metas.add(meta);
090:                }
091:
092:                Encoder encoder = new Encoder(configuration, configuration
093:                        .schema());
094:
095:                //declare wfs schema location
096:                BaseRequestType gft = (BaseRequestType) getFeature
097:                        .getParameters()[0];
098:
099:                String proxifiedBaseUrl = RequestUtils.proxifiedBaseURL(gft
100:                        .getBaseUrl(), wfs.getGeoServer().getProxyBaseUrl());
101:                encoder.setSchemaLocation(
102:                        org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE,
103:                        ResponseUtils.appendPath(proxifiedBaseUrl,
104:                                "schemas/wfs/1.1.0/wfs.xsd"));
105:
106:                //declare application schema namespaces
107:                for (Iterator i = ns2metas.entrySet().iterator(); i.hasNext();) {
108:                    Map.Entry entry = (Map.Entry) i.next();
109:
110:                    String namespaceURI = (String) entry.getKey();
111:                    Set metas = (Set) entry.getValue();
112:
113:                    StringBuffer typeNames = new StringBuffer();
114:
115:                    for (Iterator m = metas.iterator(); m.hasNext();) {
116:                        FeatureTypeInfo meta = (FeatureTypeInfo) m.next();
117:                        typeNames.append(meta.getName());
118:
119:                        if (m.hasNext()) {
120:                            typeNames.append(",");
121:                        }
122:                    }
123:
124:                    //set the schema location
125:                    encoder.setSchemaLocation(namespaceURI, ResponseUtils
126:                            .appendQueryString(proxifiedBaseUrl + "wfs",
127:                                    "service=WFS&version=1.1.0&request=DescribeFeatureType&typeName="
128:                                            + typeNames.toString()));
129:                }
130:
131:                try {
132:                    encoder.encode(results,
133:                            org.geoserver.wfs.xml.v1_1_0.WFS.FEATURECOLLECTION,
134:                            output);
135:                } catch (SAXException e) {
136:                    String msg = "Error occurred encoding features";
137:                    //SAXException does not sets initCause(). Instead, it holds its own "exception" field.
138:                    if (e.getException() != null && e.getCause() == null) {
139:                        e.initCause(e.getException());
140:                    }
141:                    throw (IOException) new IOException(msg).initCause(e);
142:                }
143:            }
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.