org.geoserver.catalog.Catalog Maven / Gradle / Ivy
/* Copyright (c) 2001 - 2008 TOPP - www.openplans.org. All rights reserved.
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
package org.geoserver.catalog;
import java.util.Iterator;
import java.util.List;
import org.geoserver.catalog.event.CatalogListener;
import java.util.Collection;
/**
* The GeoServer catalog which provides access to meta information about the
* data served by GeoServer.
*
* The following types of metadata are stored:
*
* - namespaces and workspaces
*
- coverage (raster) and data (vector) stores
*
- coverages and feature resoures
*
- styles
*
*
* Workspaces
*
* A workspace is a container for any number of stores. All workspaces can be
* obtained with the {@link #getWorkspaces()}. A workspace is identified by its
* name ({@link WorkspaceInfo#getName()}). A workspace can be looked up by its
* name with the {@link #getWorkspaceByName(String)} method.
*
* Stores
*
* The {@link #getStores(Class)} method provides access to all the stores in
* the catalog of a specific type. For instance, the following would obtain
* all datstores from the catalog:
*
* //get all datastores
* List dataStores = catalog.getStores( DataStoreInfo.class );
*
* The methods {@link #getDataStores()} and {@link #getCoverageStores()} provide
* a convenience for the two well known types.
*
*
* A store is contained within a workspace (see {@link StoreInfo#getWorkspace()}).
* The {@link #getStoresByWorkspace(WorkspaceInfo, Class)} method for only stores
* contained with a specific workspace. For instance, the following would obtain
* all datastores store within a particular workspace:
*
* //get a workspace
* WorkspaceInfo workspace = catalog.getWorkspace( "myWorkspace" );
*
* //get all datastores in that workspace
* List dataStores = catalog.getStoresByWorkspace( workspace, DataStoreInfo.class );
*
*
* Resources
*
* The {@link #getResources(Class)} method provides access to all resources in
* the catalog of a particular type. For instance, to acess all feature types in
* the catalog:
*
* List featureTypes = catalog.getResources( FeatureTypeInfo.class );
*
* The {@link #getFeatureTypes()} and {@link #getCoverages()} methods are a convenience
* for the well known types.
*
*
* A resource is contained within a namespace, therefore it is identified by a
* namespace uri, local name pair. The {@link #getResourceByName(String, String, Class)}
* method provides access to a resource by its namespace qualified name. The method
* {@link #getResourceByName(String, Class)} provides access to a resource by its
* unqualified name. The latter method will do an exhaustive search of all namespaces
* for a resource with the specified name. If only a single resoure with the name
* is found it is returned. Some examples:
*
* //get a feature type by its qualified name
* FeatureTypeInfo ft = catalog.getResourceByName(
* "http://myNamespace.org", "myFeatureType", FeatureTypeInfo.class );
*
* //get a feature type by its unqualified name
* ft = catalog.getResourceByName( "myFeatureType", FeatureTypeInfo.class );
*
* //get all feature types in a namespace
* NamespaceInfo ns = catalog.getNamespaceByURI( "http://myNamespace.org" );
* List featureTypes = catalog.getResourcesByNamespace( ns, FeatureTypeINfo.class );
*
*
* Layers
*
* A layers is used to publish a resource. The {@link #getLayers()} provides access
* to all layers in the catalog. A layer is uniquely identified by its name. The
* {@link #getLayerByName(String)} method provides access to a layer by its name.
* The {@link #getLayers(ResourceInfo)} return all the layers publish a specific
* resource. Some examples:
*
* //get a layer by its name
* LayerInfo layer = catalog.getLayer( "myLayer" );
*
* //get all the layers for a particualr feature type
* FeatureTypeInfo ft = catalog.getFeatureType( "http://myNamespace", "myFeatureType" );
* List layers = catalog.getLayers( ft );
*
*
*
*
* Modifing the Catalog
*
* Catalog objects such as stores and resoures are mutable and can be modified.
* However, any modifications made on an object do not apply until they are saved.
* For instance, consider the following example of modifying a feature type:
*
* //get a feature type
* FeatureTypeInfo featureType = catalog.getFeatureType( "http://myNamespace.org", "myFeatureType" );
*
* //modify it
* featureType.setBoundingBox( new Envelope(...) );
*
* //save it
* catalog.save( featureType );
*
*
*
* @author Justin Deoliveira, The Open Planning project
*/
public interface Catalog {
/**
* The factory used to create catalog objects.
*
*/
CatalogFactory getFactory();
/**
* Adds a new store.
*/
void add(StoreInfo store);
/**
* Removes an existing store.
*/
void remove(StoreInfo store);
/**
* Saves a store that has been modified.
*/
void save(StoreInfo store);
/**
* Returns the store with the specified id.
*
* clazz is used to determine the implementation of StoreInfo
* which should be returned. An example which would return a data store.
*
*
* DataStoreInfo dataStore = catalog.getStore("id", DataStoreInfo.class);
*
*
*
* @param id The id of the store.
* @param clazz The class of the store to return.
*
* @return The store matching id, or null
if no such store exists.
*/
T getStore(String id, Class clazz);
/**
* Returns the store with the specified name.
*
* clazz is used to determine the implementation of StoreInfo
* which should be returned. An example which would return a data store.
*
*
* DataStoreInfo dataStore = catalog.getStore("name", DataStoreInfo.class);
*
*
*
* @param name The name of the store.
* @param clazz The class of the store to return.
*
* @return The store matching name, or null
if no such store exists.
*/
T getStoreByName(String name, Class clazz);
/**
* All stores in the catalog of the specified type.
*
*
* The clazz parameter is used to filter the types of stores
* returned. An example which would return all data stores:
*
*
*
* catalog.getStores(DataStoreInfo.class);
*
*
*
*
*
*/
List getStores(Class clazz);
/**
* All stores in the specified workspace of the given type.
*
* The clazz parameter is used to filter the types of stores
* returned. An example which would return all data stores in a specific
* workspace:
*
*
* WorkspaceInfo workspace = ...;
* List dataStores =
* catalog.getStores(workspace, DataStoreInfo.class);
*
*
*
*
*
* @param workspace The workspace containing returned stores.
* @param clazz The type of stores to lookup.
*
*/
List getStoresByWorkspace(WorkspaceInfo workspace,Class clazz);
/**
* Returns a datastore matching a particular id, or null
if
* no such data store could be found.
*
* This method is convenience for:
*
* getStore( id, DataStoreInfo.class );
*
*
*/
DataStoreInfo getDataStore(String id);
/**
* Returns a datastore matching a particular name, or null
if
* no such data store could be found.
*
* This method is a convenience for:
*
* getStoreByName(name, DataStoreInfo.class)
*
*
*/
DataStoreInfo getDataStoreByName(String name);
/**
* All data stores in the catalog.
*
* The resulting list should not be modified to add or remove stores, the
* {@link #add(StoreInfo)} and {@link #remove(StoreInfo)} are used for this
* purpose.
*
*/
List getDataStores();
/**
* Returns a coverage store matching a particular id, or null
* if no such coverage store could be found.
*
* This method is convenience for:
*
* getStore( id, CoverageStoreInfo.class );
*
*
*/
CoverageStoreInfo getCoverageStore(String id);
/**
* Returns a coverage store matching a particular name, or null
* if no such coverage store could be found.
*
* This method is a convenience for:
*
* getStoreByName(name, CoverageStoreInfo.class)
*
*
*
*
*/
CoverageStoreInfo getCoverageStoreByName(String name);
/**
* All coverage stores in the catalog.
*
* The resulting list should not be modified to add or remove stores, the
* {@link #add(StoreInfo)} and {@link #remove(StoreInfo)} are used for this
* purpose.
*
*/
List getCoverageStores();
/**
* Returns the resource with the specified id.
*
* clazz is used to determine the implementation of ResourceInfo
* which should be returned. An example which would return a feature type.
*
*
* FeatureTypeInfo ft = catalog.getResource("id", FeatureTypeInfo.class);
*
*
*
* @param id The id of the resource.
* @param clazz The class of the resource to return.
*
* @return The resource matching id, or null
if no such resource exists.
*/
T getResource(String id, Class clazz);
/**
* Looks up a resource by qualified name.
*
* ns may be specified as a namespace prefix or uri.
*
*
* clazz is used to determine the implementation of ResourceInfo
* which should be returned.
*
* @param ns
* The prefix or uri to which the resource belongs, may be
* null
.
* @param name
* The name of the resource.
* @param clazz
* The class of the resource.
*
* @return The resource matching the name, or null
if no such
* resource exists.
*/
T getResourceByName(String ns, String name,
Class clazz);
/**
* Looks up a resource by its unqualified name.
*
* The lookup rules used by this method are as follows:
*
* - If a resource in the default namespace is found matching the
* specified name, it is returned.
*
- If a single resource among all non-default namespaces is found
* matching the the specified name, it is returned.
*
* Care should be taken when using this method, use of {@link #getResourceByName(String, String, Class)}
* is preferred.
*
*
* @param name The name of the resource.
* @param clazz The type of the resource.
*
*/
T getResourceByName(String name, Class clazz);
/**
* Adds a new resource.
*/
void add(ResourceInfo resource);
/**
* Removes an existing resource.
*/
void remove(ResourceInfo resource);
/**
* Saves a resource which has been modified.
*/
void save(ResourceInfo resource);
/**
* All resources in the catalog of the specified type.
*
* The clazz parameter is used to filter the types of resources
* returned. An example which would return all feature types:
*
*
*
* catalog.getResources(FeatureTypeInfo.class);
*
*
*
*
*
*/
List getResources(Class clazz);
/**
* All resources in the specified namespace of the specified type.
*
* The clazz parameter is used to filter the types of resources
* returned. An example which would return all feature types:
*
*
* @param namespace
* The namespace.
* @param clazz
* The class of resources returned.
*
* @return List of resources of the specified type in the specified
* namespace.
*/
List getResourcesByNamespace(
NamespaceInfo namespace, Class clazz);
/**
* Returns the feature type matching a particular id, or null
* if no such feature type could be found.
*
* This method is convenience for:
*
* getResource( id, FeatureTypeInfo.class );
*
*
* @return The feature type matching the id, or null
if no
* such resource exists.
*/
FeatureTypeInfo getFeatureType(String id);
/**
* Looks up a feature type by qualified name.
*
* ns may be specified as a namespace prefix or uri.
*
*
* This method is convenience for:
*
* getResourceByName( ns, name, FeatureTypeInfo.class );
*
*
*
* @param ns
* The prefix or uri to which the feature type belongs, may
* be null
.
* @param name
* The name of the feature type.
*
* @return The feature type matching the name, or null
if no
* such resource exists.
*/
FeatureTypeInfo getFeatureTypeByName(String ns, String name);
/**
* Looks up a feature type by an unqualified name.
*
* The lookup rules used by this method are as follows:
*
* - If a feature type in the default namespace is found matching the
* specified name, it is returned.
*
- If a single feature type among all non-default namespaces is found
* matching the the specified name, it is returned.
*
* Care should be taken when using this method, use of {@link #getFeatureTypeByName(String, String)}
* is preferred.
*
*
* @param name The name of the feature type.
*
* @return The single feature type matching the specified name, or null
* if either none could be found or multiple were found.
*/
FeatureTypeInfo getFeatureTypeByName( String name );
/**
* ALl feature types in the catalog.
*
* This method is a convenience for:
*
*
*
* getResources(FeatureTypeInfo.class);
*
*
*
*
*
* The resulting list should not be used to add or remove resources from
* the catalog, the {@link #add(ResourceInfo)} and {@link #remove(ResourceInfo)}
* methods are used for this purpose.
*
*/
List getFeatureTypes();
/**
* All feature types in the specified namespace.
*
* This method is a convenience for:
*
* getResourcesByNamespace(namespace, FeatureTypeInfo.class);
*
*
*
*
* @param namespace
* The namespace of feature types to return.
*
* @return All the feature types in the specified namespace.
*/
List getFeatureTypesByNamespace(NamespaceInfo namespace);
/**
* Returns the coverage matching a particular id, or null
if
* no such coverage could be found.
*
* This method is a convenience for:
*
* getResource( id, CoverageInfo.class );
*
*
*/
CoverageInfo getCoverage(String id);
/**
* Looks up a coverage by qualified name.
*
* ns may be specified as a namespace prefix or uri.
*
*
* This method is convenience for:
*
* getResourceByName(ns,name,CoverageInfo.class);
*
*
*
* @param ns
* The prefix or uri to which the coverage belongs, may be
* null
.
* @param name
* The name of the coverage.
*
* @return The coverage matching the name, or null
if no such
* resource exists.
*/
CoverageInfo getCoverageByName(String ns, String name);
/**
* Looks up a coverage by an unqualified name.
*
* The lookup rules used by this method are as follows:
*
* - If a coverage in the default namespace is found matching the
* specified name, it is returned.
*
- If a single coverage among all non-default namespaces is found
* matching the the specified name, it is returned.
*
*
* Care should be taken when using this method, use of {@link #getCoverageByName(String, String)}
* is preferred.
*
*
* @param name The name of the coverage.
*
* @return The single coverage matching the specified name, or null
* if either none could be found or multiple were found.
*/
CoverageInfo getCoverageByName( String name );
/**
* All coverages in the catalog.
*
* This method is a convenience for:
*
*
*
* getResources(CoverageInfo.class);
*
*
*
*
*
*
* This method should not be used to add or remove coverages from the
* catalog. The {@link #add(ResourceInfo)} and {@link #remove(ResourceInfo)}
* methods are used for this purpose.
*
*/
List getCoverages();
/**
* Adds a new layer.
*/
void add(LayerInfo layer);
/**
* Removes an existing layer.
*/
void remove(LayerInfo layer);
/**
* Saves a layer which has been modified.
*/
void save(LayerInfo layer);
/**
* All coverages in the specified namespace.
*
* This method is a convenience for:
*
* getResourcesByNamespace(namespace, CoverageInfo.class);
*
*
*
*
* @param namespace
* The namespace of coverages to return.
*
* @return All the coverages in the specified namespace.
*/
List getCoveragesByNamespace(NamespaceInfo namespace);
/**
* Returns the layer matching a particular id, or null
if no
* such layer could be found.
*/
LayerInfo getLayer(String id);
/**
* Returns the layer matching a particular name, or null
if no
* such layer could be found.
*/
LayerInfo getLayerByName( String name );
/**
* All layers in the catalog.
*
* The resulting list should not be used to add or remove layers to or from
* the catalog, the {@link #add(LayerInfo)} and {@link #remove(LayerInfo)}
* methods are used for this purpose.
*
*
*/
List getLayers();
/**
* All layers in the catalog that publish the specified resource.
*
* @param resource The resource.
*
* @return A list of layers for the resource, or an empty list.
*/
List getLayers( ResourceInfo resource );
/**
* Adds a new map.
*/
void add(MapInfo map);
/**
* Removes an existing map.
*/
void remove(MapInfo map);
/**
* Saves a map which has been modified.
*/
void save( MapInfo map);
/**
* All maps in the catalog.
*
* The resulting list should not be used to add or remove maps to or from
* the catalog, the {@link #add(MapInfo)} and {@link #remove(MapInfo)} methods
* are used for this purpose.
*
*/
List getMaps();
/**
* Returns the map matching a particular id, or null
if no
* such map could be found.
*/
MapInfo getMap(String id);
/**
* Returns the map matching a particular name, or null
if no
* such map could be found.
*/
MapInfo getMapByName(String name);
/**
* Adds a layer group to the catalog.
*/
void add(LayerGroupInfo layerGroup);
/**
* Removes a layer group from the catalog.
*/
void remove(LayerGroupInfo layerGroup);
/**
* Saves changes to a modified layer group.
*/
void save(LayerGroupInfo layerGroup);
/**
* All layer groups in the catalog.
*/
List getLayerGroups();
/**
* Returns the layer group matching a particular id, or null
if no
* such group could be found.
*/
LayerGroupInfo getLayerGroup(String id);
/**
* Returns the layer group matching a particular name, or null
if no
* such group could be found.
*/
LayerGroupInfo getLayerGroupByName(String name);
/**
* Adds a new style.
*
*/
void add(StyleInfo style);
/**
* Removes a style.
*/
void remove(StyleInfo style);
/**
* Saves a style which has been modified.
*/
void save(StyleInfo style);
/**
* Returns the style matching a particular id, or null
if no
* such style could be found.
*/
StyleInfo getStyle(String id);
/**
* Returns the style matching a particular name, or null
if
* no such style could be found.
*
* @param name
* The name of the style to return.
*/
StyleInfo getStyleByName(String name);
/**
* All styles in the catalog.
*
* The resulting list should not be used to add or remove styles, the methods
* {@link #add(StyleInfo)} and {@link #remove(StyleInfo)} are used for that
* purpose.
*
*/
List getStyles();
/**
* Adds a new namespace.
*/
void add(NamespaceInfo namespace);
/**
* Removes an existing namespace.
*/
void remove(NamespaceInfo namespace);
/**
* Saves a namespace which has been modified.
*/
void save(NamespaceInfo namespace);
/**
* Returns the namespace matching the specified id.
*
*/
NamespaceInfo getNamespace(String id);
/**
* Looks up a namespace by its prefix.
*
* @see NamespaceInfo#getPrefix()
*/
NamespaceInfo getNamespaceByPrefix(String prefix);
/**
* Looks up a namespace by its uri.
*
* @see NamespaceInfo#getURI()
*/
NamespaceInfo getNamespaceByURI(String uri);
/**
* The default namespace of the catalog.
*
*/
NamespaceInfo getDefaultNamespace();
/**
* Sets the default namespace of the catalog.
*
* @param defaultNamespace
* The defaultNamespace to set.
*/
void setDefaultNamespace(NamespaceInfo defaultNamespace);
/**
* All namespaces in the catalog.
*
* The resulting list should not be used to add or remove namespaces from
* the catalog, the methods {@link #add(NamespaceInfo)} and {@link #remove(NamespaceInfo)}
* should be used for that purpose.
*
*/
List getNamespaces();
/**
* Adds a new workspace
*/
void add(WorkspaceInfo workspace);
/**
* Removes an existing workspace.
*/
void remove(WorkspaceInfo workspace);
/**
* Saves changes to an existing workspace.
*/
void save(WorkspaceInfo workspace);
/**
* The default workspace for the catalog.
*/
WorkspaceInfo getDefaultWorkspace();
/**
* Sets the default workspace for the catalog.
*/
void setDefaultWorkspace( WorkspaceInfo workspace );
/**
* All workspaces in the catalog.
*
* The resulting list should not be used to add or remove workspaces from
* the catalog, the methods {@link #add(WorkspaceInfo)} and {@link #remove(WorkspaceInfo)}
* should be used for that purpose.
*
*/
List getWorkspaces();
/**
* Returns a workspace by id, or null
if no such workspace
* exists.
*/
WorkspaceInfo getWorkspace( String id );
/**
* Returns a workspace by name, or null
if no such workspace
* exists.
*/
WorkspaceInfo getWorkspaceByName( String name );
/**
* catalog listeners.
*
*/
Collection getListeners();
/**
* Adds a listener to the catalog.
*/
void addListener(CatalogListener listener);
/**
* Removes a listener from the catalog.
*/
void removeListener(CatalogListener listener);
/**
* Returns the pool or cache for resources.
*
* This object is used to load physical resources like data stores, feature
* types, styles, etc...
*
*/
ResourcePool getResourcePool();
/**
* Sets the resource pool reference.
*/
void setResourcePool( ResourcePool resourcePool );
/**
* Disposes the catalog, freeing up any resources.
*/
void dispose();
}