@@ -43,7 +43,7 @@ function(action, entity, config){
43
43
44
44
# check if resources already exists
45
45
# -------------------------------------------------------------------------------------------------
46
- resource = GEONODE $ getResourceByUUID(uuid = entity $ identifiers $ id )
46
+ resource = GEONODE $ getResourceByUUID(uuid = entity $ identifiers [[ " uuid " ]] )
47
47
if (! is.null(resource )){
48
48
config $ logger.warn(sprintf(" Resource '%s' (id = %s) already exists! Deleting it..." , resource $ uuid , resource $ pk ))
49
49
deleted = GEONODE $ deleteResource(id = resource $ pk )
@@ -67,8 +67,21 @@ function(action, entity, config){
67
67
config $ logger.info(sprintf(" Upload file '%s' [%s] to GeoNode..." , filepath , data_object $ uploadType ))
68
68
files = list.files(path = " data" , pattern = datasource_name , full.names = TRUE )
69
69
files = files [! endsWith(files , " .zip" )]
70
- created = GEONODE $ upload(files )
71
- uploaded = created $ success
70
+ dir.create(" data/temp" )
71
+ for (file in files ){
72
+ file_ext = unlist(strsplit(file , " \\ ." ))[2 ]
73
+ target = file.path(getwd(), " data/temp" , paste0(layername , " ." , file_ext ))
74
+ file.copy(from = file , to = target , copy.mode = T )
75
+ if (file_ext == " xml" ){
76
+ # post-process metadata identifier if existing to match entity uuid
77
+ md = geometa :: readISO19139(target )
78
+ md $ fileIdentifier <- entity $ identifiers [[" uuid" ]]
79
+ md $ save(target )
80
+ }
81
+ }
82
+ created = GEONODE $ upload(files = list.files(path = " data/temp" , pattern = layername , full.names = TRUE ))
83
+ uploaded = ! is.null(created $ dataset )
84
+ unlink(" data/temp" ,recursive = TRUE , force = TRUE )
72
85
}else {
73
86
errMsg <- sprintf(" Upload from local file(s): no zipped file found for source '%s' (%s)" , filepath , datasource )
74
87
config $ logger.error(errMsg )
0 commit comments