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