+
+ val moduleBehindMountPoint = mountPointSchema.getLatestModule(moduleNameBehindMountPoint)
+ if (moduleBehindMountPoint === null) {
+ throw new ResponseException(BAD_REQUEST,
+ "URI has bad format. \"" + moduleName + "\" module does not exist in mount point.")
+ }
+
+ return collectPathArguments(InstanceIdentifier.builder(), strings.subList(1, strings.size),
+ moduleBehindMountPoint, mount, returnJustMountPoint);
+ }
+
+ var Module module = null;
+ if (mountPoint === null) {
+ module = globalSchema.getLatestModule(moduleName)
+ if (module === null) {
+ throw new ResponseException(BAD_REQUEST,
+ "URI has bad format. \"" + moduleName + "\" module does not exist.")
+ }
+ } else {
+ module = mountPoint.schemaContext?.getLatestModule(moduleName)
+ if (module === null) {
+ throw new ResponseException(BAD_REQUEST,
+ "URI has bad format. \"" + moduleName + "\" module does not exist in mount point.")
+ }
+ }
+ targetNode = parentNode.findInstanceDataChildByNameAndNamespace(nodeName, module.namespace)
+ if (targetNode === null) {
+ throw new ResponseException(BAD_REQUEST, "URI has bad format. Possible reasons:\n" +
+ "1. \"" + strings.head + "\" was not found in parent data node.\n" +
+ "2. \"" + strings.head + "\" is behind mount point. Then it should be in format \"/" + MOUNT + "/" + strings.head + "\".")
+ }
+ } else { // string without module name
+ val potentialSchemaNodes = parentNode.findInstanceDataChildrenByName(nodeName)
+ if (potentialSchemaNodes.size > 1) {
+ val StringBuilder namespacesOfPotentialModules = new StringBuilder;
+ for (potentialNodeSchema : potentialSchemaNodes) {
+ namespacesOfPotentialModules.append(" ").append(potentialNodeSchema.QName.namespace.toString).append("\n")
+ }
+ throw new ResponseException(BAD_REQUEST, "URI has bad format. Node \"" + nodeName + "\" is added as augment from more than one module. "
+ + "Therefore the node must have module name and it has to be in format \"moduleName:nodeName\"."
+ + "\nThe node is added as augment from modules with namespaces:\n" + namespacesOfPotentialModules)
+ }
+ targetNode = potentialSchemaNodes.head
+ if (targetNode === null) {
+ throw new ResponseException(BAD_REQUEST, "URI has bad format. \"" + nodeName + "\" was not found in parent data node.\n")