diff --git a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java
index 5a77450..96baf72 100644
--- a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java
+++ b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java
@@ -491,8 +491,8 @@ public class GeoServerRESTPublisher {
/**
* The configure parameter is used to control how the data store is
- * configured upon file upload. It can take one of the three values “first”,
- * “none”, or “all”.
+ * configured upon file upload. It can take one of the three values first,
+ * none, or all.
* first - Only setup the first feature type available in the data store.
* This is the default.
* none - Do not configure any feature types.
@@ -516,7 +516,7 @@ public class GeoServerRESTPublisher {
* The update parameter is used to control how existing data is handled when
* the file is PUT into a datastore that (a) already exists and (b) already
* contains a schema that matches the content of the file. It can take one
- * of the two values “append”, or “overwrite”.
+ * of the two values append, or overwrite.
* append - Data being uploaded is appended to the existing data. This is
* the default.
* overwrite - Data being uploaded replaces any existing data.
@@ -1173,8 +1173,8 @@ public class GeoServerRESTPublisher {
* The recurse parameter is used to recursively delete all
* resources contained by the specified workspace. This includes
* data stores, coverage stores, feature types, etc... Allowable
- * values for this parameter are “true” or “false”. The default
- * value is “false”.
+ * values for this parameter are “true� or “false�. The default
+ * value is “false�.
* @return true if the WorkSpace was successfully removed.
*/
public boolean removeWorkspace(String workspace, boolean recurse) throws IllegalArgumentException {
@@ -1503,7 +1503,52 @@ public class GeoServerRESTPublisher {
cname = ce.getName();
return configureCoverage(ce, wsname, csname);
}
+
+ // ==========================================================================
+ // === WORLDIMAGE
+ // ==========================================================================
+ /**
+ * Publish a zipped worldimage file.
+ *
+ * It is assumed that the the zip-file contain the *.prj to set the srs.
+ *
+ *
This is equivalent call with cUrl: + *
{@code
+ *curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' \
+ * --data-binary @$ZIPFILE \
+ * http://$GSIP:$GSPORT/$SERVLET/rest/workspaces/$WORKSPACE/coveragestores/$COVERAGESTORE/file.worldimage
+ *
+ *
+ * @param workspace Workspace to use
+ * @param coveragestore Name of the coveragestore
+ * @param zipFile zip file to upload
+ * @param configure Configure parameter. It may be null.
+ * @param coverageName coverageName parameter to append. Only works if configure is set. It may be null.
+ * @return true if the operation completed successfully.
+ */
+ public boolean publishWorldimage(String workspace, String coveragestore, File zipFile, String configure, String coverageName) throws FileNotFoundException {
+ // build full URL
+ StringBuilder sbUrl = new StringBuilder(restURL).append("/rest/workspaces/").append(workspace).append("/coveragestores/").append(coveragestore)
+ .append("/file.worldimage");
+
+ if ( configure != null && coverageName != null) {
+ sbUrl.append("?configure").append(configure);
+ if ( coverageName != null) {
+ sbUrl.append("&coverageName=").append(coverageName);
+ }
+ }
+ String sentResult = HTTPUtils.put(sbUrl.toString(), zipFile, "application/zip", gsuser, gspass);
+ boolean fileSent = sentResult != null;
+
+ if (fileSent) {
+ LOGGER.info("Zipfile successfully uploaded ( zip:" + zipFile + ")");
+ } else {
+ LOGGER.warn("Error in sending zipfile " + zipFile);
+ }
+ return fileSent;
+ }
+
/**
*
*/
diff --git a/src/test/java/it/geosolutions/geoserver/rest/GeoserverRESTPublisherTest.java b/src/test/java/it/geosolutions/geoserver/rest/GeoserverRESTPublisherTest.java
index 60e45ee..208d46a 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/GeoserverRESTPublisherTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/GeoserverRESTPublisherTest.java
@@ -463,6 +463,25 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
boolean dsRemoved = publisher.removeDatastore(DEFAULT_WS, storeName);
assertTrue("removeDatastore() failed", dsRemoved);
}
+
+ public void testPublishWorldImage() throws IOException {
+ if (!enabled()) {
+ return;
+ }
+ deleteAll();
+
+ String storeName = "testWorldimage";
+
+ assertTrue(reader.getWorkspaces().isEmpty());
+ assertTrue(publisher.createWorkspace(DEFAULT_WS));
+
+ File worldImageFile = new ClassPathResource("testdata/worldimagetest.zip").getFile();
+
+ // test publish
+ boolean wp = publisher.publishWorldimage(DEFAULT_WS, storeName, worldImageFile, null, null);
+ assertTrue("Publish worldfile failed.",wp);
+
+ }
// public void testDeleteUnexistingFT() throws FileNotFoundException, IOException {
// String wsName = "this_ws_does_not_exist";
@@ -470,7 +489,7 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
// String layerName = "this_layer_does_not_exist";
//
// boolean ok = publisher.unpublishFT(wsName, storeName, layerName);
-// assertFalse("unpublished not existing layer", ok);
+// assertFalse("unpublished not existing layer", ok);
// }
private boolean existsLayer(String layername) {
return reader.getLayer(layername) != null;