001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/ogcwebservices/wps/capabilities/WPSCapabilitiesDocument.java $ 002 /*---------------- FILE HEADER ------------------------------------------ 003 004 This file is part of deegree. 005 Copyright (C) 2001-2005 by: 006 EXSE, Department of Geography, University of Bonn 007 http://www.giub.uni-bonn.de/exse/ 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 Aennchenstraße 19 030 53177 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.wps.capabilities; 045 046 import static org.deegree.ogcwebservices.wps.capabilities.WPSOperationsMetadata.DESCRIBEPROCESS; 047 import static org.deegree.ogcwebservices.wps.capabilities.WPSOperationsMetadata.EXECUTE; 048 049 import java.io.IOException; 050 import java.net.URL; 051 import java.util.HashMap; 052 import java.util.List; 053 import java.util.Map; 054 055 import org.deegree.framework.log.ILogger; 056 import org.deegree.framework.log.LoggerFactory; 057 import org.deegree.framework.xml.XMLParsingException; 058 import org.deegree.framework.xml.XMLTools; 059 import org.deegree.ogcwebservices.getcapabilities.InvalidCapabilitiesException; 060 import org.deegree.ogcwebservices.getcapabilities.OGCCapabilities; 061 import org.deegree.ogcwebservices.getcapabilities.Operation; 062 import org.deegree.ogcwebservices.getcapabilities.OperationsMetadata; 063 import org.deegree.owscommon.OWSCommonCapabilitiesDocument; 064 import org.deegree.owscommon.OWSDomainType; 065 import org.w3c.dom.Element; 066 import org.w3c.dom.Node; 067 import org.xml.sax.SAXException; 068 069 /** 070 * WPSCapabilitiesDocument.java 071 * 072 * Creates an object representation of the sample_wps_capabilities.xml document 073 * 074 * Created on 08.03.2006. 18:57:37h 075 * 076 * @author <a href="mailto:christian@kiehle.org">Christian Kiehle</a> 077 * @author <a href="mailto:christian.heier@gmx.de">Christian Heier</a> 078 * 079 * @version 1.0. 080 * 081 * @since 2.0 082 */ 083 public class WPSCapabilitiesDocument extends OWSCommonCapabilitiesDocument { 084 085 private static final ILogger LOG = LoggerFactory.getLogger( WPSCapabilitiesDocument.class ); 086 087 private static final String XML_TEMPLATE = "WPSCapabilitiesTemplate.xml"; 088 089 /** 090 * @throws IOException 091 * @throws SAXException 092 */ 093 public void createEmptyDocument() throws IOException, SAXException { 094 URL url = WPSCapabilitiesDocument.class.getResource( XML_TEMPLATE ); 095 if ( null == url ) { 096 throw new IOException( "The resource '" + XML_TEMPLATE + " ' could not be found" ); 097 } 098 load( url ); 099 } 100 101 /* 102 * (non-Javadoc) 103 * 104 * @see org.deegree.ogcwebservices.getcapabilities.OGCCapabilitiesDocument#parseCapabilities() 105 */ 106 @Override 107 public OGCCapabilities parseCapabilities() throws InvalidCapabilitiesException { 108 try { 109 110 return new WPSCapabilities( parseVersion(), parseUpdateSequence(), 111 getServiceIdentification(), getServiceProvider(), getOperationsMetadata(), null ); 112 } catch ( Exception e ) { 113 LOG.logError( e.getMessage(), e ); 114 throw new InvalidCapabilitiesException( e.getMessage() ); 115 } 116 } 117 118 /** 119 * Creates an object representation of the 120 * <code>ows:OperationsMetadata</code> section. 121 * 122 * @return object representation of the <code>ows:OperationsMetadata</code> 123 * section 124 * @throws XMLParsingException 125 */ 126 @SuppressWarnings ( "unchecked") 127 public OperationsMetadata getOperationsMetadata() throws XMLParsingException { 128 LOG.entering(); 129 List operationElementList = XMLTools.getNodes( getRootElement(), 130 "ows:OperationsMetadata/ows:Operation", nsContext ); 131 132 // build HashMap of 'ows:Operation'-elements for easier access 133 Map operations = new HashMap(); 134 for ( int i = 0; i < operationElementList.size(); i++ ) { 135 operations.put( XMLTools.getRequiredNodeAsString( 136 ( Node ) operationElementList.get( i ), "@name", nsContext ), 137 operationElementList.get( i ) ); 138 } 139 140 Operation getCapabilities = getOperation( OperationsMetadata.GET_CAPABILITIES_NAME, true, 141 operations ); 142 Operation describeProcess = getOperation( DESCRIBEPROCESS, true, operations ); 143 Operation execute = getOperation( EXECUTE, true, operations ); 144 145 List parameterElementList = XMLTools.getNodes( getRootElement(), 146 "ows:OperationsMetadata/ows:Parameter", nsContext ); 147 OWSDomainType[] parameters = new OWSDomainType[parameterElementList.size()]; 148 for ( int i = 0; i < parameters.length; i++ ) { 149 parameters[i] = getOWSDomainType( null, ( Element ) parameterElementList.get( i ) ); 150 } 151 152 List constraintElementList = XMLTools.getNodes( getRootElement(), 153 "ows:OperationsMetadata/ows:Constraint", nsContext ); 154 OWSDomainType[] constraints = new OWSDomainType[constraintElementList.size()]; 155 for ( int i = 0; i < constraints.length; i++ ) { 156 constraints[i] = getOWSDomainType( null, ( Element ) constraintElementList.get( i ) ); 157 } 158 WPSOperationsMetadata metadata = new WPSOperationsMetadata( getCapabilities, 159 describeProcess, execute, parameters, constraints ); 160 LOG.exiting(); 161 return metadata; 162 } 163 164 } 165 /* ******************************************************************** 166 Changes to this class. What the people have been up to: 167 $Log$ 168 Revision 1.5 2006/08/24 06:42:16 poth 169 File header corrected 170 171 Revision 1.4 2006/07/12 14:46:15 poth 172 comment footer added 173 174 ********************************************************************** */