cowbird.handlers.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

HANDLER_ADMIN_USER

HANDLER_ADMIN_PASSWORD

LOGGER

cowbird.handlers.impl.geoserver.HANDLER_ADMIN_USER = admin_user[source]
cowbird.handlers.impl.geoserver.HANDLER_ADMIN_PASSWORD = admin_password[source]
cowbird.handlers.impl.geoserver.LOGGER[source]
cowbird.handlers.impl.geoserver.geoserver_response_handling(func)[source]

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

Parameters

func – Function executing a http request to Geoserver

Returns

Response object

class cowbird.handlers.impl.geoserver.Geoserver(settings: cowbird.typedefs.SettingsType, name: str, **kwargs: Any)[source]

Bases: cowbird.handlers.handler.Handler, cowbird.monitoring.fsmonitor.FSMonitor

Keep Geoserver internal representation in sync with the platform.

Create the geoserver handler instance.

Parameters
  • settings – Cowbird settings for convenience

  • name – Handler name

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

Each handler 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(user_name)[source]
user_deleted(user_name)[source]
abstract permission_created(permission)[source]
abstract permission_deleted(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(filename)[source]

Call when a new file is found.

Parameters

filename – Relative filename of a new file

on_deleted(filename)[source]

Call when a file is deleted.

Parameters

filename – Relative filename of the removed file

on_modified(filename: str)None[source]

Call when a file is updated.

Parameters

filename – Relative filename of the updated file

create_workspace(name: Geoserver)None[source]

Create a new Geoserver workspace.

Parameters

name – Workspace name

remove_workspace(name: Geoserver)None[source]

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

Parameters

name – Workspace name

create_datastore(workspace_name: Geoserver)None[source]

Create a new Geoserver workspace.

Parameters
  • self – Geoserver instance

  • workspace_name – Workspace name where the datastore must be created

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

Publish a shapefile in the specified workspace.

Parameters
  • workspace_name – Name of the workspace from which the shapefile will be published

  • shapefile_name – The shapefile’s name, without file extension

validate_shapefile(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.

Parameters
  • workspace_name – Name of the workspace from which the shapefile will be published

  • shapefile_name – The shapefile’s name, without file extension

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

Remove a shapefile from the specified workspace.

Parameters
  • workspace_name – Name of the workspace from which the shapefile will be removed

  • filename – The shapefile’s name, without file extension

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

filename – Relative filename of a new file

Returns

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(workspace_name: str)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(workspace_name: Geoserver)requests.Response[source]

Request to create a new workspace.

Parameters

workspace_name – Name of workspace to be created

Returns

Response object

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

Request to remove workspace and all associated datastores and layers.

Parameters

workspace_name – Name of workspace to remove

Returns

Response object

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

Initial creation of the datastore with no connection parameters.

Parameters
  • workspace_name – Name of the workspace in which the datastore is created

  • datastore_name – Name of the datastore that will be created

Returns

Response object

_configure_datastore_request(workspace_name: Geoserver, 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.

Parameters
  • workspace_name – Name of the workspace in which the datastore is created

  • datastore_name – Name of the datastore that will be created

Returns

Response object

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

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

Parameters
  • workspace_name – Workspace where file will be published

  • datastore_name – Datastore where file will be published

  • filename – Name of the shapefile (with no extentions)

Returns

Response object

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

Request to remove specified Geoserver Feature type and corresponding layer.

Parameters
  • workspace_name – Workspace where file is published

  • datastore_name – Datastore where file is published

  • filename – Name of the shapefile (with no extentions)

Returns

Response object

cowbird.handlers.impl.geoserver.create_workspace(self, user_name)[source]
cowbird.handlers.impl.geoserver.create_datastore(self, datastore_name)[source]
cowbird.handlers.impl.geoserver.remove_workspace(self, workspace_name)[source]
cowbird.handlers.impl.geoserver.validate_shapefile(self, workspace_name, shapefile_name)[source]
cowbird.handlers.impl.geoserver.publish_shapefile(self, workspace_name, shapefile_name)[source]
cowbird.handlers.impl.geoserver.remove_shapefile(self, workspace_name, shapefile_name)[source]
exception cowbird.handlers.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.