lib/cpee/instantiation.rb in cpee-1.4.31 vs lib/cpee/instantiation.rb in cpee-1.4.32
- old
+ new
@@ -117,41 +117,58 @@
]
end
end #}}}
private :handle_starting
def handle_data(cpee,instance,data) #{{{
- if data
- srv = Riddl::Client.new(cpee, cpee + "?riddl-description")
+ if data && !data.empty?
content = XML::Smart.string('<content/>')
JSON::parse(data).each do |k,v|
content.root.add(k,v)
end
+ srv = Riddl::Client.new(cpee, cpee + "?riddl-description")
res = srv.resource("/#{instance}/properties/values/dataelements/")
status, response = res.patch [
Riddl::Parameter::Complex.new('content','text/xml',content.to_s)
]
- end # rescue nil
+ end rescue nil
end #}}}
+ def handle_endpoints(cpee,instance,data) #{{{
+ if data && !data.empty?
+ content = XML::Smart.string('<content/>')
+ JSON::parse(data).each do |k,v|
+ content.root.add(k,v)
+ end
+ srv = Riddl::Client.new(cpee, cpee + "?riddl-description")
+ res = srv.resource("/#{instance}/properties/values/endpoints/")
+ status, response = res.patch [
+ Riddl::Parameter::Complex.new('content','text/xml',content.to_s)
+ ]
+ end rescue nil
+ end #}}}
end #}}}
class InstantiateUrl < Riddl::Implementation #{{{
include Helpers
def response
cpee = @h['X_CPEE'] || @a[0]
selfurl = @a[1]
cblist = @a[2]
- status, res = Riddl::Client.new(@p[2].value).get
+
+ status, res = Riddl::Client.new(@p[2].value.gsub(/ /,'%20')).get
tdoc = if status >= 200 && status < 300
res[0].value.read
else
(@status = 500) && return
end
if (instance, uuid = load_testset(tdoc,cpee,@p[0].value)).first == -1
@status = 500
else
- handle_data cpee, instance, @p[3]&.value
+ handle_data cpee, instance, @p[3]&.value if @p[3]&.name == 'init'
+ handle_endpoints cpee, instance, @p[3]&.value if @p[3]&.name == 'endpoints'
+ handle_endpoints cpee, instance, @p[4]&.value if @p[4]&.name == 'endpoints'
+
handle_waiting cpee, instance, uuid, @p[1].value, selfurl, cblist
handle_starting cpee, instance, @p[1].value
send = {
'CPEE-INSTANCE' => instance,