Merge pull request #47 from geosolutions-it/master-StoreManager-improvements
Remove specific datastore methods from manager implementing a generic St...
This commit is contained in:
commit
447e0cef86
@ -25,7 +25,7 @@
|
|||||||
package it.geosolutions.geoserver.rest;
|
package it.geosolutions.geoserver.rest;
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.manager.GeoServerRESTAbstractManager;
|
import it.geosolutions.geoserver.rest.manager.GeoServerRESTAbstractManager;
|
||||||
import it.geosolutions.geoserver.rest.manager.GeoServerRESTDatastoreManager;
|
import it.geosolutions.geoserver.rest.manager.GeoServerRESTStoreManager;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -39,15 +39,17 @@ import java.net.URL;
|
|||||||
* <li>getPublisher() simple, high-level pubhish methods.
|
* <li>getPublisher() simple, high-level pubhish methods.
|
||||||
* <li>get<i>Foo</i>Manager, full-fledged management of catalog objects.
|
* <li>get<i>Foo</i>Manager, full-fledged management of catalog objects.
|
||||||
* </ul>
|
* </ul>
|
||||||
|
*
|
||||||
* @author Oscar Fonts
|
* @author Oscar Fonts
|
||||||
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
*/
|
*/
|
||||||
public class GeoServerRESTManager extends GeoServerRESTAbstractManager {
|
public class GeoServerRESTManager extends GeoServerRESTAbstractManager {
|
||||||
|
|
||||||
private final GeoServerRESTPublisher publisher;
|
private final GeoServerRESTPublisher publisher;
|
||||||
|
|
||||||
private final GeoServerRESTReader reader;
|
private final GeoServerRESTReader reader;
|
||||||
|
|
||||||
private final GeoServerRESTDatastoreManager datastoreManager;
|
private final GeoServerRESTStoreManager store;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
@ -60,15 +62,14 @@ public class GeoServerRESTManager extends GeoServerRESTAbstractManager {
|
|||||||
* @throws MalformedURLException {@link GeoServerRESTAbstractManager#GeoServerRESTAbstractManager(URL, String, String)}
|
* @throws MalformedURLException {@link GeoServerRESTAbstractManager#GeoServerRESTAbstractManager(URL, String, String)}
|
||||||
* @throws IllegalArgumentException {@link GeoServerRESTAbstractManager#GeoServerRESTAbstractManager(URL, String, String)}
|
* @throws IllegalArgumentException {@link GeoServerRESTAbstractManager#GeoServerRESTAbstractManager(URL, String, String)}
|
||||||
*/
|
*/
|
||||||
public GeoServerRESTManager(URL restURL, String username, String password) throws IllegalArgumentException, MalformedURLException {
|
public GeoServerRESTManager(URL restURL, String username, String password)
|
||||||
|
throws IllegalArgumentException, MalformedURLException {
|
||||||
super(restURL, username, password);
|
super(restURL, username, password);
|
||||||
|
|
||||||
// Internal publisher and reader, provide simple access methods.
|
// Internal publisher and reader, provide simple access methods.
|
||||||
publisher = new GeoServerRESTPublisher(restURL.toString(), username, password);
|
publisher = new GeoServerRESTPublisher(restURL.toString(), username, password);
|
||||||
reader = new GeoServerRESTReader(restURL, username, password);
|
reader = new GeoServerRESTReader(restURL, username, password);
|
||||||
|
store = new GeoServerRESTStoreManager(restURL, gsuser, gspass);
|
||||||
// Classes for fine-grained management of catalog components.
|
|
||||||
datastoreManager = new GeoServerRESTDatastoreManager(restURL, username, password);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeoServerRESTPublisher getPublisher() {
|
public GeoServerRESTPublisher getPublisher() {
|
||||||
@ -79,8 +80,8 @@ public class GeoServerRESTManager extends GeoServerRESTAbstractManager {
|
|||||||
return reader;
|
return reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeoServerRESTDatastoreManager getDatastoreManager() {
|
public GeoServerRESTStoreManager getStoreManager() {
|
||||||
return datastoreManager;
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,6 @@ import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy
|
|||||||
import it.geosolutions.geoserver.rest.encoder.GSWorkspaceEncoder;
|
import it.geosolutions.geoserver.rest.encoder.GSWorkspaceEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.coverage.GSCoverageEncoder;
|
import it.geosolutions.geoserver.rest.encoder.coverage.GSCoverageEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
|
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
|
||||||
import it.geosolutions.geoserver.rest.manager.GeoServerRESTDatastoreManager;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -371,7 +370,7 @@ public class GeoServerRESTPublisher {
|
|||||||
}
|
}
|
||||||
LOGGER.debug("POSTing new style " + name + " to " + sUrl);
|
LOGGER.debug("POSTing new style " + name + " to " + sUrl);
|
||||||
String result = HTTPUtils
|
String result = HTTPUtils
|
||||||
.post(sUrl, sldFile, "application/vnd.ogc.sld+xml", gsuser, gspass);
|
.post(sUrl, sldFile, Format.SLD.getContentType(), gsuser, gspass);
|
||||||
return result != null;
|
return result != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -583,15 +582,41 @@ public class GeoServerRESTPublisher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type name of a DataStoreType.
|
* Get the type name of a StoreType.
|
||||||
*
|
*
|
||||||
* @param type the DataStoreType.
|
* @param type the StoreType.
|
||||||
* @return "featuretypes.xml" for DATASTORES, "coverages.xml" otherwise.
|
* @return "dataStore" for DATASTORES, "coverageStore" otherwise.
|
||||||
|
*/
|
||||||
|
public static String getType(StoreType type) {
|
||||||
|
switch (type) {
|
||||||
|
case COVERAGESTORES:
|
||||||
|
return "coverageStore"; // Format
|
||||||
|
case DATASTORES:
|
||||||
|
return "dataStore";
|
||||||
|
default:
|
||||||
|
return "coverageStore";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type name of a StoreType.
|
||||||
|
*
|
||||||
|
* @return "featuretypes" for DATASTORES, "coverages" otherwise.
|
||||||
*/
|
*/
|
||||||
public String getTypeName() {
|
public String getTypeName() {
|
||||||
return getTypeName(this);
|
return getTypeName(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type of a StoreType.
|
||||||
|
*
|
||||||
|
* @param type the StoreType.
|
||||||
|
* @return "dataStore" for DATASTORES, "coverageStore" otherwise.
|
||||||
|
*/
|
||||||
|
public String getType() {
|
||||||
|
return getType(this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a lowercase representation of the parameter value, suitable to construct the rest call.
|
* Returns a lowercase representation of the parameter value, suitable to construct the rest call.
|
||||||
*/
|
*/
|
||||||
@ -1342,6 +1367,16 @@ public class GeoServerRESTPublisher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the mime type from a format.
|
||||||
|
*
|
||||||
|
* @param f the format key.
|
||||||
|
* @return The content-type (mime), or {@code null} if not in the enum.
|
||||||
|
*/
|
||||||
|
public String getContentType() {
|
||||||
|
return getContentType(this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a lowercase representation of the parameter. Useful when constructing the REST request.
|
* Returns a lowercase representation of the parameter. Useful when constructing the REST request.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2012 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package it.geosolutions.geoserver.rest.encoder;
|
||||||
|
|
||||||
|
import org.jdom.Element;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
|
||||||
|
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.StoreType;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.utils.PropertyXMLEncoder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic Store encoder.
|
||||||
|
*
|
||||||
|
* Provides getters and setters for parameters common to all CoverageStore.
|
||||||
|
*
|
||||||
|
* @author Carlo Cancellieri - GeoSolutions
|
||||||
|
*/
|
||||||
|
public abstract class GSAbstractStoreEncoder extends PropertyXMLEncoder {
|
||||||
|
|
||||||
|
private final GeoServerRESTPublisher.StoreType type;
|
||||||
|
|
||||||
|
protected GSAbstractStoreEncoder(GeoServerRESTPublisher.StoreType type, String storeName) {
|
||||||
|
super(type.getType());
|
||||||
|
this.type=type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StoreType getStoreType() {
|
||||||
|
return this.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
set("type", type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return ElementUtils.contains(getRoot(), "name").getTextTrim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
ensureValidName(name);
|
||||||
|
set("name", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
Element e = ElementUtils.contains(getRoot(), "name");
|
||||||
|
return e!=null?e.getTextTrim():null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
set("description", description);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
Element e = ElementUtils.contains(getRoot(), "description");
|
||||||
|
return e!=null?e.getTextTrim():null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
set("enabled", Boolean.toString(enabled));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getEnabled() {
|
||||||
|
Element e = ElementUtils.contains(getRoot(), "name");
|
||||||
|
if (e!=null)
|
||||||
|
return Boolean.parseBoolean(e.getTextTrim());
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check name validity.
|
||||||
|
*
|
||||||
|
* @param name the name
|
||||||
|
* @throws IllegalArgumentException if name is null or empty
|
||||||
|
*/
|
||||||
|
protected void ensureValidName(String name) {
|
||||||
|
if (name == null || name.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Store name cannot be null or empty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check type validity.
|
||||||
|
*
|
||||||
|
* @param type the type.
|
||||||
|
* @throws IllegalArgumentException if type is not {@value #TYPE}
|
||||||
|
*/
|
||||||
|
protected void ensureValidType(String type) {
|
||||||
|
if (!type.equals(getValidType())) {
|
||||||
|
throw new IllegalArgumentException("The store type '" + type + "' is not valid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of the implementing store.
|
||||||
|
*/
|
||||||
|
protected abstract String getValidType();
|
||||||
|
}
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2012 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package it.geosolutions.geoserver.rest.encoder.coverage;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.StoreType;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.GSAbstractStoreEncoder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic CoverageStore encoder.
|
||||||
|
*
|
||||||
|
* Provides getters and setters for parameters common to all CoverageStore.
|
||||||
|
*
|
||||||
|
* @author Carlo Cancellieri - GeoSolutions
|
||||||
|
*
|
||||||
|
* @deprecated TODO complete specialization
|
||||||
|
*/
|
||||||
|
public abstract class GSAbstractCoveragestoreEncoder extends GSAbstractStoreEncoder {
|
||||||
|
|
||||||
|
protected GSAbstractCoveragestoreEncoder(String storeName) {
|
||||||
|
super(StoreType.COVERAGESTORES,storeName);
|
||||||
|
// Add mandatory parameter
|
||||||
|
ensureValidName(storeName);
|
||||||
|
setName(storeName);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -24,30 +24,29 @@
|
|||||||
*/
|
*/
|
||||||
package it.geosolutions.geoserver.rest.encoder.datastore;
|
package it.geosolutions.geoserver.rest.encoder.datastore;
|
||||||
|
|
||||||
import java.util.Map;
|
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
|
import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
|
||||||
import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils;
|
import it.geosolutions.geoserver.rest.encoder.GSAbstractStoreEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.utils.NestedElementEncoder;
|
import it.geosolutions.geoserver.rest.encoder.utils.NestedElementEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.utils.PropertyXMLEncoder;
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic Datastore encoder.
|
* Generic Datastore encoder.
|
||||||
*
|
*
|
||||||
* Provides getters and setters for parameters common to all Datastores,
|
* Provides getters and setters for parameters common to all Datastores, an internal placeholder for specific connection parameters, and a constructor
|
||||||
* an internal placeholder for specific connection parameters, and
|
* to read parameters from a {@link RESTDataStore}.
|
||||||
* a constructor to read parameters from a {@link RESTDataStore}.
|
|
||||||
*
|
*
|
||||||
* @author Oscar Fonts
|
* @author Oscar Fonts
|
||||||
*/
|
*/
|
||||||
public abstract class GSAbstractDatastoreEncoder extends PropertyXMLEncoder {
|
public abstract class GSAbstractDatastoreEncoder extends GSAbstractStoreEncoder {
|
||||||
|
|
||||||
final static String ROOT = "dataStore";
|
final static String ROOT = "dataStore";
|
||||||
|
|
||||||
NestedElementEncoder connectionParameters = new NestedElementEncoder("connectionParameters");
|
NestedElementEncoder connectionParameters = new NestedElementEncoder("connectionParameters");
|
||||||
|
|
||||||
GSAbstractDatastoreEncoder(String storeName) {
|
GSAbstractDatastoreEncoder(String storeName) {
|
||||||
super(ROOT);
|
super(GeoServerRESTPublisher.StoreType.DATASTORES, ROOT);
|
||||||
// Add mandatory parameter
|
// Add mandatory parameter
|
||||||
ensureValidName(storeName);
|
ensureValidName(storeName);
|
||||||
setName(storeName);
|
setName(storeName);
|
||||||
@ -67,7 +66,6 @@ public abstract class GSAbstractDatastoreEncoder extends PropertyXMLEncoder {
|
|||||||
|
|
||||||
// Match datastore type
|
// Match datastore type
|
||||||
ensureValidType(store.getStoreType());
|
ensureValidType(store.getStoreType());
|
||||||
setType(store.getStoreType());
|
|
||||||
|
|
||||||
// Copy store parameters
|
// Copy store parameters
|
||||||
setDescription(store.getDescription());
|
setDescription(store.getDescription());
|
||||||
@ -75,72 +73,14 @@ public abstract class GSAbstractDatastoreEncoder extends PropertyXMLEncoder {
|
|||||||
|
|
||||||
// Copy connection parameters - bulk
|
// Copy connection parameters - bulk
|
||||||
Map<String, String> params = store.getConnectionParameters();
|
Map<String, String> params = store.getConnectionParameters();
|
||||||
for(String key : params.keySet()) {
|
for (String key : params.keySet()) {
|
||||||
connectionParameters.set(key, params.get(key));
|
connectionParameters.set(key, params.get(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setType(String type) {
|
|
||||||
set("type", type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return ElementUtils.contains(getRoot(), "type").getTextTrim();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
ensureValidName(name);
|
|
||||||
set("name", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return ElementUtils.contains(getRoot(), "name").getTextTrim();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
set("description", description);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return ElementUtils.contains(getRoot(), "description").getTextTrim();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabled(boolean enabled) {
|
|
||||||
set("enabled", Boolean.toString(enabled));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getEnabled() {
|
|
||||||
return Boolean.parseBoolean(ElementUtils.contains(getRoot(), "enabled").getTextTrim());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check name validity.
|
|
||||||
*
|
|
||||||
* @param name the name
|
|
||||||
* @throws IllegalArgumentException if name is null or empty
|
|
||||||
*/
|
|
||||||
void ensureValidName(String name) {
|
|
||||||
if (name == null || name.isEmpty()) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Store name cannot be null or empty");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check type validity.
|
|
||||||
*
|
|
||||||
* @param type the type.
|
|
||||||
* @throws IllegalArgumentException if type is not {@value #TYPE}
|
|
||||||
*/
|
|
||||||
void ensureValidType(String type) {
|
|
||||||
if (!type.equals(getValidType())) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"The store type '"+ type +"' is not valid");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of the implementing datastore.
|
* The type of the implementing datastore.
|
||||||
*/
|
*/
|
||||||
abstract String getValidType();
|
protected abstract String getValidType();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,7 +66,6 @@ public class GSArcSDEDatastoreEncoder extends GSAbstractDatastoreEncoder {
|
|||||||
super(name);
|
super(name);
|
||||||
|
|
||||||
// Set mandatory parameters
|
// Set mandatory parameters
|
||||||
setType(TYPE);
|
|
||||||
setServer(server);
|
setServer(server);
|
||||||
setUser(user);
|
setUser(user);
|
||||||
|
|
||||||
@ -212,7 +211,7 @@ public class GSArcSDEDatastoreEncoder extends GSAbstractDatastoreEncoder {
|
|||||||
/**
|
/**
|
||||||
* @return {@value #TYPE}
|
* @return {@value #TYPE}
|
||||||
*/
|
*/
|
||||||
String getValidType() {
|
protected String getValidType() {
|
||||||
return TYPE;
|
return TYPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,8 +38,7 @@ public class GSDirectoryOfShapefilesDatastoreEncoder extends GSShapefileDatastor
|
|||||||
static final String TYPE = "Directory of spatial files (shapefiles)";
|
static final String TYPE = "Directory of spatial files (shapefiles)";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a {@value #TYPE} datastore with default connection parameters,
|
* Create a {@value #TYPE} datastore with default connection parameters, given a store name and a url (the store location).
|
||||||
* given a store name and a url (the store location).
|
|
||||||
*
|
*
|
||||||
* @param name New datastore name
|
* @param name New datastore name
|
||||||
* @param url The shapefile location in the server, relative to $GEOSERVER_DATA_DIR.
|
* @param url The shapefile location in the server, relative to $GEOSERVER_DATA_DIR.
|
||||||
@ -62,7 +61,7 @@ public class GSDirectoryOfShapefilesDatastoreEncoder extends GSShapefileDatastor
|
|||||||
/**
|
/**
|
||||||
* @return {@value #TYPE}
|
* @return {@value #TYPE}
|
||||||
*/
|
*/
|
||||||
String getValidType() {
|
protected String getValidType() {
|
||||||
return TYPE;
|
return TYPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -181,7 +181,7 @@ public class GSOracleNGDatastoreEncoder extends GSAbstractDatastoreEncoder {
|
|||||||
/**
|
/**
|
||||||
* @return {@value #TYPE}
|
* @return {@value #TYPE}
|
||||||
*/
|
*/
|
||||||
String getValidType() {
|
protected String getValidType() {
|
||||||
return TYPE;
|
return TYPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,6 +44,10 @@ public class GSPostGISDatastoreEncoder extends GSAbstractDatastoreEncoder {
|
|||||||
static final boolean DEFAULT_PREPARED_STATEMENTS = false;
|
static final boolean DEFAULT_PREPARED_STATEMENTS = false;
|
||||||
static final int DEFAULT_MAX_OPEN_PREPARED_STATEMENTS = 50;
|
static final int DEFAULT_MAX_OPEN_PREPARED_STATEMENTS = 50;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param name DataStore name
|
||||||
|
*/
|
||||||
public GSPostGISDatastoreEncoder(String name) {
|
public GSPostGISDatastoreEncoder(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
|
||||||
@ -141,7 +145,7 @@ public class GSPostGISDatastoreEncoder extends GSAbstractDatastoreEncoder {
|
|||||||
/**
|
/**
|
||||||
* @return {@value #TYPE}
|
* @return {@value #TYPE}
|
||||||
*/
|
*/
|
||||||
String getValidType() {
|
protected String getValidType() {
|
||||||
return TYPE;
|
return TYPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -157,7 +157,7 @@ public class GSShapefileDatastoreEncoder extends GSAbstractDatastoreEncoder {
|
|||||||
/**
|
/**
|
||||||
* @return {@value #TYPE}
|
* @return {@value #TYPE}
|
||||||
*/
|
*/
|
||||||
String getValidType() {
|
protected String getValidType() {
|
||||||
return TYPE;
|
return TYPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,22 +24,23 @@
|
|||||||
*/
|
*/
|
||||||
package it.geosolutions.geoserver.rest.manager;
|
package it.geosolutions.geoserver.rest.manager;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.Format;
|
||||||
import it.geosolutions.geoserver.rest.HTTPUtils;
|
import it.geosolutions.geoserver.rest.HTTPUtils;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.GSAbstractStoreEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.datastore.GSAbstractDatastoreEncoder;
|
import it.geosolutions.geoserver.rest.encoder.datastore.GSAbstractDatastoreEncoder;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage datastores.
|
* Manage stores.
|
||||||
*
|
*
|
||||||
* To pass connection parameters, use the encoders derived from
|
* To pass connection parameters, use the encoders derived from
|
||||||
* {@link GSAbstractDatastoreEncoder}.
|
* {@link GSAbstractDatastoreEncoder}.
|
||||||
*
|
*
|
||||||
* @author Oscar Fonts
|
|
||||||
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
*/
|
*/
|
||||||
public class GeoServerRESTDatastoreManager extends GeoServerRESTAbstractManager {
|
public class GeoServerRESTStoreManager extends GeoServerRESTAbstractManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
@ -50,44 +51,73 @@ public class GeoServerRESTDatastoreManager extends GeoServerRESTAbstractManager
|
|||||||
* @throws MalformedURLException
|
* @throws MalformedURLException
|
||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
*/
|
*/
|
||||||
public GeoServerRESTDatastoreManager(URL restURL, String username, String password)
|
public GeoServerRESTStoreManager(URL restURL, String username, String password)
|
||||||
throws IllegalArgumentException, MalformedURLException {
|
throws IllegalArgumentException, MalformedURLException {
|
||||||
super(restURL, username, password);
|
super(restURL, username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a datastore.
|
* Create a store.
|
||||||
*
|
*
|
||||||
* @param workspace Name of the workspace to contain the datastore. This
|
* @param workspace Name of the workspace to contain the store. This
|
||||||
* will also be the prefix of any layer names contained in the
|
* will also be the prefix of any layer names contained in the
|
||||||
* datastore.
|
* store.
|
||||||
* @param datastore the set of parameters to be set to the datastore
|
* @param datastore the set of parameters to be set to the store
|
||||||
* (including connection parameters).
|
* (including connection parameters).
|
||||||
* @return <TT>true</TT> if the datastore has been successfully created,
|
* @return <TT>true</TT> if the store has been successfully created,
|
||||||
* <TT>false</TT> otherwise
|
* <TT>false</TT> otherwise
|
||||||
*/
|
*/
|
||||||
|
public boolean create(String workspace, GSAbstractStoreEncoder store) {
|
||||||
public boolean create(String workspace, GSAbstractDatastoreEncoder datastore) {
|
String sUrl = HTTPUtils.append(restURL, "/rest/workspaces/", workspace, "/", store.getStoreType().toString(),".",Format.XML.toString()).toString();
|
||||||
String sUrl = HTTPUtils.append(restURL, "/rest/workspaces/", workspace, "/datastores/").toString();
|
String xml = store.toString();
|
||||||
String xml = datastore.toString();
|
|
||||||
String result = HTTPUtils.postXml(sUrl, xml, gsuser, gspass);
|
String result = HTTPUtils.postXml(sUrl, xml, gsuser, gspass);
|
||||||
return result != null;
|
return result != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a datastore.
|
* Update a store.
|
||||||
*
|
*
|
||||||
* @param workspace Name of the workspace that contains the datastore.
|
* @param workspace Name of the workspace that contains the store.
|
||||||
* @param datastore the set of parameters to be set to the datastore
|
* @param datastore the set of parameters to be set to the store
|
||||||
* (including connection parameters).
|
* (including connection parameters).
|
||||||
* @return <TT>true</TT> if the datastore has been successfully updated,
|
* @return <TT>true</TT> if the store has been successfully updated,
|
||||||
* <TT>false</TT> otherwise
|
* <TT>false</TT> otherwise
|
||||||
*/
|
*/
|
||||||
public boolean update(String workspace, GSAbstractDatastoreEncoder datastore) {
|
public boolean update(String workspace, GSAbstractStoreEncoder store) {
|
||||||
String sUrl = HTTPUtils.append(restURL, "/rest/workspaces/", workspace, "/datastores/",
|
String sUrl = HTTPUtils.append(restURL, "/rest/workspaces/", workspace,"/", store.getStoreType().toString(),"/",
|
||||||
datastore.getName()).toString();
|
store.getName(),".",Format.XML.toString()).toString();
|
||||||
String xml = datastore.toString();
|
String xml = store.toString();
|
||||||
String result = HTTPUtils.putXml(sUrl, xml, gsuser, gspass);
|
String result = HTTPUtils.putXml(sUrl, xml, gsuser, gspass);
|
||||||
return result != null;
|
return result != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a given CoverageStore in a given Workspace.
|
||||||
|
*
|
||||||
|
* @param workspace The name of the workspace
|
||||||
|
* @param storename The name of the CoverageStore to remove.
|
||||||
|
* @param recurse if remove should be performed recursively
|
||||||
|
* @return <TT>true</TT> if the CoverageStore was successfully removed.
|
||||||
|
* @throws MalformedURLException
|
||||||
|
*/
|
||||||
|
public boolean remove(final String workspace, final GSAbstractStoreEncoder store,
|
||||||
|
final boolean recurse) throws IllegalArgumentException, MalformedURLException {
|
||||||
|
// if (workspace == null || storename == null)
|
||||||
|
// throw new IllegalArgumentException("Arguments may not be null!");
|
||||||
|
// if (workspace.isEmpty() || storename.isEmpty())
|
||||||
|
// throw new IllegalArgumentException("Arguments may not be empty!");
|
||||||
|
|
||||||
|
final StringBuffer url=HTTPUtils.append(restURL,"/rest/workspaces/",workspace,"/", store.getStoreType().toString(), "/",store.getName());
|
||||||
|
if (recurse)
|
||||||
|
url.append("?recurse=true");
|
||||||
|
final URL deleteStore = new URL(url.toString());
|
||||||
|
|
||||||
|
boolean deleted = HTTPUtils.delete(deleteStore.toExternalForm(), gsuser, gspass);
|
||||||
|
// if (!deleted) {
|
||||||
|
// LOGGER.warn("Could not delete CoverageStore " + workspace + ":" + storename);
|
||||||
|
// } else {
|
||||||
|
// LOGGER.info("CoverageStore successfully deleted " + workspace + ":" + storename);
|
||||||
|
// }
|
||||||
|
return deleted;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -24,25 +24,24 @@
|
|||||||
*/
|
*/
|
||||||
package it.geosolutions.geoserver.rest.datastore;
|
package it.geosolutions.geoserver.rest.datastore;
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
import java.net.MalformedURLException;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.datastore.GSArcSDEDatastoreEncoder;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||||
import org.slf4j.Logger;
|
import it.geosolutions.geoserver.rest.encoder.GSAbstractStoreEncoder;
|
||||||
import org.slf4j.LoggerFactory;
|
import it.geosolutions.geoserver.rest.encoder.datastore.GSArcSDEDatastoreEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.datastore.GSOracleNGDatastoreEncoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Testcase for creating arcsde-based resources on geoserver.
|
* Testcase for creating arcsde-based resources on geoserver.
|
||||||
* <P>
|
* <P>
|
||||||
* Since these tests require a running arcsde instance, this is more like integration tests.<br/>
|
* Since these tests require a running arcsde instance, this is more like integration tests.<br/>
|
||||||
* You may skip them by defining<tt> <pre>
|
* You may skip them by defining<tt> <pre>
|
||||||
* -DpgIgnore=true </pre></tt>
|
* -DpgIgnore=true </pre></tt> When <tt>pgIgnore</tt> is defined that way, failing tests will not break the build: they will be logged as
|
||||||
* When <tt>pgIgnore</tt> is defined that way, failing tests will not break
|
* errors instead.
|
||||||
* the build: they will be logged as errors instead.
|
|
||||||
*
|
*
|
||||||
* <P>
|
* <P>
|
||||||
* The target arcsde instance can be customized by defining the following env vars: <ul>
|
* The target arcsde instance can be customized by defining the following env vars:
|
||||||
|
* <ul>
|
||||||
* <LI><TT>pgHost</TT> (default <TT>localhost</TT>)</LI>
|
* <LI><TT>pgHost</TT> (default <TT>localhost</TT>)</LI>
|
||||||
* <LI><TT>pgPort</TT> (default: <TT>5432</TT>)</LI>
|
* <LI><TT>pgPort</TT> (default: <TT>5432</TT>)</LI>
|
||||||
* <LI><TT>pgDatabase</TT> (default: <TT>test</TT>)</LI>
|
* <LI><TT>pgDatabase</TT> (default: <TT>test</TT>)</LI>
|
||||||
@ -54,72 +53,26 @@ import org.slf4j.LoggerFactory;
|
|||||||
* @author etj
|
* @author etj
|
||||||
* @author Eric Grosso
|
* @author Eric Grosso
|
||||||
* @author Gianni Barrotta
|
* @author Gianni Barrotta
|
||||||
|
* @author carlo cancellieri - GeoSolutions
|
||||||
*
|
*
|
||||||
* @see GeoserverRESTTest
|
* @see GeoserverRESTTest
|
||||||
*/
|
*/
|
||||||
public class GSArcSDEDatastoreEncoderTest extends GeoserverRESTTest {
|
public class GSArcSDEDatastoreEncoderTest extends StoreIntegrationTest {
|
||||||
|
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(GSArcSDEDatastoreEncoderTest.class);
|
public GSArcSDEDatastoreEncoderTest() throws IllegalArgumentException, MalformedURLException {
|
||||||
private static final String DEFAULT_WS = "it.geosolutions";
|
|
||||||
|
|
||||||
private final boolean pgIgnore;
|
super(System.getProperty("Ignore", "false").equalsIgnoreCase("true"));
|
||||||
private final String pgServer;
|
|
||||||
private final int pgPort;
|
|
||||||
private final String pgInstance;
|
|
||||||
private final String pgUser;
|
|
||||||
private final String pgPassword;
|
|
||||||
|
|
||||||
public GSArcSDEDatastoreEncoderTest() {
|
|
||||||
|
|
||||||
pgIgnore = System.getProperty("pgIgnore", "false").equalsIgnoreCase("true");
|
|
||||||
pgServer = System.getProperty("pgServer", "localhost");
|
|
||||||
pgPort = Integer.parseInt(System.getProperty("pgPort", "5151"));
|
|
||||||
pgInstance = System.getProperty("pgInstance", "test");
|
|
||||||
pgUser = System.getProperty("pgUser", "utest");
|
|
||||||
pgPassword = System.getProperty("pgPassword", "ptest");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Override
|
||||||
public void testCreateDeleteArcSDEDatastore() {
|
public GSAbstractStoreEncoder getStoreEncoderTest() {
|
||||||
if (!enabled()) {
|
GSArcSDEDatastoreEncoder datastoreEncoder = new GSArcSDEDatastoreEncoder(
|
||||||
return;
|
System.getProperty("arcsdeHost", "localhost"),
|
||||||
}
|
System.getProperty("arcsdeSchema", "public"), System.getProperty("arcsdePassword", "ptest"));
|
||||||
deleteAll();
|
datastoreEncoder.setNamespace(DEFAULT_WS);
|
||||||
|
datastoreEncoder.setPort(Integer.parseInt(System.getProperty("arcsdePort", "5432")));
|
||||||
|
|
||||||
String wsName = DEFAULT_WS;
|
return datastoreEncoder;
|
||||||
String datastoreName = "resttestarcsde";
|
|
||||||
String description = "description";
|
|
||||||
String dsNamespace = "http://www.geo-solutions.it";
|
|
||||||
|
|
||||||
GSArcSDEDatastoreEncoder datastoreEncoder = new GSArcSDEDatastoreEncoder(datastoreName, pgServer, pgUser);
|
|
||||||
datastoreEncoder.setDescription(description);
|
|
||||||
datastoreEncoder.setNamespace(dsNamespace);
|
|
||||||
datastoreEncoder.setPort(pgPort);
|
|
||||||
datastoreEncoder.setInstance(pgInstance);
|
|
||||||
datastoreEncoder.setPassword(pgPassword);
|
|
||||||
|
|
||||||
assertTrue(publisher.createWorkspace(wsName));
|
|
||||||
|
|
||||||
// creation test
|
|
||||||
boolean created = manager.getDatastoreManager().create(wsName, datastoreEncoder);
|
|
||||||
|
|
||||||
if( ! pgIgnore )
|
|
||||||
assertTrue("arcsde datastore not created", created);
|
|
||||||
else if( ! created)
|
|
||||||
LOGGER.error("*** Datastore " + datastoreName + " has not been created.");
|
|
||||||
|
|
||||||
|
|
||||||
RESTDataStore datastore = reader.getDatastore(wsName, datastoreName);
|
|
||||||
LOGGER.info("The type of the created datastore is: " + datastore.getStoreType());
|
|
||||||
|
|
||||||
// removing test
|
|
||||||
boolean removed = publisher.removeDatastore(wsName, datastoreName, true);
|
|
||||||
if( ! pgIgnore )
|
|
||||||
assertTrue("arcsde datastore not removed", removed);
|
|
||||||
else if( ! removed )
|
|
||||||
LOGGER.error("*** Datastore " + datastoreName + " has not been removed.");
|
|
||||||
|
|
||||||
assertTrue(publisher.removeWorkspace(wsName, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,8 +24,11 @@
|
|||||||
*/
|
*/
|
||||||
package it.geosolutions.geoserver.rest.datastore;
|
package it.geosolutions.geoserver.rest.datastore;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
|
import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.GSAbstractStoreEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.datastore.GSOracleNGDatastoreEncoder;
|
import it.geosolutions.geoserver.rest.encoder.datastore.GSOracleNGDatastoreEncoder;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -54,82 +57,37 @@ import org.slf4j.LoggerFactory;
|
|||||||
* @author etj
|
* @author etj
|
||||||
* @author Eric Grosso
|
* @author Eric Grosso
|
||||||
* @author Gianni Barrotta
|
* @author Gianni Barrotta
|
||||||
|
* @author carlo cancellieri - GeoSolutions
|
||||||
*
|
*
|
||||||
* @see GeoserverRESTTest
|
* @see GeoserverRESTTest
|
||||||
*/
|
*/
|
||||||
public class GSOracleNGDatastoreEncoderTest extends GeoserverRESTTest {
|
public class GSOracleNGDatastoreEncoderTest extends StoreIntegrationTest {
|
||||||
|
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(GSOracleNGDatastoreEncoderTest.class);
|
// private final static Logger LOGGER = LoggerFactory.getLogger(GSOracleNGDatastoreEncoderTest.class);
|
||||||
private static final String DEFAULT_WS = "it.geosolutions";
|
|
||||||
|
|
||||||
private final boolean pgIgnore;
|
public GSOracleNGDatastoreEncoderTest() throws IllegalArgumentException, MalformedURLException {
|
||||||
private final String pgHost;
|
super(System.getProperty("pgIgnore", "false").equalsIgnoreCase("true"));
|
||||||
private final int pgPort;
|
|
||||||
private final String pgDatabase;
|
|
||||||
private final String pgSchema;
|
|
||||||
private final String pgUser;
|
|
||||||
private final String pgPassword;
|
|
||||||
|
|
||||||
public GSOracleNGDatastoreEncoderTest() {
|
|
||||||
|
|
||||||
pgIgnore = System.getProperty("pgIgnore", "false").equalsIgnoreCase("true");
|
|
||||||
pgHost = System.getProperty("pgHost", "localhost");
|
|
||||||
pgPort = Integer.parseInt(System.getProperty("pgPort", "5432"));
|
|
||||||
pgDatabase = System.getProperty("pgDatabase", "test");
|
|
||||||
pgSchema = System.getProperty("pgSchema", "public");
|
|
||||||
pgUser = System.getProperty("pgUser", "utest");
|
|
||||||
pgPassword = System.getProperty("pgPassword", "ptest");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Override
|
||||||
public void testCreateDeleteOracleNGDatastore() {
|
public GSAbstractStoreEncoder getStoreEncoderTest() {
|
||||||
if (!enabled()) {
|
GSOracleNGDatastoreEncoder datastoreEncoder = new GSOracleNGDatastoreEncoder(System.getProperty("oDataStoreName", "test"), System.getProperty("pgDatabase", "test"));
|
||||||
return;
|
datastoreEncoder.setNamespace(DEFAULT_WS);
|
||||||
}
|
datastoreEncoder.setHost(System.getProperty("pgHost", "localhost"));
|
||||||
deleteAll();
|
datastoreEncoder.setPort(Integer.parseInt(System.getProperty("pgPort", "5432")));
|
||||||
|
datastoreEncoder.setSchema(System.getProperty("pgUser", "postgres"));
|
||||||
|
datastoreEncoder.setUser(System.getProperty("pgSchema", "public"));
|
||||||
|
datastoreEncoder.setPassword(System.getProperty("pgPassword", "postgres"));
|
||||||
|
|
||||||
String wsName = DEFAULT_WS;
|
|
||||||
String datastoreName = "resttestOracleNG";
|
|
||||||
String description = "description";
|
|
||||||
String dsNamespace = "http://www.geo-solutions.it";
|
|
||||||
boolean exposePrimaryKeys = true;
|
boolean exposePrimaryKeys = true;
|
||||||
boolean validateConnections = false;
|
boolean validateConnections = false;
|
||||||
String primaryKeyMetadataTable = "test";
|
String primaryKeyMetadataTable = "test";
|
||||||
|
|
||||||
GSOracleNGDatastoreEncoder datastoreEncoder = new GSOracleNGDatastoreEncoder(datastoreName, pgDatabase);
|
|
||||||
datastoreEncoder.setDescription(description);
|
|
||||||
datastoreEncoder.setNamespace(dsNamespace);
|
|
||||||
datastoreEncoder.setHost(pgHost);
|
|
||||||
datastoreEncoder.setPort(pgPort);
|
|
||||||
datastoreEncoder.setSchema(pgSchema);
|
|
||||||
datastoreEncoder.setUser(pgUser);
|
|
||||||
datastoreEncoder.setPassword(pgPassword);
|
|
||||||
datastoreEncoder.setExposePrimaryKeys(exposePrimaryKeys);
|
datastoreEncoder.setExposePrimaryKeys(exposePrimaryKeys);
|
||||||
datastoreEncoder.setValidateConnections(validateConnections);
|
datastoreEncoder.setValidateConnections(validateConnections);
|
||||||
datastoreEncoder.setPrimaryKeyMetadataTable(primaryKeyMetadataTable);
|
datastoreEncoder.setPrimaryKeyMetadataTable(primaryKeyMetadataTable);
|
||||||
|
|
||||||
assertTrue(publisher.createWorkspace(wsName));
|
return datastoreEncoder;
|
||||||
|
|
||||||
// creation test
|
|
||||||
|
|
||||||
boolean created = manager.getDatastoreManager().create(wsName, datastoreEncoder);
|
|
||||||
|
|
||||||
if( ! pgIgnore )
|
|
||||||
assertTrue("OracleNG datastore not created", created);
|
|
||||||
else if( ! created)
|
|
||||||
LOGGER.error("*** Datastore " + datastoreName + " has not been created.");
|
|
||||||
|
|
||||||
|
|
||||||
RESTDataStore datastore = reader.getDatastore(wsName, datastoreName);
|
|
||||||
LOGGER.info("The type of the created datastore is: " + datastore.getStoreType());
|
|
||||||
|
|
||||||
// removing test
|
|
||||||
boolean removed = publisher.removeDatastore(wsName, datastoreName, true);
|
|
||||||
if( ! pgIgnore )
|
|
||||||
assertTrue("OracleNG datastore not removed", removed);
|
|
||||||
else if( ! removed )
|
|
||||||
LOGGER.error("*** Datastore " + datastoreName + " has not been removed.");
|
|
||||||
|
|
||||||
assertTrue(publisher.removeWorkspace(wsName, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,114 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2012 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package it.geosolutions.geoserver.rest.datastore;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.GSAbstractStoreEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.datastore.GSAbstractDatastoreEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.datastore.GSOracleNGDatastoreEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.manager.GeoServerRESTStoreManager;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <P>
|
||||||
|
* Since these tests require a running Store instance, this is more like integration tests.<br/>
|
||||||
|
*
|
||||||
|
* @author carlo cancellieri - GeoSolutions
|
||||||
|
*
|
||||||
|
* @see GeoserverRESTTest
|
||||||
|
*/
|
||||||
|
public abstract class StoreIntegrationTest extends GeoserverRESTTest {
|
||||||
|
|
||||||
|
private final static Logger LOGGER = LoggerFactory.getLogger(StoreIntegrationTest.class);
|
||||||
|
|
||||||
|
private final GeoServerRESTStoreManager storeManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ignore integration tests
|
||||||
|
*/
|
||||||
|
private final boolean ignore;
|
||||||
|
|
||||||
|
public boolean isIgnore() {
|
||||||
|
return ignore;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param ignore false if this test shoudl be disabled
|
||||||
|
* @throws IllegalArgumentException
|
||||||
|
* @throws MalformedURLException
|
||||||
|
*/
|
||||||
|
public StoreIntegrationTest(boolean ignore) throws IllegalArgumentException, MalformedURLException {
|
||||||
|
super();
|
||||||
|
this.storeManager = new GeoServerRESTStoreManager(URL, RESTUSER, RESTPW);
|
||||||
|
this.ignore=ignore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract GSAbstractStoreEncoder getStoreEncoderTest();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateDeleteDatastore() throws IllegalArgumentException, MalformedURLException {
|
||||||
|
if (!enabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
deleteAll();
|
||||||
|
|
||||||
|
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||||
|
|
||||||
|
// creation test
|
||||||
|
GSAbstractStoreEncoder storeEncoder=getStoreEncoderTest();
|
||||||
|
|
||||||
|
String storeName = storeEncoder.getName();
|
||||||
|
// String description = storeEncoder.getDescription();
|
||||||
|
|
||||||
|
boolean created = storeManager.create(DEFAULT_WS, storeEncoder);
|
||||||
|
|
||||||
|
if( ! ignore )
|
||||||
|
assertTrue("Datastore not created", created);
|
||||||
|
else if( ! created)
|
||||||
|
LOGGER.error("*** store " + storeName + " has not been created.");
|
||||||
|
|
||||||
|
|
||||||
|
RESTDataStore datastore = reader.getDatastore(DEFAULT_WS, storeName);
|
||||||
|
assertNotNull(datastore);
|
||||||
|
LOGGER.info("The type of the created datastore is: " + datastore.getStoreType());
|
||||||
|
|
||||||
|
// removing test
|
||||||
|
boolean removed = storeManager.remove(DEFAULT_WS, storeEncoder, true);
|
||||||
|
if( ! ignore )
|
||||||
|
assertTrue("Datastore not removed", removed);
|
||||||
|
else if( ! removed )
|
||||||
|
LOGGER.error("*** Datastore " + storeName + " has not been removed.");
|
||||||
|
|
||||||
|
assertTrue(publisher.removeWorkspace(DEFAULT_WS, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -24,8 +24,9 @@
|
|||||||
*/
|
*/
|
||||||
package it.geosolutions.geoserver.rest.manager;
|
package it.geosolutions.geoserver.rest.manager;
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
import it.geosolutions.geoserver.rest.datastore.StoreIntegrationTest;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
|
import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.GSAbstractStoreEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.datastore.GSAbstractDatastoreEncoder;
|
import it.geosolutions.geoserver.rest.encoder.datastore.GSAbstractDatastoreEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.datastore.GSDirectoryOfShapefilesDatastoreEncoder;
|
import it.geosolutions.geoserver.rest.encoder.datastore.GSDirectoryOfShapefilesDatastoreEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.datastore.GSShapefileDatastoreEncoder;
|
import it.geosolutions.geoserver.rest.encoder.datastore.GSShapefileDatastoreEncoder;
|
||||||
@ -62,19 +63,82 @@ import org.junit.Test;
|
|||||||
*
|
*
|
||||||
* @author Oscar Fonts
|
* @author Oscar Fonts
|
||||||
*/
|
*/
|
||||||
public class GeoserverRESTDatastoreManagerTest extends GeoserverRESTTest {
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2012 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test datastore handling (create, read and update):
|
||||||
|
*
|
||||||
|
* <ul>
|
||||||
|
* <li>Tests all the constructors and setters from {@link GSDirectoryOfShapefilesDatastoreEncoder} and parent classes (
|
||||||
|
* {@link GSShapefileDatastoreEncoder}, {@link GSAbstractDatastoreEncoder}).
|
||||||
|
*
|
||||||
|
* <li>Tests constructors and getters from {@link RESTDataStore} (reader).
|
||||||
|
*
|
||||||
|
* <li>Tests {@link GeoServerRESTDatastoreManager} create and update methods.
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* The sequence is:
|
||||||
|
* <ol>
|
||||||
|
* <li>Create a DirectoryOfShapefilesDatastoreEncoder, with default parameters.
|
||||||
|
* <li>Publish via GeoServerRESTDatastoreManager.create.
|
||||||
|
* <li>Read the datastore from server.
|
||||||
|
* <li>Test all parameter values.
|
||||||
|
* <li>Create a new Encoder from it.
|
||||||
|
* <li>Change all datastore parameter to non-default ones.
|
||||||
|
* <li>Update via GeoServerRESTDatastoreManager.update.
|
||||||
|
* <li>Read again.
|
||||||
|
* <li>Test all new values.
|
||||||
|
* </ol>
|
||||||
|
*
|
||||||
|
* @author Oscar Fonts
|
||||||
|
*/
|
||||||
|
public class GeoserverRESTDatastoreManagerTest extends StoreIntegrationTest {
|
||||||
|
|
||||||
private static final String WS_NAME = DEFAULT_WS;
|
private static final String WS_NAME = DEFAULT_WS;
|
||||||
|
|
||||||
private static final String DS_NAME = "testCreateDatastore";
|
private static final String DS_NAME = "testCreateDatastore";
|
||||||
|
|
||||||
private static final String DS_DESCRIPTION = "A description";
|
private static final String DS_DESCRIPTION = "A description";
|
||||||
|
|
||||||
private static URL LOCATION_1;
|
private static URL LOCATION_1;
|
||||||
|
|
||||||
private static URL LOCATION_2;
|
private static URL LOCATION_2;
|
||||||
|
|
||||||
public GeoserverRESTDatastoreManagerTest() throws Exception {
|
public GeoserverRESTDatastoreManagerTest() throws Exception {
|
||||||
|
super(true);
|
||||||
LOCATION_1 = new URL("file:data/1");
|
LOCATION_1 = new URL("file:data/1");
|
||||||
LOCATION_2 = new URL("file:data/2");
|
LOCATION_2 = new URL("file:data/2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GSAbstractStoreEncoder getStoreEncoderTest() {
|
||||||
|
return new GSDirectoryOfShapefilesDatastoreEncoder(DS_NAME, LOCATION_1);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
if (!enabled()) {
|
if (!enabled()) {
|
||||||
@ -88,8 +152,9 @@ public class GeoserverRESTDatastoreManagerTest extends GeoserverRESTTest {
|
|||||||
assertTrue(publisher.createWorkspace(WS_NAME));
|
assertTrue(publisher.createWorkspace(WS_NAME));
|
||||||
|
|
||||||
// Create a directory of spatial files with default parameters
|
// Create a directory of spatial files with default parameters
|
||||||
GSDirectoryOfShapefilesDatastoreEncoder create = new GSDirectoryOfShapefilesDatastoreEncoder(DS_NAME, LOCATION_1);
|
GSDirectoryOfShapefilesDatastoreEncoder create = new GSDirectoryOfShapefilesDatastoreEncoder(
|
||||||
assertTrue(manager.getDatastoreManager().create(WS_NAME, create));
|
DS_NAME, LOCATION_1);
|
||||||
|
assertTrue(manager.getStoreManager().create(WS_NAME, create));
|
||||||
|
|
||||||
// Read the store from server; check all parameter values
|
// Read the store from server; check all parameter values
|
||||||
RESTDataStore read = reader.getDatastore(WS_NAME, DS_NAME);
|
RESTDataStore read = reader.getDatastore(WS_NAME, DS_NAME);
|
||||||
@ -97,7 +162,7 @@ public class GeoserverRESTDatastoreManagerTest extends GeoserverRESTTest {
|
|||||||
assertEquals(read.getWorkspaceName(), WS_NAME);
|
assertEquals(read.getWorkspaceName(), WS_NAME);
|
||||||
assertEquals(read.isEnabled(), true);
|
assertEquals(read.isEnabled(), true);
|
||||||
|
|
||||||
Map<String,String> connParams = read.getConnectionParameters();
|
Map<String, String> connParams = read.getConnectionParameters();
|
||||||
assertEquals(connParams.get("url"), LOCATION_1.toString());
|
assertEquals(connParams.get("url"), LOCATION_1.toString());
|
||||||
assertEquals(connParams.get("charset"), "ISO-8859-1");
|
assertEquals(connParams.get("charset"), "ISO-8859-1");
|
||||||
assertEquals(connParams.get("create spatial index"), "true");
|
assertEquals(connParams.get("create spatial index"), "true");
|
||||||
@ -105,7 +170,8 @@ public class GeoserverRESTDatastoreManagerTest extends GeoserverRESTTest {
|
|||||||
assertEquals(connParams.get("cache and reuse memory maps"), "true");
|
assertEquals(connParams.get("cache and reuse memory maps"), "true");
|
||||||
|
|
||||||
// Change all parameter to non-default values
|
// Change all parameter to non-default values
|
||||||
GSDirectoryOfShapefilesDatastoreEncoder update = new GSDirectoryOfShapefilesDatastoreEncoder(read);
|
GSDirectoryOfShapefilesDatastoreEncoder update = new GSDirectoryOfShapefilesDatastoreEncoder(
|
||||||
|
read);
|
||||||
update.setDescription(DS_DESCRIPTION);
|
update.setDescription(DS_DESCRIPTION);
|
||||||
update.setEnabled(false);
|
update.setEnabled(false);
|
||||||
update.setUrl(LOCATION_2);
|
update.setUrl(LOCATION_2);
|
||||||
@ -114,8 +180,8 @@ public class GeoserverRESTDatastoreManagerTest extends GeoserverRESTTest {
|
|||||||
update.setMemoryMappedBuffer(true);
|
update.setMemoryMappedBuffer(true);
|
||||||
update.setCacheAndReuseMemoryMaps(false);
|
update.setCacheAndReuseMemoryMaps(false);
|
||||||
|
|
||||||
//update the store
|
// update the store
|
||||||
assertTrue(manager.getDatastoreManager().update(WS_NAME, update));
|
assertTrue(manager.getStoreManager().update(WS_NAME, update));
|
||||||
|
|
||||||
// Read again, check that all parameters have changed
|
// Read again, check that all parameters have changed
|
||||||
read = reader.getDatastore(WS_NAME, DS_NAME);
|
read = reader.getDatastore(WS_NAME, DS_NAME);
|
||||||
|
|||||||
@ -27,10 +27,13 @@ package it.geosolutions.geoserver.rest.publisher;
|
|||||||
|
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
|
import it.geosolutions.geoserver.rest.datastore.StoreIntegrationTest;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSPostGISDatastoreEncoder;
|
import it.geosolutions.geoserver.rest.encoder.GSAbstractStoreEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.datastore.GSPostGISDatastoreEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.manager.GeoServerRESTStoreManager;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -55,53 +58,39 @@ import org.slf4j.LoggerFactory;
|
|||||||
*
|
*
|
||||||
* @author etj
|
* @author etj
|
||||||
* @author Eric Grosso
|
* @author Eric Grosso
|
||||||
|
* @author carlo cancellieri - GeoSolutions
|
||||||
*
|
*
|
||||||
* @see GeoserverRESTTest
|
* @see GeoserverRESTTest
|
||||||
*/
|
*/
|
||||||
public class GeoserverRESTPostgisDatastoreTest extends GeoserverRESTTest {
|
public class GeoserverRESTPostgisDatastoreTest extends StoreIntegrationTest {
|
||||||
|
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTPostgisDatastoreTest.class);
|
public GeoserverRESTPostgisDatastoreTest()
|
||||||
private static final String DEFAULT_WS = "it.geosolutions";
|
throws IllegalArgumentException, MalformedURLException {
|
||||||
|
super(System.getProperty("pgIgnore", "false").equalsIgnoreCase("true"));
|
||||||
private final boolean pgIgnore;
|
|
||||||
private final String pgHost;
|
|
||||||
private final int pgPort;
|
|
||||||
private final String pgDatabase;
|
|
||||||
private final String pgSchema;
|
|
||||||
private final String pgUser;
|
|
||||||
private final String pgPassword;
|
|
||||||
|
|
||||||
public GeoserverRESTPostgisDatastoreTest() {
|
|
||||||
|
|
||||||
pgIgnore = System.getProperty("pgIgnore", "false").equalsIgnoreCase("true");
|
|
||||||
pgHost = System.getProperty("pgHost", "localhost");
|
|
||||||
pgPort = Integer.parseInt(System.getProperty("pgPort", "5432"));
|
|
||||||
pgDatabase = System.getProperty("pgDatabase", "test");
|
|
||||||
pgSchema = System.getProperty("pgSchema", "public");
|
|
||||||
pgUser = System.getProperty("pgUser", "utest");
|
|
||||||
pgPassword = System.getProperty("pgPassword", "ptest");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreateDeletePostGISDatastore() {
|
|
||||||
if (!enabled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
deleteAll();
|
|
||||||
|
|
||||||
String wsName = DEFAULT_WS;
|
@Override
|
||||||
String datastoreName = "resttestpostgis";
|
public GSAbstractStoreEncoder getStoreEncoderTest(){
|
||||||
String description = "description";
|
|
||||||
String dsNamespace = "http://www.geo-solutions.it";
|
|
||||||
boolean exposePrimaryKeys = true;
|
boolean exposePrimaryKeys = true;
|
||||||
boolean validateConnections = false;
|
boolean validateConnections = false;
|
||||||
String primaryKeyMetadataTable = "test";
|
String primaryKeyMetadataTable = "test";
|
||||||
|
|
||||||
GSPostGISDatastoreEncoder datastoreEncoder = new GSPostGISDatastoreEncoder();
|
String datastoreName = "resttestpostgis";
|
||||||
datastoreEncoder.defaultInit();
|
String description = "description";
|
||||||
datastoreEncoder.setName(datastoreName);
|
String dsNamespace = "http://www.geo-solutions.it";
|
||||||
|
|
||||||
|
GSPostGISDatastoreEncoder datastoreEncoder = new GSPostGISDatastoreEncoder(datastoreName);
|
||||||
datastoreEncoder.setDescription(description);
|
datastoreEncoder.setDescription(description);
|
||||||
datastoreEncoder.setNamespace(dsNamespace);
|
datastoreEncoder.setNamespace(dsNamespace);
|
||||||
|
|
||||||
|
String pgHost = System.getProperty("pgHost", "localhost");
|
||||||
|
int pgPort = Integer.parseInt(System.getProperty("pgPort", "5432"));
|
||||||
|
String pgDatabase = System.getProperty("pgDatabase", "test");
|
||||||
|
String pgSchema = System.getProperty("pgSchema", "public");
|
||||||
|
String pgUser = System.getProperty("pgUser", "utest");
|
||||||
|
String pgPassword = System.getProperty("pgPassword", "ptest");
|
||||||
|
|
||||||
datastoreEncoder.setHost(pgHost);
|
datastoreEncoder.setHost(pgHost);
|
||||||
datastoreEncoder.setPort(pgPort);
|
datastoreEncoder.setPort(pgPort);
|
||||||
datastoreEncoder.setDatabase(pgDatabase);
|
datastoreEncoder.setDatabase(pgDatabase);
|
||||||
@ -111,29 +100,7 @@ public class GeoserverRESTPostgisDatastoreTest extends GeoserverRESTTest {
|
|||||||
datastoreEncoder.setExposePrimaryKeys(exposePrimaryKeys);
|
datastoreEncoder.setExposePrimaryKeys(exposePrimaryKeys);
|
||||||
datastoreEncoder.setValidateConnections(validateConnections);
|
datastoreEncoder.setValidateConnections(validateConnections);
|
||||||
datastoreEncoder.setPrimaryKeyMetadataTable(primaryKeyMetadataTable);
|
datastoreEncoder.setPrimaryKeyMetadataTable(primaryKeyMetadataTable);
|
||||||
|
return datastoreEncoder;
|
||||||
assertTrue(publisher.createWorkspace(wsName));
|
|
||||||
|
|
||||||
// creation test
|
|
||||||
boolean created = publisher.createPostGISDatastore(wsName, datastoreEncoder);
|
|
||||||
|
|
||||||
if( ! pgIgnore )
|
|
||||||
assertTrue("PostGIS datastore not created", created);
|
|
||||||
else if( ! created)
|
|
||||||
LOGGER.error("*** Datastore " + datastoreName + " has not been created.");
|
|
||||||
|
|
||||||
|
|
||||||
RESTDataStore datastore = reader.getDatastore(wsName, datastoreName);
|
|
||||||
LOGGER.info("The type of the created datastore is: " + datastore.getType());
|
|
||||||
|
|
||||||
// removing test
|
|
||||||
boolean removed = publisher.removeDatastore(wsName, datastoreName);
|
|
||||||
if( ! pgIgnore )
|
|
||||||
assertTrue("PostGIS datastore not removed", removed);
|
|
||||||
else if( ! removed )
|
|
||||||
LOGGER.error("*** Datastore " + datastoreName + " has not been removed.");
|
|
||||||
|
|
||||||
assertTrue(publisher.removeWorkspace(wsName));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,15 +60,13 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
|
|||||||
|
|
||||||
@After
|
@After
|
||||||
public void cleanUp(){
|
public void cleanUp(){
|
||||||
if(enabled()){
|
|
||||||
deleteAllWorkspaces();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReloadDataStore() throws FileNotFoundException, IOException {
|
public void testReloadDataStore() throws FileNotFoundException, IOException {
|
||||||
if (!enabled())
|
if (!enabled())
|
||||||
return;
|
return;
|
||||||
|
deleteAllWorkspacesRecursively();
|
||||||
|
|
||||||
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||||
|
|
||||||
@ -91,6 +89,7 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
|
|||||||
if (!enabled()) {
|
if (!enabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
deleteAllWorkspacesRecursively();
|
||||||
|
|
||||||
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||||
|
|
||||||
@ -126,6 +125,7 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
|
|||||||
if (!enabled()) {
|
if (!enabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
deleteAllWorkspacesRecursively();
|
||||||
// Assume.assumeTrue(enabled);
|
// Assume.assumeTrue(enabled);
|
||||||
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||||
|
|
||||||
@ -159,6 +159,7 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
|
|||||||
if (!enabled()) {
|
if (!enabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
deleteAllWorkspacesRecursively();
|
||||||
// Assume.assumeTrue(enabled);
|
// Assume.assumeTrue(enabled);
|
||||||
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||||
|
|
||||||
@ -192,6 +193,7 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
|
|||||||
if (!enabled()) {
|
if (!enabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
deleteAllWorkspacesRecursively();
|
||||||
// Assume.assumeTrue(enabled);
|
// Assume.assumeTrue(enabled);
|
||||||
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||||
|
|
||||||
@ -236,6 +238,7 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
|
|||||||
if (!enabled()) {
|
if (!enabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
deleteAllWorkspacesRecursively();
|
||||||
// Assume.assumeTrue(enabled);
|
// Assume.assumeTrue(enabled);
|
||||||
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||||
|
|
||||||
@ -278,6 +281,7 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
|
|||||||
public void testPublishShpUsingDeclaredNativeCRS() throws Exception {
|
public void testPublishShpUsingDeclaredNativeCRS() throws Exception {
|
||||||
if (!enabled())
|
if (!enabled())
|
||||||
return;
|
return;
|
||||||
|
deleteAllWorkspacesRecursively();
|
||||||
|
|
||||||
// layer publication params
|
// layer publication params
|
||||||
String workspace = DEFAULT_WS;
|
String workspace = DEFAULT_WS;
|
||||||
@ -315,6 +319,7 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
|
|||||||
public void testPublishShpUsingWKTNativeCRS() throws Exception {
|
public void testPublishShpUsingWKTNativeCRS() throws Exception {
|
||||||
if (!enabled())
|
if (!enabled())
|
||||||
return;
|
return;
|
||||||
|
deleteAllWorkspacesRecursively();
|
||||||
|
|
||||||
// layer publication params
|
// layer publication params
|
||||||
String workspace = DEFAULT_WS;
|
String workspace = DEFAULT_WS;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user