From 0978997f9f47215bcf80438edaae8bc1635140b2 Mon Sep 17 00:00:00 2001 From: ccancellieri Date: Mon, 21 Jan 2013 19:03:10 +0100 Subject: [PATCH] backport to the 1.5.x branch --- .../geoserver/rest/GeoServerRESTManager.java | 9 ++ .../rest/GeoServerRESTPublisher.java | 2 +- .../encoder/GSPostGISDatastoreEncoder.java | 2 +- .../GeoServerRESTDataStoreManager.java | 98 +++++++++++++++++++ 4 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 src/main/java/it/geosolutions/geoserver/rest/manager/GeoServerRESTDataStoreManager.java diff --git a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTManager.java b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTManager.java index f18e4bc..4a4f968 100644 --- a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTManager.java +++ b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTManager.java @@ -25,6 +25,7 @@ package it.geosolutions.geoserver.rest; 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; @@ -84,4 +85,12 @@ public class GeoServerRESTManager extends GeoServerRESTAbstractManager { return store; } + /** + * + * @Deprecated use {GeoServerRESTManager#getStoreManager()} + */ + public GeoServerRESTDataStoreManager getDatastoreManager() { + return (GeoServerRESTDataStoreManager) store; + } + } diff --git a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java index 7589231..3f9c601 100644 --- a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java +++ b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java @@ -30,11 +30,11 @@ import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem; import it.geosolutions.geoserver.rest.encoder.GSBackupEncoder; import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder; import it.geosolutions.geoserver.rest.encoder.GSNamespaceEncoder; -import it.geosolutions.geoserver.rest.encoder.GSPostGISDatastoreEncoder; import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder; import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy; import it.geosolutions.geoserver.rest.encoder.GSWorkspaceEncoder; import it.geosolutions.geoserver.rest.encoder.coverage.GSCoverageEncoder; +import it.geosolutions.geoserver.rest.encoder.datastore.GSPostGISDatastoreEncoder; import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder; import java.io.File; diff --git a/src/main/java/it/geosolutions/geoserver/rest/encoder/GSPostGISDatastoreEncoder.java b/src/main/java/it/geosolutions/geoserver/rest/encoder/GSPostGISDatastoreEncoder.java index 0d85ff0..63766a2 100644 --- a/src/main/java/it/geosolutions/geoserver/rest/encoder/GSPostGISDatastoreEncoder.java +++ b/src/main/java/it/geosolutions/geoserver/rest/encoder/GSPostGISDatastoreEncoder.java @@ -35,7 +35,7 @@ import it.geosolutions.geoserver.rest.encoder.utils.PropertyXMLEncoder; * @author ETj * @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it * - * @deprecated Will be removed in next version 1.5.x. + * @deprecated Will be removed in next version 1.6.x. * Use {@link it.geosolutions.geoserver.rest.encoder.datastore.GSPostGISDatastoreEncoder} instead. */ public class GSPostGISDatastoreEncoder extends PropertyXMLEncoder { diff --git a/src/main/java/it/geosolutions/geoserver/rest/manager/GeoServerRESTDataStoreManager.java b/src/main/java/it/geosolutions/geoserver/rest/manager/GeoServerRESTDataStoreManager.java new file mode 100644 index 0000000..5d99a3d --- /dev/null +++ b/src/main/java/it/geosolutions/geoserver/rest/manager/GeoServerRESTDataStoreManager.java @@ -0,0 +1,98 @@ +/* + * 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.manager; + +import it.geosolutions.geoserver.rest.encoder.GSAbstractStoreEncoder; +import it.geosolutions.geoserver.rest.encoder.datastore.GSAbstractDatastoreEncoder; + +import java.net.MalformedURLException; +import java.net.URL; + +/** + * Manage datastores. + * + * To pass connection parameters, use the encoders derived from {@link GSAbstractDatastoreEncoder}. + * + * @author Oscar Fonts + * @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it + * + * @deprecated currently this is only a {@link GeoServerRESTStoreManager} wrapper for datastore + */ +public class GeoServerRESTDataStoreManager extends GeoServerRESTStoreManager { + + /** + * Default constructor. + * + * @param restURL GeoServer REST API endpoint + * @param username GeoServer REST API authorized username + * @param password GeoServer REST API password for the former username + * @throws MalformedURLException + * @throws IllegalArgumentException + */ + public GeoServerRESTDataStoreManager(URL restURL, String username, String password) + throws IllegalArgumentException, MalformedURLException { + super(restURL, username, password); + } + + /** + * Create a store. + * + * @param workspace Name of the workspace to contain the store. This will also be the prefix of any layer names contained in the store. + * @param datastore the set of parameters to be set to the store (including connection parameters). + * @return true if the store has been successfully created, false otherwise + * + * @deprecated use {@link GeoServerRESTStoreManager#create(String, GSAbstractStoreEncoder)} + */ + public boolean create(String workspace, GSAbstractDatastoreEncoder store) { + return super.create(workspace, store); + } + + /** + * Update a store. + * + * @param workspace Name of the workspace that contains the store. + * @param datastore the set of parameters to be set to the store (including connection parameters). + * @return true if the store has been successfully updated, false otherwise + * @deprecated use {@link GeoServerRESTStoreManager#update(String, GSAbstractStoreEncoder)} + */ + public boolean update(String workspace, GSAbstractDatastoreEncoder store) { + return super.update(workspace, store); + } + + /** + * 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 true if the CoverageStore was successfully removed. + * @throws MalformedURLException + */ + public boolean remove(final String workspace, final GSAbstractStoreEncoder store, + final boolean recurse) throws IllegalArgumentException, MalformedURLException { + + return super.remove(workspace, store, recurse); + } +}