Skip to content

TNPOA1 create, update, delete

Paolo Ciccarese edited this page Jan 9, 2015 · 1 revision

Creation of a comment

curl -i -X POST http://localhost:8090/s/annotation \
    -H "Content-Type: application/json" \
    -d'{"apiKey":"testkey","outCmd":"frame", "validate":"ON", "flavor":"OA", "item":{"@context":"https://raw.githubusercontent.com/Annotopia/AtSmartStorage/master/web-app/data/OAContext.json" ,"@id" : "urn:temp:001","@type" : "http://www.w3.org/ns/oa#Annotation","motivatedBy":"oa:commenting","annotatedBy":{"@id":"http://orcid.org/0000-0002-5156-2703","@type":"foaf:Person","foaf:name":"Paolo Ciccarese"},"annotatedAt":"2014-02-17T09:46:11EST","serializedBy":"urn:application:domeo","serializedAt":"2014-02-17T09:46:51EST", "hasBody" : {"@type" : ["cnt:ContentAsText", "dctypes:Text"],"cnt:chars": "This is Paolo Ciccarese''s CV","dc:format": "text/plain"},"hasTarget" : "http://paolociccarese.info"}}'

The server will return some a message similar to:

{
  ...
  "@graph" : [ {
    "@id" : "http://localhost:8090/s/annotation/ECDDC23C-FC40-4CF1-9A20-DC5750454B62",
    "@type" : "oa:Annotation",
    "permissions" : null,
    "http://purl.org/pav/previousVersion" : "urn:temp:001",
    "annotatedAt" : "2014-02-17T09:46:11EST",
    "annotatedBy" : {
      "@id" : "http://orcid.org/0000-0002-5156-2703",
      "@type" : "foaf:Person",
      "name" : "Paolo Ciccarese"
    },
    "hasBody" : {
      "@id" : "http://localhost:8090/s/content/8D49B806-74AC-4F7E-8282-8B6C2244AA85",
      "@type" : [ "cnt:ContentAsText", "dctypes:Text" ],
      "format" : "text/plain",
      "http://purl.org/pav/previousVersion" : "blank",
      "chars" : "This is Paolo Ciccareses CV"
    },
    "hasTarget" : "http://paolociccarese.info",
    "motivatedBy" : "oa:commenting",
    "serializedAt" : "2014-02-17T09:46:51EST",
    "serializedBy" : "urn:application:domeo"
  } ]
}]}}

From such message we pick the @graph[0].@id:

http://localhost:8090/s/annotation/ECDDC23C-FC40-4CF1-9A20-DC5750454B62

And we use it to compose the following message that consists in a PUT for updating the set.

Updating the comment

curl -i -X PUT http://localhost:8090/s/annotation \
    -H "Content-Type: application/json" \
    -d'{"apiKey":"testkey","outCmd":"frame", "validate":"ON", "flavor":"OA", "item":{"@context":"https://raw.githubusercontent.com/Annotopia/AtSmartStorage/master/web-app/data/OAContext.json" ,"@id" : "http://localhost:8090/s/annotation/ECDDC23C-FC40-4CF1-9A20-DC5750454B62","@type"  : "http://www.w3.org/ns/oa#Annotation","motivatedBy":"oa:commenting","annotatedBy":{"@id":"http://orcid.org/0000-0002-5156-2703","@type":"foaf:Person","foaf:name":"Paolo Ciccarese"},"annotatedAt":"2014-02-17T09:46:11EST","serializedBy":"urn:application:domeo","serializedAt":"2014-02-17T09:46:51EST", "hasBody" : {"@type" : ["cnt:ContentAsText", "dctypes:Text"],"cnt:chars": "This is Paolo Ciccarese''s Resume","dc:format": "text/plain"},"hasTarget" : "http://paolociccarese.info"}}'

Which returns something like

{ 
   ...
  "@graph" : [ {
    "@id" : "http://localhost:8090/s/annotation/ECDDC23C-FC40-4CF1-9A20-DC5750454B62",
    "@type" : "oa:Annotation",
    "permissions" : null,
    "annotatedAt" : "2014-02-17T09:46:11EST",
    "annotatedBy" : {
      "@id" : "http://orcid.org/0000-0002-5156-2703",
      "@type" : "foaf:Person",
      "name" : "Paolo Ciccarese"
    },
    "hasBody" : {
      "@id" : "_:b0",
      "@type" : [ "dctypes:Text", "cnt:ContentAsText" ],
      "format" : "text/plain",
      "chars" : "This is Paolo Ciccareses Resume"
    },
    "hasTarget" : "http://paolociccarese.info",
    "motivatedBy" : "oa:commenting",
    "serializedAt" : "2014-02-17T09:46:51EST",
    "serializedBy" : "urn:application:domeo"
  } ]
}]}}

Deleting the comment

For deleting the comment it is necessary to call a DELETE passing the URI of the annotation do be deleted as an argument.

curl -i -X DELETE http://localhost:8090/s/annotation \
    -H "Content-Type: application/json" \
    -d'{"apiKey":"testkey","uri":"http://localhost:8090/s/annotation/ECDDC23C-FC40-4CF1-9A20-DC5750454B62"}'