Source Code Cross Referenced for GetRecordById.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:        //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/ogcwebservices/csw/discovery/GetRecordById.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:        package org.deegree.ogcwebservices.csw.discovery;
044:
045:        import java.util.Map;
046:
047:        import org.deegree.framework.log.ILogger;
048:        import org.deegree.framework.log.LoggerFactory;
049:        import org.deegree.framework.util.IDGenerator;
050:        import org.deegree.framework.util.StringTools;
051:        import org.deegree.framework.xml.NamespaceContext;
052:        import org.deegree.framework.xml.XMLParsingException;
053:        import org.deegree.framework.xml.XMLTools;
054:        import org.deegree.ogcbase.CommonNamespaces;
055:        import org.deegree.ogcwebservices.InvalidParameterValueException;
056:        import org.deegree.ogcwebservices.MissingParameterValueException;
057:        import org.deegree.ogcwebservices.OGCWebServiceException;
058:        import org.deegree.ogcwebservices.csw.AbstractCSWRequest;
059:        import org.deegree.ogcwebservices.csw.CSWPropertiesAccess;
060:        import org.deegree.ogcwebservices.csw.NonexistentCollectionException;
061:        import org.deegree.ogcwebservices.csw.NonexistentTypeException;
062:        import org.w3c.dom.Element;
063:
064:        /**
065:         * The mandatory GetRecordById request retrieves the default representation of catalogue records
066:         * using their identifier. The GetRecordById operation is an implementation of the Present operation
067:         * from the general model. This operation presumes that a previous query has been performed in order
068:         * to obtain the identifiers that may be used with this operation. For example, records returned by
069:         * a GetRecords operation may contain references to other records in the catalogue that may be
070:         * retrieved using the GetRecordById operation. This operation is also a subset of the GetRecords
071:         * operation, and is included as a convenient short form for retrieving and linking to records in a
072:         * catalogue.
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 GetRecordById extends AbstractCSWRequest {
083:
084:            private static final long serialVersionUID = -3602776884510160189L;
085:
086:            private static final ILogger LOG = LoggerFactory
087:                    .getLogger(GetRecordById.class);
088:
089:            private static NamespaceContext nsContext = CommonNamespaces
090:                    .getNamespaceContext();
091:
092:            private String[] ids = null;
093:
094:            private String elementSetName = null;
095:
096:            /**
097:             * creates a <code>GetRecordById</code> request from the XML fragment passed. The passed
098:             * element must be valid against the OGC CSW 2.0 GetRecordById schema.
099:             * 
100:             * @param id
101:             *            unique ID of the request
102:             * @param root
103:             *            root element of the GetRecors request
104:             * @return a GetRecordById bean representation created from the xml fragment.
105:             * @throws MissingParameterValueException
106:             * @throws InvalidParameterValueException
107:             * @throws OGCWebServiceException
108:             */
109:            public static GetRecordById create(String id, Element root)
110:                    throws MissingParameterValueException,
111:                    InvalidParameterValueException, OGCWebServiceException {
112:
113:                String version = null;
114:                try {
115:                    // first try to read verdsion attribute which is optional for CSW 2.0.0 and 2.0.1
116:                    version = XMLTools.getNodeAsString(root, "./@version",
117:                            nsContext, null);
118:                } catch (XMLParsingException e) {
119:
120:                }
121:                if (version == null) {
122:                    // if no version attribute has been set try mapping namespace URI to a version;
123:                    // this is not well defined for 2.0.0 and 2.0.1 which uses the same namespace.
124:                    // in this case 2.0.0 will be returned!
125:                    version = CSWPropertiesAccess.getString(root
126:                            .getNamespaceURI());
127:                }
128:
129:                // read class for version depenging parsing of GetRecords request from properties 
130:                String className = CSWPropertiesAccess
131:                        .getString("GetRecordById" + version);
132:                Class clzz = null;
133:                try {
134:                    clzz = Class.forName(className);
135:                } catch (ClassNotFoundException e) {
136:                    LOG.logError(e.getMessage(), e);
137:                    throw new InvalidParameterValueException(e.getMessage(), e);
138:                }
139:                GetRecordByIdDocument document = null;
140:                try {
141:                    document = (GetRecordByIdDocument) clzz.newInstance();
142:                } catch (InstantiationException e) {
143:                    LOG.logError(e.getMessage(), e);
144:                    throw new InvalidParameterValueException(e.getMessage(), e);
145:                } catch (IllegalAccessException e) {
146:                    LOG.logError(e.getMessage(), e);
147:                    throw new InvalidParameterValueException(e.getMessage(), e);
148:                }
149:
150:                document.setRootElement(root);
151:
152:                return document.parse(id);
153:
154:            }
155:
156:            /**
157:             * Creates a new <code>GetRecordById</code> instance from the values stored in the submitted
158:             * Map. Keys (parameter names) in the Map must be uppercase.
159:             * 
160:             * @TODO evaluate vendorSpecificParameter
161:             * 
162:             * @param kvp
163:             *            Map containing the parameters
164:             * @return a GetRecordById bean representation, the internal request id will be set to
165:             *         Long.toString( IDGenerator.getInstance().generateUniqueID() ).
166:             * @exception InvalidParameterValueException
167:             * @exception MissingParameterValueException
168:             * @exception NonexistentCollectionException
169:             * @exception NonexistentTypeException
170:             */
171:            public static GetRecordById create(Map<String, String> kvp) {
172:
173:                String version = kvp.remove("VERSION");
174:                String elementSetName = kvp.remove("ELEMENTSETNAME");
175:                String tmp = kvp.remove("ID");
176:                String[] ids = StringTools.toArray(tmp, ",", true);
177:
178:                return new GetRecordById(Long.toString(IDGenerator
179:                        .getInstance().generateUniqueID()), version, kvp, ids,
180:                        elementSetName);
181:            }
182:
183:            /**
184:             * Creates a new <code>GetRecordById</code> instance from the values stored in the submitted
185:             * Map. Keys (parameter names) in the Map must be uppercase.
186:             * 
187:             * @param id
188:             *            of the request, and not the requested ids.
189:             * 
190:             * @TODO evaluate vendorSpecificParameter
191:             * 
192:             * @param kvp
193:             *            Map containing the parameters
194:             * @return a GetRecordById bean representation.
195:             * @exception InvalidParameterValueException
196:             * @exception MissingParameterValueException
197:             * @exception NonexistentCollectionException
198:             * @exception NonexistentTypeException
199:             */
200:            public static GetRecordById create(String id,
201:                    Map<String, String> kvp) {
202:
203:                String version = kvp.remove("VERSION");
204:                String elementSetName = kvp.remove("ELEMENTSETNAME");
205:                String tmp = kvp.remove("ID");
206:                String[] ids = StringTools.toArray(tmp, ",", true);
207:
208:                return new GetRecordById(id, version, kvp, ids, elementSetName);
209:            }
210:
211:            /**
212:             * 
213:             * @param ids
214:             *            identifiers of the requested catalogue entries
215:             * @param elementSetName
216:             *            requested element set (brief|summary|full). Can be <code>null</code>; will be
217:             *            treaded as full.
218:             */
219:            GetRecordById(String id, String version,
220:                    Map<String, String> vendorSpecificParameters, String[] ids,
221:                    String elementSetName) {
222:                super (version, id, vendorSpecificParameters);
223:                this .ids = ids;
224:                this .elementSetName = elementSetName;
225:            }
226:
227:            /**
228:             * @return the requested element set name. If the returned value equals <code>null</code> a
229:             *         'summary' request shall be performed. possible values are:
230:             *         <ul>
231:             *         <li>brief</li>
232:             *         <li>summary</li>
233:             *         <li>full</li>
234:             *         </ul>
235:             * 
236:             */
237:            public String getElementSetName() {
238:                return elementSetName;
239:            }
240:
241:            /**
242:             * @return the requested ids as an array of strings
243:             */
244:            public String[] getIds() {
245:                return ids;
246:            }
247:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.