org.vfny.geoserver.global
Class Data

java.lang.Object
  extended byorg.vfny.geoserver.global.GlobalLayerSupertype
      extended byorg.vfny.geoserver.global.Data
All Implemented Interfaces:
org.geotools.data.Catalog

public class Data
extends org.vfny.geoserver.global.GlobalLayerSupertype
implements org.geotools.data.Catalog

This class stores all the information that a catalog would (and CatalogConfig used to).


Constructor Summary
Data(DataDTO config, java.io.File dir)
          Data constructor.
 
Method Summary
static java.lang.String get(java.util.Map map, java.lang.String key)
          get purpose.
static boolean get(java.util.Map map, java.lang.String key, boolean defaultValue)
          get purpose.
static java.nio.charset.Charset get(java.util.Map map, java.lang.String key, java.nio.charset.Charset defaultCharSet)
          get purpose.
static java.lang.Class get(java.util.Map map, java.lang.String key, java.lang.Class defaultType)
          get purpose.
static java.io.File get(java.util.Map map, java.lang.String key, java.io.File defaultFile)
          get purpose.
static int get(java.util.Map map, java.lang.String key, int defaultValue)
          get purpose.
static java.util.logging.Level get(java.util.Map map, java.lang.String key, java.util.logging.Level defaultLevel)
          get purpose.
static java.util.List get(java.util.Map map, java.lang.String key, java.util.List defaultList)
          get purpose.
static java.util.Map get(java.util.Map map, java.lang.String key, java.util.Map defaultMap)
          get purpose.
static java.lang.String get(java.util.Map map, java.lang.String key, java.lang.String defaultValue)
          get purpose.
static java.net.URL get(java.util.Map map, java.lang.String key, java.net.URL defaultUrl)
          get purpose.
 java.io.File getBaseDir()
          Returns the baseDir for use with relative paths.
 DataStoreInfo getDataStoreInfo(java.lang.String id)
          Locate a DataStoreInfo by its id attribute.
 java.util.Set getDataStores()
          Access to the set of DataStores in use by GeoServer.
 NameSpaceInfo getDefaultNameSpace()
          getDefaultNameSpace purpose.
 java.lang.String getDefaultPrefix()
          Prefix of the defaultNamespace.
 org.geotools.data.FeatureSource getFeatureSource(java.lang.String prefix, java.lang.String typeName)
          Convience method for Accessing FeatureSource by prefix:typeName.
 FeatureTypeInfo getFeatureTypeInfo(java.lang.String typeName)
          getFeatureTypeInfo purpose.
 FeatureTypeInfo getFeatureTypeInfo(java.lang.String namespacePrefix, java.lang.String uri)
          Gets a FeatureTypeInfo from a local type name (ie unprefixed), and a uri.
 java.util.Map getFeatureTypeInfos()
          Retrieve map of FeatureTypeInfo by prefix:typeName.
 NameSpaceInfo getNameSpace(java.lang.String prefix)
          getNameSpace purpose.
 org.geotools.data.NamespaceMetaData getNamespaceMetaData(java.lang.String prefix)
          Implement getNamespace.
 NameSpaceInfo[] getNameSpaces()
          getNameSpaces purpose.
 java.util.Set getPrefixes()
          Set of available Namespace prefixes.
 org.geotools.styling.Style getStyle(java.lang.String id)
           
 java.util.Map getStyles()
          getStyles purpose.
 org.geotools.styling.Style loadStyle(java.io.File fileName)
          Load GeoTools2 Style from a fileName
 org.geotools.styling.Style loadStyle(java.lang.String fileName, java.lang.String base)
           
 boolean lockExists(java.lang.String lockID)
          Implement lockExists.
 void lockRefresh(java.lang.String lockID)
          Refresh lock by authorization
 boolean lockRefresh(java.lang.String lockID, org.geotools.data.Transaction t)
          Implement lockRefresh.
 void lockRelease(java.lang.String lockID)
          Release lock by authorization
 boolean lockRelease(java.lang.String lockID, org.geotools.data.Transaction t)
          Implement lockRelease.
