diff --git a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java index 0cb8277..da1ee34 100644 --- a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java +++ b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java @@ -700,7 +700,7 @@ public class GeoServerRESTPublisher { * @param coveragestore * Name of the coveragestore * @param file - * zip file to upload + * file to upload * @param configure * Configure parameter. It may be null. * @param params @@ -753,19 +753,7 @@ public class GeoServerRESTPublisher { // ========================================================================== /** - * Publish a GeoTiff. - * - *
- * This is the equivalent call with cUrl: - * - *
- * {@code
- * curl -u admin:geoserver -XPUT -H 'Content-type: text' -d "file:$FULLPATH" \
- * http://$GSIP:$GSPORT/$SERVLET/rest/workspaces/$WORKSPACE/coveragestores/$STORENAME/external.geotiff
- * }
- *
- *
- * @return true if the operation completed successfully.
+ * Simple wrapper for {@link #publishGeoTIFF(String, String, String, File)}
*/
public boolean publishGeoTIFF(String workspace, String storeName,
File geotiff) throws FileNotFoundException {
@@ -773,6 +761,37 @@ public class GeoServerRESTPublisher {
"image/geotiff", geotiff, ParameterConfigure.FIRST,
(NameValuePair[]) null);
}
+
+ /**
+ * Publish a GeoTiff.
+ * Simple wrapper for {@link #publishCoverage(String, String, String, String, File, ParameterConfigure, NameValuePair...)}
+ * + * This is the equivalent call with cUrl: + * + *
+ * {@code
+ * curl -u admin:geoserver -XPUT -H 'Content-type: text' -d "file:$FULLPATH" \
+ * http://$GSIP:$GSPORT/$SERVLET/rest/workspaces/$WORKSPACE/coveragestores/$STORENAME/external.geotiff
+ * }
+ *
+ *
+ * @param workspace Workspace to use
+ * @param storeName Name of the coveragestore (if null the file name will be used)
+ * @param layerName the name of the coverage (if null the file name will be used)
+ * @param geotiff file to upload
+ * @return true if the operation completed successfully.
+ * @throws FileNotFoundException if file does not exists
+ * @throws IllegalArgumentException if workspace or geotiff are null
+ */
+ public boolean publishGeoTIFF(final String workspace, final String storeName, final String layerName,
+ final File geotiff) throws FileNotFoundException, IllegalArgumentException {
+ if (workspace==null || geotiff==null)
+ throw new IllegalArgumentException("Unable to proceed, some arguments are null");
+
+ return publishCoverage(workspace, (storeName!=null)?storeName:FilenameUtils.getBaseName(geotiff.getAbsolutePath()), "geotiff",
+ "image/geotiff", geotiff, ParameterConfigure.FIRST,
+ (layerName!=null)?new NameValuePair[]{new NameValuePair("coverageName", layerName)}:(NameValuePair[]) null);
+ }
/**
* Publish a GeoTiff already in a filesystem readable by GeoServer.
diff --git a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTGeoTiffTest.java b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTGeoTiffTest.java
index a584a98..fe853a1 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTGeoTiffTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTGeoTiffTest.java
@@ -102,6 +102,10 @@ public class GeoserverRESTGeoTiffTest extends GeoserverRESTTest {
assertNotNull("publish() failed", pub);
+ pub = publisher.publishGeoTIFF(DEFAULT_WS, storeName+"another", "layername", geotiff);
+
+ assertNotNull("publish() failed", pub);
+
//delete
assertTrue("Unpublish() failed", publisher.removeCoverageStore(DEFAULT_WS, storeName,true));
}