cowbird.services.impl.geoserver

Module Contents

Classes

Geoserver

Keep Geoserver internal representation in sync with the platform.

Functions

geoserver_response_handling(func)

Decorator for response and logging handling for the different Geoserver HTTP requests.

create_workspace(self, user_name)

create_datastore(self, datastore_name)

remove_workspace(self, workspace_name)

validate_shapefile(self, workspace_name, shapefile_name)

publish_shapefile(self, workspace_name, shapefile_name)

remove_shapefile(self, workspace_name, shapefile_name)

Attributes

SERVICE_ADMIN_USER

SERVICE_ADMIN_PASSWORD

LOGGER

cowbird.services.impl.geoserver.SERVICE_ADMIN_USER = admin_user[source]
cowbird.services.impl.geoserver.SERVICE_ADMIN_PASSWORD = admin_password[source]
cowbird.services.impl.geoserver.LOGGER[source]
cowbird.services.impl.geoserver.geoserver_response_handling(func)[source]

Decorator for response and logging handling for the different Geoserver HTTP requests.

@param func : Function executing a http request to Geoserver @return : Response object

class cowbird.services.impl.geoserver.Geoserver(settings: str, name: dict, **kwargs)[source]

Bases: cowbird.services.service.Service, cowbird.monitoring.fsmonitor.FSMonitor

Keep Geoserver internal representation in sync with the platform.

Create the geoserver service instance.

@param settings: Cowbird settings for convenience @param name: Service name

required_params[source]
abstract get_resource_id(self: str, resource_full_name)str[source]

Each service must provide this implementation required by the permission synchronizer.

The function needs to find the resource id in Magpie from the resource full name using its knowledge of the service. If the resource doesn’t already exist, the function needs to create it, again using its knowledge of resource type and parent resource type if required.

user_created(self, user_name)[source]
user_deleted(self, user_name)[source]
abstract permission_created(self, permission)[source]
abstract permission_deleted(self, permission)[source]
static get_instance()[source]

Return the Geoserver singleton instance from the class name used to retrieve the FSMonitor from the DB.

on_created(self, filename)[source]

Call when a new file is found.

Parameters

filename – Relative filename of a new file

on_deleted(self, filename)[source]

Call when a file is deleted.

Parameters

filename – Relative filename of the removed file

on_modified(self: str, filename)None[source]

Call when a file is updated.

Parameters

filename – Relative filename of the updated file

create_workspace(self: Geoserver, name: str)None[source]

Create a new Geoserver workspace.

@param name: Workspace name

remove_workspace(self: Geoserver, name: str)None[source]

Removes a workspace from geoserver. Will also remove all datastores associated with the workspace.

@param name: Workspace name

create_datastore(self: Geoserver, workspace_name: str)None[source]

Create a new Geoserver workspace.

@param self: Geoserver instance @param workspace_name: Workspace name where the datastore must be created

publish_shapefile(self: Geoserver, workspace_name: str, shapefile_name: str)None[source]

Publish a shapefile in the specified workspace.

@param workspace_name: Name of the workspace from which the shapefile will be published @param shapefile_name: The shapefile’s name, without file extension

validate_shapefile(self, workspace_name, shapefile_name)[source]

Validate shapefile. Will look for the three other files necessary for Geoserver publishing (.prj, .dbf, .shx) and raise a FileNotFoundError exception if one is missing.

@param workspace_name: Name of the workspace from which the shapefile will be published @param shapefile_name: The shapefile’s name, without file extension

remove_shapefile(self: Geoserver, workspace_name: str, filename: str)None[source]

Remove a shapefile from the specified workspace.

@param workspace_name: Name of the workspace from which the shapefile will be removed @param filename: The shapefile’s name, without file extension

static _get_shapefile_info(filename: str)Tuple[str, str][source]

@param filename: Relative filename of a new file @return: Workspace name (str) where file is located and shapefile name (str)

static _get_datastore_name(workspace_name: str)str[source]

Return datastore name used to represent the datastore inside Geoserver.

To be used in the HTTP requests sent to Geoserver. This name does not exist on the file system.

_shapefile_folder_dir(self: str, workspace_name)str[source]

Returns the path to the user’s shapefile datastore inside the file system.

static _geoserver_user_datastore_dir(user_name: str)str[source]

Returns the path to the user’s shapefile datastore inside the Geoserver instance container, ie.

where the WORKSPACE_DIR env variable is mapped in the Geoserver container.

_create_workspace_request(self: Geoserver, workspace_name: str)requests.Response[source]

Request to create a new workspace.

@param workspace_name: Name of workspace to be created @return: Response object

_remove_workspace_request(self: Geoserver, workspace_name: str)requests.Response[source]

Request to remove workspace and all associated datastores and layers.

@param workspace_name: Name of workspace to remove @return: Response object

_create_datastore_dir(self: str, workspace_name)None[source]
_create_datastore_request(self: Geoserver, workspace_name: str, datastore_name: str)requests.Response[source]

Initial creation of the datastore with no connection parameters.

@param workspace_name: Name of the workspace in which the datastore is created @param datastore_name: Name of the datastore that will be created @return: Response object

_configure_datastore_request(self: Geoserver, workspace_name: str, datastore_name: str, datastore_path: str)requests.Response[source]

Configures the connection parameters of the datastore.

This is done as a secondary step because Geoserver tends to create the wrong type of datastore (shapefile instead of directory of shapefiles) when setting them at creation.

@param workspace_name: Name of the workspace in which the datastore is created @param datastore_name: Name of the datastore that will be created @return: Response object

_publish_shapefile_request(self: Geoserver, workspace_name: str, datastore_name: str, filename: str)requests.Response[source]

Request to publish a shapefile in Geoserver. Does so by creating a Feature type in Geoserver.

@param workspace_name: Workspace where file will be published @param datastore_name: Datastore where file will be published @param filename: Name of the shapefile (with no extentions) @return: Response object

_remove_shapefile_request(self: Geoserver, workspace_name: str, datastore_name: str, filename: str)requests.Response[source]

Request to remove specified Geoserver Feature type and corresponding layer.

@param workspace_name: Workspace where file is published @param datastore_name: Datastore where file is published @param filename: Name of the shapefile (with no extentions) @return: Response object

cowbird.services.impl.geoserver.create_workspace(self, user_name)[source]
cowbird.services.impl.geoserver.create_datastore(self, datastore_name)[source]
cowbird.services.impl.geoserver.remove_workspace(self, workspace_name)[source]
cowbird.services.impl.geoserver.validate_shapefile(self, workspace_name, shapefile_name)[source]
cowbird.services.impl.geoserver.publish_shapefile(self, workspace_name, shapefile_name)[source]
cowbird.services.impl.geoserver.remove_shapefile(self, workspace_name, shapefile_name)[source]
exception cowbird.services.impl.geoserver.GeoserverError[source]

Bases: Exception

Generic Geoserver error used to break request chains, as RequestTask only retries for a specific exception (RequestException).

Initialize self. See help(type(self)) for accurate signature.