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.wms.requests;
06:
07: import org.vfny.geoserver.Request;
08: import org.vfny.geoserver.ServiceException;
09: import org.vfny.geoserver.global.WMS;
10: import org.vfny.geoserver.util.requests.CapabilitiesRequest;
11: import org.vfny.geoserver.util.requests.readers.KvpRequestReader;
12: import org.vfny.geoserver.wms.servlets.WMService;
13: import java.util.Map;
14: import javax.servlet.http.HttpServletRequest;
15:
16: /**
17: * This utility reads in a GetCapabilities KVP request and turns it into an
18: * appropriate internal CapabilitiesRequest object, upon request.
19: *
20: * @author Rob Hranac, TOPP
21: * @author Gabriel Rold?n, Axios Engineering
22: * @version $Id: CapabilitiesKvpReader.java 8406 2008-02-14 19:49:39Z saul.farber $
23: */
24: public class CapabilitiesKvpReader extends KvpRequestReader {
25: /**
26: * Constructor with raw request string. Calls parent.
27: *
28: * @param kvPairs The raw string of a capabilities kvp request.
29: *
30: *
31: */
32: public CapabilitiesKvpReader(Map kvPairs, WMService service) {
33: super (kvPairs, service);
34: }
35:
36: /**
37: * Get Capabilities request.
38: *
39: * @return Capabilities request.
40: *
41: * @throws ServiceException DOCUMENT ME!
42: */
43: public Request getRequest(HttpServletRequest request)
44: throws ServiceException {
45: CapabilitiesRequest currentRequest = new WMSCapabilitiesRequest(
46: service);
47: currentRequest.setHttpServletRequest(request);
48:
49: String reqVersion = WMS.getVersion();
50:
51: if (keyExists("VERSION")) {
52: reqVersion = getValue("VERSION");
53: } else if (keyExists("WMTVER")) {
54: reqVersion = getValue("WMTVER");
55: }
56:
57: currentRequest.setVersion(reqVersion);
58:
59: if (keyExists("UPDATESEQUENCE")) {
60: currentRequest
61: .setUpdateSequence(getValue("UPDATESEQUENCE"));
62: }
63:
64: return currentRequest;
65: }
66: }
|