Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/server/GCServiceImpl.java @ 1409:ec6e4dad1279
Read and display all FLYS relevant information of Capabilities documents.
flys-client/trunk@3296 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 21 Nov 2011 18:15:44 +0000 |
parents | 5b5a20e4c4e5 |
children | 63be3137abac |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/GCServiceImpl.java Mon Nov 21 12:00:48 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/GCServiceImpl.java Mon Nov 21 18:15:44 2011 +0000 @@ -11,6 +11,7 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet; import org.w3c.dom.Document; +import org.w3c.dom.Node; import org.apache.log4j.Logger; @@ -18,6 +19,7 @@ import de.intevation.flys.client.shared.exceptions.ServerException; import de.intevation.flys.client.shared.model.Capabilities; +import de.intevation.flys.client.shared.model.ContactInformation; import de.intevation.flys.client.client.services.GCService; @@ -37,6 +39,36 @@ public static final String ERR_MALFORMED_URL = "error_malformed_url"; + public static final String XPATH_TITLE = + "/WMS_Capabilities/Service/Title/text()"; + + public static final String XPATH_ONLINE_RESOURCE = + "/WMS_Capabilities/Service/OnlineResource/@href"; + + public static final String XPATH_CONTACT_INFORMATION = + "/WMS_Capabilities/Service/ContactInformation"; + + public static final String XPATH_CI_PERSON = + "ContactPersonPrimary/ContactPerson/text()"; + + public static final String XPATH_CI_ORGANIZATION = + "ContactPersonPrimary/ContactOrganization/text()"; + + public static final String XPATH_CI_ADDRESS = + "ContactAddress/Address/text()"; + + public static final String XPATH_CI_CITY = + "ContactAddress/City/text()"; + + public static final String XPATH_CI_POSTCODE = + "ContactAddress/PostCode/text()"; + + public static final String XPATH_CI_PHONE = + "ContactVoiceTelephone/text()"; + + public static final String XPATH_CI_EMAIL = + "ContactElectronicMailAddress/text()"; + public static final String XPATH_FEES = "/WMS_Capabilities/Service/Fees/text()"; @@ -87,6 +119,16 @@ throw new ServerException(ERR_GC_DOC_NOT_VALID); } + String title = (String) XMLUtils.xpath( + doc, + XPATH_TITLE, + XPathConstants.STRING); + + String onlineResource = (String) XMLUtils.xpath( + doc, + XPATH_ONLINE_RESOURCE, + XPathConstants.STRING); + String fees = (String) XMLUtils.xpath( doc, XPATH_FEES, @@ -97,12 +139,74 @@ XPATH_ACCESS_CONSTRAINTS, XPathConstants.STRING); + Node contactInformation = (Node) XMLUtils.xpath( + doc, + XPATH_CONTACT_INFORMATION, + XPathConstants.NODE); + + ContactInformation ci = parseContactInformation(contactInformation); + logger.debug("Found fees: " + fees); logger.debug("Found access constraints: " + accessConstraints); // TODO PARSE LAYERS - return new Capabilities(fees, accessConstraints, null); + return new Capabilities( + title, + onlineResource, + ci, + fees, + accessConstraints, + null); + } + + + protected ContactInformation parseContactInformation(Node node) { + String person = (String) XMLUtils.xpath( + node, + XPATH_CI_PERSON, + XPathConstants.STRING); + + String organization = (String) XMLUtils.xpath( + node, + XPATH_CI_ORGANIZATION, + XPathConstants.STRING); + + String address = (String) XMLUtils.xpath( + node, + XPATH_CI_ADDRESS, + XPathConstants.STRING); + + String postcode = (String) XMLUtils.xpath( + node, + XPATH_CI_POSTCODE, + XPathConstants.STRING); + + String city = (String) XMLUtils.xpath( + node, + XPATH_CI_CITY, + XPathConstants.STRING); + + String phone = (String) XMLUtils.xpath( + node, + XPATH_CI_PHONE, + XPathConstants.STRING); + + String email = (String) XMLUtils.xpath( + node, + XPATH_CI_EMAIL, + XPathConstants.STRING); + + ContactInformation ci = new ContactInformation(); + ci.setPerson(person); + ci.setOrganization(organization); + ci.setAddress(address); + ci.setPostcode(postcode); + ci.setCity(city); + ci.setPhone(phone); + ci.setEmail(email); + + return ci; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :