Changeset 22963 in osm for applications/editors/josm


Ignore:
Timestamp:
2010-09-03T02:29:56+02:00 (14 years ago)
Author:
yellowbkpk
Message:

Keeping track of the original URL the user entered instead of the one that we manufacture for GetCapabilities.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/AddWMSLayerPanel.java

    r22962 r22963  
    184184        a.append(serviceUrl.getPath());
    185185        a.append("?");
     186        if(serviceUrl.getQuery() != null) {
     187            a.append(serviceUrl.getQuery());
     188            if (!serviceUrl.getQuery().endsWith("&")) {
     189                a.append("&");
     190            }
     191        }
    186192        return a.toString();
    187193    }
     
    213219
    214220    private void attemptGetCapabilities(String serviceUrlStr) {
    215         serviceUrl = null;
     221        URL getCapabilitiesUrl = null;
    216222        try {
    217223            if (!serviceUrlStr.trim().contains("capabilities")) {
    218224                // If the url doesn't already have GetCapabilities, add it in
    219                 serviceUrl = new URL(serviceUrlStr + "VERSION=1.1.1&SERVICE=WMS&REQUEST=GetCapabilities");
     225                getCapabilitiesUrl = new URL(serviceUrlStr + "VERSION=1.1.1&SERVICE=WMS&REQUEST=GetCapabilities");
    220226            } else {
    221227                // Otherwise assume it's a good URL and let the subsequent error
    222228                // handling systems deal with problems
    223                 serviceUrl = new URL(serviceUrlStr);
    224             }
     229                getCapabilitiesUrl = new URL(serviceUrlStr);
     230            }
     231            serviceUrl = new URL(serviceUrlStr);
    225232        } catch (HeadlessException e) {
    226233            return;
     
    231238        }
    232239
    233         System.out.println("Connecting to: " + serviceUrl);
     240        System.out.println("Connecting to: " + getCapabilitiesUrl);
    234241
    235242        String incomingData;
    236243        try {
    237             URLConnection openConnection = serviceUrl.openConnection();
     244            URLConnection openConnection = getCapabilitiesUrl.openConnection();
    238245            InputStream inputStream = openConnection.getInputStream();
    239246            BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
     
    281288
    282289        try {
    283             treeRootNode.setUserObject(serviceUrl.getHost());
     290            treeRootNode.setUserObject(getCapabilitiesUrl.getHost());
    284291            Element capabilityElem = getChild(document.getDocumentElement(), "Capability");
    285292            List<Element> children = getChildren(capabilityElem, "Layer");
Note: See TracChangeset for help on using the changeset viewer.