protected  java.lang.String notNull(java.lang.String s)
          checks s for nullity and if so, returns an empty String, else just returns s
 void registerDataStore(org.geotools.data.DataStore dataStore)
          Register a DataStore with this Catalog.
 java.util.Map statusDataStores()
          Dynamically tries to connect to every DataStore!
 java.util.Map statusNamespaces()
          Dynamically tries to connect to every Namespace!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Data

public Data(DataDTO config,
            java.io.File dir)
     throws ConfigurationException
Data constructor.

Creates a Data object from the data provided.

Parameters:
config - DataDTO initial data.
Throws:
ConfigurationException
Method Detail

statusDataStores

public java.util.Map statusDataStores()
Dynamically tries to connect to every DataStore!

Returns a map of Exception by dataStoreId:typeName. If by some marvel the we could connect to a FeatureSource we will record Boolean.TRUE.

Returns:
Map of Exception by dataStoreId:typeName

statusNamespaces

public java.util.Map statusNamespaces()
Dynamically tries to connect to every Namespace!

Returns a map of Exception by prefix:typeName. If by some marvel the we could connect to a FeatureSource we will record Boolean.TRUE.

Returns:
Map of Exception by prefix:typeName

getDataStoreInfo

public DataStoreInfo getDataStoreInfo(java.lang.String id)
Locate a DataStoreInfo by its id attribute.

Parameters:
id - the DataStoreInfo id looked for
Returns:
the DataStoreInfo with id attribute equals to id or null if there no exists

getNameSpaces

public NameSpaceInfo[] getNameSpaces()
getNameSpaces purpose.

List of all relevant namespaces

Returns:
NameSpaceInfo[]

getNameSpace

public NameSpaceInfo getNameSpace(java.lang.String prefix)
getNameSpace purpose.

The NameSpaceInfo from the specified prefix

Parameters:
prefix -
Returns:
NameSpaceInfo resulting from the specified prefix

getDefaultNameSpace

public NameSpaceInfo getDefaultNameSpace()
getDefaultNameSpace purpose.

Returns the default NameSpaceInfo for this Data object.

Returns:
NameSpaceInfo the default name space

getStyles

public java.util.Map getStyles()
getStyles purpose.

A reference to the map of styles

Returns:
Map A map containing the Styles.

getStyle

public org.geotools.styling.Style getStyle(java.lang.String id)

getFeatureTypeInfo

public FeatureTypeInfo getFeatureTypeInfo(java.lang.String typeName)
                                   throws java.util.NoSuchElementException
getFeatureTypeInfo purpose.

returns the FeatureTypeInfo for the specified unique name

Parameters:
typeName - String The FeatureTypeInfo Name
Returns:
FeatureTypeInfo
Throws:
java.util.NoSuchElementException

getFeatureTypeInfo

public FeatureTypeInfo getFeatureTypeInfo(java.lang.String namespacePrefix,
                                          java.lang.String uri)
Gets a FeatureTypeInfo from a local type name (ie unprefixed), and a uri.

This method is slow, use getFeatureType(String typeName), where possible. For not he only user should be TransactionFeatureHandler.

TODO: Jody here - David is this still correct?

Parameters:
namespacePrefix - Name NameSpaceInfo name
uri - NameSpaceInfo uri
Returns:
FeatureTypeInfo

getFeatureTypeInfos

public java.util.Map getFeatureTypeInfos()
Retrieve map of FeatureTypeInfo by prefix:typeName.

Returns all the featuretype information objects

Returns:
Map of FetureTypeInfo by prefix:typeName

loadStyle

public org.geotools.styling.Style loadStyle(java.lang.String fileName,
                                            java.lang.String base)
                                     throws java.io.IOException
Throws:
java.io.IOException

loadStyle

public org.geotools.styling.Style loadStyle(java.io.File fileName)
                                     throws java.io.IOException
