server/handlerwrappers/default.rb in cpee-1.3.209 vs server/handlerwrappers/default.rb in cpee-1.3.211

- old
+ new

@@ -41,35 +41,29 @@ @handler_passthrough = nil @handler_returnValue = nil end # }}} def activity_handle(passthrough, parameters) # {{{ - @controller.notify("activity/calling", :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :passthrough => passthrough, :endpoint => @handler_endpoint, :parameters => parameters) + @controller.notify("activity/calling", :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :passthrough => passthrough, :endpoint => @handler_endpoint, :parameters => parameters, :time=>Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z")) if passthrough.nil? params = [] callback = Digest::MD5.hexdigest(Kernel::rand().to_s) (parameters[:arguments] || []).each do |s| if s.respond_to?(:mimetype) params << Riddl::Parameter::Complex.new(s.name.to_s,v.mimetype,v.value) else params << Riddl::Parameter::Simple.new(s.name.to_s,CPEE::ValueHelper::generate(s.value)) end end - params << Riddl::Header.new("CPEE_BASE",@controller.base_url) - params << Riddl::Header.new("CPEE_INSTANCE",@controller.instance_url) - params << Riddl::Header.new("CPEE_CALLBACK",@controller.instance_url + '/callbacks/' + callback) - params << Riddl::Header.new("CPEE_CALLBACK_ID",callback) - params << Riddl::Header.new("CPEE_ACTIVITY",@handler_position) - params << Riddl::Header.new("CPEE_LABEL",parameters[:label]) + params << Riddl::Header.new("CPEE-BASE",@controller.base_url) params << Riddl::Header.new("CPEE-INSTANCE",@controller.instance_url) params << Riddl::Header.new("CPEE-CALLBACK",@controller.instance_url + '/callbacks/' + callback) params << Riddl::Header.new("CPEE-CALLBACK_ID",callback) params << Riddl::Header.new("CPEE-ACTIVITY",@handler_position) params << Riddl::Header.new("CPEE-LABEL",parameters[:label]) @controller.attributes.each do |key,value| - params << Riddl::Header.new("CPEE_ATTR_#{key}",value) params << Riddl::Header.new("CPEE-ATTR-#{key.gsub(/_/,'-')}",value) end type = parameters[:method] || 'post' client = Riddl::Client.new(@handler_endpoint) @@ -109,19 +103,19 @@ def activity_no_longer_necessary # {{{ true end # }}} def inform_activity_done # {{{ - @controller.notify("activity/done", :endpoint => @handler_endpoint, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position) + @controller.notify("activity/done", :endpoint => @handler_endpoint, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :time=>Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z")) end # }}} def inform_activity_manipulate # {{{ - @controller.notify("activity/manipulating", :endpoint => @handler_endpoint, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position) + @controller.notify("activity/manipulating", :endpoint => @handler_endpoint, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :time=>Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z")) end # }}} def inform_activity_failed(err) # {{{ puts err.message puts err.backtrace - @controller.notify("activity/failed", :endpoint => @handler_endpoint, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :message => err.message, :line => err.backtrace[0].match(/(.*?):(\d+):/)[2], :where => err.backtrace[0].match(/(.*?):(\d+):/)[1]) + @controller.notify("activity/failed", :endpoint => @handler_endpoint, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :message => err.message, :line => err.backtrace[0].match(/(.*?):(\d+):/)[2], :where => err.backtrace[0].match(/(.*?):(\d+):/)[1], :time=>Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z")) end # }}} def inform_manipulate_change(status,changed_dataelements,changed_endpoints,dataelements,endpoints) # {{{ unless status.nil? @controller.serialize_status! @controller.notify("status/change", :endpoint => @handler_endpoint, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :id => status.id, :message => status.message) @@ -135,14 +129,14 @@ @controller.notify("endpoints/change", :endpoint => @handler_endpoint, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :changed => changed_endpoints) end end # }}} def vote_sync_after # {{{ - @controller.call_vote("activity/syncing_after", :endpoint => @handler_endpoint, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position) + @controller.call_vote("activity/syncing_after", :endpoint => @handler_endpoint, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :time=>Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z")) end # }}} def vote_sync_before(parameters=nil) # {{{ - @controller.call_vote("activity/syncing_before", :endpoint => @handler_endpoint, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :parameters => parameters) + @controller.call_vote("activity/syncing_before", :endpoint => @handler_endpoint, :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :parameters => parameters, :time=>Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z")) end # }}} def simplify_result(result) if result.length == 1 if result[0].is_a? Riddl::Parameter::Simple @@ -184,15 +178,15 @@ end end end def callback(result=nil,options={}) - @controller.notify("activity/receiving", :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :endpoint => @handler_endpoint, :received => structurize_result(result)) + @controller.notify("activity/receiving", :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :endpoint => @handler_endpoint, :received => structurize_result(result), :time=>Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z")) result = simplify_result(result) if options['CPEE_UPDATE'] @handler_returnValue = result if options['CPEE_UPDATE_STATUS'] - @controller.notify("activity/status", :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :endpoint => @handler_endpoint, :status => options['CPEE_UPDATE_STATUS']) + @controller.notify("activity/status", :instance => @controller.instance, :instance_uuid => @controller.uuid, :activity => @handler_position, :endpoint => @handler_endpoint, :status => options['CPEE_UPDATE_STATUS'], :time=>Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z")) end @handler_continue.continue WEEL::Signal::Again else @controller.callbacks.delete(@handler_passthrough) @handler_returnValue = result