Geoserver : removeSchema never called when deleting featureType on a custom DataAccess class

27 views Asked by At

I have developed my own GeoServer DataAccess to be able to use a specific data source for my architecture. Once the plugin is deployed, it integrates well into GeoServer, and through the API, I can create layers using this datastore and obtain a WMS stream. OK, I'm quite happy with that.

The problem I encounter arises when deleting (by API) a featureType using this DataAccess.

The removeSchema method of the DataAccess.java interface is not called by GeoServer during the delete of the layer, and I don't know why. I use a cache in my data access, and it is not cleared when deleting the layer via this method.

Here is the implementation I have for my DataAccess:

@Override
public void removeSchema(Name typeName) throws IOException {
    this.schemaCache.remove(typeName);
}

This method is never called by the geoserver. I would expected that the DELETE feature type have to call it.

At the moment, the only solution I have is to modify the DELETE endpoint of the featureType controller (FeatureTypeController.java) to add the call to this "removeSchema":

try {
    DataAccess<? extends FeatureType, ? extends Feature> store = dsInfo.getDataStore(null);
    store.removeSchema(ftInfo.getQualifiedName());
} catch (IOException e) {
    throw new RestException("Could not load datastore: " + storeName, HttpStatus.NOT_FOUND);
}

I'm trying to find out if there is a simpler way to call this "removeSchema" when deleting a layer.

1

There are 1 answers

0
Ian Turton On

I can't recall ever having called it my self, but from a quick check of the ShapefileDataStore code it looks like it physically deletes (removes) the actual file from disk so is probably something that GeoServer should be doing when a datastore is removed from the server.