001 //$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/owscommon_1_1_0/operations/GetResourceByIDDocument.java $ 002 /*---------------------------------------------------------------------------- 003 This file is part of deegree, http://deegree.org/ 004 Copyright (C) 2001-2009 by: 005 Department of Geography, University of Bonn 006 and 007 lat/lon GmbH 008 009 This library is free software; you can redistribute it and/or modify it under 010 the terms of the GNU Lesser General Public License as published by the Free 011 Software Foundation; either version 2.1 of the License, or (at your option) 012 any later version. 013 This library is distributed in the hope that it will be useful, but WITHOUT 014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 015 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 016 details. 017 You should have received a copy of the GNU Lesser General Public License 018 along with this library; if not, write to the Free Software Foundation, Inc., 019 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 020 021 Contact information: 022 023 lat/lon GmbH 024 Aennchenstr. 19, 53177 Bonn 025 Germany 026 http://lat-lon.de/ 027 028 Department of Geography, University of Bonn 029 Prof. Dr. Klaus Greve 030 Postfach 1147, 53001 Bonn 031 Germany 032 http://www.geographie.uni-bonn.de/deegree/ 033 034 e-mail: info@deegree.org 035 ----------------------------------------------------------------------------*/ 036 037 package org.deegree.owscommon_1_1_0.operations; 038 039 import static org.deegree.framework.xml.XMLTools.getNodeAsString; 040 import static org.deegree.framework.xml.XMLTools.getNodesAsStringList; 041 042 import java.util.ArrayList; 043 import java.util.List; 044 045 import org.deegree.framework.xml.XMLFragment; 046 import org.deegree.framework.xml.XMLParsingException; 047 import org.deegree.ogcbase.CommonNamespaces; 048 import org.w3c.dom.Element; 049 050 /** 051 * <code>GetResourceByID</code> supplies the methods for parsing the ows 1.1.0 GetResourceById 052 * xml-dom structure. 053 * 054 * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a> 055 * 056 * @author last edited by: $Author: mschneider $ 057 * 058 * @version $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18 Jun 2009) $ 059 * 060 */ 061 public class GetResourceByIDDocument extends XMLFragment { 062 063 private static final long serialVersionUID = 2061011143514168497L; 064 065 private static final String PRE = CommonNamespaces.OWS_1_1_0PREFIX + ":"; 066 067 /** 068 * @return a list of resourceID uri's or an empty list if no resourceID's were given. 069 * @throws XMLParsingException 070 * if the node could not be parsed. 071 */ 072 public List<String> parseResourceIDs() 073 throws XMLParsingException { 074 Element root = getRootElement(); 075 List<String> result = new ArrayList<String>(); 076 if ( root != null ) { 077 result = getNodesAsStringList( root, PRE + "ResourceID", nsContext ); 078 } 079 return result; 080 } 081 082 /** 083 * @return a String containing an output format (mime-type) or an empty String if no output 084 * format was given. 085 * @throws XMLParsingException 086 * if the node could not be parsed. 087 */ 088 public String parseOutputFormats() 089 throws XMLParsingException { 090 Element root = getRootElement(); 091 String result = new String(); 092 if ( root != null ) { 093 result = getNodeAsString( root, PRE + "OutputFormat", nsContext, "" ); 094 } 095 return result; 096 } 097 098 /** 099 * @return the mandatory version string. 100 * @throws XMLParsingException 101 * if the attribute was not given. 102 */ 103 public String parseVersion() 104 throws XMLParsingException { 105 Element root = getRootElement(); 106 String result = new String(); 107 if ( root != null ) { 108 result = root.getAttribute( "version" ); 109 if ( result == null || "".equals( result.trim() ) ) { 110 throw new XMLParsingException( 111 "The version attribute is mandatory for a resourceById (ows 1.1.0) request" ); 112 } 113 114 } 115 return result; 116 } 117 118 /** 119 * @return the mandatory service string. 120 * @throws XMLParsingException 121 * if the attribute was not given. 122 */ 123 public String parseService() 124 throws XMLParsingException { 125 Element root = getRootElement(); 126 String result = new String(); 127 if ( root != null ) { 128 result = root.getAttribute( "service" ); 129 if ( result == null || "".equals( result.trim() ) ) { 130 throw new XMLParsingException( 131 "The service attribute is mandatory for a resourceById (ows 1.1.0) request" ); 132 } 133 } 134 return result; 135 } 136 137 }