Add the PURGE param to the delete store methods.
This commit is contained in:
parent
3e580b73d1
commit
02439fa277
@ -2006,7 +2006,12 @@ public class GeoServerRESTPublisher {
|
|||||||
*/
|
*/
|
||||||
public boolean removeDatastore(String workspace, String storename, final boolean recurse)
|
public boolean removeDatastore(String workspace, String storename, final boolean recurse)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
return removeStore(workspace, storename, StoreType.DATASTORES, recurse);
|
return removeStore(workspace, storename, StoreType.DATASTORES, recurse, Purge.NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeDatastore(String workspace, String storename, final boolean recurse, final Purge purge)
|
||||||
|
throws IllegalArgumentException {
|
||||||
|
return removeStore(workspace, storename, StoreType.DATASTORES, recurse, purge);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2031,9 +2036,27 @@ public class GeoServerRESTPublisher {
|
|||||||
*/
|
*/
|
||||||
public boolean removeCoverageStore(final String workspace, final String storename,
|
public boolean removeCoverageStore(final String workspace, final String storename,
|
||||||
final boolean recurse) throws IllegalArgumentException {
|
final boolean recurse) throws IllegalArgumentException {
|
||||||
return removeStore(workspace, storename, StoreType.COVERAGESTORES, recurse);
|
return removeStore(workspace, storename, StoreType.COVERAGESTORES, recurse, Purge.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a given CoverageStore in a given Workspace.
|
||||||
|
*
|
||||||
|
* Note that purging may not work when deleting mosaics (https://jira.codehaus.org/browse/GEOT-4613).
|
||||||
|
*
|
||||||
|
* @param workspace The name of the workspace
|
||||||
|
* @param storename The name of the CoverageStore to remove.
|
||||||
|
* @param recurse if remove should be performed recursively
|
||||||
|
* @param purge the purge method
|
||||||
|
* @return <TT>true</TT> if the CoverageStore was successfully removed.
|
||||||
|
*/
|
||||||
|
public boolean removeCoverageStore(final String workspace, final String storename,
|
||||||
|
final boolean recurse, final Purge purge) throws IllegalArgumentException {
|
||||||
|
return removeStore(workspace, storename, StoreType.COVERAGESTORES, recurse, purge);
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Purge {NONE, METADATA, ALL};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a given Datastore in a given Workspace.
|
* Remove a given Datastore in a given Workspace.
|
||||||
*
|
*
|
||||||
@ -2041,11 +2064,12 @@ public class GeoServerRESTPublisher {
|
|||||||
* @param storename The name of the Datastore to remove.
|
* @param storename The name of the Datastore to remove.
|
||||||
* @param the {@link StoreType} type
|
* @param the {@link StoreType} type
|
||||||
* @param recurse if remove should be performed recursively
|
* @param recurse if remove should be performed recursively
|
||||||
|
* @param purge the purge method
|
||||||
* @throws IllegalArgumentException if workspace or storename are null or empty
|
* @throws IllegalArgumentException if workspace or storename are null or empty
|
||||||
* @return <TT>true</TT> if the store was successfully removed.
|
* @return <TT>true</TT> if the store was successfully removed.
|
||||||
*/
|
*/
|
||||||
private boolean removeStore(String workspace, String storename, StoreType type,
|
private boolean removeStore(String workspace, String storename, StoreType type,
|
||||||
final boolean recurse) throws IllegalArgumentException {
|
final boolean recurse, final Purge purge) throws IllegalArgumentException {
|
||||||
try {
|
try {
|
||||||
if (workspace == null || storename == null)
|
if (workspace == null || storename == null)
|
||||||
throw new IllegalArgumentException("Arguments may not be null!");
|
throw new IllegalArgumentException("Arguments may not be null!");
|
||||||
@ -2055,8 +2079,10 @@ public class GeoServerRESTPublisher {
|
|||||||
final StringBuilder url = new StringBuilder(restURL);
|
final StringBuilder url = new StringBuilder(restURL);
|
||||||
url.append("/rest/workspaces/").append(workspace).append("/").append(type).append("/")
|
url.append("/rest/workspaces/").append(workspace).append("/").append(type).append("/")
|
||||||
.append(storename);
|
.append(storename);
|
||||||
if (recurse)
|
url.append("?recurse=").append(recurse);
|
||||||
url.append("?recurse=true");
|
if(purge != null)
|
||||||
|
url.append("&purge=").append(purge);
|
||||||
|
|
||||||
final URL deleteStore = new URL(url.toString());
|
final URL deleteStore = new URL(url.toString());
|
||||||
|
|
||||||
boolean deleted = HTTPUtils.delete(deleteStore.toExternalForm(), gsuser, gspass);
|
boolean deleted = HTTPUtils.delete(deleteStore.toExternalForm(), gsuser, gspass);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user