lib/cpee/instantiation.rb in cpee-1.4.20 vs lib/cpee/instantiation.rb in cpee-1.4.21

- old
+ new

@@ -68,15 +68,17 @@ #pp han.children.first url = han.attributes['url'] inp = "url=" + URI.encode_www_form_component(url) inp = inp + "&topic=" + han.children.first.attributes['topic'] inp = inp + "&" + han.children.first.qname.to_s + "=" + han.children.first.to_s - pp cpee+ins+"/notifications/subscriptions/" - pp inp - status,body = Riddl::Client::new(cpee+ins+"/notifications/subscriptions/").post([Riddl::Parameter::Simple.new("url",han.attributes['url']),Riddl::Parameter::Simple.new("topic",han.children.first.attributes['topic']),Riddl::Parameter::Simple.new(han.children.first.qname.to_s,han.children.first.to_s)]) - pp status - pp body + status,body = Riddl::Client::new(cpee+ins+"/notifications/subscriptions/").post( + [ + Riddl::Parameter::Simple.new("url",han.attributes['url']), + Riddl::Parameter::Simple.new("topic",han.children.first.attributes['topic']), + Riddl::Parameter::Simple.new(han.children.first.qname.to_s,han.children.first.to_s) + ] + ) end end end end [ins, uuid] @@ -145,15 +147,22 @@ end if (instance, uuid = load_testset(tdoc,cpee,@p[0].value)).first == -1 @status = 500 else - @headers << Riddl::Header.new('CPEE-INSTANTIATION',File.join(cpee,instance)) handle_data cpee, instance, @p[3]&.value handle_waiting cpee, instance, uuid, @p[1].value, selfurl, cblist handle_starting cpee, instance, @p[1].value - return Riddl::Parameter::Simple.new("url",cpee + instance) + + send = { + 'CPEE-INSTANCE' => instance, + 'CPEE-INSTANCE-URL' => File.join(cpee,instance), + 'CPEE-INSTANCE-UUID' => uuid, + 'CPEE-BEHAVIOR' => @p[1].value + } + @headers << Riddl::Header.new('CPEE-INSTANTIATION',JSON::generate(send)) + Riddl::Parameter::Complex.new('instance','application/json',JSON::generate(send)) end end end #}}} class InstantiateXML < Riddl::Implementation #{{{ @@ -172,15 +181,21 @@ end if (instance, uuid = load_testset(tdoc,cpee)).first == -1 @status = 500 else - @headers << Riddl::Header.new('CPEE-INSTANTIATION',File.join(cpee,instance)) handle_data cpee, instance, @p[data+1]&.value handle_waiting cpee, instance, uuid, behavior, selfurl, cblist handle_starting cpee, instance, behavior - return Riddl::Parameter::Simple.new("url",cpee + instance) + + send = { + 'CPEE-INSTANCE' => instance, + 'CPEE-INSTANCE-URL' => File.join(cpee,instance), + 'CPEE-INSTANCE-UUID' => uuid, + 'CPEE-BEHAVIOR' => behavior + } + Riddl::Parameter::Complex.new('instance','application/json',JSON::generate(send)) end end end #}}} class HandleInstance < Riddl::Implementation #{{{ @@ -215,16 +230,17 @@ notification = JSON.parse(@p[3].value) key = @r.last cb, condition, instance, uuid, instance_url = cblist.lrange(key,0,-1) - send = { + orisend = { 'CPEE-INSTANCE' => instance, 'CPEE-INSTANCE-URL' => instance_url, 'CPEE-INSTANCE-UUID' => uuid, 'CPEE-STATE' => notification['state'] } + send = orisend.dup if notification['state'] == condition cblist.del(key) srv = Riddl::Client.new(cpee, cpee + "?riddl-description") res = srv.resource("/#{instance}/properties/values/dataelements") @@ -234,12 +250,10 @@ doc.register_namespace 'p', 'http://riddl.org/ns/common-patterns/properties/1.0' doc.find('/p:value/*').each do |e| send[e.qname.name] = CPEE::ValueHelper::parse(e.text) end end - Riddl::Client.new(cb).put [ - Riddl::Parameter::Complex.new('dataelements','application/json',JSON::generate(send)) - ] + Riddl::Client.new(cb).put Riddl::Parameter::Complex.new('dataelements','application/json',JSON::generate(send)) else Riddl::Client.new(cb).put [ Riddl::Header.new('CPEE-UPDATE','true'), Riddl::Parameter::Complex.new('dataelements','application/json',JSON::generate(send)) ]