From: Tony Tkacik Date: Mon, 3 Mar 2014 10:41:25 +0000 (+0000) Subject: Merge "Bug 383 - exception raised if key part of URI is incorrect" X-Git-Tag: autorelease-tag-v20140601202136_82eb3f9~358 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=7eb31665534a5e8c61b4cb4ae6caf4030a3dfd36;hp=-c Merge "Bug 383 - exception raised if key part of URI is incorrect" --- 7eb31665534a5e8c61b4cb4ae6caf4030a3dfd36 diff --combined opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend index 2b9c78bb87,66e5cbf910..837d7ae5b7 --- 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 +43,14 @@@ import org.opendaylight.yangtools.yang. 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" @@@ -356,6 -356,7 +356,6 @@@ private def toUriString(Object object) { if(object === null) return ""; -// return object.toString.replace("/",URI_SLASH_PLACEHOLDER) return URLEncoder.encode(object.toString,URI_ENCODING_CHAR_SET) } @@@ -548,12 -549,18 +548,18 @@@ val typedef = (node as LeafSchemaNode).type; var decoded = TypeDefinitionAwareCodec.from(typedef)?.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); } @@@ -619,13 -626,6 +625,13 @@@ decodedPathArgs.add(URLDecoder.decode(pathArg, URI_ENCODING_CHAR_SET)) } return decodedPathArgs + } + + def urlPathArgDecode(String pathArg) { + if (pathArg !== null) { + return URLDecoder.decode(pathArg, URI_ENCODING_CHAR_SET) + } + return null } }