Source Code Cross Referenced for WCSGetCapabilities.java in  » GIS » deegree » org » deegree » ogcwebservices » wcs » getcapabilities » 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 » deegree » org.deegree.ogcwebservices.wcs.getcapabilities 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // $HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/ogcwebservices/wcs/getcapabilities/WCSGetCapabilities.java $
002:        /*----------------    FILE HEADER  ------------------------------------------
003:
004:         This file is part of deegree.
005:         Copyright (C) 2001-2008 by:
006:         EXSE, Department of Geography, University of Bonn
007:         http://www.giub.uni-bonn.de/deegree/
008:         lat/lon GmbH
009:         http://www.lat-lon.de
010:
011:         This library is free software; you can redistribute it and/or
012:         modify it under the terms of the GNU Lesser General Public
013:         License as published by the Free Software Foundation; either
014:         version 2.1 of the License, or (at your option) any later version.
015:
016:         This library is distributed in the hope that it will be useful,
017:         but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
019:         Lesser General Public License for more details.
020:
021:         You should have received a copy of the GNU Lesser General Public
022:         License along with this library; if not, write to the Free Software
023:         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024:
025:         Contact:
026:
027:         Andreas Poth
028:         lat/lon GmbH
029:         Aennchenstr. 19
030:         53115 Bonn
031:         Germany
032:         E-Mail: poth@lat-lon.de
033:
034:         Prof. Dr. Klaus Greve
035:         Department of Geography
036:         University of Bonn
037:         Meckenheimer Allee 166
038:         53115 Bonn
039:         Germany
040:         E-Mail: greve@giub.uni-bonn.de
041:
042:        
043:         ---------------------------------------------------------------------------*/
044:        package org.deegree.ogcwebservices.wcs.getcapabilities;
045:
046:        import java.io.UnsupportedEncodingException;
047:        import java.net.URLDecoder;
048:        import java.util.Map;
049:
050:        import org.deegree.framework.log.ILogger;
051:        import org.deegree.framework.log.LoggerFactory;
052:        import org.deegree.framework.util.CharsetUtils;
053:        import org.deegree.framework.util.KVP2Map;
054:        import org.deegree.framework.util.StringTools;
055:        import org.deegree.framework.xml.XMLParsingException;
056:        import org.deegree.framework.xml.XMLTools;
057:        import org.deegree.ogcbase.CommonNamespaces;
058:        import org.deegree.ogcbase.ExceptionCode;
059:        import org.deegree.ogcwebservices.InvalidParameterValueException;
060:        import org.deegree.ogcwebservices.MissingParameterValueException;
061:        import org.deegree.ogcwebservices.OGCWebServiceException;
062:        import org.deegree.ogcwebservices.getcapabilities.GetCapabilities;
063:        import org.w3c.dom.Document;
064:        import org.w3c.dom.Element;
065:
066:        /**
067:         * Each Web Coverage Server must describe its capabilities. This clause defines the structure
068:         * intended to convey general information about the service itself, and summary information about
069:         * the available data collections from which coverages may be requested.<p/> An instance of
070:         * <tt>WCSGetCapabilities</tt> encapsulates a GetCapabilites request against a WCS and offeres two
071:         * factory methods inherited from <tT>GetCapabilities</tt> for request creation using KVP and one
072:         * own method for request creation from a DOM object.
073:         * 
074:         * @version $Revision: 9345 $
075:         * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
076:         * @author last edited by: $Author: apoth $
077:         * 
078:         * @version 1.0. $Revision: 9345 $, $Date: 2007-12-27 08:22:25 -0800 (Thu, 27 Dec 2007) $
079:         * 
080:         * @since 2.0
081:         */
082:        public class WCSGetCapabilities extends GetCapabilities {
083:
084:            private static final ILogger LOG = LoggerFactory
085:                    .getLogger(WCSGetCapabilities.class);
086:
087:            /**
088:             * creates a GetCapabilities request from its KVP representation
089:             * 
090:             * @param id
091:             *            unique ID of the request
092:             * @param kvp
093:             *            request
094:             * @return created <tt>DescribeCoverage</tt>
095:             * @throws OGCWebServiceException
096:             *             will be thrown if something general is wrong
097:             * @throws InvalidParameterValueException
098:             * @throws MissingParameterValueException
099:             */
100:            public static GetCapabilities create(String id, String kvp)
101:                    throws OGCWebServiceException,
102:                    InvalidParameterValueException,
103:                    MissingParameterValueException {
104:                Map<String, String> map = KVP2Map.toMap(kvp);
105:                map.put("ID", id);
106:                return create(map);
107:            }
108:
109:            /**
110:             * creates a GetCapabilities request from its KVP representation
111:             * 
112:             * @param map
113:             *            request
114:             * @return created <tt>DescribeCoverage</tt>
115:             * @throws OGCWebServiceException
116:             *             will be thrown if something general is wrong
117:             * @throws InvalidParameterValueException
118:             * @throws MissingParameterValueException
119:             */
120:            public static GetCapabilities create(Map<String, String> map)
121:                    throws OGCWebServiceException,
122:                    InvalidParameterValueException,
123:                    MissingParameterValueException {
124:
125:                String version = getParam("VERSION", map, "1.0.0");
126:                /*
127:                 * if ( version == null ) { version = "1.0.0"; } if ( version.compareTo("1.0.0") < 0 ) {
128:                 * ExceptionCode code = ExceptionCode.INVALIDPARAMETERVALUE; throw new
129:                 * InvalidParameterValueException( "WCSGetCapabilities", "version must be equal to " + "or
130:                 * greater than 1.0.0", code ); } else { version = "1.0.0"; }
131:                 */
132:
133:                String service = getRequiredParam("SERVICE", map);
134:                if (!service.equals("WCS")) {
135:                    ExceptionCode code = ExceptionCode.INVALIDPARAMETERVALUE;
136:                    throw new InvalidParameterValueException(
137:                            "WCSGetCapabilities", "'service' must be 'WCS'",
138:                            code);
139:                }
140:                String updateSeq = getParam("UPDATESEQUENCE", map, null);
141:                String tmp = getParam("SECTION", map, null);
142:                String[] sections = null;
143:                if (tmp != null) {
144:                    sections = StringTools.toArray(tmp, ",", true);
145:                    if (!validateSection(sections)) {
146:                        ExceptionCode code = ExceptionCode.INVALIDPARAMETERVALUE;
147:                        throw new InvalidParameterValueException(
148:                                "WCSGetCapabilities",
149:                                "invalid value for section parameter", code);
150:                    }
151:                }
152:                String id = getParam("ID", map, "" + System.currentTimeMillis());
153:
154:                return new WCSGetCapabilities(id, version, updateSeq, sections,
155:                        map);
156:            }
157:
158:            /**
159:             * creates a GetCapabilities request from its XML representation
160:             * 
161:             * @param id
162:             *            unique ID of the request
163:             * @param doc
164:             *            XML representation of the request
165:             * @return created <tt>DescribeCoverage</tt>
166:             * @throws OGCWebServiceException
167:             *             will be thrown if something general is wrong
168:             * @throws InvalidParameterValueException
169:             * @throws MissingParameterValueException
170:             */
171:            public static GetCapabilities create(String id, Document doc)
172:                    throws OGCWebServiceException,
173:                    InvalidParameterValueException,
174:                    MissingParameterValueException {
175:                String version = null;
176:                String service = null;
177:                String updateSeq = null;
178:                String[] sections = null;
179:                try {
180:                    Element root = XMLTools.getRequiredChildElement(
181:                            "GetCapabilities", CommonNamespaces.WCSNS, doc);
182:
183:                    version = XMLTools.getAttrValue(root, null, "version",
184:                            "1.0.0");
185:
186:                    service = XMLTools
187:                            .getAttrValue(root, null, "service", null);
188:                    if (service == null) {
189:                        ExceptionCode code = ExceptionCode.MISSINGPARAMETERVALUE;
190:                        throw new MissingParameterValueException(
191:                                "WCSGetCapabilities", "'service' is missing",
192:                                code);
193:                    } else if (!service.equals("WCS")) {
194:                        ExceptionCode code = ExceptionCode.INVALIDPARAMETERVALUE;
195:                        throw new InvalidParameterValueException(
196:                                "WCSGetCapabilities",
197:                                "'service' must be 'WCS'", code);
198:                    }
199:
200:                    updateSeq = XMLTools.getAttrValue(root, null,
201:                            "updateSequence", null);
202:
203:                    String tmp = XMLTools.getStringValue("section",
204:                            CommonNamespaces.WCSNS, root, "/");
205:                    if (tmp != null) {
206:                        sections = StringTools.toArray(tmp, ",", true);
207:                        if (!validateSection(sections)) {
208:                            ExceptionCode code = ExceptionCode.INVALIDPARAMETERVALUE;
209:                            throw new InvalidParameterValueException(
210:                                    "WCSGetCapabilities",
211:                                    "invalid value for section parameter", code);
212:                        }
213:                    }
214:
215:                } catch (XMLParsingException e) {
216:                    LOG.logError("WCSGetCapabilities", e);
217:                    ExceptionCode code = ExceptionCode.INVALID_FORMAT;
218:                    throw new OGCWebServiceException("WCSGetCapabilities", e
219:                            .getMessage(), code);
220:                }
221:
222:                return new WCSGetCapabilities(id, version, updateSeq, sections,
223:                        null);
224:            }
225:
226:            /**
227:             * valid values are:
228:             * <ul>
229:             * <li>null
230:             * <li>/
231:             * <li>/WCS_Capabilities/CapabilitiesService
232:             * <li>/WCS_Capabilities/Capabilitiy
233:             * <li>/WCS_Capabilities/ContentMetadata
234:             * </ul>
235:             * 
236:             * @param sections
237:             */
238:            private static boolean validateSection(String[] sections) {
239:                if (sections == null)
240:                    return false;
241:                for (int i = 0; i < sections.length; i++) {
242:                    try {
243:                        sections[i] = URLDecoder.decode(sections[i],
244:                                CharsetUtils.getSystemCharset());
245:                    } catch (UnsupportedEncodingException e) {
246:                        e.printStackTrace();
247:                    }
248:                    if (sections[i] != null
249:                            && !"/".equals(sections[i])
250:                            && !"/WCS_Capabilities/Service".equals(sections[i])
251:                            && !"/WCS_Capabilities/Capability"
252:                                    .equals(sections[i])
253:                            && !"/WCS_Capabilities/ContentMetadata"
254:                                    .equals(sections[i])) {
255:                        return false;
256:                    }
257:                }
258:                return true;
259:            }
260:
261:            /**
262:             * @param id
263:             * @param version
264:             * @param updateSequence
265:             * @param sections
266:             * @param vendoreSpec
267:             */
268:            public WCSGetCapabilities(String id, String version,
269:                    String updateSequence, String[] sections,
270:                    Map<String, String> vendoreSpec) {
271:                super (id, version, updateSequence, null, sections, null,
272:                        vendoreSpec);
273:            }
274:
275:            /**
276:             * returns WCS as service name
277:             */
278:            public String getServiceName() {
279:                return "WCS";
280:            }
281:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.