X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2FControllerContext.xtend;h=cb02fc89bfe604fb58e34854ea85f27edb1a403e;hp=9b5c507811c18257f19abf7dacaf2452d849081e;hb=9b843f3565f84258ebea1b437ae1025dfd4a52d2;hpb=986d8ca7ceae77314cc3e63461b960a28a032955 diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend index 9b5c507811..cb02fc89bf 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend @@ -43,14 +43,14 @@ import org.opendaylight.yangtools.yang.model.api.ListSchemaNode import org.opendaylight.yangtools.yang.model.api.Module import org.opendaylight.yangtools.yang.model.api.RpcDefinition import org.opendaylight.yangtools.yang.model.api.SchemaContext -import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener +import org.opendaylight.yangtools.yang.model.api.SchemaContextListener import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition import org.slf4j.LoggerFactory import static com.google.common.base.Preconditions.* import static javax.ws.rs.core.Response.Status.* -class ControllerContext implements SchemaServiceListener { +class ControllerContext implements SchemaContextListener { val static LOG = LoggerFactory.getLogger(ControllerContext) val static ControllerContext INSTANCE = new ControllerContext val static NULL_VALUE = "null" @@ -483,7 +483,7 @@ class ControllerContext implements SchemaServiceListener { + "\" cannot contain \"null\" value as a key." ) } - keyValues.addKeyValue(listNode.getDataChildByName(key), uriKeyValue); + keyValues.addKeyValue(listNode.getDataChildByName(key), uriKeyValue, mountPoint); i = i + 1; } consumed = consumed + i; @@ -541,19 +541,25 @@ class ControllerContext implements SchemaServiceListener { } } - private def void addKeyValue(HashMap map, DataSchemaNode node, String uriValue) { + private def void addKeyValue(HashMap map, DataSchemaNode node, String uriValue, MountInstance mountPoint) { checkNotNull(uriValue); checkArgument(node instanceof LeafSchemaNode); val urlDecoded = URLDecoder.decode(uriValue); val typedef = (node as LeafSchemaNode).type; - var decoded = TypeDefinitionAwareCodec.from(typedef)?.deserialize(urlDecoded) + var decoded = RestCodec.from(typedef, mountPoint)?.deserialize(urlDecoded) + var additionalInfo = "" if(decoded === null) { var baseType = RestUtil.resolveBaseTypeFrom(typedef) if(baseType instanceof IdentityrefTypeDefinition) { decoded = toQName(urlDecoded) + additionalInfo = "For key which is of type identityref it should be in format module_name:identity_name." } } + if (decoded === null) { + throw new ResponseException(BAD_REQUEST, uriValue + " from URI can't be resolved. "+ additionalInfo ) + } + map.put(node.QName, decoded); }