Merge "Bug 946: Fixed eclipse errors with nagasena projects"
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / main / java / org / opendaylight / controller / sal / restconf / impl / ControllerContext.xtend
index 2b9c78bb87a2134313676e0097f47e18ca8bd17e..cb02fc89bfe604fb58e34854ea85f27edb1a403e 100644 (file)
@@ -483,7 +483,7 @@ class ControllerContext implements SchemaContextListener {
                         + "\" 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 SchemaContextListener {
         }
     }
     
-    private def void addKeyValue(HashMap<QName, Object> map, DataSchemaNode node, String uriValue) {
+    private def void addKeyValue(HashMap<QName, Object> 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);
     }