geosolutions-it / geoserver-manager

Java client library for GeoServer
MIT License
254 stars 192 forks source link

Erroneous implementation of GeoServerRESTReader#existsLayer(String workspace, String name) #206

Open dosyfier opened 7 years ago

dosyfier commented 7 years ago

Seen on geoserver-manager 1.7.0.

The GeoServerRESTReader#existsLayer(String workspace, String name) method seems to be erroneously implemented since it calls: GeoServerRESTReader#existsLayerGroup(String workspace, String name, boolean quietOnNotFound) instead of: GeoServerRESTReader#existsLayer(String workspace, String name, boolean quietOnNotFound)

See the GeoServerRESTReader class, line 906.

doublebyte1 commented 7 years ago

I also ran into this issue (1.7.0); it seems to be a bug, to redirect existsLayer to existsLayerGroup.

As a workaround, you call an override of this function, with an extra argument quietOnNotFound, which works.

    public boolean existsLayer(String workspace, String name, boolean quietOnNotFound){
        String url;
        if (workspace == null) {
            url = baseurl + "/rest/layers/" + name + ".xml";
        } else {
            url = baseurl + "/rest/layers/" + workspace + ":" + name + ".xml";
        }  
        String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
        return HTTPUtils.exists(composed, username, password);
}