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


001:        /*----------------    FILE HEADER  ------------------------------------------
002:
003:         This file is part of deegree.
004:         Copyright (C) 2001-2008 by:
005:         EXSE, Department of Geography, University of Bonn
006:         http://www.giub.uni-bonn.de/deegree/
007:         lat/lon GmbH
008:         http://www.lat-lon.de
009:
010:         This library is free software; you can redistribute it and/or
011:         modify it under the terms of the GNU Lesser General Public
012:         License as published by the Free Software Foundation; either
013:         version 2.1 of the License, or (at your option) any later version.
014:
015:         This library is distributed in the hope that it will be useful,
016:         but WITHOUT ANY WARRANTY; without even the implied warranty of
017:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
018:         Lesser General Public License for more details.
019:
020:         You should have received a copy of the GNU Lesser General Public
021:         License along with this library; if not, write to the Free Software
022:         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
023:
024:         Contact:
025:
026:         Andreas Poth
027:         lat/lon GmbH
028:         Aennchenstr. 19
029:         53115 Bonn
030:         Germany
031:         E-Mail: poth@lat-lon.de
032:
033:         Prof. Dr. Klaus Greve
034:         Department of Geography
035:         University of Bonn
036:         Meckenheimer Allee 166
037:         53115 Bonn
038:         Germany
039:         E-Mail: greve@giub.uni-bonn.de
040:         
041:         ---------------------------------------------------------------------------*/
042:
043:        package org.deegree.ogcwebservices.csw.discovery;
044:
045:        import java.io.IOException;
046:        import java.net.URL;
047:
048:        import org.deegree.datatypes.QualifiedName;
049:        import org.deegree.framework.util.StringTools;
050:        import org.deegree.framework.xml.XMLFragment;
051:        import org.deegree.framework.xml.XMLParsingException;
052:        import org.deegree.framework.xml.XMLTools;
053:        import org.deegree.ogcbase.ExceptionCode;
054:        import org.deegree.ogcwebservices.InvalidParameterValueException;
055:        import org.deegree.ogcwebservices.MissingParameterValueException;
056:        import org.deegree.ogcwebservices.OGCWebServiceException;
057:        import org.w3c.dom.Node;
058:        import org.xml.sax.SAXException;
059:        import static org.deegree.ogcbase.CommonNamespaces.*;
060:
061:        /**
062:         * Represents an XML GetRecordsResponse document of an OGC CSW 2.0 compliant service.
063:         * <p>
064:         * The &lt;GetRecordsResponse&gt; element is a container for the response of the GetRecords
065:         * operation. Three levels of detail may be contained in the response document.
066:         * <ul>
067:         * <li>The &lt;RequestId&gt; element may be used to correlate the response to a GetRecords request
068:         * for which a value was defined for the requestId attribute.
069:         * <li>&lt;SearchStatus&gt; element must be present and indicates the status of the response. The
070:         * status attribute is used to indicate the completion status of the GetRecords operation. Table 65
071:         * shows the possible values for the status attribute.
072:         * <li>The &lt;SearchResults&gt; element is a generic XML container for the actual response to a
073:         * GetRecords request. The content of the &lt;SearchResults&gt; element is the set of records
074:         * returned by the GetRecords operation. The actual records returned by the catalogue should
075:         * substitute for the element &lt;csw:AbstractRecord&gt.
076:         * </ul>
077:         * 
078:         * @author <a href="mailto:mschneider@lat-lon.de">Markus Schneider </a>
079:         * 
080:         * @author last edited by: $Author: aschmitz $
081:         * 
082:         * @version $Revision: 9499 $, $Date: 2008-01-09 07:47:04 -0800 (Wed, 09 Jan 2008) $
083:         * 
084:         * 
085:         */
086:        public class GetRecordsResultDocument extends XMLFragment {
087:
088:            private static final long serialVersionUID = 2796229558893029054L;
089:
090:            private static final String XML_TEMPLATE = "GetRecordsResponseTemplate.xml";
091:
092:            public GetRecordsResultDocument() {
093:                // load later
094:            }
095:
096:            public GetRecordsResultDocument(String version) {
097:                super (new QualifiedName("csw", "GetRecordsResponse", version
098:                        .equals("2.0.2") ? CSW202NS : CSWNS));
099:            }
100:
101:            /**
102:             * Extracts a <code>GetRecordsResult</code> representation of this object.
103:             * 
104:             * @param request
105:             * 
106:             * @return the actual GetRecordResult as a bean.
107:             * @throws MissingParameterValueException
108:             * @throws InvalidParameterValueException
109:             * @throws OGCWebServiceException
110:             */
111:            public GetRecordsResult parseGetRecordsResponse(GetRecords request)
112:                    throws MissingParameterValueException,
113:                    InvalidParameterValueException, OGCWebServiceException {
114:                try {
115:                    String requestId = null;
116:                    SearchStatus searchStatus = null;
117:                    SearchResults searchResults = null;
118:                    // '<csw:GetRecordsResponse>'-element (required)
119:                    Node contextNode = XMLTools.getRequiredNode(
120:                            getRootElement(), "self::csw:GetRecordsResponse",
121:                            nsContext);
122:
123:                    // 'version'-attribute (optional)
124:                    String version = XMLTools.getNodeAsString(contextNode,
125:                            "@version", nsContext, GetRecords.DEFAULT_VERSION);
126:
127:                    // '<csw:RequestId>'-element (optional)
128:                    requestId = XMLTools.getNodeAsString(contextNode,
129:                            "csw:RequestId", nsContext, requestId);
130:
131:                    // '<csw:SearchStatus>'-element (required)
132:                    String status = XMLTools.getRequiredNodeAsString(
133:                            contextNode, "csw:SearchStatus/@status", nsContext);
134:                    String timestamp = XMLTools.getNodeAsString(contextNode,
135:                            "csw:SearchStatus/@timestamp", nsContext, null);
136:                    searchStatus = new SearchStatus(status, timestamp);
137:
138:                    // '<csw:SearchResults>'-element (required)
139:                    contextNode = XMLTools.getRequiredNode(contextNode,
140:                            "csw:SearchResults", nsContext);
141:
142:                    // 'requestId'-attribute (optional)
143:                    requestId = XMLTools.getNodeAsString(contextNode,
144:                            "@requestId", nsContext, requestId);
145:
146:                    // 'resultSetId'-attribute (optional)
147:                    String resultSetId = XMLTools.getNodeAsString(contextNode,
148:                            "@resultSetId", nsContext, null);
149:
150:                    // 'elementSet'-attribute (optional)
151:                    String elementSet = XMLTools.getNodeAsString(contextNode,
152:                            "@elementSet", nsContext, null);
153:
154:                    // 'recordSchema'-attribute (optional)
155:                    String recordSchema = XMLTools.getNodeAsString(contextNode,
156:                            "@recordSchema", nsContext, null);
157:
158:                    // 'numberOfRecordsMatched'-attribute (required)
159:                    int numberOfRecordsMatched = XMLTools.getRequiredNodeAsInt(
160:                            contextNode, "@numberOfRecordsMatched", nsContext);
161:
162:                    // 'numberOfRecordsReturned'-attribute (required)
163:                    int numberOfRecordsReturned = XMLTools
164:                            .getRequiredNodeAsInt(contextNode,
165:                                    "@numberOfRecordsReturned", nsContext);
166:
167:                    // 'nextRecord'-attribute (required)
168:                    int nextRecord = XMLTools.getRequiredNodeAsInt(contextNode,
169:                            "@nextRecord", nsContext);
170:
171:                    // 'expires'-attribute (optional)
172:                    String expires = XMLTools.getNodeAsString(contextNode,
173:                            "@expires", nsContext, "null");
174:
175:                    searchResults = new SearchResults(requestId, resultSetId,
176:                            elementSet, recordSchema, numberOfRecordsReturned,
177:                            numberOfRecordsMatched, nextRecord, contextNode,
178:                            expires);
179:                    return new GetRecordsResult(request, version, searchStatus,
180:                            searchResults);
181:                } catch (XMLParsingException e) {
182:                    ExceptionCode code = ExceptionCode.INVALID_FORMAT;
183:                    throw new OGCWebServiceException(
184:                            "GetRecordsResponseDocument", StringTools
185:                                    .stackTraceToString(e), code);
186:                }
187:
188:            }
189:
190:            /**
191:             * creates an emtpy document as defined by the template
192:             * 
193:             * @throws IOException
194:             *             if the template could not be found
195:             * @throws SAXException
196:             *             if an error occurs while creating the rootnode.
197:             */
198:            public void createEmptyDocument() throws IOException, SAXException {
199:                URL url = GetRecordsResultDocument.class
200:                        .getResource(XML_TEMPLATE);
201:                if (url == null) {
202:                    throw new IOException("The resource '" + XML_TEMPLATE
203:                            + " could not be found.");
204:                }
205:                load(url);
206:            }
207:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.