eblondel / geonapi

R Interface to GeoNetwork API
https://github.com/eblondel/geonapi/wiki
Other
7 stars 2 forks source link

Create a metadata record #11

Closed LuciaSegovia closed 3 years ago

LuciaSegovia commented 3 years ago

I can't get the 'create a metadata record' piece of code running

`mdfile <- system.file("extdata/examples", "metadata.xml", package = "geonapi")

created = GN$insertMetadata(file = mdfile, group = "1", category = "datasets")

config <- GNPrivConfiguration$new()

config$setPrivileges("all", c("view","dynamic","featured"))

GN$setPrivConfiguration(id = created, config = config)

`

The object 'created' is NULL(empty)

Any idea why is this happening?

Thanks!!

eblondel commented 3 years ago

@LuciaSegovia The first thing to check is the operation performed behind the R code. For that you should enable logger = "DEBUG" when creating the GNManager. When running the insertmetadata R will print more verbose logs on the atual http operation that is performed to insert the metadata. Once you get this can you paste it here? Thanks

LuciaSegovia commented 3 years ago

Thanks for the reply! I have done it and this is what I got:

mdfile <- system.file("extdata/examples", "metadata.xml", package = "geonapi")

created = GN$insertMetadata(file = mdfile, group = "1", category = "datasets") [geonapi][INFO] Inserting metadata ... -> POST /geonetwork/srv/eng/xml.metadata.insert HTTP/1.1 -> Host: metadata.micronutrient.support -> Accept-Encoding: deflate, gzip -> Cookie: JSESSIONID=E0DF3DF40E0A6E77BF5095EC8B7B7BD7; XSRF-TOKEN=0195e0a7-48e4-40a0-a308-6fe1aa20be05; sessionExpiry=1609842517032; serverTime=1609842517032 -> Accept: application/json, text/xml, application/xml, / -> User-Agent: geonapi-0.4 -> Content-type: text/xml -> Authorization: Basic bHVjaWE6MDIvSnVuLzE5ODc= -> X-XSRF-TOKEN: 0195e0a7-48e4-40a0-a308-6fe1aa20be05 -> Content-Length: 18980 ->

my-metadata-identifier my-parent-metadata-identifier someone1 somewhere someposition1 myphonenumber1 myfacsimile1 theaddress thecity 111 France someone@theorg.org http://somelink someresourcename someone2 somewhere someposition2 myphonenumber2 myfacsimile2 theaddress thecity 111 France someone@theorg.org http://somelink someresourcename 2015-01-01T01:00:00 ISO 19115:2003/19139 1.0 my-dataset-identifier 4326 EPSG sometitle 2015-01-01 1.0 2015-01-01 identifier someone somewhere someposition myphonenumber myfacsimile theaddress thecity 111 France someone@theorg.org http://somelink somename abstract purpose credit1 credit2 someone somewhere someposition myphonenumber myfacsimile theaddress thecity 111 France someone@theorg.org http://somelink somename http://wwww.somefile.org/png1 Map Overview 1 image/png keyword1 keyword2 General 2015-01-01 limitation1 limitation2 limitation3 biota oceans true -180 180 -90 90 some additional information false eng false title alternate title 2015-01-01 http://somelink/featurecatalogue http://somelink1 WWW:LINK-1.0-http--link name1 description1 http://somelink2 WWW:LINK-1.0-http--link name2 description2 http://somelink3 WWW:LINK-1.0-http--link name3 description3 specification title specification alternate title 2015-01-01 some explanation about the conformance true statement ]]>1datasets_none_off

<- HTTP/1.1 500 <- Server: nginx/1.19.2 <- Date: Tue, 05 Jan 2021 10:29:01 GMT <- Content-Type: application/xml;charset=UTF-8 <- Transfer-Encoding: chunked <- Connection: keep-alive <- Set-Cookie: serverTime=1609842541285; Path=/ <- Set-Cookie: sessionExpiry=1609844641285; Path=/ <- X-Frame-Options: DENY <- Content-Security-Policy: frame-ancestors 'none' <- Pragma: no-cache <- Cache-Control: no-cache <- Expires: -1 <- Strict-Transport-Security: max-age=16070400; includeSubDomains <- Internal Server Error (HTTP 500).[geonapi][ERROR] <?xml version="1.0" encoding="UTF-8"?>

could not execute batch; SQL [insert into Metadata (data, changeDate, createDate, displayorder, doctype, extra, popularity, rating, root, schemaId, title, isTemplate, isHarvested, harvestUri, harvestUuid, groupOwner, owner, source, uuid, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; constraint [uk_e9w46i6v429h02tmynm3eefiy]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute batch DataIntegrityViolationException ... ... ... ... ... ... ... ... ... ... ... eng xml.metadata.insert
LuciaSegovia commented 3 years ago

There is a part that it doesn't show, I am not sure why... (Sorry, I'm quite new on this...)

eblondel commented 3 years ago

Do you know the version of the Geonetwork you use?

LuciaSegovia commented 3 years ago

It's 'GeoNetwork 3.10.4.0'

eblondel commented 3 years ago

Is your geonetwork available on the web so I can test? In case you can share with me the info by email.

LuciaSegovia commented 3 years ago

I've just sent you an email :)

LuciaSegovia commented 3 years ago

Hi @eblondel!

It worked!! I can add metadata now using your package!

Thanks v much!!

eblondel commented 3 years ago

Great to hear this @LuciaSegovia , thanks for reporting :-)