From f21d695a59e7fb418addde44de800534858025c9 Mon Sep 17 00:00:00 2001 From: eblondel Date: Mon, 3 Apr 2023 14:22:00 +0200 Subject: [PATCH] #293 manage deletion if resource already exists --- inst/actions/geonode4R_publish_ogc_services.R | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/inst/actions/geonode4R_publish_ogc_services.R b/inst/actions/geonode4R_publish_ogc_services.R index e87f815c..72fe406d 100644 --- a/inst/actions/geonode4R_publish_ogc_services.R +++ b/inst/actions/geonode4R_publish_ogc_services.R @@ -40,6 +40,15 @@ function(action, entity, config){ #layername/sourcename layername <- if(!is.null(data_object$layername)) data_object$layername else entity$identifiers$id + #check if resources already exists + #------------------------------------------------------------------------------------------------- + resource = GEONODE$getResourceByUUID(uuid = entity$identifiers$id) + if(!is.null(resource)){ + config$logger.warn(sprintf("Resource '%s' (id = %s) already exists! Deleting it...", resource$uuid, resource$pk)) + deleted = GEONODE$deleteResource(id = resource$pk) + if(deleted) config$logger.warn(sprintf("Resource '%s' (id = %s) deleted!", resource$uuid, resource$pk)) + } + #upload #------------------------------------------------------------------------------------------------- if(data_object$upload){