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
+8 -5
+8 -5
View File
@@ -221,7 +221,9 @@ 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 = () =>
switch task.subtask.name
when 'getParameterNames'
this.getParameterNames(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) => this.getParameterNames(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) =>
common.extend(allDeviceUpdates, deviceUpdates) common.extend(allDeviceUpdates, deviceUpdates)
if deviceUpdates and deviceUpdates.parameterNames if deviceUpdates and deviceUpdates.parameterNames
@@ -230,13 +232,13 @@ this.addObject = (task, methodResponse, callback) ->
if status is STATUS_FINISHED if status is STATUS_FINISHED
task.subtask = {name : 'getParameterValues', parameterNames : task.parameterNames} task.subtask = {name : 'getParameterValues', parameterNames : task.parameterNames}
subtask()
else if status is STATUS_STARTED else if status is STATUS_STARTED
callback(err, STATUS_STARTED, cwmpResponse, allDeviceUpdates) callback(err, STATUS_STARTED, cwmpResponse, allDeviceUpdates)
else else
throw Error('Unexpected subtask status') throw Error('Unexpected subtask status')
) )
when 'getParameterValues'
if task.subtask.name is '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 deviceUpdates and deviceUpdates.parameterValues
@@ -253,15 +255,16 @@ this.addObject = (task, methodResponse, callback) ->
methodResponse = {parameterList : {}} methodResponse = {parameterList : {}}
if status is STATUS_FINISHED and task.appliedParameterValues.length > 0 if status is STATUS_FINISHED and task.appliedParameterValues.length > 0
task.subtask = {name : 'setParameterValues', parameterValues : task.appliedParameterValues} task.subtask = {name : 'setParameterValues', parameterValues : task.appliedParameterValues}
subtask()
else else
callback(err, status, cwmpResponse, allDeviceUpdates) callback(err, status, cwmpResponse, allDeviceUpdates)
) )
when 'setParameterValues'
if task.subtask.name is 'setParameterValues'
this.setParameterValues(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) => this.setParameterValues(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) =>
common.extend(allDeviceUpdates, deviceUpdates) common.extend(allDeviceUpdates, deviceUpdates)
callback(err, status, cwmpResponse, allDeviceUpdates) callback(err, status, cwmpResponse, allDeviceUpdates)
) )
subtask()
this.deleteObject = (task, methodResponse, callback) -> this.deleteObject = (task, methodResponse, callback) ->