datastores.rst 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. .. _rest_api_datastores:
  2. Data stores
  3. ===========
  4. A ``data store`` contains vector format spatial data. It can be a file (such as a shapefile), a database (such as PostGIS), or a server (such as a :ref:`remote Web Feature Service <data_external_wfs>`).
  5. ``/workspaces/<ws>/datastores[.<format>]``
  6. ------------------------------------------
  7. Controls all data stores in a given workspace.
  8. .. list-table::
  9. :header-rows: 1
  10. * - Method
  11. - Action
  12. - Status code
  13. - Formats
  14. - Default Format
  15. * - GET
  16. - List all data stores in workspace ``ws``
  17. - 200
  18. - HTML, XML, JSON
  19. - HTML
  20. * - POST
  21. - Create a new data store
  22. - 201 with ``Location`` header
  23. - XML, JSON
  24. -
  25. * - PUT
  26. -
  27. - 405
  28. -
  29. -
  30. * - DELETE
  31. -
  32. - 405
  33. -
  34. -
  35. ``/workspaces/<ws>/datastores/<ds>[.<format>]``
  36. -----------------------------------------------
  37. Controls a particular data store in a given workspace.
  38. .. list-table::
  39. :header-rows: 1
  40. * - Method
  41. - Action
  42. - Status code
  43. - Formats
  44. - Default Format
  45. - Parameters
  46. * - GET
  47. - Return data store ``ds``
  48. - 200
  49. - HTML, XML, JSON
  50. - HTML
  51. - :ref:`quietOnNotFound <rest_api_datastores_quietOnNotFound>`
  52. * - POST
  53. -
  54. - 405
  55. -
  56. -
  57. -
  58. * - PUT
  59. - Modify data store ``ds``
  60. -
  61. -
  62. -
  63. -
  64. * - DELETE
  65. - Delete data store ``ds``
  66. -
  67. -
  68. -
  69. - :ref:`recurse <rest_api_datastores_recurse>`
  70. Exceptions
  71. ~~~~~~~~~~
  72. .. list-table::
  73. :header-rows: 1
  74. * - Exception
  75. - Status code
  76. * - GET for a data store that does not exist
  77. - 404
  78. * - PUT that changes name of data store
  79. - 403
  80. * - PUT that changes workspace of data store
  81. - 403
  82. * - DELETE against a data store that contains configured feature types
  83. - 403
  84. Parameters
  85. ~~~~~~~~~~
  86. .. _rest_api_datastores_recurse:
  87. ``recurse``
  88. ^^^^^^^^^^^
  89. The ``recurse`` parameter recursively deletes all layers referenced by the specified data store. Allowed values for this parameter are "true" or "false". The default value is "false".
  90. .. _rest_api_datastores_quietOnNotFound:
  91. ``quietOnNotFound``
  92. ^^^^^^^^^^^^^^^^^^^^
  93. The ``quietOnNotFound`` parameter avoids to log an Exception when the data store is not present. Note that 404 status code will be returned anyway.
  94. ``/workspaces/<ws>/datastores/<ds>/[file|url|external][.<extension>]``
  95. ----------------------------------------------------------------------
  96. These endpoints (``file``, ``url``, and ``external``) allow a file containing either spatial data or a mapping configuration (in case an app-schema data store is targeted), to be added (via a PUT request) into an existing data store, or will create a new data store if it doesn't already exist. The three endpoints are used to specify the method that is used to upload the file:
  97. * ``file``—Uploads a file from a local source. The body of the request is the file itself.
  98. * ``url``—Uploads a file from an remote source. The body of the request is a URL pointing to the file to upload. This URL must be visible from the server.
  99. * ``external``—Uses an existing file on the server. The body of the request is the absolute path to the existing file.
  100. .. list-table::
  101. :header-rows: 1
  102. * - Method
  103. - Action
  104. - Status code
  105. - Formats
  106. - Default Format
  107. - Parameters
  108. * - GET
  109. - *Deprecated*. Retrieve the underlying files for the data store as a zip file with MIME type ``application/zip``
  110. - 200
  111. -
  112. -
  113. -
  114. * - POST
  115. -
  116. - 405
  117. -
  118. -
  119. -
  120. * - PUT
  121. - Uploads files to the data store ``ds``, creating it if necessary
  122. - 200
  123. - :ref:`See note below <rest_api_datastores_file_put>`
  124. -
  125. - :ref:`configure <rest_api_datastores_configure>`, :ref:`target <rest_api_datastores_target>`, :ref:`update <rest_api_datastores_update>`, :ref:`charset <rest_api_datastores_charset>`
  126. * - DELETE
  127. -
  128. - 405
  129. -
  130. -
  131. -
  132. Exceptions
  133. ~~~~~~~~~~
  134. .. list-table::
  135. :header-rows: 1
  136. * - Exception
  137. - Status code
  138. * - GET for a data store that does not exist
  139. - 404
  140. * - GET for a data store that is not file based
  141. - 404
  142. Parameters
  143. ~~~~~~~~~~
  144. .. _rest_api_datastores_extension:
  145. ``extension``
  146. ^^^^^^^^^^^^^
  147. The ``extension`` parameter specifies the type of data being uploaded. The following extensions are supported:
  148. .. list-table::
  149. :header-rows: 1
  150. * - Extension
  151. - Datastore
  152. * - shp
  153. - Shapefile
  154. * - properties
  155. - Property file
  156. * - h2
  157. - H2 Database
  158. * - appschema
  159. - App-schema mapping configuration
  160. .. _rest_api_datastores_file_put:
  161. File PUT
  162. ^^^^^^^^
  163. A file can be PUT to a data store as a standalone or zipped archive file. Standalone files are only suitable for data stores that work with a single file such as a GML store. Data stores that work with multiple files, such as the shapefile store, must be sent as a zip archive.
  164. When uploading a standalone file, set the ``Content-type`` appropriately based on the file type. If you are loading a zip archive, set the ``Content-type`` to ``application/zip``.
  165. .. _rest_api_datastores_file_put_appschema:
  166. file PUT Application Schema
  167. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  168. The app-schema mapping configuration can either be uploaded as a single file, or split in multiple files for reusability and/or mapping constraints (e.g. multiple mappings of the same feature type are needed). If multiple mapping files are uploaded as a zip archive, the extension of the main mapping file (the one including the others via the ``<includedTypes>`` tag) must be ``.appschema``, otherwise it will not be recognized as the data store's primary file and publishing will fail.
  169. The application schemas (XSD files) required to define the mapping can be added to the zip archive and uploaded along with the mapping configuration. All files contained in the archive are uploaded to the same folder, so the path to the secondary mapping files and the application schemas, as specified in the main mapping file, is simply the file name of the included resource.
  170. .. _rest_api_datastores_configure:
  171. ``configure``
  172. ^^^^^^^^^^^^^
  173. The ``configure`` parameter controls how the data store is configured upon file upload. It can take one of the three values:
  174. * ``first``—(*Default*) Only setup the first feature type available in the data store.
  175. * ``none``—Do not configure any feature types.
  176. * ``all``—Configure all feature types.
  177. .. note::
  178. When uploading an app-schema mapping configuration, only the feature types mapped in the main mapping file are considered to be top level features and will be automatically configured when ``configure=all`` or ``configure=first`` is specified.
  179. .. _rest_api_datastores_target:
  180. ``target``
  181. ^^^^^^^^^^
  182. The ``target`` parameter determines what format or storage engine will be used when a new data store is created on the server for uploaded data. When importing data into an existing data store, it is ignored. The allowed values for this parameter are the same as for the :ref:`extension parameter <rest_api_datastores_extension>`, except for ``appschema``, which doesn't make sense in this context.
  183. .. _rest_api_datastores_update:
  184. ``update``
  185. ^^^^^^^^^^
  186. The ``update`` parameter controls how existing data is handled when the file is PUT into a data store that already exists and already contains a schema that matches the content of the file. The parameter accepts one of the following values:
  187. * ``append``—Data being uploaded is appended to the existing data. This is the default.
  188. * ``overwrite``—Data being uploaded replaces any existing data.
  189. The parameter is ignored for app-schema data stores, which are read-only.
  190. .. _rest_api_datastores_charset:
  191. ``charset``
  192. ^^^^^^^^^^^
  193. The ``charset`` parameter specifies the character encoding of the file being uploaded (such as "ISO-8559-1").