cpee 1.4.18 → 1.4.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cockpit/testsets/Subprocess.xml +52 -0
- data/cockpit/testsets/Take_5.xml +44 -0
- data/cockpit/testsets/testsets.xml +1 -0
- data/cpee.gemspec +1 -1
- data/lib/cpee/controller.rb +7 -31
- data/lib/cpee/empty_workflow.rb +8 -4
- data/lib/cpee/implementation.rb +9 -1
- data/lib/cpee/instantiation.rb +40 -17
- data/lib/cpee/value_helper.rb +32 -0
- data/lib/engine.xml +1 -1
- data/log/display.rb +46 -0
- data/log/logs/27d46c68-d457-4ca8-808a-094585842aea.xes.yaml +130 -0
- data/log/logs/292ee7f7-fab8-438d-b251-5fc4d13b3d5b.xes.yaml +171 -0
- data/log/logs/546a855f-6223-49ed-bc7d-c256b391663b.xes.yaml +74 -0
- data/log/logs/5673f24b-5ac0-4bd6-b315-16992f02ddbb.xes.yaml +336 -0
- data/log/logs/7a4ad7e9-2fdb-41da-a623-094f5eaca9ce.xes.yaml +74 -0
- data/log/logs/7d24f231-44db-4d0b-8193-4601ede4591e.xes.yaml +167 -0
- data/log/logs/8abdeac5-a28a-4aad-9fad-e47e47f58f0a.xes.yaml +171 -0
- data/log/logs/a6ff458b-8e56-4411-a552-9b943ed69d6b.xes.yaml +128 -0
- data/log/logs/ccb051e7-639f-4b51-a1e3-3fd5a55f2c02.xes.yaml +128 -0
- data/log/logs/fbc5fa87-ba3c-40b9-9605-e1bb1cc7e0d9.xes.yaml +130 -0
- data/log/sic.rb +51 -0
- data/log/template.xes_yaml +3 -1
- data/log/xes_xml.rb +1 -1
- data/log/xes_yaml.pid +1 -0
- data/log/xes_yaml.rb +1 -1
- data/server/dev.rb +33 -0
- data/server/handlerwrappers/default.rb +5 -2
- data/server/{resources → instances/1}/notifications/ruleengine/consumer-secret +0 -0
- data/server/{resources → instances/1}/notifications/ruleengine/producer-secret +0 -0
- data/server/{resources → instances/1}/notifications/ruleengine/subscription.xml +0 -0
- data/server/instances/1/properties.xml +31 -0
- data/server/instances/10/notifications/1b735894fe9c3cc45308d1ed4cd6b930/consumer-secret +1 -0
- data/server/instances/10/notifications/1b735894fe9c3cc45308d1ed4cd6b930/producer-secret +1 -0
- data/server/instances/10/notifications/1b735894fe9c3cc45308d1ed4cd6b930/subscription.xml +5 -0
- data/server/instances/10/notifications/logging/consumer-secret +1 -0
- data/server/instances/10/notifications/logging/producer-secret +1 -0
- data/server/instances/10/notifications/logging/subscription.xml +16 -0
- data/server/instances/10/properties.xml +80 -0
- data/server/instances/11/notifications/logging/consumer-secret +1 -0
- data/server/instances/11/notifications/logging/producer-secret +1 -0
- data/server/instances/11/notifications/logging/subscription.xml +16 -0
- data/server/instances/11/properties.xml +97 -0
- data/server/instances/12/notifications/2678055be8f23525a98b5c031fe2ee46/consumer-secret +1 -0
- data/server/instances/12/notifications/2678055be8f23525a98b5c031fe2ee46/producer-secret +1 -0
- data/server/instances/12/notifications/2678055be8f23525a98b5c031fe2ee46/subscription.xml +5 -0
- data/server/instances/12/notifications/logging/consumer-secret +1 -0
- data/server/instances/12/notifications/logging/producer-secret +1 -0
- data/server/instances/12/notifications/logging/subscription.xml +16 -0
- data/server/instances/12/properties.xml +80 -0
- data/server/instances/13/notifications/90d34985542a88c3071d176f6400efe7/consumer-secret +1 -0
- data/server/instances/13/notifications/90d34985542a88c3071d176f6400efe7/producer-secret +1 -0
- data/server/instances/13/notifications/90d34985542a88c3071d176f6400efe7/subscription.xml +38 -0
- data/server/instances/13/notifications/logging/consumer-secret +1 -0
- data/server/instances/13/notifications/logging/producer-secret +1 -0
- data/server/instances/13/notifications/logging/subscription.xml +16 -0
- data/server/instances/13/properties.xml +97 -0
- data/server/instances/14/notifications/fa408cd6922b14cb1bfeee36e895f636/consumer-secret +1 -0
- data/server/instances/14/notifications/fa408cd6922b14cb1bfeee36e895f636/producer-secret +1 -0
- data/server/instances/14/notifications/fa408cd6922b14cb1bfeee36e895f636/subscription.xml +5 -0
- data/server/instances/14/notifications/logging/consumer-secret +1 -0
- data/server/instances/14/notifications/logging/producer-secret +1 -0
- data/server/instances/14/notifications/logging/subscription.xml +16 -0
- data/server/instances/14/properties.xml +80 -0
- data/server/instances/2/notifications/ruleengine/consumer-secret +1 -0
- data/server/instances/2/notifications/ruleengine/producer-secret +1 -0
- data/server/instances/2/notifications/ruleengine/subscription.xml +16 -0
- data/server/instances/2/properties.xml +31 -0
- data/server/instances/3/notifications/ruleengine/consumer-secret +1 -0
- data/server/instances/3/notifications/ruleengine/producer-secret +1 -0
- data/server/instances/3/notifications/ruleengine/subscription.xml +16 -0
- data/server/instances/3/properties.xml +31 -0
- data/server/instances/4/notifications/ruleengine/consumer-secret +1 -0
- data/server/instances/4/notifications/ruleengine/producer-secret +1 -0
- data/server/instances/4/notifications/ruleengine/subscription.xml +16 -0
- data/server/instances/4/properties.xml +31 -0
- data/server/instances/5/notifications/logging/consumer-secret +1 -0
- data/server/instances/5/notifications/logging/producer-secret +1 -0
- data/server/instances/5/notifications/logging/subscription.xml +16 -0
- data/server/instances/5/properties.xml +97 -0
- data/server/instances/6/notifications/ae6d58eba25c66a57b41181de8935442/consumer-secret +1 -0
- data/server/instances/6/notifications/ae6d58eba25c66a57b41181de8935442/producer-secret +1 -0
- data/server/instances/6/notifications/ae6d58eba25c66a57b41181de8935442/subscription.xml +5 -0
- data/server/instances/6/notifications/logging/consumer-secret +1 -0
- data/server/instances/6/notifications/logging/producer-secret +1 -0
- data/server/instances/6/notifications/logging/subscription.xml +16 -0
- data/server/instances/6/properties.xml +78 -0
- data/server/instances/7/notifications/d83173e3a3f5d1e05f5182042d5b627e/consumer-secret +1 -0
- data/server/instances/7/notifications/d83173e3a3f5d1e05f5182042d5b627e/producer-secret +1 -0
- data/server/instances/7/notifications/d83173e3a3f5d1e05f5182042d5b627e/subscription.xml +5 -0
- data/server/instances/7/notifications/logging/consumer-secret +1 -0
- data/server/instances/7/notifications/logging/producer-secret +1 -0
- data/server/instances/7/notifications/logging/subscription.xml +16 -0
- data/server/instances/7/properties.xml +78 -0
- data/server/instances/8/notifications/d6eb404431e5643fdbcf3a3ead0bdec5/consumer-secret +1 -0
- data/server/instances/8/notifications/d6eb404431e5643fdbcf3a3ead0bdec5/producer-secret +1 -0
- data/server/instances/8/notifications/d6eb404431e5643fdbcf3a3ead0bdec5/subscription.xml +5 -0
- data/server/instances/8/notifications/logging/consumer-secret +1 -0
- data/server/instances/8/notifications/logging/producer-secret +1 -0
- data/server/instances/8/notifications/logging/subscription.xml +16 -0
- data/server/instances/8/properties.xml +80 -0
- data/server/instances/9/notifications/e242ccf30f3878511aaf390e20e42d5d/consumer-secret +1 -0
- data/server/instances/9/notifications/e242ccf30f3878511aaf390e20e42d5d/producer-secret +1 -0
- data/server/instances/9/notifications/e242ccf30f3878511aaf390e20e42d5d/subscription.xml +38 -0
- data/server/instances/9/notifications/logging/consumer-secret +1 -0
- data/server/instances/9/notifications/logging/producer-secret +1 -0
- data/server/instances/9/notifications/logging/subscription.xml +16 -0
- data/server/instances/9/properties.xml +97 -0
- data/server/resources/notifications/logging/consumer-secret +1 -0
- data/server/resources/notifications/logging/producer-secret +1 -0
- data/server/resources/notifications/logging/subscription.xml +16 -0
- data/server/resources/transformation_dslx.xsl +2 -2
- data/server/server.pid +1 -0
- data/tools/cpee +22 -8
- metadata +103 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abed28f89d5a0d2d9fb9a1b3441abf39da7558ece841f3f5bf5e73112cb761fe
|
4
|
+
data.tar.gz: b7ebbda76cd00081c7512a934e77ee23b5566b334d782ce03ae38f65ba610d6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2655808212b6d633c2e85172285dd8cf8405bc8944a0cc00c22336e0189f585ea8ff6ed5ff0b33f55f54524bf8f55940659dd65788c3b2e5972f5bd51ccd714d
|
7
|
+
data.tar.gz: f170b5a892b8e5c649cf451074e987bc8f24a0c662491de161bfc95fc4c7a6992fb11e9e949c45f6ba2780978436ecb563b50c75ea4ca2a617527b6a3b40319a
|
@@ -0,0 +1,52 @@
|
|
1
|
+
<testset>
|
2
|
+
<dataelements/>
|
3
|
+
<handlerwrapper>DefaultHandlerWrapper</handlerwrapper>
|
4
|
+
<endpoints>
|
5
|
+
<timeout xmlns="http://riddl.org/ns/common-patterns/properties/1.0">http://gruppe.wst.univie.ac.at/~mangler/services/timeout.php</timeout>
|
6
|
+
<instantiate xmlns="http://riddl.org/ns/common-patterns/properties/1.0">http://localhost:9296/url/</instantiate>
|
7
|
+
</endpoints>
|
8
|
+
<positions/>
|
9
|
+
<description>
|
10
|
+
<description xmlns="http://cpee.org/ns/description/1.0">
|
11
|
+
<call id="a1" endpoint="instantiate">
|
12
|
+
<parameters>
|
13
|
+
<label>Take 5</label>
|
14
|
+
<method>:post</method>
|
15
|
+
<arguments>
|
16
|
+
<info>Take Time</info>
|
17
|
+
<behavior>wait_running</behavior>
|
18
|
+
<url>http://localhost/testsets/Take_5.xml</url>
|
19
|
+
<init>
|
20
|
+
<a>3</a>
|
21
|
+
</init>
|
22
|
+
</arguments>
|
23
|
+
</parameters>
|
24
|
+
<finalize output="result">data.instance = result['CPEE-INSTANCE']
|
25
|
+
data.res = result</finalize>
|
26
|
+
<update output="result"/>
|
27
|
+
<_timing>
|
28
|
+
<_timing_min/>
|
29
|
+
<_timing_max/>
|
30
|
+
<_timing_avg/>
|
31
|
+
</_timing>
|
32
|
+
<_notes>
|
33
|
+
<_notes_general/>
|
34
|
+
<_notes_output/>
|
35
|
+
<_attachments/>
|
36
|
+
</_notes>
|
37
|
+
</call>
|
38
|
+
</description>
|
39
|
+
</description>
|
40
|
+
<transformation>
|
41
|
+
<description type="copy"/>
|
42
|
+
<dataelements type="none"/>
|
43
|
+
<endpoints type="none"/>
|
44
|
+
</transformation>
|
45
|
+
<attributes>
|
46
|
+
<info xmlns="http://riddl.org/ns/common-patterns/properties/1.0">Subprocess</info>
|
47
|
+
<modeltype xmlns="http://riddl.org/ns/common-patterns/properties/1.0">CPEE</modeltype>
|
48
|
+
<theme xmlns="http://riddl.org/ns/common-patterns/properties/1.0">default</theme>
|
49
|
+
<customer xmlns="http://riddl.org/ns/common-patterns/properties/1.0">pilotfabrik</customer>
|
50
|
+
<status xmlns="http://riddl.org/ns/common-patterns/properties/1.0">development</status>
|
51
|
+
</attributes>
|
52
|
+
</testset>
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<testset>
|
2
|
+
<dataelements/>
|
3
|
+
<handlerwrapper>DefaultHandlerWrapper</handlerwrapper>
|
4
|
+
<endpoints>
|
5
|
+
<timeout xmlns="http://riddl.org/ns/common-patterns/properties/1.0">http://gruppe.wst.univie.ac.at/~mangler/services/timeout.php</timeout>
|
6
|
+
</endpoints>
|
7
|
+
<positions/>
|
8
|
+
<description>
|
9
|
+
<description xmlns="http://cpee.org/ns/description/1.0">
|
10
|
+
<call id="a1" endpoint="timeout">
|
11
|
+
<parameters>
|
12
|
+
<label/>
|
13
|
+
<method>:post</method>
|
14
|
+
<arguments>
|
15
|
+
<timeout>5</timeout>
|
16
|
+
</arguments>
|
17
|
+
</parameters>
|
18
|
+
<finalize output="result">data.a = 17</finalize>
|
19
|
+
<update output="result"/>
|
20
|
+
<_timing>
|
21
|
+
<_timing_min/>
|
22
|
+
<_timing_max/>
|
23
|
+
<_timing_avg/>
|
24
|
+
</_timing>
|
25
|
+
<_notes>
|
26
|
+
<_notes_general/>
|
27
|
+
<_attachments/>
|
28
|
+
</_notes>
|
29
|
+
</call>
|
30
|
+
</description>
|
31
|
+
</description>
|
32
|
+
<transformation>
|
33
|
+
<description type="copy"/>
|
34
|
+
<dataelements type="none"/>
|
35
|
+
<endpoints type="none"/>
|
36
|
+
</transformation>
|
37
|
+
<attributes>
|
38
|
+
<info xmlns="http://riddl.org/ns/common-patterns/properties/1.0"></info>
|
39
|
+
<modeltype xmlns="http://riddl.org/ns/common-patterns/properties/1.0">CPEE</modeltype>
|
40
|
+
<theme xmlns="http://riddl.org/ns/common-patterns/properties/1.0">default</theme>
|
41
|
+
<customer xmlns="http://riddl.org/ns/common-patterns/properties/1.0">pilotfabrik</customer>
|
42
|
+
<status xmlns="http://riddl.org/ns/common-patterns/properties/1.0">development</status>
|
43
|
+
</attributes>
|
44
|
+
</testset>
|
data/cpee.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "cpee"
|
3
|
-
s.version = "1.4.
|
3
|
+
s.version = "1.4.20"
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.license = "LGPL-3.0"
|
6
6
|
s.summary = "Preliminary release of cloud process execution engine (cpee). If you just need workflow execution, without a rest/xmpp service exposing it, then use WEEL"
|
data/lib/cpee/controller.rb
CHANGED
@@ -19,38 +19,10 @@ require ::File.dirname(__FILE__) + '/handler_properties'
|
|
19
19
|
require ::File.dirname(__FILE__) + '/handler_notifications'
|
20
20
|
require ::File.dirname(__FILE__) + '/callback'
|
21
21
|
require ::File.dirname(__FILE__) + '/empty_workflow'
|
22
|
+
require ::File.dirname(__FILE__) + '/value_helper'
|
22
23
|
|
23
24
|
module CPEE
|
24
25
|
|
25
|
-
class ValueHelper #{{{
|
26
|
-
def self::generate(value)
|
27
|
-
if [String, Integer, Float, TrueClass, FalseClass, Date].include? value.class
|
28
|
-
value.to_s
|
29
|
-
elsif [Hash, Array].include? value.class
|
30
|
-
JSON::generate(value)
|
31
|
-
elsif value.respond_to?(:to_s)
|
32
|
-
value.to_s
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def self::parse(value)
|
37
|
-
case value.downcase
|
38
|
-
when 'true'
|
39
|
-
true
|
40
|
-
when 'false'
|
41
|
-
false
|
42
|
-
when 'nil', 'null'
|
43
|
-
nil
|
44
|
-
else
|
45
|
-
begin
|
46
|
-
JSON::parse(value)
|
47
|
-
rescue
|
48
|
-
(Integer value rescue nil) || (Float value rescue nil) || value.to_s rescue nil || ''
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end #}}}
|
53
|
-
|
54
26
|
class AttributesHelper #{{{
|
55
27
|
def translate(__attributes__,__dataelements__,__endpoints__)
|
56
28
|
@data = WEEL::ReadHash.new(__dataelements__)
|
@@ -283,7 +255,7 @@ module CPEE
|
|
283
255
|
pos.children.delete_all!
|
284
256
|
@positions = @instance.positions
|
285
257
|
@instance.positions.each do |p|
|
286
|
-
pos.add("#{p.position}",p.detail,'passthrough' => p.passthrough)
|
258
|
+
pos.add("#{p.position}",p.detail,'passthrough' => p.passthrough.to_s.empty? ? nil : p.passthrough)
|
287
259
|
end
|
288
260
|
end
|
289
261
|
end # }}}
|
@@ -580,6 +552,8 @@ module CPEE
|
|
580
552
|
params = notf.map{|ke,va|Riddl::Parameter::Simple.new(ke,va)}
|
581
553
|
params << Riddl::Header.new("CPEE-BASE",self.base)
|
582
554
|
params << Riddl::Header.new("CPEE-INSTANCE",self.instance)
|
555
|
+
params << Riddl::Header.new("CPEE-INSTANCE-URL",self.instance_url)
|
556
|
+
params << Riddl::Header.new("CPEE-INSTANCE-UUID",self.uuid)
|
583
557
|
client.post params
|
584
558
|
elsif url.class == Riddl::Utils::Notifications::Producer::WS
|
585
559
|
e = XML::Smart::string("<event/>")
|
@@ -618,7 +592,9 @@ module CPEE
|
|
618
592
|
client = Riddl::Client.new(u,'http://riddl.org/ns/common-patterns/notifications-consumer/1.0/consumer.xml')
|
619
593
|
params = notf.map{|ke,va|Riddl::Parameter::Simple.new(ke,va)}
|
620
594
|
params << Riddl::Header.new("CPEE-BASE",self.base_url)
|
621
|
-
params << Riddl::Header.new("CPEE-INSTANCE",self.
|
595
|
+
params << Riddl::Header.new("CPEE-INSTANCE",self.instance)
|
596
|
+
params << Riddl::Header.new("CPEE-INSTANCE-URL",self.instance_url)
|
597
|
+
params << Riddl::Header.new("CPEE-INSTANCE-UUID",self.uuid)
|
622
598
|
params << Riddl::Header.new("CPEE-CALLBACK",self.instance_url + '/callbacks/' + callback)
|
623
599
|
@mutex.synchronize do
|
624
600
|
status, result, headers = client.post params
|
data/lib/cpee/empty_workflow.rb
CHANGED
@@ -1,18 +1,22 @@
|
|
1
1
|
# This file is part of CPEE.
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# CPEE is free software: you can redistribute it and/or modify it under the terms
|
4
4
|
# of the GNU General Public License as published by the Free Software Foundation,
|
5
5
|
# either version 3 of the License, or (at your option) any later version.
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# CPEE is distributed in the hope that it will be useful, but WITHOUT ANY
|
8
8
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
9
9
|
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# You should have received a copy of the GNU General Public License along with
|
12
12
|
# CPEE (file COPYING in the main directory). If not, see
|
13
13
|
# <http://www.gnu.org/licenses/>.
|
14
14
|
|
15
|
-
|
15
|
+
if Module.const_defined?(:CPEE) && CPEE.const_defined?(:DEVELOP) && CPEE::DEVELOP.const_defined?(:WEEL)
|
16
|
+
require File.join(CPEE::DEVELOP::WEEL,'weel')
|
17
|
+
else
|
18
|
+
require 'weel'
|
19
|
+
end
|
16
20
|
require ::File.dirname(__FILE__) + '/../../server/handlerwrappers/default'
|
17
21
|
|
18
22
|
class EmptyWorkflow < WEEL
|
data/lib/cpee/implementation.rb
CHANGED
@@ -168,6 +168,10 @@ module CPEE
|
|
168
168
|
controller[id].info = name
|
169
169
|
controller[id].state_change!
|
170
170
|
|
171
|
+
@headers << Riddl::Header.new("CPEE-INSTANCE", controller[id].instance)
|
172
|
+
@headers << Riddl::Header.new("CPEE-INSTANCE-URL", controller[id].instance_url)
|
173
|
+
@headers << Riddl::Header.new("CPEE-INSTANCE-UUID", controller[id].uuid)
|
174
|
+
|
171
175
|
Riddl::Parameter::Simple.new("id", id)
|
172
176
|
end
|
173
177
|
end #}}}
|
@@ -240,7 +244,11 @@ module CPEE
|
|
240
244
|
return
|
241
245
|
end
|
242
246
|
Riddl::Parameter::Complex.new("res","text/plain") do
|
243
|
-
|
247
|
+
begin
|
248
|
+
controller[id].console(@p[0].value)
|
249
|
+
rescue => e
|
250
|
+
e.message
|
251
|
+
end
|
244
252
|
end
|
245
253
|
end
|
246
254
|
end #}}}
|
data/lib/cpee/instantiation.rb
CHANGED
@@ -19,6 +19,7 @@ require 'base64'
|
|
19
19
|
require 'uri'
|
20
20
|
require 'redis'
|
21
21
|
require 'json'
|
22
|
+
require ::File.dirname(__FILE__) + '/value_helper'
|
22
23
|
|
23
24
|
module CPEE
|
24
25
|
module Instantiation
|
@@ -28,6 +29,7 @@ module CPEE
|
|
28
29
|
module Helpers #{{{
|
29
30
|
def load_testset(tdoc,cpee,name=nil) #{{{
|
30
31
|
ins = -1
|
32
|
+
uuid = nil
|
31
33
|
XML::Smart.string(tdoc) do |doc|
|
32
34
|
doc.register_namespace 'desc', 'http://cpee.org/ns/description/1.0'
|
33
35
|
doc.register_namespace 'prop', 'http://riddl.org/ns/common-patterns/properties/1.0'
|
@@ -40,10 +42,11 @@ module CPEE
|
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
43
|
-
status, response = res.post Riddl::Parameter::Simple.new("info",doc.find("string(/testset/attributes/prop:info)"))
|
45
|
+
status, response, headers = res.post Riddl::Parameter::Simple.new("info",doc.find("string(/testset/attributes/prop:info)"))
|
44
46
|
|
45
47
|
if status == 200
|
46
48
|
ins = response.first.value
|
49
|
+
uuid = headers['CPEE_INSTANCE_UUID']
|
47
50
|
params = []
|
48
51
|
|
49
52
|
res = srv.resource("/#{ins}/properties/values")
|
@@ -76,10 +79,10 @@ module CPEE
|
|
76
79
|
end
|
77
80
|
end
|
78
81
|
end
|
79
|
-
|
82
|
+
[ins, uuid]
|
80
83
|
end #}}}
|
81
84
|
private :load_testset
|
82
|
-
def handle_waiting(cpee,instance,behavior,selfurl,cblist) #{{{
|
85
|
+
def handle_waiting(cpee,instance,uuid,behavior,selfurl,cblist) #{{{
|
83
86
|
if behavior =~ /^wait/
|
84
87
|
condition = behavior.match(/_([^_]+)_/)&.[](1) || 'finished'
|
85
88
|
@headers << Riddl::Header.new('CPEE-CALLBACK','true')
|
@@ -96,6 +99,7 @@ module CPEE
|
|
96
99
|
cblist.rpush(cbk, cb)
|
97
100
|
cblist.rpush(cbk, condition)
|
98
101
|
cblist.rpush(cbk, instance)
|
102
|
+
cblist.rpush(cbk, uuid)
|
99
103
|
cblist.rpush(cbk, File.join(cpee,instance))
|
100
104
|
end
|
101
105
|
end
|
@@ -112,7 +116,7 @@ module CPEE
|
|
112
116
|
end
|
113
117
|
end #}}}
|
114
118
|
private :handle_starting
|
115
|
-
def handle_data(cpee,instance,data)
|
119
|
+
def handle_data(cpee,instance,data) #{{{
|
116
120
|
if data
|
117
121
|
srv = Riddl::Client.new(cpee, cpee + "?riddl-description")
|
118
122
|
JSON::parse(data).each do |k,v|
|
@@ -123,7 +127,7 @@ module CPEE
|
|
123
127
|
sleep 0.42
|
124
128
|
end rescue nil
|
125
129
|
end
|
126
|
-
end
|
130
|
+
end #}}}
|
127
131
|
end #}}}
|
128
132
|
|
129
133
|
class InstantiateUrl < Riddl::Implementation #{{{
|
@@ -140,17 +144,17 @@ module CPEE
|
|
140
144
|
(@status = 500) && return
|
141
145
|
end
|
142
146
|
|
143
|
-
if (instance = load_testset(tdoc,cpee,@p[0].value)) == -1
|
147
|
+
if (instance, uuid = load_testset(tdoc,cpee,@p[0].value)).first == -1
|
144
148
|
@status = 500
|
145
149
|
else
|
146
150
|
@headers << Riddl::Header.new('CPEE-INSTANTIATION',File.join(cpee,instance))
|
147
151
|
handle_data cpee, instance, @p[3]&.value
|
148
|
-
handle_waiting cpee, instance, @p[1].value, selfurl, cblist
|
152
|
+
handle_waiting cpee, instance, uuid, @p[1].value, selfurl, cblist
|
149
153
|
handle_starting cpee, instance, @p[1].value
|
150
154
|
return Riddl::Parameter::Simple.new("url",cpee + instance)
|
151
155
|
end
|
152
156
|
end
|
153
|
-
end
|
157
|
+
end #}}}
|
154
158
|
|
155
159
|
class InstantiateXML < Riddl::Implementation #{{{
|
156
160
|
include Helpers
|
@@ -167,12 +171,12 @@ module CPEE
|
|
167
171
|
@p[data].value.read
|
168
172
|
end
|
169
173
|
|
170
|
-
if (instance = load_testset(tdoc,cpee)) == -1
|
174
|
+
if (instance, uuid = load_testset(tdoc,cpee)).first == -1
|
171
175
|
@status = 500
|
172
176
|
else
|
173
177
|
@headers << Riddl::Header.new('CPEE-INSTANTIATION',File.join(cpee,instance))
|
174
178
|
handle_data cpee, instance, @p[data+1]&.value
|
175
|
-
handle_waiting cpee, instance, behavior, selfurl, cblist
|
179
|
+
handle_waiting cpee, instance, uuid, behavior, selfurl, cblist
|
176
180
|
handle_starting cpee, instance, behavior
|
177
181
|
return Riddl::Parameter::Simple.new("url",cpee + instance)
|
178
182
|
end
|
@@ -188,10 +192,17 @@ module CPEE
|
|
188
192
|
cblist = @a[2]
|
189
193
|
instance = @p[1].value
|
190
194
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
+
srv = Riddl::Client.new(cpee, cpee + "?riddl-description")
|
196
|
+
res = srv.resource("/#{instance}/properties/values/attributes/uuid")
|
197
|
+
status, response = res.get
|
198
|
+
|
199
|
+
if status >= 200 && status < 300
|
200
|
+
uuid = XML::Smart::string(response.first.value).root.text
|
201
|
+
handle_data cpee, instance, @p[2]&.value
|
202
|
+
handle_waiting cpee, instance, uuid, @p[0].value, selfurl, cblist
|
203
|
+
handle_starting cpee, instance, @p[0].value
|
204
|
+
return Riddl::Parameter::Simple.new("url",cpee + instance)
|
205
|
+
end
|
195
206
|
end
|
196
207
|
end #}}}
|
197
208
|
|
@@ -204,23 +215,35 @@ module CPEE
|
|
204
215
|
notification = JSON.parse(@p[3].value)
|
205
216
|
|
206
217
|
key = @r.last
|
207
|
-
cb, condition, instance, instance_url = cblist.lrange(key,0,-1)
|
218
|
+
cb, condition, instance, uuid, instance_url = cblist.lrange(key,0,-1)
|
219
|
+
|
220
|
+
send = {
|
221
|
+
'CPEE-INSTANCE' => instance,
|
222
|
+
'CPEE-INSTANCE-URL' => instance_url,
|
223
|
+
'CPEE-INSTANCE-UUID' => uuid,
|
224
|
+
'CPEE-STATE' => notification['state']
|
225
|
+
}
|
226
|
+
|
208
227
|
if notification['state'] == condition
|
209
228
|
cblist.del(key)
|
210
229
|
srv = Riddl::Client.new(cpee, cpee + "?riddl-description")
|
211
230
|
res = srv.resource("/#{instance}/properties/values/dataelements")
|
212
231
|
status, response = res.get
|
213
|
-
send = { 'CPEE-INSTANCE' => instance_url }
|
214
232
|
if status >= 200 && status < 300
|
215
233
|
doc = XML::Smart.string(response[0].value.read)
|
216
234
|
doc.register_namespace 'p', 'http://riddl.org/ns/common-patterns/properties/1.0'
|
217
235
|
doc.find('/p:value/*').each do |e|
|
218
|
-
send[e.qname.name] = e.text
|
236
|
+
send[e.qname.name] = CPEE::ValueHelper::parse(e.text)
|
219
237
|
end
|
220
238
|
end
|
221
239
|
Riddl::Client.new(cb).put [
|
222
240
|
Riddl::Parameter::Complex.new('dataelements','application/json',JSON::generate(send))
|
223
241
|
]
|
242
|
+
else
|
243
|
+
Riddl::Client.new(cb).put [
|
244
|
+
Riddl::Header.new('CPEE-UPDATE','true'),
|
245
|
+
Riddl::Parameter::Complex.new('dataelements','application/json',JSON::generate(send))
|
246
|
+
]
|
224
247
|
end
|
225
248
|
end
|
226
249
|
end #}}}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module CPEE
|
2
|
+
|
3
|
+
class ValueHelper
|
4
|
+
def self::generate(value)
|
5
|
+
if [String, Integer, Float, TrueClass, FalseClass, Date].include? value.class
|
6
|
+
value.to_s
|
7
|
+
elsif [Hash, Array].include? value.class
|
8
|
+
JSON::generate(value)
|
9
|
+
elsif value.respond_to?(:to_s)
|
10
|
+
value.to_s
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self::parse(value)
|
15
|
+
case value.downcase
|
16
|
+
when 'true'
|
17
|
+
true
|
18
|
+
when 'false'
|
19
|
+
false
|
20
|
+
when 'nil', 'null'
|
21
|
+
nil
|
22
|
+
else
|
23
|
+
begin
|
24
|
+
JSON::parse(value)
|
25
|
+
rescue
|
26
|
+
(Integer value rescue nil) || (Float value rescue nil) || value.to_s rescue nil || ''
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|