Load GeoTools2 Style from a fileName

Parameters:
fileName - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

lockRelease

public void lockRelease(java.lang.String lockID)
Release lock by authorization

Parameters:
lockID -

lockRefresh

public void lockRefresh(java.lang.String lockID)
Refresh lock by authorization

Should use your own transaction?

Parameters:
lockID -

lockRefresh

public boolean lockRefresh(java.lang.String lockID,
                           org.geotools.data.Transaction t)
                    throws java.io.IOException
Implement lockRefresh.

Specified by:
lockRefresh in interface org.geotools.data.Catalog
Parameters:
lockID -
t -
Returns:
true if lock was found and refreshed
Throws:
java.io.IOException
See Also:
org.geotools.data.Data#lockRefresh(java.lang.String, org.geotools.data.Transaction)

lockRelease

public boolean lockRelease(java.lang.String lockID,
                           org.geotools.data.Transaction t)
                    throws java.io.IOException
Implement lockRelease.

Specified by:
lockRelease in interface org.geotools.data.Catalog
Parameters:
lockID -
t -
Returns:
true if the lock was found and released
Throws:
java.io.IOException
See Also:
org.geotools.data.Data#lockRelease(java.lang.String, org.geotools.data.Transaction)

lockExists

public boolean lockExists(java.lang.String lockID)
Implement lockExists.

Specified by:
lockExists in interface org.geotools.data.Catalog
Parameters:
lockID -
Returns:
true if lockID exists
See Also:
org.geotools.data.Data#lockExists(java.lang.String)

getPrefixes

public java.util.Set getPrefixes()
Set of available Namespace prefixes.

Specified by:
getPrefixes in interface org.geotools.data.Catalog
Returns:
Set of namespace Prefixes
See Also:
Catalog.getPrefixes()

getDefaultPrefix

public java.lang.String getDefaultPrefix()
Prefix of the defaultNamespace.

Specified by:
getDefaultPrefix in interface org.geotools.data.Catalog
Returns:
prefix of the default namespace
See Also:
Catalog.getDefaultPrefix()

getNamespaceMetaData

public org.geotools.data.NamespaceMetaData getNamespaceMetaData(java.lang.String prefix)
Implement getNamespace.

Description ...

Specified by:
getNamespaceMetaData in interface org.geotools.data.Catalog
Parameters:
prefix -
Returns:
See Also:
org.geotools.data.Catalog#getNamespace(java.lang.String)

registerDataStore

public void registerDataStore(org.geotools.data.DataStore dataStore)
                       throws java.io.IOException
Register a DataStore with this Catalog.

This is part of the public CatalogAPI, the fact that we don't want to support it here may be gounds for it's removal.

GeoSever and the global package would really like to have complete control over the DataStores in use by the application. It recognize that this may not always be possible. As GeoServer is extend with additional Modules (such as config) that wish to locate and talk to DataStores independently of GeoServer the best we can do is ask them to register with the this Catalog in global.

This reveals what may be a deisgn flaw in GeoTools2 DataStore. We have know way of knowing if the dataStore has already been placed into our care as DataStores are not good at identifying themselves. To complicate matters most keep a static connectionPool around in their Factory - it could be that the Factories are supposed to be smart enough to prevent duplication.

Specified by:
registerDataStore in interface org.geotools.data.Catalog
Parameters:
dataStore -
Throws:
java.io.IOException
See Also:
Catalog.registerDataStore(org.geotools.data.DataStore)

getDataStores

public java.util.Set getDataStores()
Access to the set of DataStores in use by GeoServer.

The provided Set may not be modified :-)

Specified by:
getDataStores in interface org.geotools.data.Catalog
Returns:
See Also:
org.geotools.data.Catalog#getDataStores(java.lang.String)

getFeatureSource

public org.geotools.data.FeatureSource getFeatureSource(java.lang.String prefix,
                                                        java.lang.String typeName)
                                                 throws java.io.IOException
Convience method for Accessing FeatureSource by prefix:typeName.

