Ignore:
Timestamp:
2018-01-03T23:17:07+01:00 (23 months ago)
Author:
Don-vip
Message:

fix #15730 - support WMS capabilities with embedded HTML in layer Abstract tag

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java

    r13260 r13274  
    44import java.awt.HeadlessException;
    55import java.io.IOException;
     6import java.io.InputStream;
    67import java.io.StringReader;
    78import java.io.StringWriter;
     
    235236
    236237        final Response response = HttpClient.create(getCapabilitiesUrl).connect();
    237         String incomingData = null;
    238238
    239239        if (response.getResponseCode() >= 400) {
     
    241241        }
    242242
     243        parseCapabilities(serviceUrlStr, response.getContent());
     244    }
     245
     246    void parseCapabilities(String serviceUrlStr, InputStream contentStream) throws IOException, WMSGetCapabilitiesException {
     247        String incomingData = null;
    243248        try {
    244249            DocumentBuilder builder = Utils.newSafeDOMBuilder();
     
    247252                return new InputSource(new StringReader(""));
    248253            });
    249             Document document = builder.parse(response.getContent());
     254            Document document = builder.parse(contentStream);
    250255            Element root = document.getDocumentElement();
    251256
     
    369374        getChildrenStream(element)
    370375            .filter(child -> "CRS".equals(child.getNodeName()) || "SRS".equals(child.getNodeName()))
    371             .map(child -> (String) getContent(child))
     376            .map(child -> getContent(child))
    372377            .filter(crs -> !crs.isEmpty())
    373378            .map(crs -> crs.trim().toUpperCase(Locale.ENGLISH))
     
    421426            return missing;
    422427        else {
    423             String content = (String) getContent(child);
     428            String content = getContent(child);
    424429            return (!content.isEmpty()) ? content : empty;
    425430        }
    426431    }
    427432
    428     private static Object getContent(Element element) {
     433    private static String getContent(Element element) {
    429434        NodeList nl = element.getChildNodes();
    430435        StringBuilder content = new StringBuilder();
     
    433438            switch (node.getNodeType()) {
    434439                case Node.ELEMENT_NODE:
    435                     return node;
     440                    content.append(getContent((Element) node));
     441                    break;
    436442                case Node.CDATA_SECTION_NODE:
    437443                case Node.TEXT_NODE:
Note: See TracChangeset for help on using the changeset viewer.