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

org.vfny.geoserver.config.DataStoreConfig Maven / Gradle / Ivy

There is a newer version: 1.7.0
Show newest version
/* Copyright (c) 2001 - 2007 TOPP - www.openplans.org.  All rights reserved.
 * This code is licensed under the GPL 2.0 license, availible at the root
 * application directory.
 */
package org.vfny.geoserver.config;

import org.geotools.data.DataStore;
import org.geotools.data.DataStoreFactorySpi;
import org.vfny.geoserver.global.dto.DataStoreInfoDTO;
import org.vfny.geoserver.util.DataStoreUtils;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletContext;


/**
 * DataStoreInfo purpose.
 *
 * 

* Used to describe a datastore, typically one specified in the catalog.xml * config file. *

* *

* * @author dzwiers, Refractions Research, Inc. * @version $Id: DataStoreConfig.java 6326 2007-03-15 18:36:40Z jdeolive $ */ public class DataStoreConfig { /** unique datasore identifier */ private String id; /** unique namespace to refer to this datastore */ private String nameSpaceId; /** wether this data store is enabled */ private boolean enabled = true; /** a short description about this data store */ private String title; /** a short description about this data store */ private String _abstract; /** connection parameters to create the DataStoreInfo */ private Map connectionParams; /** Config ONLY! DataStoreFactory used to test params */ private DataStoreFactorySpi factory; /** * Create a new DataStoreConfig from a dataStoreId and factoryDescription * *

* Creates a DataStoreInfo to represent an instance with default data. *

* * @param dataStoreId Description of DataStore (see DataStoreUtils) * @param factoryDescription DOCUMENT ME! * * @see defaultSettings() */ public DataStoreConfig(String dataStoreId, String factoryDescription) { this(dataStoreId, DataStoreUtils.aquireFactory(factoryDescription)); } /** Creates a new DataStoreConfig for the provided factory. */ public DataStoreConfig(String dataStoreId, DataStoreFactorySpi factory) { this.factory = factory; id = dataStoreId; nameSpaceId = ""; enabled = true; title = ""; _abstract = ""; connectionParams = DataStoreUtils.defaultParams(factory); } /** * DataStoreInfo constructor. * *

* Creates a copy of the DataStoreInfoDTO provided. All the datastructures * are cloned. *

* * @param dto The datastore to copy. */ public DataStoreConfig(DataStoreInfoDTO dto) { reset(dto); } /** * Called to update Config class based on DTO information * * @param dto DOCUMENT ME! * * @throws NullPointerException DOCUMENT ME! */ public void reset(DataStoreInfoDTO dto) { if (dto == null) { throw new NullPointerException("Non null DataStoreInfoDTO required"); } factory = DataStoreUtils.aquireFactory(dto.getConnectionParams()); id = dto.getId(); nameSpaceId = dto.getNameSpaceId(); enabled = dto.isEnabled(); _abstract = dto.getAbstract(); connectionParams = new HashMap(dto.getConnectionParams()); } /** * Implement loadDTO. * *

* Populates the data fields with the DataStoreInfoDTO provided. *

* * @param ds the DataStoreInfoDTO to use. * * @throws NullPointerException DOCUMENT ME! * * @see org.vfny.geoserver.config.DataStructure#loadDTO(java.lang.Object) */ public void update(DataStoreInfoDTO ds) { if (ds == null) { throw new NullPointerException("DataStoreInfo Data Transfer Object required"); } id = ds.getId(); nameSpaceId = ds.getNameSpaceId(); enabled = ds.isEnabled(); _abstract = ds.getAbstract(); try { connectionParams = new HashMap(ds.getConnectionParams()); //clone? } catch (Exception e) { connectionParams = new HashMap(); } } /** * Implement toDTO. * *

* Create a DataStoreInfoDTO from the current config object. *

* * @return The data represented as a DataStoreInfoDTO * * @see org.vfny.geoserver.config.DataStructure#toDTO() */ public DataStoreInfoDTO toDTO() { DataStoreInfoDTO ds = new DataStoreInfoDTO(); ds.setId(id); ds.setNameSpaceId(nameSpaceId); ds.setEnabled(enabled); ds.setAbstract(_abstract); try { ds.setConnectionParams(new HashMap(connectionParams)); } catch (Exception e) { // default already created } return ds; } /** * getAbstract purpose. * *

* Description ... *

* * @return */ public String getAbstract() { return _abstract; } /** * getConnectionParams purpose. * *

* Description ... *

* * @return */ public Map getConnectionParams() { return connectionParams; } /** * isEnabled purpose. * *

* Description ... *

* * @return */ public boolean isEnabled() { return enabled; } /** * This is the DataStore ID * *

* *

* * @return */ public String getId() { return id; } /** * getNameSpace purpose. * *

* Description ... *

* * @return */ public String getNameSpaceId() { return nameSpaceId; } /** * getTitle purpose. * *

* Description ... *

* * @return */ public String getTitle() { return title; } /** * setAbstract purpose. * *

* Description ... *

* * @param string */ public void setAbstract(String string) { if (string != null) { _abstract = string; } } /** * setConnectionParams purpose. * *

* Description ... *

* * @param map */ public void setConnectionParams(Map map) { connectionParams = map; } /** * setEnabled purpose. * *

* Description ... *

* * @param b */ public void setEnabled(boolean b) { enabled = b; } /** * setNameSpace purpose. * *

* Description ... *

* * @param support */ public void setNameSpaceId(String support) { if (support != null) { nameSpaceId = support; } } /** * setTitle purpose. * *

* Description ... *

* * @param string */ public void setTitle(String string) { if (string != null) { title = string; } } // Access to Dyanmic Content /** * It would be nice if we did not throw this away - but life is too short * * @return Real DataStore generated by this DataStoreConfig * * @throws IOException If DataStore could not be aquired */ public DataStore findDataStore(ServletContext sc) throws IOException { return DataStoreUtils.acquireDataStore(connectionParams, sc); } /** * Get DataStoreFactorySpi used for this DataStoreConfig. * * @return DataStoreFactorySpi that this DataStoreConfig matches */ public DataStoreFactorySpi getFactory() { return factory; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy