View Javadoc
1   package fr.ifremer.dali.map.wmts;
2   
3   import org.geotools.data.ows.GetCapabilitiesRequest;
4   import org.geotools.data.ows.HTTPResponse;
5   import org.geotools.data.wmts.WMTSSpecification;
6   import org.geotools.data.wmts.response.WMTSGetCapabilitiesResponse;
7   import org.geotools.ows.ServiceException;
8   
9   import java.io.IOException;
10  import java.net.URL;
11  
12  /**
13   * Allow the apiKey in request, but sometimes need to still in lower case
14   *
15   * @author peck7 on 15/06/2019.
16   */
17  public class WMTSSpecification2 extends WMTSSpecification {
18  
19      private static final String APIKEY = "key";
20  
21      @Override
22      public GetCapabilitiesRequest createGetCapabilitiesRequest(URL server) {
23          return new GetCapsRequest2(server);
24      }
25  
26      static public class GetCapsRequest2 extends WMTSSpecification.GetCapsRequest {
27          /**
28           * Construct a Request compatible with a 1.0.1 WMTS.
29           *
30           * @param urlGetCapabilities
31           *            URL of GetCapabilities document.
32           */
33          public GetCapsRequest2(URL urlGetCapabilities) {
34              super(urlGetCapabilities);
35          }
36  
37          @Override
38          protected void initService() {
39              setProperty(SERVICE, "WMTS");
40          }
41  
42          @Override
43          protected void initVersion() {
44              setProperty(VERSION, WMTS_VERSION); // $NON-NLS-1$ //$NON-NLS-2$
45          }
46  
47          @Override
48          protected String processKey(String key) {
49  
50              if (key.equalsIgnoreCase(APIKEY)) return APIKEY;
51  
52              return WMTSSpecification.processKey(key);
53          }
54  
55          @Override
56          public WMTSGetCapabilitiesResponse createResponse(HTTPResponse httpResponse)
57                  throws ServiceException, IOException {
58              return new WMTSGetCapabilitiesResponse(httpResponse, hints);
59          }
60      }
61  }