All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.geosolutions.geoserver.rest.encoder.datastore.GSArcSDEDatastoreEncoder Maven / Gradle / Ivy

Go to download

GeoServer Manager is a library to interact with GeoServer The scope of this library is to have a simple API, and use as few external libs as possible.

There is a newer version: 1.8.7
Show newest version
/*
 *  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.datastore;

import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils;

/**
 * Encoder for an {@value #TYPE} datastore.
 *
 * @author Gianni Barrotta
 * @author Oscar Fonts
 * @version $Id: $
 */
public class GSArcSDEDatastoreEncoder extends GSAbstractDatastoreEncoder {

	static final String TYPE = "ArcSDE";
	
	static final String DEFAULT_DB_TYPE = "arcsde";
	static final int DEFAULT_PORT = 5151;
	static final int DEFAULT_MIN_CONNECTIONS = 2;
	static final int DEFAULT_MAX_CONNECTIONS = 6;
	static final int DEFAULT_CONNECTION_TIMEOUT = 500;
	static final boolean DEFAULT_ALLOW_NON_SPATIAL_TABLES = false;
 
    /**
     * Create an {@value #TYPE} datastore with default connection parameters,
     * given a store name, a server name, and a user name.
     *
     * The following default connection parameters are set:
     * 
    *
  • dbtype: {@value #DEFAULT_DB_TYPE} *
  • port: {@value #DEFAULT_PORT} *
  • pool.minConnections: {@value #DEFAULT_MIN_CONNECTIONS} *
  • pool.maxConnections: {@value #DEFAULT_MAX_CONNECTIONS} *
  • pool.timeOut: {@value #DEFAULT_CONNECTION_TIMEOUT} *
  • datastore.allowNonSpatialTables: {@value #DEFAULT_ALLOW_NON_SPATIAL_TABLES} *
* * @param name New datastore name * @param server New server name * @param user New user name */ public GSArcSDEDatastoreEncoder(String name, String server, String user) { super(name); // Set mandatory parameters setServer(server); setUser(user); // Set default values setDbType(DEFAULT_DB_TYPE); setPort(DEFAULT_PORT); setMinConnections(DEFAULT_MIN_CONNECTIONS); setMaxConnections(DEFAULT_MAX_CONNECTIONS); setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT); setAllowNonSpatialTables(DEFAULT_ALLOW_NON_SPATIAL_TABLES); } /** * Create an {@value #TYPE} datastore encoder from an existing store read from server. * * @param store The existing store. * @throws java.lang.IllegalArgumentException if store type or mandatory parameters are not valid */ public GSArcSDEDatastoreEncoder(RESTDataStore store) { super(store); // Check mandatory parameter validity ensureValidServer(store.getConnectionParameters().get("server")); ensureValidUser(store.getConnectionParameters().get("user")); } /** *

setDbType

* * @param dbtype a {@link java.lang.String} object. */ public void setDbType(String dbtype) { connectionParameters.set("dbtype", dbtype); } /** *

getDbType

* * @return a {@link java.lang.String} object. */ public String getDbType() { return ElementUtils.contains(connectionParameters.getRoot(), "dbtype").getTextTrim(); } /** *

setServer

* * @param server a {@link java.lang.String} object. */ public void setServer(String server) { ensureValidServer(server); connectionParameters.set("server", server); } /** *

getServer

* * @return a {@link java.lang.String} object. */ public String getServer() { return ElementUtils.contains(connectionParameters.getRoot(), "server").getTextTrim(); } /** *

setPort

* * @param port a int. */ public void setPort(int port) { connectionParameters.set("port", Integer.toString(port)); } /** *

getPort

* * @return a int. */ public int getPort() { return Integer.parseInt(ElementUtils.contains(connectionParameters.getRoot(), "port").getTextTrim()); } /** *

setInstance

* * @param instance a {@link java.lang.String} object. */ public void setInstance(String instance) { connectionParameters.set("instance", instance); } /** *

getInstance

* * @return a {@link java.lang.String} object. */ public String getInstance() { return ElementUtils.contains(connectionParameters.getRoot(), "instance").getTextTrim(); } /** *

setUser

* * @param user a {@link java.lang.String} object. */ public void setUser(String user) { ensureValidUser(user); connectionParameters.set("user", user); } /** *

getUser

* * @return a {@link java.lang.String} object. */ public String getUser() { return ElementUtils.contains(connectionParameters.getRoot(), "user").getTextTrim(); } /** *

setPassword

* * @param password a {@link java.lang.String} object. */ public void setPassword(String password) { connectionParameters.set("password", password); } /** *

getPassword

* * @return a {@link java.lang.String} object. */ public String getPassword() { return ElementUtils.contains(connectionParameters.getRoot(), "password").getTextTrim(); } /** *

setNamespace

* * @param namespace a {@link java.lang.String} object. */ public void setNamespace(String namespace) { connectionParameters.set("namespace", namespace); } /** *

getNamespace

* * @return a {@link java.lang.String} object. */ public String getNamespace() { return ElementUtils.contains(connectionParameters.getRoot(), "namespace").getTextTrim(); } /** *

setMinConnections

* * @param minConnections a int. */ public void setMinConnections(int minConnections) { connectionParameters.set("pool.minConnections", Integer.toString(minConnections)); } /** *

getMinConnections

* * @return a int. */ public int getMinConnections() { return Integer.parseInt(ElementUtils.contains(connectionParameters.getRoot(), "pool.minConnections").getTextTrim()); } /** *

setMaxConnections

* * @param maxConnections a int. */ public void setMaxConnections(int maxConnections) { connectionParameters.set("pool.maxConnections", Integer.toString(maxConnections)); } /** *

getMaxConnections

* * @return a int. */ public int getMaxConnections() { return Integer.parseInt(ElementUtils.contains(connectionParameters.getRoot(), "pool.maxConnections").getTextTrim()); } /** *

setConnectionTimeout

* * @param seconds a int. */ public void setConnectionTimeout(int seconds) { connectionParameters.set("pool.timeOut", Integer.toString(seconds)); } /** *

getConnectionTimeout

* * @return a int. */ public int getConnectionTimeout() { return Integer.parseInt(ElementUtils.contains(connectionParameters.getRoot(), "pool.timeOut").getTextTrim()); } /** *

setAllowNonSpatialTables

* * @param allowNonSpatialTables a boolean. */ public void setAllowNonSpatialTables(boolean allowNonSpatialTables) { connectionParameters.set("datastore.allowNonSpatialTables", Boolean.toString(allowNonSpatialTables)); } /** *

getAllowNonSpatialTables

* * @return a boolean. */ public boolean getAllowNonSpatialTables() { return Boolean.parseBoolean(ElementUtils.contains(connectionParameters.getRoot(), "datastore.allowNonSpatialTables").getTextTrim()); } /** * Check server validity. * * @param server the server name * @throws IllegalArgumentException if server name is null or empty */ private static void ensureValidServer(String server) { if (server == null || server.length() == 0) { throw new IllegalArgumentException( "ArcSDE store server name cannot be null or empty"); } } /** * Check user validity. * * @param user the user name * @throws IllegalArgumentException if user name is null or empty */ private static void ensureValidUser(String user) { if (user == null || user.length() == 0) { throw new IllegalArgumentException( "ArcSDE store user name cannot be null or empty"); } } /** *

getValidType

* * @return {@value #TYPE} */ protected String getValidType() { return TYPE; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy