Issue_137
This commit is contained in:
parent
f06c49806d
commit
75dec9c726
@ -54,7 +54,6 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -203,6 +202,17 @@ public class GeoServerRESTReader {
|
|||||||
return styleManager.existsStyle(styleName);
|
return styleManager.existsStyle(styleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a Style exists in the configured GeoServer instance.
|
||||||
|
* @param styleName the name of the style to check for.
|
||||||
|
* @param quietOnNotFound if true, mute exception if false is returned
|
||||||
|
* @return <TT>true</TT> on HTTP 200, <TT>false</TT> on HTTP 404
|
||||||
|
* @throws RuntimeException if any other HTTP code than 200 or 404 was retrieved.
|
||||||
|
*/
|
||||||
|
public boolean existsStyle(String styleName, boolean quietOnNotFound) throws RuntimeException {
|
||||||
|
return styleManager.existsStyle(styleName, quietOnNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see GeoServerRESTStyleManager#existsStyle(java.lang.String, java.lang.String)
|
* @see GeoServerRESTStyleManager#existsStyle(java.lang.String, java.lang.String)
|
||||||
* @since GeoServer 2.2
|
* @since GeoServer 2.2
|
||||||
@ -311,6 +321,31 @@ public class GeoServerRESTReader {
|
|||||||
return RESTDataStore.build(response);
|
return RESTDataStore.build(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected DataStore is present
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the datastore
|
||||||
|
* @param dsName name of the datastore
|
||||||
|
* @return boolean indicating if the datastore exists
|
||||||
|
*/
|
||||||
|
public boolean existsDatastore(String workspace, String dsName){
|
||||||
|
return existsDatastore(workspace, dsName, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected DataStore is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the datastore
|
||||||
|
* @param dsName name of the datastore
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the datastore exists
|
||||||
|
*/
|
||||||
|
public boolean existsDatastore(String workspace, String dsName, boolean quietOnNotFound){
|
||||||
|
String url = baseurl + "/rest/workspaces/" + workspace + "/datastores/" + dsName + ".xml";
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//=== FEATURETYPES
|
//=== FEATURETYPES
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
@ -330,6 +365,33 @@ public class GeoServerRESTReader {
|
|||||||
return RESTFeatureType.build(response);
|
return RESTFeatureType.build(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected FeatureType is present.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the datastore
|
||||||
|
* @param dsName name of the datastore
|
||||||
|
* @param ftName name of the featuretype
|
||||||
|
* @return boolean indicating if the featuretype exists
|
||||||
|
*/
|
||||||
|
public boolean existsFeatureType(String workspace, String dsName, String ftName){
|
||||||
|
return existsFeatureType(workspace, dsName, ftName, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected FeatureType is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the datastore
|
||||||
|
* @param dsName name of the datastore
|
||||||
|
* @param ftName name of the featuretype
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the featuretype exists
|
||||||
|
*/
|
||||||
|
public boolean existsFeatureType(String workspace, String dsName, String ftName, boolean quietOnNotFound){
|
||||||
|
String url = baseurl + "/rest/workspaces/" + workspace + "/datastores/" + dsName + "/featuretypes/" + ftName +".xml";
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//=== COVERAGESTORES
|
//=== COVERAGESTORES
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
@ -380,6 +442,31 @@ public class GeoServerRESTReader {
|
|||||||
return RESTCoverageStore.build(response);
|
return RESTCoverageStore.build(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Coverage store is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the coveragestore
|
||||||
|
* @param dsName name of the coveragestore
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the coveragestore exists
|
||||||
|
*/
|
||||||
|
public boolean existsCoveragestore(String workspace, String csName, boolean quietOnNotFound){
|
||||||
|
String url = baseurl + "/rest/workspaces/" + workspace + "/coveragestores/" + csName + ".xml";
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Coverage store is present.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the coveragestore
|
||||||
|
* @param dsName name of the coveragestore
|
||||||
|
* @return boolean indicating if the coveragestore exists
|
||||||
|
*/
|
||||||
|
public boolean existsCoveragestore(String workspace, String csName){
|
||||||
|
return existsCoveragestore(workspace, csName, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//=== COVERAGES
|
//=== COVERAGES
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
@ -416,6 +503,33 @@ public class GeoServerRESTReader {
|
|||||||
return RESTCoverage.build(load(url));
|
return RESTCoverage.build(load(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Coverage is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the coveragestore
|
||||||
|
* @param dsName name of the coveragestore
|
||||||
|
* @param name name of the coverage
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the coverage exists
|
||||||
|
*/
|
||||||
|
public boolean existsCoverage(String workspace, String store, String name, boolean quietOnNotFound){
|
||||||
|
String url = baseurl + "/rest/workspaces/" + workspace + "/coveragestores/" + store + "/coverages/"+name+".xml";
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Coverage is present.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the coveragestore
|
||||||
|
* @param store name of the coveragestore
|
||||||
|
* @param name name of the coverage
|
||||||
|
* @return boolean indicating if the coverage exists
|
||||||
|
*/
|
||||||
|
public boolean existsCoverage(String workspace, String store, String name){
|
||||||
|
return existsCoverage(workspace, store, name, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get detailed info about a Coverage given the Layer where it's published with.
|
* Get detailed info about a Coverage given the Layer where it's published with.
|
||||||
*
|
*
|
||||||
@ -508,7 +622,35 @@ public class GeoServerRESTReader {
|
|||||||
return getLayerGroup(null, name);
|
return getLayerGroup(null, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected LayerGroup is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the LayerGroup
|
||||||
|
* @param name name of the LayerGroup
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the LayerGroup exists
|
||||||
|
*/
|
||||||
|
public boolean existsLayerGroup(String workspace, String name, boolean quietOnNotFound){
|
||||||
|
String url;
|
||||||
|
if (workspace == null) {
|
||||||
|
url = baseurl + "/rest/layergroups/" + name + ".xml";
|
||||||
|
} else {
|
||||||
|
url = baseurl + "/rest/workspaces/" + workspace + "/layergroups/" + name + ".xml";
|
||||||
|
}
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected LayerGroup is present.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the LayerGroup
|
||||||
|
* @param name name of the LayerGroup
|
||||||
|
* @return boolean indicating if the LayerGroup exists
|
||||||
|
*/
|
||||||
|
public boolean existsLayerGroup(String workspace, String name){
|
||||||
|
return existsLayerGroup(workspace, name, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//=== LAYERS
|
//=== LAYERS
|
||||||
@ -583,6 +725,36 @@ public class GeoServerRESTReader {
|
|||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Layer is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the Layer
|
||||||
|
* @param name name of the Layer
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the Layer exists
|
||||||
|
*/
|
||||||
|
public boolean existsLayer(String workspace, String name, boolean quietOnNotFound){
|
||||||
|
String url;
|
||||||
|
if (workspace == null) {
|
||||||
|
url = baseurl + "/rest/layers/" + name + ".xml";
|
||||||
|
} else {
|
||||||
|
url = baseurl + "/rest/layers/" + workspace + ":" + name + ".xml";
|
||||||
|
}
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Layer is present.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the Layer
|
||||||
|
* @param name name of the Layer
|
||||||
|
* @return boolean indicating if the Layer exists
|
||||||
|
*/
|
||||||
|
public boolean existsLayer(String workspace, String name){
|
||||||
|
return existsLayerGroup(workspace, name, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//=== NAMESPACES
|
//=== NAMESPACES
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
@ -634,6 +806,32 @@ public class GeoServerRESTReader {
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Namespace is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param prefix namespace prefix.
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the Namespace exists
|
||||||
|
*/
|
||||||
|
public boolean existsNamespace(String prefix, boolean quietOnNotFound) {
|
||||||
|
if (prefix == null || prefix.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Namespace prefix cannot be null or empty");
|
||||||
|
}
|
||||||
|
String url = baseurl + "/rest/namespaces/" + prefix + ".xml";
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Namespace is present.
|
||||||
|
*
|
||||||
|
* @param prefix namespace prefix.
|
||||||
|
* @return boolean indicating if the Namespace exists
|
||||||
|
*/
|
||||||
|
public boolean existsNamespace(String prefix){
|
||||||
|
return existsNamespace(prefix, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//=== WORKSPACES
|
//=== WORKSPACES
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
@ -670,6 +868,36 @@ public class GeoServerRESTReader {
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Workspace is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param prefix Workspace prefix.
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the Workspace exists
|
||||||
|
*/
|
||||||
|
public boolean existsWorkspace(String prefix, boolean quietOnNotFound) {
|
||||||
|
if (prefix == null || prefix.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Workspace prefix cannot be null or empty");
|
||||||
|
}
|
||||||
|
String url = baseurl + "/rest/workspaces/" + prefix + ".xml";
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Workspace is present.
|
||||||
|
*
|
||||||
|
* @param prefix Workspace prefix.
|
||||||
|
* @return boolean indicating if the Workspace exists
|
||||||
|
*/
|
||||||
|
public boolean existsWorkspace(String prefix){
|
||||||
|
return existsWorkspace(prefix, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//=== Structured Coverages
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get information about a granule for a structured coverage.
|
* Get information about a granule for a structured coverage.
|
||||||
*
|
*
|
||||||
@ -703,6 +931,38 @@ public class GeoServerRESTReader {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Granule is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the coveragestore
|
||||||
|
* @param coverageStore name of the coveragestore
|
||||||
|
* @param coverage name of the coverage
|
||||||
|
* @param id id of the granule
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the Granule exists
|
||||||
|
*/
|
||||||
|
public boolean existsGranule(String workspace, String coverageStore, String coverage,
|
||||||
|
String id, boolean quietOnNotFound) {
|
||||||
|
String url = baseurl + "/rest/workspaces/" + workspace + "/coveragestores/" + coverageStore
|
||||||
|
+ "/coverages/" + coverage + "/index/granules/" + id + ".xml";
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Granule is present.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the coveragestore
|
||||||
|
* @param coverageStore name of the coveragestore
|
||||||
|
* @param coverage name of the coverage
|
||||||
|
* @param id id of the granule
|
||||||
|
* @return boolean indicating if the Granule exists
|
||||||
|
*/
|
||||||
|
public boolean existsGranule(String workspace, String coverageStore, String coverage, String id) {
|
||||||
|
return existsGranule(workspace, coverageStore, coverage, id,
|
||||||
|
Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get information about the schema of the index for a structured coverage.
|
* Get information about the schema of the index for a structured coverage.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -35,6 +35,10 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class Util {
|
public class Util {
|
||||||
|
|
||||||
|
public static final String QUIET_ON_NOT_FOUND_PARAM = "quietOnNotFound=";
|
||||||
|
|
||||||
|
public static final boolean DEFAULT_QUIET_ON_NOT_FOUND = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for a stylename in global and in all workspaces.
|
* Search for a stylename in global and in all workspaces.
|
||||||
*/
|
*/
|
||||||
@ -54,4 +58,16 @@ public class Util {
|
|||||||
|
|
||||||
return styles;
|
return styles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Append the quietOnNotFound parameter to the input URL
|
||||||
|
* @param quietOnNotFound parameter
|
||||||
|
* @param url input url
|
||||||
|
* @return a composed url with the parameter appended
|
||||||
|
*/
|
||||||
|
public static String appendQuietOnNotFound(boolean quietOnNotFound, String url) {
|
||||||
|
boolean contains = url.contains("?");
|
||||||
|
String composed = url + (contains ? "&":"?") + QUIET_ON_NOT_FOUND_PARAM + quietOnNotFound;
|
||||||
|
return composed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,7 @@ package it.geosolutions.geoserver.rest.manager;
|
|||||||
|
|
||||||
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
|
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
|
||||||
import it.geosolutions.geoserver.rest.HTTPUtils;
|
import it.geosolutions.geoserver.rest.HTTPUtils;
|
||||||
|
import it.geosolutions.geoserver.rest.Util;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTStyle;
|
import it.geosolutions.geoserver.rest.decoder.RESTStyle;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTStyleList;
|
import it.geosolutions.geoserver.rest.decoder.RESTStyleList;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -61,8 +62,20 @@ public class GeoServerRESTStyleManager extends GeoServerRESTAbstractManager {
|
|||||||
* @throws RuntimeException if any other HTTP code than 200 or 404 was retrieved.
|
* @throws RuntimeException if any other HTTP code than 200 or 404 was retrieved.
|
||||||
*/
|
*/
|
||||||
public boolean existsStyle(String name) throws RuntimeException {
|
public boolean existsStyle(String name) throws RuntimeException {
|
||||||
|
return existsStyle(name, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a Style exists in the configured GeoServer instance. User can choose if log a possible exception or not
|
||||||
|
* @param name the name of the style to check for.
|
||||||
|
* @param quietOnNotFound if true, mute exception if false is returned
|
||||||
|
* @return <TT>true</TT> on HTTP 200, <TT>false</TT> on HTTP 404
|
||||||
|
* @throws RuntimeException if any other HTTP code than 200 or 404 was retrieved.
|
||||||
|
*/
|
||||||
|
public boolean existsStyle(String name, boolean quietOnNotFound) {
|
||||||
String url = buildXmlUrl(null, name);
|
String url = buildXmlUrl(null, name);
|
||||||
return HTTPUtils.exists(url, gsuser, gspass);
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed , gsuser, gspass);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,8 +124,17 @@ public class GeoServerRESTStyleManager extends GeoServerRESTAbstractManager {
|
|||||||
* @since GeoServer 2.2
|
* @since GeoServer 2.2
|
||||||
*/
|
*/
|
||||||
public boolean existsStyle(String workspace, String name) {
|
public boolean existsStyle(String workspace, String name) {
|
||||||
|
return existsStyle(workspace, name, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @since GeoServer 2.6
|
||||||
|
*/
|
||||||
|
public boolean existsStyle(String workspace, String name, boolean quietOnNotFound) {
|
||||||
String url = buildXmlUrl(workspace, name);
|
String url = buildXmlUrl(workspace, name);
|
||||||
return HTTPUtils.exists(url, gsuser, gspass);
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed , gsuser, gspass);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -92,6 +92,8 @@ public class GSLayerGroupEncoderTest extends GeoserverRESTTest {
|
|||||||
groupWriter.addLayer("topp:boundaries");
|
groupWriter.addLayer("topp:boundaries");
|
||||||
groupWriter.addLayer("topp:cities");
|
groupWriter.addLayer("topp:cities");
|
||||||
assertTrue(publisher.createLayerGroup(groupName, groupWriter));
|
assertTrue(publisher.createLayerGroup(groupName, groupWriter));
|
||||||
|
// Test exists
|
||||||
|
assertTrue(reader.existsLayerGroup(null, groupName));
|
||||||
try {
|
try {
|
||||||
RESTLayerGroup groupReader = reader.getLayerGroup(groupName);
|
RESTLayerGroup groupReader = reader.getLayerGroup(groupName);
|
||||||
assertNull(groupReader.getWorkspace());
|
assertNull(groupReader.getWorkspace());
|
||||||
@ -114,6 +116,8 @@ public class GSLayerGroupEncoderTest extends GeoserverRESTTest {
|
|||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
assertTrue(publisher.removeLayerGroup(groupName));
|
assertTrue(publisher.removeLayerGroup(groupName));
|
||||||
|
// Test not exists
|
||||||
|
assertFalse(reader.existsLayerGroup(null, groupName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,6 +133,8 @@ public class GSLayerGroupEncoderTest extends GeoserverRESTTest {
|
|||||||
groupWriter.addLayer("topp:boundaries");
|
groupWriter.addLayer("topp:boundaries");
|
||||||
groupWriter.addLayer("topp:cities");
|
groupWriter.addLayer("topp:cities");
|
||||||
assertTrue(publisher.createLayerGroup("topp", groupName, groupWriter));
|
assertTrue(publisher.createLayerGroup("topp", groupName, groupWriter));
|
||||||
|
// Test exists
|
||||||
|
assertTrue(reader.existsLayerGroup("topp", groupName));
|
||||||
try {
|
try {
|
||||||
RESTLayerGroup groupReader = reader.getLayerGroup("topp", groupName);
|
RESTLayerGroup groupReader = reader.getLayerGroup("topp", groupName);
|
||||||
assertEquals("topp", groupReader.getWorkspace());
|
assertEquals("topp", groupReader.getWorkspace());
|
||||||
@ -151,6 +157,8 @@ public class GSLayerGroupEncoderTest extends GeoserverRESTTest {
|
|||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
assertTrue(publisher.removeLayerGroup("topp", groupName));
|
assertTrue(publisher.removeLayerGroup("topp", groupName));
|
||||||
|
// Test not exists
|
||||||
|
assertFalse(reader.existsLayerGroup("topp", groupName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -68,10 +68,14 @@ public class GeoserverRESTGeoTiffTest extends GeoserverRESTTest {
|
|||||||
// known state?
|
// known state?
|
||||||
assertFalse("Cleanup failed", existsLayer(layerName));
|
assertFalse("Cleanup failed", existsLayer(layerName));
|
||||||
|
|
||||||
|
// Test exists
|
||||||
|
assertFalse(reader.existsLayer(DEFAULT_WS, layerName));
|
||||||
|
|
||||||
// test insert
|
// test insert
|
||||||
boolean pc = publisher.publishExternalGeoTIFF(DEFAULT_WS, storeName, geotiff, layerName,"EPSG:4326",ProjectionPolicy.FORCE_DECLARED,"raster");
|
boolean pc = publisher.publishExternalGeoTIFF(DEFAULT_WS, storeName, geotiff, layerName,"EPSG:4326",ProjectionPolicy.FORCE_DECLARED,"raster");
|
||||||
assertTrue("publish() failed", pc);
|
assertTrue("publish() failed", pc);
|
||||||
assertTrue(existsLayer(layerName));
|
assertTrue(existsLayer(layerName));
|
||||||
|
assertFalse(reader.existsLayer(DEFAULT_WS, layerName));
|
||||||
LOGGER.info("Published "+pc);
|
LOGGER.info("Published "+pc);
|
||||||
RESTCoverageStore reloadedCS = reader.getCoverageStore(DEFAULT_WS, storeName);
|
RESTCoverageStore reloadedCS = reader.getCoverageStore(DEFAULT_WS, storeName);
|
||||||
|
|
||||||
@ -102,6 +106,9 @@ public class GeoserverRESTGeoTiffTest extends GeoserverRESTTest {
|
|||||||
boolean pub = publisher.publishGeoTIFF(DEFAULT_WS, storeName, geotiff);
|
boolean pub = publisher.publishGeoTIFF(DEFAULT_WS, storeName, geotiff);
|
||||||
|
|
||||||
assertNotNull("publish() failed", pub);
|
assertNotNull("publish() failed", pub);
|
||||||
|
// Test exists
|
||||||
|
assertTrue(reader.existsCoveragestore(DEFAULT_WS, storeName));
|
||||||
|
assertTrue(reader.existsCoverage(DEFAULT_WS, storeName, storeName));
|
||||||
|
|
||||||
pub = publisher.publishGeoTIFF(DEFAULT_WS, storeName+"another", "layername", geotiff);
|
pub = publisher.publishGeoTIFF(DEFAULT_WS, storeName+"another", "layername", geotiff);
|
||||||
|
|
||||||
@ -114,6 +121,8 @@ public class GeoserverRESTGeoTiffTest extends GeoserverRESTTest {
|
|||||||
|
|
||||||
//delete
|
//delete
|
||||||
assertTrue("Unpublish() failed", publisher.removeCoverageStore(DEFAULT_WS, storeName,true));
|
assertTrue("Unpublish() failed", publisher.removeCoverageStore(DEFAULT_WS, storeName,true));
|
||||||
|
// Test not exists
|
||||||
|
assertFalse(reader.existsCoveragestore(DEFAULT_WS, storeName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -29,6 +29,7 @@ package it.geosolutions.geoserver.rest.publisher;
|
|||||||
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.ParameterConfigure;
|
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.ParameterConfigure;
|
||||||
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTCoverageStore;
|
import it.geosolutions.geoserver.rest.decoder.RESTCoverageStore;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.RESTStructuredCoverageGranulesList;
|
||||||
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
||||||
@ -40,6 +41,8 @@ import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Pr
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
|
||||||
import org.apache.commons.httpclient.NameValuePair;
|
import org.apache.commons.httpclient.NameValuePair;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -77,7 +80,7 @@ public class GeoserverRESTImageMosaicTest extends GeoserverRESTTest {
|
|||||||
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTImageMosaicTest.class);
|
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTImageMosaicTest.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateDeleteImageMosaicDatastore() {
|
public void testCreateDeleteImageMosaicDatastore() throws MalformedURLException, UnsupportedEncodingException {
|
||||||
if (!enabled()) {
|
if (!enabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -169,7 +172,14 @@ public class GeoserverRESTImageMosaicTest extends GeoserverRESTTest {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
fail(e.getLocalizedMessage());
|
fail(e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
// Get a Granule
|
||||||
|
String coverageName = "time_geotiff";
|
||||||
|
RESTStructuredCoverageGranulesList granules = reader.getGranules(wsName, coverageStoreName, coverageName, null, null, null);
|
||||||
|
String granuleId = granules.get(0).getFid();
|
||||||
|
// Test Granule Exists
|
||||||
|
assertTrue(reader.existsGranule(wsName, coverageStoreName, coverageName, granuleId));
|
||||||
|
// test a Granule does not exists
|
||||||
|
assertFalse(reader.existsGranule(wsName, coverageStoreName, coverageName, granuleId.substring(0, granuleId.indexOf(".")) + "." + granules.size() + 1));
|
||||||
|
|
||||||
// removing recursively coveragestore
|
// removing recursively coveragestore
|
||||||
boolean removed = publisher.removeCoverageStore(coverageStore.getWorkspaceName(), coverageStore.getName(), true);
|
boolean removed = publisher.removeCoverageStore(coverageStore.getWorkspaceName(), coverageStore.getName(), true);
|
||||||
|
|||||||
@ -58,6 +58,10 @@ public class GeoserverRESTNamespaceTest extends GeoserverRESTTest {
|
|||||||
assertTrue(publisher.createNamespace("NS2", URI.create("http://b.example.com")));
|
assertTrue(publisher.createNamespace("NS2", URI.create("http://b.example.com")));
|
||||||
assertEquals(2, reader.getNamespaces().size());
|
assertEquals(2, reader.getNamespaces().size());
|
||||||
|
|
||||||
|
// Test Namespace exists
|
||||||
|
assertTrue(reader.existsNamespace("NS1"));
|
||||||
|
assertTrue(reader.existsNamespace("NS2"));
|
||||||
|
|
||||||
// When creating a namespace, its associated workspace will be automatically created:
|
// When creating a namespace, its associated workspace will be automatically created:
|
||||||
assertEquals(2, reader.getWorkspaces().size());
|
assertEquals(2, reader.getWorkspaces().size());
|
||||||
|
|
||||||
@ -96,5 +100,7 @@ public class GeoserverRESTNamespaceTest extends GeoserverRESTTest {
|
|||||||
|
|
||||||
assertEquals(0, reader.getNamespaces().size());
|
assertEquals(0, reader.getNamespaces().size());
|
||||||
assertEquals(0, reader.getWorkspaces().size());
|
assertEquals(0, reader.getWorkspaces().size());
|
||||||
|
// Test non existens
|
||||||
|
assertFalse(reader.existsNamespace("NS1"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,6 +101,10 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
|
|||||||
boolean published = publisher.publishShp(DEFAULT_WS, storeName, layerName, zipFile);
|
boolean published = publisher.publishShp(DEFAULT_WS, storeName, layerName, zipFile);
|
||||||
assertTrue("publish() failed", published);
|
assertTrue("publish() failed", published);
|
||||||
assertTrue(existsLayer(layerName));
|
assertTrue(existsLayer(layerName));
|
||||||
|
// Test exists datastore
|
||||||
|
assertTrue(reader.existsDatastore(DEFAULT_WS, storeName));
|
||||||
|
// Test exists featuretype
|
||||||
|
assertTrue(reader.existsFeatureType(DEFAULT_WS, storeName, layerName));
|
||||||
|
|
||||||
RESTLayer layer = reader.getLayer(layerName);
|
RESTLayer layer = reader.getLayer(layerName);
|
||||||
|
|
||||||
@ -111,10 +115,16 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
|
|||||||
assertTrue("Unpublish() failed", ok);
|
assertTrue("Unpublish() failed", ok);
|
||||||
assertFalse(existsLayer(layerName));
|
assertFalse(existsLayer(layerName));
|
||||||
|
|
||||||
|
// Test not exists featuretype
|
||||||
|
assertFalse(reader.existsFeatureType(DEFAULT_WS, storeName, layerName));
|
||||||
|
|
||||||
// remove also datastore
|
// remove also datastore
|
||||||
boolean dsRemoved = publisher.removeDatastore(DEFAULT_WS, storeName,false);
|
boolean dsRemoved = publisher.removeDatastore(DEFAULT_WS, storeName,false);
|
||||||
assertTrue("removeDatastore() failed", dsRemoved);
|
assertTrue("removeDatastore() failed", dsRemoved);
|
||||||
|
|
||||||
|
// Test not exists datastore
|
||||||
|
assertFalse(reader.existsDatastore(DEFAULT_WS, storeName));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -78,6 +78,8 @@ public class GeoserverRESTWorkspaceTest extends GeoserverRESTTest {
|
|||||||
|
|
||||||
assertTrue(reader.getWorkspaces().isEmpty());
|
assertTrue(reader.getWorkspaces().isEmpty());
|
||||||
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||||
|
// test exists
|
||||||
|
assertTrue(reader.existsWorkspace(DEFAULT_WS));
|
||||||
|
|
||||||
File geotiff = new ClassPathResource("testdata/resttestdem.tif").getFile();
|
File geotiff = new ClassPathResource("testdata/resttestdem.tif").getFile();
|
||||||
|
|
||||||
@ -89,5 +91,7 @@ public class GeoserverRESTWorkspaceTest extends GeoserverRESTTest {
|
|||||||
|
|
||||||
// remove workspace and all of its contents
|
// remove workspace and all of its contents
|
||||||
assertTrue(publisher.removeWorkspace(DEFAULT_WS,true));
|
assertTrue(publisher.removeWorkspace(DEFAULT_WS,true));
|
||||||
|
// Test not exists
|
||||||
|
assertFalse(reader.existsWorkspace(DEFAULT_WS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user