diff --git a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java index 7367ef8..6f63a3c 100644 --- a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java +++ b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java @@ -422,13 +422,38 @@ public class GeoServerRESTPublisher { * @param workspace an existing workspace * @param storeName the name of the coverageStore to be created * @param mosaicDir the directory where the raster images are located + * @param srs the coverage declared SRS * @param defaultStyle may be null + * * @return true if the operation completed successfully. + * * @throws FileNotFoundException - * - * @deprecated work in progress */ public RESTCoverageStore publishExternalMosaic(String workspace, String storeName, File mosaicDir, String srs, String defaultStyle) throws FileNotFoundException { + GSCoverageEncoder coverageEncoder = new GSCoverageEncoder(); + coverageEncoder.setSRS(srs); + + return publishExternalMosaic(workspace, storeName, mosaicDir, coverageEncoder, defaultStyle); + } + + /** + * Publish a Mosaic already in a filesystem readable by GeoServer. + * + *
Sample cUrl usage:
+ * curl -u admin:geoserver -XPUT -H 'Content-type: text' -d "file:$ABSPORTDIR"
+ * http://$GSIP:$GSPORT/$SERVLET/rest/workspaces/$WORKSPACE/coveragestores/$BAREDIR/external.imagemosaic
+ *
+ * @param workspace an existing workspace
+ * @param storeName the name of the coverageStore to be created
+ * @param mosaicDir the directory where the raster images are located
+ * @param coverageEncoder the set of parameters to be set to the coverage
+ * @param defaultStyle may be null
+ *
+ * @return true if the operation completed successfully.
+ *
+ * @throws FileNotFoundException
+ */
+ public RESTCoverageStore publishExternalMosaic(String workspace, String storeName, File mosaicDir, GSCoverageEncoder coverageEncoder, String defaultStyle) throws FileNotFoundException {
RESTCoverageStore store = configureExternaMosaicDatastore(workspace, storeName, mosaicDir);
if (store != null ) {
try {
@@ -440,14 +465,9 @@ public class GeoServerRESTPublisher {
return null;
}
String coverageName = covList.get(0).getName();
-
- // config coverage props (srs)
- GSCoverageEncoder coverageEncoder = new GSCoverageEncoder();
- coverageEncoder.setSRS(srs);
configureCoverage(coverageEncoder, workspace, storeName, coverageName);
-
// config layer props (style, ...)
GSLayerEncoder layerEncoder = new GSLayerEncoder();
layerEncoder.setDefaultStyle(defaultStyle);
diff --git a/src/main/java/it/geosolutions/geoserver/rest/encoder/GSCoverageEncoder.java b/src/main/java/it/geosolutions/geoserver/rest/encoder/GSCoverageEncoder.java
index 542c644..00fe6c4 100644
--- a/src/main/java/it/geosolutions/geoserver/rest/encoder/GSCoverageEncoder.java
+++ b/src/main/java/it/geosolutions/geoserver/rest/encoder/GSCoverageEncoder.java
@@ -29,14 +29,10 @@ package it.geosolutions.geoserver.rest.encoder;
*
* @author ETj (etj at geo-solutions.it)
*/
-public class GSCoverageEncoder extends PropertyXMLEncoder {
+public class GSCoverageEncoder extends GSResourceEncoder {
public GSCoverageEncoder() {
super("coverage");
set("enabled", "true");
}
-
- public void setSRS(String srs) {
- setOrRemove("srs", srs);
- }
}
diff --git a/src/main/java/it/geosolutions/geoserver/rest/encoder/GSFeatureTypeEncoder.java b/src/main/java/it/geosolutions/geoserver/rest/encoder/GSFeatureTypeEncoder.java
index 8e6ae0c..0cc6cf5 100644
--- a/src/main/java/it/geosolutions/geoserver/rest/encoder/GSFeatureTypeEncoder.java
+++ b/src/main/java/it/geosolutions/geoserver/rest/encoder/GSFeatureTypeEncoder.java
@@ -29,7 +29,7 @@ package it.geosolutions.geoserver.rest.encoder;
*
* @author ETj (etj at geo-solutions.it)
*/
-public class GSFeatureTypeEncoder extends PropertyXMLEncoder {
+public class GSFeatureTypeEncoder extends GSResourceEncoder {
public GSFeatureTypeEncoder() {
super("featureType");
@@ -38,14 +38,5 @@ public class GSFeatureTypeEncoder extends PropertyXMLEncoder {
public void setName(String name) {
setOrRemove("name", name);
- }
-
- public void setSRS(String srs) {
- setOrRemove("srs", srs);
- }
-
-// public void setNativeCRS(String crs) {
-// setOrRemove("nativeCRS", crs);
-// }
-
+ }
}
\ No newline at end of file
diff --git a/src/main/java/it/geosolutions/geoserver/rest/encoder/GSResourceEncoder.java b/src/main/java/it/geosolutions/geoserver/rest/encoder/GSResourceEncoder.java
new file mode 100644
index 0000000..d2dbc6d
--- /dev/null
+++ b/src/main/java/it/geosolutions/geoserver/rest/encoder/GSResourceEncoder.java
@@ -0,0 +1,49 @@
+/*
+ * GeoServer-Manager - Simple Manager Library for GeoServer
+ *
+ * Copyright (C) 2007,2011 GeoSolutions S.A.S.
+ * http://www.geo-solutions.it
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package it.geosolutions.geoserver.rest.encoder;
+
+/**
+ *
+ * @author ETj (etj at geo-solutions.it)
+ */
+public abstract class GSResourceEncoder extends PropertyXMLEncoder {
+
+ protected GSResourceEncoder(String rootName) {
+ super(rootName);
+ }
+
+ public void setSRS(String srs) {
+ setOrRemove("srs", srs);
+ }
+
+ public void setLatLonBoundingBox(double minx, double maxy, double maxx, double miny, String crs) {
+ setOrRemove("latLonBoundingBox/minx", String.valueOf(minx));
+ setOrRemove("latLonBoundingBox/maxy", String.valueOf(maxy));
+ setOrRemove("latLonBoundingBox/maxx", String.valueOf(maxx));
+ setOrRemove("latLonBoundingBox/miny", String.valueOf(miny));
+ setOrRemove("latLonBoundingBox/crs", crs);
+ }
+}