Fixed a couple of bugs in AddObject method.

This commit is contained in:
Zaid Abdulla committed 2013-08-18 11:02:20 +03:00
1 parent 3ad8d08ea9
commit 13da4dc2da
1 file changed
+7 -6
+7 -6
View File
@@ -118,12 +118,9 @@ this.getParameterNames = (task, methodResponse, callback) ->
rootPath = '' rootPath = ''
ps = path.split('.') ps = path.split('.')
for p in ps for p in ps
if root[p]?
root = root[p]
rootPath += "#{p}." rootPath += "#{p}."
else root = root[p]
root = null break if not root?
break
else else
root = device['InternetGatewayDevice'] root = device['InternetGatewayDevice']
rootPath = 'InternetGatewayDevice.' rootPath = 'InternetGatewayDevice.'
@@ -135,6 +132,8 @@ this.getParameterNames = (task, methodResponse, callback) ->
parameters[p[0]] = 1 for p in methodResponse.parameterList parameters[p[0]] = 1 for p in methodResponse.parameterList
findMissingParameters(root, parameters, rootPath, deviceUpdates.deletedObjects) findMissingParameters(root, parameters, rootPath, deviceUpdates.deletedObjects)
else else
# avoid adding and deleting the same param
if rootPath isnt task.parameterPath
deviceUpdates.deletedObjects = [rootPath.slice(0, -1)] deviceUpdates.deletedObjects = [rootPath.slice(0, -1)]
# some devices don't return the root object as described in the standard. add manually to update timestamp # some devices don't return the root object as described in the standard. add manually to update timestamp
@@ -241,7 +240,9 @@ this.addObject = (task, methodResponse, callback) ->
when 'getParameterValues' when 'getParameterValues'
this.getParameterValues(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) => this.getParameterValues(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) =>
common.extend(allDeviceUpdates, deviceUpdates) common.extend(allDeviceUpdates, deviceUpdates)
if deviceUpdates and deviceUpdates.parameterValues # if values are given, compare with default values
if task.parameterValues?
if deviceUpdates and deviceUpdates.parameterValues?
for p1 in deviceUpdates.parameterValues for p1 in deviceUpdates.parameterValues
for p2 in task.parameterValues for p2 in task.parameterValues
if common.endsWith(p1[0], ".#{p2[0]}") if common.endsWith(p1[0], ".#{p2[0]}")