Fixed bug where addObject task doesn't return response

This commit is contained in:
Zaid Abdulla committed 2013-07-23 02:12:55 +03:00
1 parent bcfd56d868
commit c268f6a321
1 file changed
+42 -39
+42 -39
View File
@@ -221,47 +221,50 @@ this.addObject = (task, methodResponse, callback) ->
callback(null, STATUS_STARTED, {methodRequest : {type : 'AddObject', objectName : "#{task.objectName}."}}) callback(null, STATUS_STARTED, {methodRequest : {type : 'AddObject', objectName : "#{task.objectName}."}})
return return
if task.subtask.name is 'getParameterNames' subtask = () =>
this.getParameterNames(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) => switch task.subtask.name
common.extend(allDeviceUpdates, deviceUpdates) when 'getParameterNames'
if deviceUpdates and deviceUpdates.parameterNames this.getParameterNames(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) =>
for p in deviceUpdates.parameterNames common.extend(allDeviceUpdates, deviceUpdates)
task.parameterNames.push(p[0]) if not common.endsWith(p[0], '.') if deviceUpdates and deviceUpdates.parameterNames
for p in deviceUpdates.parameterNames
task.parameterNames.push(p[0]) if not common.endsWith(p[0], '.')
if status is STATUS_FINISHED if status is STATUS_FINISHED
task.subtask = {name : 'getParameterValues', parameterNames : task.parameterNames} task.subtask = {name : 'getParameterValues', parameterNames : task.parameterNames}
else if status is STATUS_STARTED subtask()
callback(err, STATUS_STARTED, cwmpResponse, allDeviceUpdates) else if status is STATUS_STARTED
else callback(err, STATUS_STARTED, cwmpResponse, allDeviceUpdates)
throw Error('Unexpected subtask status') else
) throw Error('Unexpected subtask status')
)
when 'getParameterValues'
this.getParameterValues(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) =>
common.extend(allDeviceUpdates, deviceUpdates)
if deviceUpdates and deviceUpdates.parameterValues
for p1 in deviceUpdates.parameterValues
for p2 in task.parameterValues
if common.endsWith(p1[0], ".#{p2[0]}")
t = if p2[2] then p2[2] else p1[2]
v = common.matchType(p1[1], p2[1])
# TODO only include if writable
task.appliedParameterValues.push([p1[0], v, t])
if task.subtask.name is 'getParameterValues' if methodResponse.faultcode?
this.getParameterValues(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) => # Ignore GetParameterValues errors. A workaround for the crappy Seewon devices.
common.extend(allDeviceUpdates, deviceUpdates) methodResponse = {parameterList : {}}
if deviceUpdates and deviceUpdates.parameterValues if status is STATUS_FINISHED and task.appliedParameterValues.length > 0
for p1 in deviceUpdates.parameterValues task.subtask = {name : 'setParameterValues', parameterValues : task.appliedParameterValues}
for p2 in task.parameterValues subtask()
if common.endsWith(p1[0], ".#{p2[0]}") else
t = if p2[2] then p2[2] else p1[2] callback(err, status, cwmpResponse, allDeviceUpdates)
v = common.matchType(p1[1], p2[1]) )
# TODO only include if writable when 'setParameterValues'
task.appliedParameterValues.push([p1[0], v, t]) this.setParameterValues(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) =>
common.extend(allDeviceUpdates, deviceUpdates)
if methodResponse.faultcode? callback(err, status, cwmpResponse, allDeviceUpdates)
# Ignore GetParameterValues errors. A workaround for the crappy Seewon devices. )
methodResponse = {parameterList : {}} subtask()
if status is STATUS_FINISHED and task.appliedParameterValues.length > 0
task.subtask = {name : 'setParameterValues', parameterValues : task.appliedParameterValues}
else
callback(err, status, cwmpResponse, allDeviceUpdates)
)
if task.subtask.name is 'setParameterValues'
this.setParameterValues(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) =>
common.extend(allDeviceUpdates, deviceUpdates)
callback(err, status, cwmpResponse, allDeviceUpdates)
)
this.deleteObject = (task, methodResponse, callback) -> this.deleteObject = (task, methodResponse, callback) ->