A Research Data Repository Service for Managing Metadata Documents based on JSON or XML.
The following example shows the update of the metadata record. As mentioned before the ETag is needed:
metadata-record4json-v2.json:
{
"relatedResource": {
"identifier": "anyResourceId",
"identifierType": "INTERNAL"
},
"schema": {
"identifier": "my_first_json",
"identifierType": "INTERNAL"
},
"schemaVersion": "2",
"acl": [ {
"id":null,
"sid":"guest",
"permission":"READ"
} ]
}
metadata-v2.json:
{
"title": "My second JSON document",
"date": "2018-07-02"
}
$ curl 'http://localhost:8040/api/v1/metadata/6785ad43-9a17-40b5-9653-220a8232ef2f?version=1' -i -X PUT \
-H 'Content-Type: multipart/form-data' \
-H 'If-Match: "558661553"' \
-F 'record=@metadata-record4json-v2.json;type=application/json' \
-F 'document=@metadata-v2.json;type=application/xml' \
-F 'version=1'
You can see, that only the ACL entry for “guest” was added. All other properties are still the same. HTTP-wise the call looks as follows:
PUT /api/v1/metadata/6785ad43-9a17-40b5-9653-220a8232ef2f?version=1 HTTP/1.1
Content-Type: multipart/form-data; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
If-Match: "558661553"
Host: localhost:8040
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=version
1
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=record; filename=metadata-record4json-v2.json
Content-Type: application/json
{"id":"6785ad43-9a17-40b5-9653-220a8232ef2f","pid":null,"relatedResource":{"id":null,"identifier":"https://repo/anyResourceId","identifierType":"URL"},"createdAt":"2022-05-20T09:54:03Z","lastUpdate":"2022-05-20T09:54:03.45Z","schema":{"id":null,"identifier":"my_first_json","identifierType":"INTERNAL"},"schemaVersion":2,"recordVersion":1,"acl":[{"id":3,"sid":"SELF","permission":"ADMINISTRATE"}],"metadataDocumentUri":"http://localhost:8040/api/v1/metadata/6785ad43-9a17-40b5-9653-220a8232ef2f?version=1","documentHash":"sha1:97ac2fb17cd40aac07a55444dc161d615c70af8a"}
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=document; filename=metadata-v2.json
Content-Type: application/xml
{
"title": "My second JSON document",
"date": "2018-07-02"
}
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm--
You will get the new metadata record with the additional ACL entry. Version number of record was incremented by one and ‘lastUpdate’ was also modified by the server.
HTTP/1.1 200 OK
Location: http://localhost:8040/api/v1/metadata/6785ad43-9a17-40b5-9653-220a8232ef2f?version=2
ETag: "-2140772637"
Content-Type: application/json
Content-Length: 692
{
"id" : "6785ad43-9a17-40b5-9653-220a8232ef2f",
"relatedResource" : {
"identifier" : "https://repo/anyResourceId",
"identifierType" : "URL"
},
"createdAt" : "2022-05-20T09:54:03Z",
"lastUpdate" : "2022-05-20T09:54:03.677Z",
"schema" : {
"identifier" : "http://localhost:8040/api/v1/schemas/my_first_json?version=2",
"identifierType" : "URL"
},
"schemaVersion" : 2,
"recordVersion" : 2,
"acl" : [ {
"id" : 3,
"sid" : "SELF",
"permission" : "ADMINISTRATE"
} ],
"metadataDocumentUri" : "http://localhost:8040/api/v1/metadata/6785ad43-9a17-40b5-9653-220a8232ef2f?version=2",
"documentHash" : "sha1:1844c8057b673ae260fcc6b6ba146529b2b52771"
}
What you see is, that the metadata record looks different from the original document.
« PREVIOUS | NEXT » |
---|---|