Let’s say there are two workspaces, ws1 and ws2, and I want to configure the same shapefile store/featuretype under both workspaces through the REST API. Once the stores are created, it’s impossible to create the feature types.
To reproduce, run the following against a geoserver instance running off a “release” data directory:
echo create ws1
curl -X POST -u admin:geoserver -H "Accept: application/json" -H "Content-Type: application/json" "http://localhost:8080/geoserver/rest/workspaces" --data '{"workspace":{"name":"ws1"}}'
echo create ws2
curl -X POST -u admin:geoserver -H "Accept: application/json" -H "Content-Type: application/json" "http://localhost:8080/geoserver/rest/workspaces" --data '{"workspace":{"name":"ws2"}}'
echo create store ws1/roads
curl -X POST -u admin:geoserver -H "Accept: application/json" -H "Content-Type: application/json" "http://localhost:8080/geoserver/rest/workspaces/ws1/datastores" --data '{"dataStore":{"name":"roads", "connectionParameters":{"filetype":"shapefile","fstype":"shape","url":"file:data/sf/roads.shp"}}}'
echo create store ws2/roads
curl -X POST -u admin:geoserver -H "Accept: application/json" -H "Content-Type: application/json" "http://localhost:8080/geoserver/rest/workspaces/ws2/datastores" --data '{"dataStore":{"name":"roads", "connectionParameters":{"filetype":"shapefile","fstype":"shape","url":"file:data/sf/roads.shp"}}}'
echo create featruretype ws1/roads
curl -X POST -u admin:geoserver -H "Accept: application/json" -H "Content-Type: application/json" "http://localhost:8080/geoserver/rest/workspaces/ws1/datastores/roads/featuretypes" --data '{"featureType":{"name":"roads","store":{"name":"roads"}}}'
echo create featruretype ws2/roads
curl -X POST -u admin:geoserver -H "Accept: application/json" -H "Content-Type: application/json" "http://localhost:8080/geoserver/rest/workspaces/ws2/datastores/roads/featuretypes" --data '{"featureType":{"name":"roads","store":{"name":"roads"}}}'
The featruretype ws1/roads step should succeed, instead it throws the following exception:
25 Apr 16:26:41 ERROR [geoserver.rest] - Schema 'http://ws1:roads' does not exist.
java.io.IOException: Schema 'http://ws1:roads' does not exist.
at org.geotools.data.store.ContentDataStore.ensureEntry(ContentDataStore.java:533)
at org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:331)
at org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:592)
at org.geoserver.catalog.ResourcePool.getFeatureSource(ResourcePool.java:1233)
at org.geoserver.catalog.impl.FeatureTypeInfoImpl.getFeatureSource(FeatureTypeInfoImpl.java:128)
at org.geoserver.catalog.CatalogBuilder.getNativeBounds(CatalogBuilder.java:554)
at org.geoserver.catalog.CatalogBuilder.doSetupBounds(CatalogBuilder.java:456)
at org.geoserver.catalog.CatalogBuilder.setupBounds(CatalogBuilder.java:445)
at org.geoserver.catalog.CatalogBuilder.initFeatureType(CatalogBuilder.java:694)
at org.geoserver.rest.catalog.FeatureTypeController.featureTypePost(FeatureTypeController.java:236)
|