FIWARE / context.Orion-LD

Context Broker and CEF building block for context data management which supports both the NGSI-LD and the NGSI-v2 APIs
https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.06.01_60/gs_CIM009v010601p.pdf
GNU Affero General Public License v3.0
50 stars 43 forks source link

Problem with PATCH processing (update an attribute #799

Closed flopezag closed 3 years ago

flopezag commented 3 years ago

I am using the current latest version of Orion-LD:

{
    "compile_time": "Sun Apr 18 17:32:55 UTC 2021",
    "compiled_by": "root",
    "compiled_in": "buildkitsandbox",
    "doc": "https://fiware-orion.readthedocs.org/en/master/",
    "git_hash": "nogitversion",
    "orion version": "1.15.0-next",
    "orionld version": "post-v0.7",
    "release_date": "Sun Apr 18 17:32:55 UTC 2021",
    "uptime": "0 d, 0 h, 22 m, 37 s"
}

When I have tried to update an attribute of an entity that it was created previously following this request:

printf '{
  "@context": "https://smartdatamodels.org/context.jsonld",
  "id": "urn:ngsi-ld:Blower:Blower2",
  "type": "Blower",
  "name": {
    "type": "Property",
    "value": "Blower 2"
  },
  "description": {
    "type": "Property",
    "value": "Blower 2 providing aeration for wastewater treatment process."
  },
  "airflow": {
    "type": "Property",
    "value": 368.75
  },
  "energy": {
    "type": "Property",
    "value": 29.89
  },
  "pressure": {
    "type": "Property",
    "value": 84.06
  }
}' | http POST 'http://localhost:1026/ngsi-ld/v1/entities/' \
  Content-Type:'application/ld+json'

and now update the energy attribute, for example:

printf '{
      "type": "Property",
      "value": 28.87
}' | http PATCH http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Blower:Blower2/attrs/energy \
  Link:'<https://smartdatamodels.org/context.jsonld>'

I obtained an error:

HTTP/1.1 404 Not Found
Connection: Keep-Alive
Content-Length: 214
Content-Type: application/json
Date: Mon, 19 Apr 2021 14:22:28 GMT

{
    "detail": "Entity 'urn:ngsi-ld:Blower:Blower2', Attribute 'energy' (https://uri=fiware=org/ns/data-models#energy)",
    "title": "Entity/Attribute not found",
    "type": "https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound"
}

But I can request the concrete information of that entity:

http http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Blower:Blower2
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 485
Content-Type: application/ld+json
Date: Mon, 19 Apr 2021 14:17:07 GMT

{
    "@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld",
    "airflow": {
        "type": "Property",
        "value": 368.75
    },
    "description": {
        "type": "Property",
        "value": "Blower 2 providing aeration for wastewater treatment process."
    },
    "https://uri.fiware.org/ns/data-models#energy": {
        "type": "Property",
        "value": 29.89
    },
    "https://uri.fiware.org/ns/data-models#pressure": {
        "type": "Property",
        "value": 84.06
    },
    "id": "urn:ngsi-ld:Blower:Blower2",
    "name": {
        "type": "Property",
        "value": "Blower 2"
    },
    "type": "Blower"
}

I repeated the process but using the docker image with tag 0.7-PRE-115, and I can update the property of the entity:

printf '{
      "type": "Property",
      "value": 8.87
}' | http PATCH http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Blower:Blower2/attrs/energy \
  Link:'<https://smartdatamodels.org/context.jsonld>'
HTTP/1.1 204 No Content
Connection: Keep-Alive
Date: Mon, 19 Apr 2021 14:43:25 GMT

and requesting the information about that entity, I can confirm that it was updated:

http http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Blower:Blower2
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 484
Content-Type: application/ld+json
Date: Mon, 19 Apr 2021 14:57:41 GMT

{
    "@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld",
    "airflow": {
        "type": "Property",
        "value": 368.75
    },
    "description": {
        "type": "Property",
        "value": "Blower 2 providing aeration for wastewater treatment process."
    },
    "https://uri.fiware.org/ns/data-models#energy": {
        "type": "Property",
        "value": 8.87
    },
    "https://uri.fiware.org/ns/data-models#pressure": {
        "type": "Property",
        "value": 84.06
    },
    "id": "urn:ngsi-ld:Blower:Blower2",
    "name": {
        "type": "Property",
        "value": "Blower 2"
    },
    "type": "Blower"
}
kzangeli commented 3 years ago

We tested it together and there was no problem after all - false alarm