01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.vfny.geoserver.wcs.requests.readers;
06:
07: import org.vfny.geoserver.Request;
08: import org.vfny.geoserver.util.requests.readers.KvpRequestReader;
09: import org.vfny.geoserver.wcs.WcsException;
10: import org.vfny.geoserver.wcs.requests.DescribeRequest;
11: import org.vfny.geoserver.wcs.servlets.WCService;
12: import java.util.Map;
13: import javax.servlet.http.HttpServletRequest;
14:
15: /**
16: * This utility reads in a DescribeCoverage KVP request and turns it into an
17: * appropriate internal DescribeRequest object.
18: *
19: * @author Rob Hranac, TOPP
20: * @author Gabriel Rold�n
21: * @author $Author: Alessio Fabiani (alessio.fabiani@gmail.com) $ (last modification)
22: * @author $Author: Simone Giannecchini (simboss1@gmail.com) $ (last modification)
23: * @version $Id: DescribeKvpReader.java 6326 2007-03-15 18:36:40Z jdeolive $
24: */
25: public class DescribeKvpReader extends KvpRequestReader {
26: /**
27: * Constructor with raw request string. Calls parent.
28: *
29: * @param kvPairs the key/value pairs containing DESCRIBE
30: */
31: public DescribeKvpReader(Map kvPairs, WCService service) {
32: super (kvPairs, service);
33: }
34:
35: /**
36: * Returns a list of requested feature types..
37: *
38: * @param request the servlet request holding the server config
39: *
40: * @return DescribeRequest request object.
41: * @throws WcsException
42: */
43: public Request getRequest(HttpServletRequest request)
44: throws WcsException {
45: DescribeRequest currentRequest = new DescribeRequest(
46: (WCService) service);
47:
48: if (keyExists("SERVICE")) {
49: final String service = getValue("SERVICE");
50:
51: if (service.trim().toUpperCase().startsWith("WCS")) {
52: currentRequest.setService(service);
53: } else {
54: throw new WcsException("SERVICE parameter is wrong.");
55: }
56: } else {
57: throw new WcsException("SERVICE parameter is mandatory.");
58: }
59:
60: if (keyExists("VERSION")) {
61: final String version = getValue("VERSION");
62:
63: if (version.equals("1.0.0")) {
64: currentRequest.setVersion(version);
65: } else {
66: throw new WcsException("VERSION parameter is wrong.");
67: }
68: } else {
69: throw new WcsException("VERSION parameter is mandatory.");
70: }
71:
72: if (keyExists("REQUEST")) {
73: final String requestType = getValue("REQUEST");
74:
75: if (requestType.equalsIgnoreCase("DescribeCoverage")) {
76: currentRequest.setRequest(requestType);
77: } else {
78: throw new WcsException("REQUEST parameter is wrong.");
79: }
80: } else {
81: throw new WcsException("REQUEST parameter is mandatory.");
82: }
83:
84: currentRequest.setHttpServletRequest(request);
85: currentRequest.setVersion(getValue("VERSION"));
86: currentRequest.setRequest(getValue("REQUEST"));
87: currentRequest.setOutputFormat(getValue("OUTPUTFORMAT"));
88: currentRequest.setCoverages(readFlat(getValue("COVERAGE"),
89: INNER_DELIMETER));
90:
91: return currentRequest;
92: }
93: }
|