From 84967563004e0a544b9b89b995bc63a990570c48 Mon Sep 17 00:00:00 2001 From: Carl Schroedl Date: Mon, 12 Sep 2016 17:26:09 -0500 Subject: [PATCH] First cut of private implementation for #199 --- .../rest/GeoServerRESTPublisher.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java index c68c5330..2816b6b5 100644 --- a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java +++ b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java @@ -3206,4 +3206,75 @@ public void postImport(int i) throws Exception { importerManager.postImport(i); } + /** + * Defines multiple modes of recalculating bounding boxes. + * + * @author Carl Schroedl - cschroedl@usgs.gov + */ + public enum BBoxRecalculationMode { + /** + * Do not calculate any fields, regardless of the projection, projection + * policy, etc. This might be useful to avoid slow recalculation when + * operating against large datasets. + */ + NONE(""), + + /** + * Recalculate the native bounding box, but do not recalculate the + * lat/long bounding box. + */ + NATIVE_BBOX("nativebbox"), + + /** + * Recalculate both the native bounding box and the lat/long bounding + * box. + */ + NATIVE_AND_LAT_LON_BBOX("nativebbox,latlonbbox") + ; + + private final String paramValue; + + /** + * Associates the enum value with a URL query string parameter value + * @param paramValue + */ + BBoxRecalculationMode(String paramValue){ + this.paramValue = paramValue; + } + + /** + * Get the URL param value + * @return The query string parameter value + */ + public String getParamValue(){ + return paramValue; + } + } + + /** + * + * Recalculate the bounding box for a feature or a type + * + * @param type + * @param workspace + * @param storeName + * @param layerName + * @param calculationMode + * @return true if recalculation succeeded, false otherwise. + */ + private boolean recalculateBBox(StoreType type, String workspace, String storeName, String layerName, BBoxRecalculationMode calculationMode){ + + String sUrl = restURL + "/rest/workspaces/" + workspace + "/" + + type.getType() +"s/" + storeName + "/" + + type.getTypeName() + "/" + + layerName + "." + Format.XML.toString() + "?recalculate=" + + calculationMode.getParamValue(); + + LOGGER.debug("Constructed the following url for bounding box recalculation: "); + + String sendResult = HTTPUtils.put(sUrl, "", "text/plain", gsuser, + gspass); + + return sendResult != null; + } }