diff --git a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java index 19502c2..2975db5 100644 --- a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java +++ b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java @@ -1199,7 +1199,9 @@ public class GeoServerRESTPublisher { String layerName, File zipFile, String nativeCrs, String defaultStyle) throws FileNotFoundException, IllegalArgumentException { - return publishShp(workspace, storename, (NameValuePair[])null, layerName, UploadMethod.FILE, zipFile.toURI(), nativeCrs, ProjectionPolicy.NONE,defaultStyle); + return publishShp(workspace, storename, (NameValuePair[]) null, + layerName, UploadMethod.FILE, zipFile.toURI(), nativeCrs, + ProjectionPolicy.FORCE_DECLARED, defaultStyle); } /** diff --git a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTShapeTest.java b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTShapeTest.java index cb349da..960b001 100644 --- a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTShapeTest.java +++ b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTShapeTest.java @@ -235,6 +235,38 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest { } + /** + * Test case to solve error described in: + * https://github.com/geosolutions-it/geoserver-manager/issues/11 + * + * @throws IllegalArgumentException + * @throws FileNotFoundException + */ + public void testPublishShpUsingDeclaredNativeCRS() throws Exception { + if (!enabled()) + return; + + // layer publication params + String workspace = DEFAULT_WS; + String storename = "resttestshp"; + String layerName = "cities"; + File zipFile = new ClassPathResource("testdata/testshp_no_prj.zip") + .getFile(); + String nativeCrs = "EPSG:4230"; + String defaultStyle = null; + + // Cleanup + deleteAllWorkspacesRecursively(); + assertTrue(publisher.createWorkspace(workspace)); + + // Publish layer + assertTrue(publisher.publishShp(workspace, storename, layerName, + zipFile, nativeCrs, defaultStyle)); + + // Read CRS. Should be using the one indicated at publication time. + assertNotNull(reader.getLayer(layerName)); + } + // public void testDeleteUnexistingFT() throws FileNotFoundException, IOException { // String wsName = "this_ws_does_not_exist"; diff --git a/src/test/resources/testdata/testshp_no_prj.zip b/src/test/resources/testdata/testshp_no_prj.zip new file mode 100644 index 0000000..734704f Binary files /dev/null and b/src/test/resources/testdata/testshp_no_prj.zip differ