[udig-devel] using capabilities document to prevent duplicate WMS servers

Jody Garnett jgarnett at refractions.net
Thu Feb 7 20:41:59 PST 2008


In reviewing the WMSInfo code being ported to GeoTools I am being bad 
... I am fixing a long standing bug/annoyance and would like a code review.

One of the things that happens with WMS is that we relax what is a valid 
capabilities URL; indeed the specification lets you leave off parts of 
such as VERSION=1.2

As an example the demo geoserver link is:
- http://127.0.0.1:8080/geoserver/wms?service=WMS&request=GetCapabilities

We only need this much of the URL in order to function:
- http://127.0.0.1:8080/geoserver/wms?SERVICE=WMS&

With this in mind please review the following code:
>         /**
>          * The source of this WMS is the capabilities document.
>          * <p>
>          * We make an effort here to look in the capabilities document
>          * provided for the unambiguous capabilities URI. This covers
>          * the case where the capabilities document has been cached
>          * on disk and we are restoring a WebMapServer instance.
>          */
>         public URI getSource() {
>             try {
>                 URL source = 
> getCapabilities().getRequest().getGetCapabilities().getGet();
>                 return source.toURI();
>             }
>             catch( NullPointerException huh ){                
>             }
>             catch (URISyntaxException e) {
>             }
>             try {
>                 return serverURL.toURI();
>             } catch (URISyntaxException e) {
>                 return null;
>             }
>         }
This code would accomplish two things:
- it would prevent duplicates being added
- it would let you make a WebMapSevice from a local file; and still have 
the source correct

What do you think?
Jody



More information about the udig-devel mailing list