server/handlerwrappers/default.rb in cpee-1.3.191 vs server/handlerwrappers/default.rb in cpee-1.3.192
- old
+ new
@@ -13,10 +13,11 @@
# <http://www.gnu.org/licenses/>.
class DefaultHandlerWrapper < WEEL::HandlerWrapperBase
def initialize(arguments,endpoint=nil,position=nil,continue=nil) # {{{
@controller = arguments[0]
+ @log_hash = {}
@handler_continue = continue
@handler_endpoint = endpoint
@handler_position = position
@handler_passthrough = nil
@handler_returnValue = nil
@@ -145,18 +146,37 @@
result = JSON::parse(result[0].value.read) rescue nil
elsif result[0].mimetype == 'application/xml' || result[0].mimetype == 'text/xml'
result = XML::Smart::string(result[0].value.read) rescue nil
elsif result[0].mimetype == 'text/plain'
result = result[0].value.read
+ elsif result[0].mimetype == 'text/html'
+ result[0].value.read
else
result = result[0]
end
end
end
result
end
+ def structurize_result(result)
+ result.map do |r|
+ if r.is_a? Riddl::Parameter::Simple
+ { r.name => r.value }
+ elsif r.is_a? Riddl::Parameter::Complex
+ {
+ r.name => {
+ 'mimetype' => r.mimetype,
+ 'content' => r.value.read
+ }
+ }
+ r.value.rewind
+ end
+ end
+ end
+
def callback(result=nil,options={})
+ @controller.notify("activity/receiving", :instance => @controller.instance, :activity => @handler_position, :endpoint => @handler_endpoint, :received => structurize_result(result))
result = simplify_result(result)
if options['CPEE_UPDATE']
@handler_returnValue = result
if options['CPEE_UPDATE_STATUS']
@controller.notify("activity/status", :instance => @controller.instance, :activity => @handler_position, :endpoint => @handler_endpoint, :status => options['CPEE_UPDATE_STATUS'])