implementing-mapper.rst 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. .. _rest_services_implementing_mapper:
  2. Implementing a REST PathMapper
  3. ==============================
  4. In this section is described how to implement a new *RESTUploadPathMapper* sub-class.
  5. A *RESTUploadPathMapper* object is used for mapping the path of the uploaded files following new remapping policy. An example could be a Regular Expression remapping
  6. based on the input file name.
  7. This is the *RESTUploadPathMapper* interface::
  8. /**
  9. * Plugin interface used to transform the position of files during rest uploads
  10. */
  11. public interface RESTUploadPathMapper{
  12. /**
  13. * Remaps the position of a store path. The implementor is free to append, modify
  14. * or replace the store root directory, REST upload will append workspace/store to
  15. * it
  16. *
  17. * @throws IOException
  18. */
  19. public void mapStorePath(StringBuilder rootDir, String workspace, String store,
  20. Map<String, String> storeParams) throws IOException;
  21. /**
  22. * Remaps the position of a file inside a store (e.g., a image being harvested into
  23. * a mosaic. The implementor is free to alter the item path.
  24. *
  25. * @throws IOException
  26. */
  27. public void mapItemPath(String workspace, String store,
  28. Map<String, String> storeParams, StringBuilder itemPath, String itemName) throws IOException;
  29. }
  30. Implementation
  31. --------------
  32. Each implementation must follows these rules:
  33. * Remapping of the Root Directory requires to create a final root of the following structure::
  34. ${rootDirectory}/workspace/store
  35. * Developers can choose both the relative path of the file (if it is inside a zip directory structure) and the filename itself.
  36. * File remapping cannot return directories.
  37. * If additional parameters are required, they can be stored inside the Metadata Map of the Global, WorkSpace or Store settings.
  38. The steps for creating a new **RESTUploadPathMapper** implementation are:
  39. #. Extend the base implementation *RESTUploadPathMapperImpl* and create the desired PathMapper.
  40. #. Configure it as a Spring Bean inside the *applicationContext*. For example::
  41. <bean id="ECQLRUPathMapper" class="org.geoserver.rest.ecql.RESTUploadECQLPathMapper">
  42. <constructor-arg ref="catalog"/>
  43. </bean>
  44. If any optional parameter requires to be configured, then a GUI panel must be created using Wicket. The panel will be added to the Global and WorkSpace Settings configuration page.
  45. The steps for creating the GUI panel are:
  46. #. Creation of a new extension of the *SettingsPluginPanel* class.
  47. .. note:: Note that this panel must extract the parameters from the Metadata Map of the *settings* object.
  48. #. Definition of a Spring Bean which will be an instance of the *SettingsPluginPanelInfo* class and will have the class defined above as component class (*priority* property can be avoided). For example::
  49. <bean id="restECQLSettingsPanel" class="org.geoserver.web.data.settings.SettingsPluginPanelInfo">
  50. <description>This bean adds the necessary form fields to REST Settings</description>
  51. <property name="id" value="restECQLSettingsPanel"/>
  52. <property name="titleKey" value="restECQLsettings"/>
  53. <property name="componentClass" value="org.geoserver.rest.web.RESTECQLSettingsPanel"/>
  54. <property name="priority" value="1"/>
  55. </bean>
  56. #. Then the result will be added at the bottom of the GeoServer *Global Settings* and *Edit WorkSpace* Pages:
  57. .. figure:: settings.png