added reset function

This commit is contained in:
ccancellieri 2011-10-04 15:39:12 +02:00
parent 882475be5c
commit 7369cfd82a
3 changed files with 32 additions and 15 deletions

View File

@ -65,7 +65,7 @@ public class GeoServerRESTPublisher {
* @param password password auth credential
*/
public GeoServerRESTPublisher(String restURL, String username, String password) {
this.restURL = restURL;
this.restURL = HTTPUtils.decurtSlash(restURL);
this.gsuser = username;
this.gspass = password;
}
@ -680,12 +680,30 @@ public class GeoServerRESTPublisher {
}
}
/**
* reload the target geoserver configuration
* @return true if success
*
* @see http://docs.geoserver.org/stable/en/user/restconfig/rest-config-api.html
*/
public boolean reload() {
String sUrl = restURL + "/rest/reload";
String result = HTTPUtils.post(sUrl, "", "text/plain", gsuser, gspass);
return result != null;
}
/**
* reset the target geoserver configuration
* @return true if success
*
* @see http://docs.geoserver.org/stable/en/user/restconfig/rest-config-api.html
*/
public boolean reset() {
String sUrl = restURL + "/rest/reset";
String result = HTTPUtils.post(sUrl, "", "text/plain", gsuser, gspass);
return result != null;
}
public boolean removeLayerGroup(String name) {
try {
URL deleteUrl = new URL(restURL + "/rest/layergroups/" + name);

View File

@ -426,5 +426,18 @@ class HTTPUtils {
}
}
}
/**
* recursively remove ending slashes
*
* @param geoserverURL
* @return
*/
public static String decurtSlash(String geoserverURL) {
if (geoserverURL.endsWith("/")) {
geoserverURL = decurtSlash(geoserverURL.substring(0, geoserverURL.length() - 1));
}
return geoserverURL;
}
}

View File

@ -1,14 +0,0 @@
package it.geosolutions.geoserver.rest.encoder;
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
import it.geosolutions.geoserver.rest.encoder.coverage.GSCoverageEncoder;
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
import org.junit.Assert;
import org.junit.Test;
public class GSResourceEncoderTest {
}