First cut of private implementation for #199

This commit is contained in:
Carl Schroedl 2016-09-12 17:26:09 -05:00
parent 25759e86a5
commit 8496756300

View File

@ -3206,4 +3206,75 @@ public class GeoServerRESTPublisher {
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;
}
}