[OLINGO-604] Ignore odata annotations for action requests
This commit is contained in:
parent
ae97061e3c
commit
87fa79ad93
|
@ -195,6 +195,22 @@ public class ODataJsonDeserializer implements ODataDeserializer {
|
|||
Map<String, Parameter> parameters = new LinkedHashMap<String, Parameter>();
|
||||
if (tree != null) {
|
||||
consumeParameters(edmAction, tree, parameters);
|
||||
|
||||
final List<String> toRemove = new ArrayList<String>();
|
||||
Iterator<Entry<String, JsonNode>> fieldsIterator = tree.fields();
|
||||
while (fieldsIterator.hasNext()) {
|
||||
Map.Entry<String, JsonNode> field = fieldsIterator.next();
|
||||
|
||||
if (field.getKey().contains(ODATA_CONTROL_INFORMATION_PREFIX)) {
|
||||
// Control Information is ignored for requests as per specification chapter "4.5 Control Information"
|
||||
toRemove.add(field.getKey());
|
||||
} else if (field.getKey().contains(ODATA_ANNOTATION_MARKER)) {
|
||||
throw new DeserializerException("Custom annotation with field name: " + field.getKey() + " not supported",
|
||||
DeserializerException.MessageKeys.NOT_IMPLEMENTED);
|
||||
}
|
||||
}
|
||||
// remove here to avoid iterator issues.
|
||||
tree.remove(toRemove);
|
||||
assertJsonNodeIsEmpty(tree);
|
||||
}
|
||||
return DeserializerResultImpl.with().actionParameters(parameters).build();
|
||||
|
|
|
@ -65,6 +65,22 @@ public class ODataJsonDeserializerActionParametersTest extends AbstractODataDese
|
|||
assertTrue(parameters.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ignoreODataAnnotations() throws Exception {
|
||||
final String input =
|
||||
"{\"ParameterDuration@odata.type\":\"Edm.Duration\","
|
||||
+ "\"ParameterDuration\":\"P42DT11H22M33S\",\"ParameterInt16\":42}";
|
||||
final Map<String, Parameter> parameters = deserialize(input, "UARTTwoParam");
|
||||
assertNotNull(parameters);
|
||||
assertEquals(2, parameters.size());
|
||||
Parameter parameter = parameters.get("ParameterInt16");
|
||||
assertNotNull(parameter);
|
||||
assertEquals((short) 42, parameter.getValue());
|
||||
parameter = parameters.get("ParameterDuration");
|
||||
assertNotNull(parameter);
|
||||
assertEquals(BigDecimal.valueOf(3669753), parameter.getValue());
|
||||
}
|
||||
|
||||
@Test(expected = DeserializerException.class)
|
||||
public void bindingParameter() throws Exception {
|
||||
deserialize("{\"ParameterETAllPrim\":{\"PropertyInt16\":42}}", "BAETAllPrimRT", "ETAllPrim");
|
||||
|
|
Loading…
Reference in New Issue