This method is part of the public Catalog API. It allows the Validation framework to be writen using only public Geotools2 interfaces.

Specified by:
getFeatureSource in interface org.geotools.data.Catalog
Parameters:
prefix - Namespace prefix in which the FeatureType available
typeName - typeNamed used to identify FeatureType
Returns:
Throws:
java.io.IOException - DOCUMENT ME!
See Also:
Catalog.getFeatureSource(java.lang.String, java.lang.String)

getBaseDir

public java.io.File getBaseDir()
Returns the baseDir for use with relative paths.

Returns:
Returns the baseDir.

notNull

protected java.lang.String notNull(java.lang.String s)
checks s for nullity and if so, returns an empty String, else just returns s

Parameters:
s - String
Returns:
String non-null String (null -> "")

get

public static java.lang.String get(java.util.Map map,
                                   java.lang.String key)
get purpose.

Gets a String from a map of Strings

Parameters:
map - Map the map to extract the string from
key - String the key for the map.
Returns:
String the value in the map.
See Also:
Map

get

public static java.io.File get(java.util.Map map,
                               java.lang.String key,
                               java.io.File defaultFile)
get purpose.

Gets a File from a map given the specified key. If the file is not found the default file is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultFile - The default value should the key not exist.
Returns:
File a File as described above.

get

public static java.lang.String get(java.util.Map map,
                                   java.lang.String key,
                                   java.lang.String defaultValue)
get purpose.

Gets a String from a map of Strings, and returns the default if the string does not exist.

Parameters:
map - Map the map to extract the string from
key - String the key for the map.
defaultValue - The default value should the key not exist.
Returns:
String the value in the map.
See Also:
Map

get

public static java.util.List get(java.util.Map map,
                                 java.lang.String key,
                                 java.util.List defaultList)
get purpose.

Gets a List from a map given the specified key. If the list is not found the default list is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultList - The default value should the key not exist.
Returns:
List a List as described above.

get

public static java.util.Map get(java.util.Map map,
                                java.lang.String key,
                                java.util.Map defaultMap)
get purpose.

Gets a Map from a map given the specified key. If the map is not found the default map is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultMap - The default value should the key not exist.
Returns:
Map a Map as described above.

get

public static int get(java.util.Map map,
                      java.lang.String key,
                      int defaultValue)
get purpose.

Gets a int from a map given the specified key. If the int is not found the default int is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultValue - The default value should the key not exist.
Returns:
int an int as described above.

get

public static boolean get(java.util.Map map,
                          java.lang.String key,
                          boolean defaultValue)
get purpose.

Gets a boolean from a map given the specified key. If the boolean is not found the default boolean is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultValue - The default value should the key not exist.
Returns:
boolean an boolean as described above.

get

public static java.nio.charset.Charset get(java.util.Map map,
                                           java.lang.String key,
                                           java.nio.charset.Charset defaultCharSet)
get purpose.

Gets a Charset from a map given the specified key. If the Charset is not found the default Charset is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultCharSet - The default value should the key not exist.
Returns:
Charset an boolean as described above.

get

public static java.util.logging.Level get(java.util.Map map,
                                          java.lang.String key,
                                          java.util.logging.Level defaultLevel)
get purpose.

Gets a Level from a map given the specified key. If the Level is not found the default Level is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultLevel - The default value should the key not exist.
Returns:
Level an boolean as described above.

get

public static java.net.URL get(java.util.Map map,
                               java.lang.String key,
                               java.net.URL defaultUrl)
get purpose.

Gets a URL from a map given the specified key. If the URL is not found the default URL is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultUrl - The default value should the key not exist.
Returns:
URL an boolean as described above.

get

public static java.lang.Class get(java.util.Map map,
                                  java.lang.String key,
                                  java.lang.Class defaultType)
get purpose.

Gets a Class from a map given the specified key. If the Class is not found the default Class is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultType - The default value should the key not exist.
Returns:
Class an boolean as described above.