Open senoadiw opened 3 years ago
First, we should implement a separate method/methods that use the package_ or resource_patch API call to update the received WFS or WMS url accordingly to CKAN.
private static void updateUrlToCKAN(String wfsUrl, String wmsUrl, boolean useResourcePatch, String apiKey ...)
etc.
The API key we already have (https://github.com/geoenvo/oskari-server-extension-dps/blob/wb-idp/server-extension/src/main/java/wbidp/oskari/util/CKANLayerDataHandler.java#L296) and the url's for the GeoServer WFS/WMS are formed during the sync.
Second, the method call/calls for updating the url's to CKAN can be added somewhere around here: https://github.com/geoenvo/oskari-server-extension-dps/blob/wb-idp/server-extension/src/main/java/wbidp/oskari/util/CKANLayerDataHandler.java#L341-L343
You can of course add separate methods for adding WFS/WMS url and also for the different API calls to keep the methods clear and simple. Then you would just call the method accordingly depending on the added layer type and metadata. Which ever is more convenient.
We might need to add a check for the shape resource to determine if it contains the metadata separately or in the zip to decide which API call we use.
for datasets with the XML metadata uploaded as a separate file, update the "wms_url" and "wfs_url" on the dataset level using the package_patch API call (https://docs.ckan.org/en/2.8/api/index.html?highlight=package_patch#ckan.logic.action.patch.package_patch)for datasets with the XML metadata included in a zipped shapefile, update the "wms_url" and "wfs_url" on the resource level using the resource_patch API call (https://docs.ckan.org/en/2.8/api/index.html?highlight=package_patch#ckan.logic.action.patch.resource_patch)
API call example:
Refer to the following jsonl dataset dump: ckandatasetsdump.zip
dataset "test 1" has the XML metadata in a separate file, API call to update the wms_url and wfs_url fields on the dataset level ("26fc00fb-283e-490a-b858-7e02d9aac705" is the dataset id)dataset "test 2 metadata in zipped shapefile" has an embedded XML metadata file in a zipped shapefile, API call to update the wms_url and wfs_url fields on the resource level ("0b7f8caa-6d28-46f3-90fb-8c4edf1fc1a9" is the resource id)
20210909 revision: wms_url and wfs_url extra fields are now stored only on the resource level, so method 1 API call to package_patch is not necessary anymore