annotate flys-client/src/main/java/de/intevation/flys/client/server/CapabilitiesParser.java @ 1448:c39aa5a6478c

#409 Made layer list and map layers synchron. flys-client/trunk@3465 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 19 Dec 2011 14:58:24 +0000
parents 42d6cf6e10b7
children ea2aae01e7c4
rev   line source
1417
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.server;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.io.InputStream;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.io.IOException;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import java.net.MalformedURLException;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import java.net.URL;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import java.net.URLConnection;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import java.util.ArrayList;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import java.util.List;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import java.util.regex.Matcher;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import java.util.regex.Pattern;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import javax.xml.xpath.XPathConstants;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import org.w3c.dom.Document;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import org.w3c.dom.Node;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 import org.w3c.dom.NodeList;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import org.apache.log4j.Logger;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import de.intevation.artifacts.common.utils.XMLUtils;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 import de.intevation.flys.client.shared.exceptions.ServerException;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 import de.intevation.flys.client.shared.model.Capabilities;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 import de.intevation.flys.client.shared.model.ContactInformation;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 import de.intevation.flys.client.shared.model.WMSLayer;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 public class CapabilitiesParser {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 private static final Logger logger =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 Logger.getLogger(CapabilitiesParser.class);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 public static final String ERR_GC_REQUEST_FAILED =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 "error_gc_req_failed";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 public static final String ERR_GC_DOC_NOT_VALID =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 "error_gc_doc_not_valid";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 public static final String ERR_MALFORMED_URL =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 "error_malformed_url";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 public static final String XPATH_WMS_CAPS =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 "/WMS_Capabilities";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 public static final String XPATH_WMT_CAPS =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 "/WMT_MS_Capabilities";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 public static final String XPATH_TITLE =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 "Service/Title/text()";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 public static final String XPATH_ONLINE_RESOURCE =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 "Service/OnlineResource/@href";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 public static final String XPATH_CONTACT_INFORMATION =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 "Service/ContactInformation";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 public static final String XPATH_CI_PERSON =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 "ContactPersonPrimary/ContactPerson/text()";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 public static final String XPATH_CI_ORGANIZATION =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 "ContactPersonPrimary/ContactOrganization/text()";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 public static final String XPATH_CI_ADDRESS =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 "ContactAddress/Address/text()";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 public static final String XPATH_CI_CITY =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 "ContactAddress/City/text()";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 public static final String XPATH_CI_POSTCODE =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 "ContactAddress/PostCode/text()";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 public static final String XPATH_CI_PHONE =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 "ContactVoiceTelephone/text()";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 public static final String XPATH_CI_EMAIL =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 "ContactElectronicMailAddress/text()";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 public static final String XPATH_FEES =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 "Service/Fees/text()";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 public static final String XPATH_ACCESS_CONSTRAINTS =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 "Service/AccessConstraints/text()";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 public static final String XPATH_LAYERS =
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 "Capability/Layer";
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 public static final Pattern SRS_PATTERN = Pattern.compile("(EPSG:\\d+)*");
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 private CapabilitiesParser() {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 public static void main(String[] args) {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 logger.info("Do static Capabilities request/parsing.");
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 String log4jProperties = System.getenv(BaseServlet.LOG4J_PROPERTIES);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 LoggingConfigurator.init(log4jProperties);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 try {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 Capabilities caps = getCapabilities(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 "http://czech-republic.atlas.intevation.de/cgi-bin/saar-wms?REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.0");
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 catch (ServerException se) {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 se.printStackTrace();
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 logger.info("Finished fetching capabiltiies.");
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115 public static Capabilities getCapabilities(String urlStr)
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116 throws ServerException
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 try {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119 URL url = new URL(urlStr);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 logger.debug("Open connection to url: " + urlStr);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 URLConnection conn = url.openConnection();
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 conn.connect();
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126 InputStream is = conn.getInputStream();
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128 return parse(is);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130 catch (MalformedURLException mue) {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131 logger.warn(mue, mue);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
132 throw new ServerException(ERR_MALFORMED_URL);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134 catch (IOException ioe) {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 logger.warn(ioe, ioe);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138 throw new ServerException(ERR_GC_REQUEST_FAILED);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
139 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
140
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142 protected static Capabilities parse(InputStream is)
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143 throws ServerException
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145 logger.debug("GCServiceImpl.parseCapabilitiesResponse");
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 Document doc = XMLUtils.parseDocument(is, false);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149 if (doc == null) {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150 throw new ServerException(ERR_GC_DOC_NOT_VALID);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153 return CapabilitiesParser.parse(doc);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 public static Capabilities parse(Document doc)
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 throws ServerException
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159 {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 Node capabilities = getCapabilitiesNode(doc);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162 String title = (String) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163 capabilities,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 XPATH_TITLE,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165 XPathConstants.STRING);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
166
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
167 String onlineResource = (String) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
168 capabilities,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 XPATH_ONLINE_RESOURCE,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170 XPathConstants.STRING);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
171
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172 String fees = (String) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173 capabilities,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
174 XPATH_FEES,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
175 XPathConstants.STRING);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177 String accessConstraints = (String) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 capabilities,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179 XPATH_ACCESS_CONSTRAINTS,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
180 XPathConstants.STRING);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
181
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182 Node contactInformation = (Node) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183 capabilities,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
184 XPATH_CONTACT_INFORMATION,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
185 XPathConstants.NODE);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
186
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
187 ContactInformation ci = parseContactInformation(contactInformation);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
188
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
189 logger.debug("Found fees: " + fees);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190 logger.debug("Found access constraints: " + accessConstraints);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
191
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192 NodeList layerNodes = (NodeList) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
193 capabilities,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
194 XPATH_LAYERS,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
195 XPathConstants.NODESET);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
196
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
197 List<WMSLayer> layers = parseLayers(layerNodes, onlineResource);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
198
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199 return new Capabilities(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200 title,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201 onlineResource,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
202 ci,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203 fees,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204 accessConstraints,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205 layers);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
207
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
209 protected static Node getCapabilitiesNode(Document doc)
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210 throws ServerException {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
211 Node capabilities = (Node) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212 doc,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213 XPATH_WMS_CAPS,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214 XPathConstants.NODE);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
215
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
216 if (capabilities == null) {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217 logger.info("No '/WMS_Capabilities' node found.");
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
218 logger.info("Try to find a '/WMT_MS_Capabilities' node.");
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
219
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
220 capabilities = (Node) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
221 doc,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
222 XPATH_WMT_CAPS,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
223 XPathConstants.NODE);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
224 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
225
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
226 if (capabilities == null) {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
227 throw new ServerException(ERR_GC_DOC_NOT_VALID);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
228 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
229
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
230 return capabilities;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
231 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
232
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
233
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
234 protected static ContactInformation parseContactInformation(Node node) {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
235 String person = (String) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
236 node,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
237 XPATH_CI_PERSON,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
238 XPathConstants.STRING);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
239
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
240 String organization = (String) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
241 node,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
242 XPATH_CI_ORGANIZATION,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
243 XPathConstants.STRING);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
244
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
245 String address = (String) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
246 node,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
247 XPATH_CI_ADDRESS,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
248 XPathConstants.STRING);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
249
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
250 String postcode = (String) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
251 node,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
252 XPATH_CI_POSTCODE,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
253 XPathConstants.STRING);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
254
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
255 String city = (String) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
256 node,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
257 XPATH_CI_CITY,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
258 XPathConstants.STRING);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
259
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
260 String phone = (String) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
261 node,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
262 XPATH_CI_PHONE,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
263 XPathConstants.STRING);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
264
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
265 String email = (String) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
266 node,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
267 XPATH_CI_EMAIL,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
268 XPathConstants.STRING);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
269
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
270 ContactInformation ci = new ContactInformation();
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
271 ci.setPerson(person);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
272 ci.setOrganization(organization);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
273 ci.setAddress(address);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
274 ci.setPostcode(postcode);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
275 ci.setCity(city);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
276 ci.setPhone(phone);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
277 ci.setEmail(email);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
278
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
279 return ci;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
280 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
281
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
282
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
283 /**
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
284 * @param layersNode
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
285 * @param onlineResource
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
286 *
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
287 * @return
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
288 */
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
289 protected static List<WMSLayer> parseLayers(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
290 NodeList layersNode,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
291 String onlineResource
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
292 ) {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
293 int len = layersNode != null ? layersNode.getLength() : 0;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
294
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
295 logger.debug("Node has " + len + " layers.");
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
296
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
297 List<WMSLayer> layers = new ArrayList<WMSLayer>(len);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
298
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
299 for (int i = 0; i < len; i++) {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
300 layers.add(parseLayer(layersNode.item(i), onlineResource));
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
301 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
302
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
303 return layers;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
304 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
305
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
306
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
307 protected static WMSLayer parseLayer(Node layerNode, String onlineResource) {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
308 String title = (String) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
309 layerNode,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
310 "Title/text()",
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
311 XPathConstants.STRING);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
312
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
313 String name = (String) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
314 layerNode,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
315 "Name/text()",
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
316 XPathConstants.STRING);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
317
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
318 logger.debug("Found layer: " + title + "(" + name + ")");
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
319
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
320 List<String> srs = parseSRS(layerNode);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
321
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
322 NodeList layersNodes = (NodeList) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
323 layerNode,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
324 "Layer",
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
325 XPathConstants.NODESET);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
326
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
327 List<WMSLayer> layers = parseLayers(layersNodes, onlineResource);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
328
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
329 return new WMSLayer(onlineResource, title, name, srs, layers);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
330 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
331
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
332
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
333 protected static List<String> parseSRS(Node layerNode) {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
334 String srsStr = (String) XMLUtils.xpath(
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
335 layerNode,
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
336 "SRS/text()",
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
337 XPathConstants.STRING);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
338
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
339 if (srsStr == null || srsStr.length() == 0) {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
340 logger.debug("No explicit SRS for this layer specified.");
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
341 return null;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
342 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
343
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
344 String[] splittedSrs = srsStr.split(" ");
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
345 List<String> srs = new ArrayList<String>();
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
346
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
347 for (String singleSrs: splittedSrs) {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
348 Matcher m = SRS_PATTERN.matcher(singleSrs);
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
349
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
350 if (m.matches()) {
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
351 logger.debug("Found SRS '" + m.group(1) + "'");
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
352 srs.add(m.group(1));
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
353 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
354 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
355
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
356 return srs;
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
357 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
358 }
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
359 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org