001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/src/org/deegree/ogcwebservices/wps/describeprocess/DescribeProcessRequest.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/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 package org.deegree.ogcwebservices.wps.describeprocess; 044 045 import java.security.InvalidParameterException; 046 import java.util.ArrayList; 047 import java.util.List; 048 import java.util.Map; 049 050 import org.deegree.datatypes.Code; 051 import org.deegree.framework.log.ILogger; 052 import org.deegree.framework.log.LoggerFactory; 053 import org.deegree.framework.util.KVP2Map; 054 import org.deegree.framework.util.StringTools; 055 import org.deegree.ogcwebservices.InvalidParameterValueException; 056 import org.deegree.ogcwebservices.MissingParameterValueException; 057 import org.deegree.ogcwebservices.OGCWebServiceException; 058 import org.deegree.ogcwebservices.OperationNotSupportedException; 059 import org.deegree.ogcwebservices.wps.WPSRequestBaseType; 060 import org.w3c.dom.Element; 061 062 /** 063 * DescribeProcessRequest.java 064 * 065 * Created on 09.03.2006. 22:33:16h 066 * 067 * WPS DescribeProcess operation request. 068 * 069 * @author <a href="mailto:christian@kiehle.org">Christian Kiehle</a> 070 * @author <a href="mailto:christian.heier@gmx.de">Christian Heier</a> 071 * @author last edited by: $Author:wanhoff$ 072 * 073 * @version $Revision: 9345 $, $Date:20.03.2007$ 074 */ 075 public class DescribeProcessRequest extends WPSRequestBaseType { 076 077 private static final ILogger LOG = LoggerFactory.getLogger( DescribeProcessRequest.class ); 078 079 /** 080 * @param version 081 * @param id 082 * @param vendorSpecificParameter 083 * @param identifier 084 */ 085 public DescribeProcessRequest( String version, String id, Map<String, String> vendorSpecificParameter, 086 List<Code> identifier ) { 087 super( version, id, vendorSpecificParameter ); 088 this.identifier = identifier; 089 090 } 091 092 /** 093 * Unordered list of one or more identifiers of the processes for which the client is requesting 094 * detailed descriptions. This element shall be repeated for each process for which a 095 * description is requested. These Identifiers are unordered, but the WPS shall return the 096 * descriptions in the order in which they were requested. 097 */ 098 protected List<Code> identifier; 099 100 /** 101 * @return Returns the identifier. 102 */ 103 public List<Code> getIdentifier() { 104 if ( identifier == null ) { 105 identifier = new ArrayList<Code>(); 106 } 107 return this.identifier; 108 } 109 110 /** 111 * Creates a WPSDescribeProcess Request class representation from a key/value pair encoded 112 * request 113 * 114 * @param id 115 * @param request 116 * @return 117 * @throws InvalidParameterValueException 118 * @throws MissingParameterValueException 119 */ 120 @SuppressWarnings("unchecked") 121 public static DescribeProcessRequest create( String id, String request ) 122 throws InvalidParameterValueException, MissingParameterValueException { 123 Map map = KVP2Map.toMap( request ); 124 map.put( "ID", id ); 125 return create( map ); 126 127 } 128 129 /** 130 * 131 * @param request 132 * @return 133 * @throws InvalidParameterValueException 134 * @throws MissingParameterValueException 135 */ 136 public static DescribeProcessRequest create( Map request ) 137 throws InvalidParameterValueException, MissingParameterValueException { 138 139 String version = extractVersionParameter( request ); 140 String id = (String) request.get( "ID" ); 141 Map<String, String> vendorSpecificParameters = null; 142 143 List<Code> identifier = null; 144 145 String tmp = (String) request.get( "IDENTIFIER" ); 146 147 if ( null == tmp ) { 148 String msg = "Parameter 'Identifier' must be set."; 149 LOG.logError( msg ); 150 throw new MissingParameterValueException( msg ); 151 } 152 String[] values = StringTools.toArray( tmp, ",", false ); 153 154 if ( values.length == 0 ) { 155 String msg = "Identifier must at least declare one process name."; 156 LOG.logError( msg ); 157 throw new InvalidParameterException( msg ); 158 } 159 identifier = new ArrayList<Code>( values.length ); 160 for ( int i = 0; i < values.length; i++ ) { 161 162 identifier.add( new Code( values[i], null ) ); 163 } 164 165 return new DescribeProcessRequest( version, id, vendorSpecificParameters, identifier ); 166 } 167 168 /** 169 * XML-coded decribe process request currently not supported. This is not a mandatory operation. 170 * 171 * @see "OGC 05-007r4 Subclause 9.2.3" 172 * 173 * @param id 174 * @param element 175 * @return 176 * @throws OGCWebServiceException 177 * @throws MissingParameterValueException 178 * @throws InvalidParameterValueException 179 */ 180 public static DescribeProcessRequest create( String id, Element element ) 181 throws OGCWebServiceException { 182 throw new OperationNotSupportedException( 183 "HTTP post transfer of XML encoded describe process request not supported." ); 184 } 185 186 }