Regards,
Our problem is ‘a priori’ related to the GE implementation Orion Context Broker. Our version Orion Context Broker: 0.14.0.
We have a Web Service which we have implemented, sending data collected by a number of dispositives, to a machine that we have deployed in our account Fi-ware Platform. The problem that has been presented to us is that one of the attributes we are setting is a type attribute “coords” and when we are trying to make an update of the entity, does not allow us to update that attribute, and gives the following error (see below, a part of the response). We also want to update this field.
</contextAttribute>
<contextAttribute>
<name>android_version</name>
<type />
<contextValue />
</contextAttribute>
<contextAttribute>
<name>date</name>
<type />
<contextValue />
</contextAttribute>
<contextAttribute>
<name>position</name>
<type>coords</type>
<contextValue />
<metada>
<contextMetadata>
<name>location</name>
<type>string</type>
<value>WSG84</value>
</contextMetadata>
</metada>
</contextAttribute>
</contextAttributeList>
</contextElement>
<statusCode>
<code>472</code>
<reasonPhrase>request parameter is invalid/not allowed</reasonPhrase>
<details>action:UPDATE - entity: (300000000000008, dispositivo) - offending attribute: position - location attribute has to be defined at creation time, with APPEND</details>
</statusCode>
</contextElementResponse>
The REST request that we are setting to the ContextBroker and which is giving us problems is:
public static String payloadUpdateTemplate =
@"<updateContextRequest>
<contextElementList>
<contextElement>
<entityId type='dispositivo' isPattern='false'>
<id>{0}</id>
</entityId>
<contextAttributeList>
<contextAttribute>
<name>temperature</name>
<type>Cº</type>
<contextValue>{1}</contextValue>
</contextAttribute>
<contextAttribute>
<name>latitude</name>
<type>φ</type>
<contextValue>{2}</contextValue>
</contextAttribute>
<contextAttribute>
<name>longitude</name>
<type>λ</type>
<contextValue>{3}</contextValue>
</contextAttribute>
<contextAttribute>
<name>altitude</name>
<type>m</type>
<contextValue>{4}</contextValue>
</contextAttribute>
<contextAttribute>
<name>acceleration</name>
<type>m/s²</type>
<contextValue>{5}</contextValue>
</contextAttribute>
<contextAttribute>
<name>android_version</name>
<type></type>
<contextValue>{6}</contextValue>
</contextAttribute>
<contextAttribute>
<name>date</name>
<type></type>
<contextValue>{7}</contextValue>
</contextAttribute>
<contextAttribute>
<name>position</name>
<type>coords</type>
<contextValue>{2}, {3}</contextValue>
<metadata>
<contextMetadata>
<name>location</name>
<type>string</type>
<value>WSG84</value>
</contextMetadata>
</metadata>
</contextAttribute>
</contextAttributeList>
</contextElement>
</contextElementList>
<updateAction>UPDATE</updateAction>
</updateContextRequest>";
Yes, we have previously created the entity that we are trying to update, using updateContext operation with APPEND action type. The payload that we are using to do entity creation is:
public static String payloadInsertTemplate =
@"<updateContextRequest>
<contextElementList>
<contextElement>
<entityId type='dispositivo' isPattern='false'>
<id>{0}</id>
</entityId>
<contextAttributeList>
<contextAttribute>
<name>temperature</name>
<type>Cº</type>
<contextValue>{1}</contextValue>
</contextAttribute>
<contextAttribute>
<name>latitude</name>
<type>φ</type>
<contextValue>{2}</contextValue>
</contextAttribute>
<contextAttribute>
<name>longitude</name>
<type>λ</type>
<contextValue>{3}</contextValue>
</contextAttribute>
<contextAttribute>
<name>altitude</name>
<type>m</type>
<contextValue>{4}</contextValue>
</contextAttribute>
<contextAttribute>
<name>acceleration</name>
<type>m/s²</type>
<contextValue>{5}</contextValue>
</contextAttribute>
<contextAttribute>
<name>android_version</name>
<type></type>
<contextValue>{6}</contextValue>
</contextAttribute>
<contextAttribute>
<name>date</name>
<type></type>
<contextValue>{7}</contextValue>
</contextAttribute>
<contextAttribute>
<name>position</name>
<type>coords</type>
<contextValue>{2}, {3}</contextValue>
<metadata>
<contextMetadata>
<name>location</name>
<type>string</type>
<value>WSG84</value>
</contextMetadata>
</metadata>
</contextAttribute>
</contextAttributeList>
</contextElement>
</contextElementList>
<updateAction>APPEND</updateAction>
</updateContextRequest>";
We are using a REST Web Service. The literal {0} in the payload identifies each entity of the context. For example, if the ID of a dispositivo is 1111, the literal {0} will be 1111. In the other side, if the code of a sensor is 2222, the literal {0} will be 2222. The literal {0} is an identification key (unique and not null).
More information,
1) First of all, we insert a new entity with the following payload. The literal {0} is the ID of the entity, for example, id(entity) = 30000000000002. The literal {1} is the current value of the temperature of the entity Id, for example, temperature(entity) = 30,0.
public static String payloadInsertTemplate =
@"<updateContextRequest>
<contextElementList>
<contextElement>
<entityId type='dispositivo' isPattern='false'>
<id>{0}</id>
</entityId>
<contextAttributeList>
<contextAttribute>
<name>temperature</name>
<type>Cº</type>
<contextValue>{1}</contextValue>
</contextAttribute>
.
.
.
.
<contextAttribute>
<name>position</name>
<type>coords</type>
<contextValue>{2}, {3}</contextValue>
<metadata>
<contextMetadata>
<name>location</name>
<type>string</type>
<value>WSG84</value>
</contextMetadata>
</metadata>
</contextAttribute>
</contextAttributeList>
</contextElement>
</contextElementList>
<updateAction>APPEND</updateAction>
</updateContextRequest>";
2) The result of the insertion operation is as follows.
<updateContextResponse>
<contextResponseList>
<contextElementResponse>
<contextElement>
<entityId type="dispositivo" isPattern="false">
<id>30000000000002</id>
</entityId>
<contextAttributeList>
<contextAttribute>
<name>temperature</name>
<type>Cº</type>
<contextValue />
</contextAttribute>
.
.
.
.
<contextAttribute>
<name>position</name>
<type>coords</type>
<contextValue />
<metadata>
<contextMetadata>
<name>location</name>
<type>string</type>
<value>WSG84</value>
</contextMetadata>
</metadata>
</contextAttribute>
</contexAttributeList>
</contextElement>
<statusCode>
<code>200</code>
<reasonPhrase>OK</reasonPhrase>
</statusCode>
</contextElementResponse>
</contextResponseList>
</updateContextResponse>
3) We make the query and we can check the new values created with the payload.
<queryContextRequest>
<entityIdList>
<entityId type='dispositivo' isPattern='false'>
<id>{0}</id>
</entityId>
</entityIdList>
<attributeList/>
</queryContextRequest>
4) Then we are getting the value that we have introduced.
<queryContextResponse>
<contextResponseList>
<contextElementResponse>
<contextElement>
<entityId type="dispositivo" isPattern="false">
<id>30000000000002</id>
</entityId>
<contextAttributeList>
<contextAttribute>
<name>temperature</name>
<type>Cº</type>
<contextValue>30,0</contextValue>
</contextAttribute>
.
.
.
.
<contextAttribute>
<name>position</name>
<type>coords</type>
<contextValue>36.723804, -4.417518</contextValue>
<metadata>
<contextMetadata>
<name>location</name>
<type>string</type>
<value>WSG84</value>
</contextMetadata>
</metadata>
</contextAttribute>
</contextAttributeList>
</contextElement>
<statusCode>
<code>200</code>
<reasonPhrase>OK</reasonPhrase>
</statusCode>
</contextElementResponse>
</contextResponseList>
5) Now we try to do the update of this data which we have introduced correctly (how you can check) and it gives the error.
{0}
literal in the template is not the actual entity ID, isn't it? – fgalan