BUG-7833: Fix identityref codecs 70/53870/7
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 26 Mar 2017 19:38:00 +0000 (21:38 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 4 Apr 2017 15:59:51 +0000 (17:59 +0200)
commit3fef6ae3770c27bc84c39477cef53f79415c400b
treeaafdc8a48f067e54ef32654760d569e68e455b89
parent715442142530f0a6af457ec8a206b644567ab419
BUG-7833: Fix identityref codecs

Introduce QNameCodecUtil to help JSON and XML codecs correctly implement
their identityref codecs. As it turns out, both only need to provide
proper mapping functions without having to deal with multiple codec
hierarchies.

The patch is also more strict about parsing the string, as it rejects
malformed identityrefs, i.e. those which contain invalid characters.

This fixes BUG-7833, which is triggered by invalid PUT, where we parse
an empty string as a null identityref.

Change-Id: I1f3086a0f9e930f7782dff8d6c39329d4b28ed14
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/IdentityrefJSONCodec.java [new file with mode: 0644]
yang/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONCodecFactory.java
yang/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONStringIdentityrefCodec.java [deleted file]
yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/IdentityrefXmlCodec.java
yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/codec/QNameCodecUtil.java [new file with mode: 0644]