cpee 2.1.26 → 2.1.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/cockpit/templates/Frames.xml +297 -0
  3. data/cockpit/templates/Subprocess.xml +79 -0
  4. data/cockpit/templates/Subprocess.xml.attrs +13 -0
  5. data/cockpit/templates/Track Test.xml +31 -28
  6. data/cockpit/templates/Track Test.xml.attrs +11 -0
  7. data/cockpit/templates/Wait.xml +73 -0
  8. data/cockpit/templates/Wait.xml.attrs +13 -0
  9. data/cockpit/templates/Worklist.xml +58 -26
  10. data/cockpit/templates/instantiate/Take_Perf.xml +13 -10
  11. data/cockpit/templates/instantiate/Take_Sub.xml +4 -8
  12. data/cockpit/templates/instantiate/Take_X.xml +12 -9
  13. data/cockpit/themes/compact/theme.js +1 -1
  14. data/cockpit/themes/control/theme.js +1 -1
  15. data/cockpit/themes/default/theme.js +1 -1
  16. data/cockpit/themes/extended/theme.js +1 -1
  17. data/cockpit/themes/model/theme.js +1 -1
  18. data/cockpit/themes/packed/theme.js +1 -1
  19. data/cockpit/themes/preset/theme.js +1 -1
  20. data/cpee.gemspec +1 -1
  21. data/lib/cpee/fail.rb +23 -0
  22. data/lib/cpee/implementation.rb +34 -18
  23. data/lib/cpee/implementation_callbacks.rb +20 -15
  24. data/lib/cpee/implementation_notifications.rb +22 -17
  25. data/lib/cpee/implementation_properties.rb +66 -61
  26. data/lib/cpee/message.rb +15 -13
  27. data/lib/cpee/persistence.rb +33 -10
  28. data/server/executionhandlers/ruby/connection.rb +15 -5
  29. data/server/executionhandlers/ruby/controller.rb +11 -6
  30. data/server/executionhandlers/ruby/dsl_to_dslx.xsl +36 -6
  31. data/server/routing/end.pid +1 -0
  32. data/server/routing/forward-events.pid +1 -0
  33. data/server/routing/forward-events.rb +6 -0
  34. data/server/routing/forward-votes.pid +1 -0
  35. data/server/routing/persist.pid +1 -0
  36. data/server/routing/persist.rb +4 -2
  37. data/server/server.conf +1 -1
  38. metadata +13 -6
  39. data/cockpit/templates/Coopis 2010.xml.active +0 -1
  40. data/cockpit/templates/Coopis 2010.xml.active-uuid +0 -1
  41. data/cockpit/templates/UR-VUE 2020 Solution Baseline.xml.active +0 -1
  42. data/cockpit/templates/UR-VUE 2020 Solution Baseline.xml.active-uuid +0 -1
@@ -1,33 +1,75 @@
1
+ <?xml version="1.0"?>
1
2
  <testset xmlns="http://cpee.org/ns/properties/2.0">
2
3
  <executionhandler>ruby</executionhandler>
3
- <dataelements>
4
- <bla/>
5
- </dataelements>
4
+ <dataelements/>
6
5
  <endpoints>
7
6
  <timeout>http://gruppe.wst.univie.ac.at/~mangler/services/timeout.php</timeout>
8
- <worklist>http://cpee.org:9398</worklist>
7
+ <subprocess>https-post://cpee.org/flow/start/url/</subprocess>
8
+ <worklist>https-post://cpee.org/worklist/server/</worklist>
9
+ <send>https-post://cpee.org/ing/correlators/message/send/</send>
10
+ <receive>https-get://cpee.org/ing/correlators/message/receive/</receive>
11
+ <user>https-post://cpee.org/services/timeout-user.php</user>
12
+ <auto>https-post://cpee.org/services/timeout-auto.php</auto>
9
13
  </endpoints>
10
- <positions/>
14
+ <attributes>
15
+ <info>Worklist</info>
16
+ <modeltype>CPEE</modeltype>
17
+ <organisation1>http://cpee.org/~demo/orgviz/organisation_informatik.xml</organisation1>
18
+ <theme>extended</theme>
19
+ <creator>Christine Ashcreek</creator>
20
+ <author>Christine Ashcreek</author>
21
+ <design_stage>development</design_stage>
22
+ <design_dir>Templates.dir</design_dir>
23
+ </attributes>
11
24
  <description>
12
25
  <description xmlns="http://cpee.org/ns/description/1.0">
13
26
  <call id="a1" endpoint="worklist">
14
27
  <parameters>
15
28
  <label>OK OR NOT OK</label>
16
- <method>:post</method>
17
29
  <arguments>
18
- <orgmodel>organisation1</orgmodel>
19
- <domain>Virtual Business 1</domain>
20
- <form>http://cpee.org/~demo/form/form-f.html</form>
21
- <role>Regular</role>
22
- <schaden>55546</schaden>
23
- <text>fetzen hin</text>
30
+ <orgmodel>https://cpee.org/~demo/orgviz/organisation_informatik.xml</orgmodel>
31
+ <domain>VirtualBusiness1</domain>
32
+ <form>https://cpee.org/~demo/form/form-f.html</form>
33
+ <role>Assistant</role>
34
+ <data>
35
+ <schaden>10000</schaden>
36
+ <text>destroyed</text>
37
+ </data>
24
38
  </arguments>
25
39
  </parameters>
26
40
  <code>
27
- <finalize>data.bla = result</finalize>
41
+ <prepare/>
42
+ <finalize output="result">data.bla = result</finalize>
43
+ <update output="result"/>
44
+ <rescue output="result"/>
28
45
  </code>
29
- <annotations/>
30
- <documentation/>
46
+ <annotations>
47
+ <_timing>
48
+ <_timing_weight/>
49
+ <_timing_avg/>
50
+ <explanations/>
51
+ </_timing>
52
+ <_context_data_analysis>
53
+ <probes/>
54
+ <ips/>
55
+ </_context_data_analysis>
56
+ <report>
57
+ <url/>
58
+ </report>
59
+ <_notes>
60
+ <_notes_general/>
61
+ </_notes>
62
+ </annotations>
63
+ <documentation>
64
+ <input/>
65
+ <output/>
66
+ <implementation>
67
+ <description/>
68
+ </implementation>
69
+ <code>
70
+ <description/>
71
+ </code>
72
+ </documentation>
31
73
  </call>
32
74
  </description>
33
75
  </description>
@@ -36,14 +78,4 @@
36
78
  <dataelements type="none"/>
37
79
  <endpoints type="none"/>
38
80
  </transformation>
39
- <attributes>
40
- <info>Worklist</info>
41
- <modeltype>CPEE</modeltype>
42
- <organisation1>http://cpee.org/~demo/orgviz/organisation_informatik.xml</organisation1>
43
- <theme>extended</theme>
44
- <creator>Christine Ashcreek</creator>
45
- <author>Christine Ashcreek</author>
46
- <design_stage>development</design_stage>
47
- <design_dir>Templates.dir</design_dir>
48
- </attributes>
49
- </testset>
81
+ </testset>
@@ -15,19 +15,22 @@
15
15
  <method>:get</method>
16
16
  <arguments/>
17
17
  </parameters>
18
- <_timing>
19
- <_timing_min/>
20
- <_timing_max/>
21
- <_timing_avg/>
22
- </_timing>
23
- <_notes>
24
- <_notes_general/>
25
- <_attachments/>
26
- </_notes>
27
18
  <code>
28
19
  <finalize output="result"/>
29
20
  <update output="result"/>
30
21
  </code>
22
+ <annotations>
23
+ <_timing>
24
+ <_timing_min/>
25
+ <_timing_max/>
26
+ <_timing_avg/>
27
+ </_timing>
28
+ <_notes>
29
+ <_notes_general/>
30
+ <_attachments/>
31
+ </_notes>
32
+ </annotations>
33
+ <documentation/>
31
34
  </call>
32
35
  </description>
33
36
  </description>
@@ -43,4 +46,4 @@
43
46
  <customer>pilotfabrik</customer>
44
47
  <status>development</status>
45
48
  </attributes>
46
- </testset>
49
+ </testset>
@@ -19,14 +19,6 @@
19
19
  <endpoints/>
20
20
  <stream/>
21
21
  </arguments>
22
- <stream>
23
- <sensors/>
24
- <aggregators/>
25
- <costs/>
26
- </stream>
27
- <report>
28
- <url/>
29
- </report>
30
22
  </parameters>
31
23
  <annotations>
32
24
  <_timing>
@@ -39,7 +31,11 @@
39
31
  <_notes>
40
32
  <_notes_general/>
41
33
  </_notes>
34
+ <report>
35
+ <url/>
36
+ </report>
42
37
  </annotations>
38
+ <documentation/>
43
39
  </call>
44
40
  </description>
45
41
  </description>
@@ -17,19 +17,22 @@
17
17
  <timeout>!data.time</timeout>
18
18
  </arguments>
19
19
  </parameters>
20
- <_timing>
21
- <_timing_min/>
22
- <_timing_max/>
23
- <_timing_avg/>
24
- </_timing>
25
- <_notes>
26
- <_notes_general/>
27
- <_attachments/>
28
- </_notes>
29
20
  <code>
30
21
  <finalize output="result">data.duration = data.time</finalize>
31
22
  <update output="result"/>
32
23
  </code>
24
+ <annotations>
25
+ <_timing>
26
+ <_timing_min/>
27
+ <_timing_max/>
28
+ <_timing_avg/>
29
+ </_timing>
30
+ <_notes>
31
+ <_notes_general/>
32
+ <_attachments/>
33
+ </_notes>
34
+ </annotations>
35
+ <documentation/>
33
36
  </call>
34
37
  </description>
35
38
  </description>
@@ -311,7 +311,7 @@ function WFAdaptorManifestation(adaptor) {
311
311
  },
312
312
  'info': function(node){ return { 'element-endpoint': $(node).attr('endpoint') }; },
313
313
  'resolve_symbol': function(node) {
314
- if($('code', node).length > 0) {
314
+ if($('> code', node).length > 0) {
315
315
  return 'callmanipulate';
316
316
  } else {
317
317
  return 'call';
@@ -329,7 +329,7 @@ function WFAdaptorManifestation(adaptor) {
329
329
  },
330
330
  'info': function(node){ return { 'element-endpoint': $(node).attr('endpoint') }; },
331
331
  'resolve_symbol': function(node) {
332
- if($('code', node).length > 0) {
332
+ if($('> code', node).length > 0) {
333
333
  return 'callmanipulate';
334
334
  } else {
335
335
  return 'call';
@@ -311,7 +311,7 @@ function WFAdaptorManifestation(adaptor) {
311
311
  },
312
312
  'info': function(node){ return { 'element-endpoint': $(node).attr('endpoint') }; },
313
313
  'resolve_symbol': function(node) {
314
- if($('code', node).length > 0) {
314
+ if($('> code', node).length > 0) {
315
315
  return 'callmanipulate';
316
316
  } else {
317
317
  return 'call';
@@ -329,7 +329,7 @@ function WFAdaptorManifestation(adaptor) {
329
329
  },
330
330
  'info': function(node){ return { 'element-endpoint': $(node).attr('endpoint') }; },
331
331
  'resolve_symbol': function(node) {
332
- if($('code', node).length > 0) {
332
+ if($('> code', node).length > 0) {
333
333
  return 'callmanipulate';
334
334
  } else {
335
335
  return 'call';
@@ -292,7 +292,7 @@ function WFAdaptorManifestation(adaptor) {
292
292
  },
293
293
  'info': function(node){ return { 'element-endpoint': $(node).attr('endpoint') }; },
294
294
  'resolve_symbol': function(node) {
295
- if($('code', node).length > 0) {
295
+ if($('> code', node).length > 0) {
296
296
  return 'callmanipulate';
297
297
  } else {
298
298
  return 'call';
@@ -311,7 +311,7 @@ function WFAdaptorManifestation(adaptor) {
311
311
  },
312
312
  'info': function(node){ return { 'element-endpoint': $(node).attr('endpoint') }; },
313
313
  'resolve_symbol': function(node) {
314
- if($('code', node).length > 0) {
314
+ if($('> code', node).length > 0) {
315
315
  return 'callmanipulate';
316
316
  } else {
317
317
  return 'call';
@@ -311,7 +311,7 @@ function WFAdaptorManifestation(adaptor) {
311
311
  },
312
312
  'info': function(node){ return { 'element-endpoint': $(node).attr('endpoint') }; },
313
313
  'resolve_symbol': function(node) {
314
- if($('code', node).length > 0) {
314
+ if($('> code', node).length > 0) {
315
315
  return 'callmanipulate';
316
316
  } else {
317
317
  return 'call';
data/cpee.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee"
3
- s.version = "2.1.26"
3
+ s.version = "2.1.32"
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.org). If you just need workflow execution, without a rest service exposing it, then use WEEL."
data/lib/cpee/fail.rb ADDED
@@ -0,0 +1,23 @@
1
+
2
+ # This file is part of CPEE.
3
+ #
4
+ # CPEE is free software: you can redistribute it and/or modify it under the terms
5
+ # of the GNU General Public License as published by the Free Software Foundation,
6
+ # either version 3 of the License, or (at your option) any later version.
7
+ #
8
+ # CPEE is distributed in the hope that it will be useful, but WITHOUT ANY
9
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
10
+ # PARTICULAR PURPOSE. See the GNU General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU General Public License along with
13
+ # CPEE (file COPYING in the main directory). If not, see
14
+ # <http://www.gnu.org/licenses/>.
15
+
16
+ module CPEE
17
+ class FAIL < Riddl::Implementation #{{{
18
+ def response
19
+ @status = 404
20
+ nil
21
+ end
22
+ end #}}}
23
+ end
@@ -16,6 +16,7 @@ require 'fileutils'
16
16
  require 'redis'
17
17
  require 'riddl/server'
18
18
  require 'riddl/client'
19
+ require_relative 'fail'
19
20
  require_relative 'redis'
20
21
  require_relative 'message'
21
22
  require_relative 'persistence'
@@ -83,7 +84,7 @@ module CPEE
83
84
  opts[:sse_connections] = {}
84
85
 
85
86
  opts[:statemachine] = CPEE::StateMachine.new opts[:states], %w{running simulating replaying finishing stopping abandoned finished} do |id|
86
- opts[:redis].get("instance:#{id}/state")
87
+ CPEE::Persistence::extract_item(id,opts,"state")
87
88
  end
88
89
 
89
90
  opts[:runtime_cmds] << [
@@ -176,16 +177,14 @@ module CPEE
176
177
 
177
178
  class Instances < Riddl::Implementation #{{{
178
179
  def response
179
- redis = @a[0][:redis]
180
+ opts = @a[0]
180
181
  Riddl::Parameter::Complex.new("wis","text/xml") do
181
182
  ins = XML::Smart::string('<instances/>')
182
- redis.zrevrange('instances',0,-1).each do |instance|
183
- statekey = "instance:#{instance}/state"
184
- attributes = "instance:#{instance}/attributes/"
185
- info = redis.get(attributes + 'info')
186
- uuid = redis.get(attributes + 'uuid')
187
- state = redis.get(statekey)
188
- state_changed = redis.get(File.join(statekey,'@changed'))
183
+ CPEE::Persistence::each_object(opts) do |instance|
184
+ info = CPEE::Persistence::extract_item(instance,opts,'attributes/info')
185
+ uuid = CPEE::Persistence::extract_item(instance,opts,'attributes/uuid')
186
+ state = CPEE::Persistence::extract_item(instance,opts,'state')
187
+ state_changed = CPEE::Persistence::extract_item(instance,opts,'state/@changed')
189
188
  ins.root.add('instance', info, 'uuid' => uuid, 'id' => instance, 'state' => state, 'state_changed' => state_changed )
190
189
  end
191
190
  ins.to_s
@@ -209,9 +208,9 @@ module CPEE
209
208
  doc = XML::Smart::open_unprotected(opts[:properties_init])
210
209
  doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0'
211
210
  name = @p[0].value
212
- id = redis.zrevrange('instances', 0, 0).first.to_i + 1
211
+ id = CPEE::Persistence::new_object(opts)
213
212
  uuid = SecureRandom.uuid
214
- instance = 'instance:' + id.to_s
213
+ instance = CPEE::Persistence::OBJ + ':' + id.to_s
215
214
  redis.multi do |multi|
216
215
  multi.zadd('instances',id,id)
217
216
  doc.root.find(PROPERTIES_PATHS_FULL.join(' | ')).each do |e|
@@ -235,12 +234,12 @@ module CPEE
235
234
  doc.register_namespace 'np', 'http://riddl.org/ns/common-patterns/notifications-producer/2.0'
236
235
  key = File.basename(File.dirname(f))
237
236
  url = doc.find('string(/np:subscription/@url)')
238
- multi.sadd("instance:#{id}/handlers",key)
239
- multi.set("instance:#{id}/handlers/#{key}/url",url)
237
+ multi.sadd(CPEE::Persistence::OBJ + ":#{id}/handlers",key)
238
+ multi.set(CPEE::Persistence::OBJ + ":#{id}/handlers/#{key}/url",url)
240
239
  doc.find('/np:subscription/np:topic/*').each do |e|
241
240
  c = File.join(e.parent.attributes['id'],e.qname.name,e.text)
242
- multi.sadd("instance:#{id}/handlers/#{key}",c)
243
- multi.sadd("instance:#{id}/handlers/#{c}",key)
241
+ multi.sadd(CPEE::Persistence::OBJ + ":#{id}/handlers/#{key}",c)
242
+ multi.sadd(CPEE::Persistence::OBJ + ":#{id}/handlers/#{c}",key)
244
243
  end
245
244
  end rescue nil # all the ones that are not ok, are ignored
246
245
  end
@@ -251,6 +250,12 @@ module CPEE
251
250
  multi.set(File.join(instance, 'state', '@changed'), Time.now.xmlschema(3))
252
251
  end
253
252
 
253
+ content = {
254
+ :state => 'ready',
255
+ :attributes => CPEE::Persistence::extract_list(id,opts,'attributes').to_h
256
+ }
257
+ CPEE::Message::send(:event,'state/change',File.join(opts[:url],'/'),id,uuid,name,content,redis)
258
+
254
259
  @headers << Riddl::Header.new("CPEE-INSTANCE", id.to_s)
255
260
  @headers << Riddl::Header.new("CPEE-INSTANCE-URL", File.join(opts[:url].to_s,id.to_s,'/'))
256
261
  @headers << Riddl::Header.new("CPEE-INSTANCE-UUID", uuid)
@@ -263,7 +268,7 @@ module CPEE
263
268
  def response
264
269
  opts = @a[0]
265
270
  id = @r[0].to_i
266
- unless opts[:redis].exists?("instance:#{id}/state")
271
+ unless CPEE::Persistence::exists?(id,opts)
267
272
  @status = 404
268
273
  return
269
274
  end
@@ -285,11 +290,22 @@ module CPEE
285
290
  opts = @a[0]
286
291
  redis = opts[:redis]
287
292
  id = @r[0].to_i
288
- unless redis.exists?("instance:#{id}/state")
293
+ unless CPEE::Persistence::exists?(id,opts)
289
294
  @status = 404
290
295
  return
291
296
  end
292
- empt = redis.keys("instance:#{id}/*").to_a
297
+
298
+ content = {
299
+ :state => 'purged',
300
+ :attributes => CPEE::Persistence::extract_list(id,opts,'attributes').to_h
301
+ }
302
+ state = CPEE::Persistence::extract_item(id,opts,'state')
303
+ if state == 'stopped' || state == 'ready'
304
+ CPEE::Message::send(:event,'state/change',File.join(opts[:url],'/'),id,content[:attributes]['uuid'],content[:attributes]['info'],content,redis)
305
+ end
306
+
307
+ empt = CPEE::Persistence::keys(id,opts).to_a
308
+ empt.delete_if{|e| e =~ /\/handlers/ }
293
309
  redis.multi do |multi|
294
310
  multi.del empt
295
311
  multi.zrem 'instances', id
@@ -13,17 +13,22 @@
13
13
  # <http://www.gnu.org/licenses/>.
14
14
 
15
15
  require 'json'
16
+ require_relative 'fail'
16
17
 
17
18
  module CPEE
18
19
  module Callbacks
19
20
 
20
21
  def self::implementation(id,opts)
21
22
  Proc.new do
22
- run CPEE::Callbacks::Callbacks, id, opts if get
23
- on resource do
24
- run CPEE::Callbacks::GetCallback, id, opts if get
25
- run CPEE::Callbacks::DelCallback, id, opts if delete
26
- run CPEE::Callbacks::ExCallback, id, opts if put
23
+ if CPEE::Persistence::exists?(id,opts)
24
+ run CPEE::Callbacks::Callbacks, id, opts if get
25
+ on resource do
26
+ run CPEE::Callbacks::GetCallback, id, opts if get
27
+ run CPEE::Callbacks::DelCallback, id, opts if delete
28
+ run CPEE::Callbacks::ExCallback, id, opts if put
29
+ end
30
+ else
31
+ run CPEE::FAIL
27
32
  end
28
33
  end
29
34
  end
@@ -50,13 +55,13 @@ module CPEE
50
55
  opts = @a[1]
51
56
  callback = @r[-1]
52
57
 
53
- if opts[:redis].sismember("instance:#{id}/callbacks",callback)
58
+ if CPEE::Persistence::is_member?(id,opts,'callbacks',callback)
54
59
  res = {}
55
- res[:uuid] = opts[:redis].get("instance:#{id}/callback/#{callback}/uuid")
56
- res[:type] = opts[:redis].get("instance:#{id}/callback/#{callback}/type")
57
- res[:position] = opts[:redis].get("instance:#{id}/callback/#{callback}/position")
58
- res[:label] = opts[:redis].get("instance:#{id}/callback/#{callback}/label")
59
- if sub = opts[:redis].get("instance:#{id}/callback/#{callback}/subscription")
60
+ res[:uuid] = CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/uuid")
61
+ res[:type] = CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/type")
62
+ res[:position] = CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/position")
63
+ res[:label] = CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/label")
64
+ if sub = CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/subscription")
60
65
  res[:subscription] = sub
61
66
  end
62
67
 
@@ -73,7 +78,7 @@ module CPEE
73
78
  opts = @a[1]
74
79
  callback = @r[-1]
75
80
 
76
- if opts[:redis].get("instance:#{id}/callback/#{callback}/type") == 'callback'
81
+ if CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/type") == 'callback'
77
82
  CPEE::Message::send(
78
83
  :'callback-end',
79
84
  callback,
@@ -84,7 +89,7 @@ module CPEE
84
89
  {},
85
90
  opts[:redis]
86
91
  )
87
- elsif opts[:redis].get("instance:#{id}/callback/#{callback}/type") == 'vote'
92
+ elsif CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/type") == 'vote'
88
93
  CPEE::Message::send(
89
94
  :'vote-response',
90
95
  callback,
@@ -108,7 +113,7 @@ module CPEE
108
113
  opts = @a[1]
109
114
  callback = @r[-1]
110
115
 
111
- if opts[:redis].get("instance:#{id}/callback/#{callback}/type") == 'callback'
116
+ if CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/type") == 'callback'
112
117
  ret = {}
113
118
  ret['values'] = @p.map{ |e|
114
119
  [e.name, e.class == Riddl::Parameter::Simple ? [:simple,e.value] : [:complex,e.mimetype,e.value.path] ]
@@ -125,7 +130,7 @@ module CPEE
125
130
  ret,
126
131
  opts[:redis]
127
132
  )
128
- elsif opts[:redis].get("instance:#{id}/callback/#{callback}/type") == 'vote'
133
+ elsif CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/type") == 'vote'
129
134
  if @p.length == 1 && @p[0].name == 'continue' && @p[0].class == Riddl::Parameter::Simple
130
135
  CPEE::Message::send(
131
136
  :'vote-response',
@@ -13,29 +13,34 @@
13
13
  # <http://www.gnu.org/licenses/>.
14
14
 
15
15
  require 'json'
16
+ require_relative 'fail'
16
17
 
17
18
  module CPEE
18
19
  module Notifications
19
20
 
20
21
  def self::implementation(id,opts)
21
22
  Proc.new do
22
- on resource "notifications" do
23
- run CPEE::Notifications::Overview if get
24
- on resource "topics" do
25
- run CPEE::Notifications::Topics, opts if get
26
- end
27
- on resource "subscriptions" do
28
- run CPEE::Notifications::Subscriptions, id, opts if get
29
- run CPEE::Notifications::CreateSubscription, id, opts if post 'create_subscription'
30
- on resource do
31
- run CPEE::Notifications::Subscription, id, opts if get
32
- run CPEE::Notifications::UpdateSubscription, id, opts if put 'change_subscription'
33
- run CPEE::Notifications::DeleteSubscription, id, opts if delete
34
- on resource 'sse' do
35
- run CPEE::Notifications::SSE, id, opts if sse
23
+ if CPEE::Persistence::exists?(id,opts)
24
+ on resource "notifications" do
25
+ run CPEE::Notifications::Overview if get
26
+ on resource "topics" do
27
+ run CPEE::Notifications::Topics, opts if get
28
+ end
29
+ on resource "subscriptions" do
30
+ run CPEE::Notifications::Subscriptions, id, opts if get
31
+ run CPEE::Notifications::CreateSubscription, id, opts if post 'create_subscription'
32
+ on resource do
33
+ run CPEE::Notifications::Subscription, id, opts if get
34
+ run CPEE::Notifications::UpdateSubscription, id, opts if put 'change_subscription'
35
+ run CPEE::Notifications::DeleteSubscription, id, opts if delete
36
+ on resource 'sse' do
37
+ run CPEE::Notifications::SSE, id, opts if sse
38
+ end
36
39
  end
37
40
  end
38
41
  end
42
+ else
43
+ run CPEE::FAIL
39
44
  end
40
45
  end
41
46
  end
@@ -184,7 +189,7 @@ module CPEE
184
189
  on.pmessage do |pat, what, message|
185
190
  if pat == 'forward:*'
186
191
  id, key = what.match(/forward:([^\/]+)\/(.+)/).captures
187
- if sse = opts.dig(:sse_connections,id.to_i,key)
192
+ if sse = opts.dig(:sse_connections,id,key)
188
193
  sse.send message
189
194
  else
190
195
  DeleteSubscription::set(id,opts,key)
@@ -193,7 +198,7 @@ module CPEE
193
198
  mess = JSON.parse(message[message.index(' ')+1..-1])
194
199
  state = mess.dig('content','state')
195
200
  if state == 'finished' || state == 'abandoned'
196
- opts.dig(:sse_connections,mess.dig('instance').to_i)&.each do |key,sse|
201
+ opts.dig(:sse_connections,mess.dig('instance').to_s)&.each do |key,sse|
197
202
  EM.add_timer(10) do # just to be sure that all messages arrived. 10 seconds should be enough ... we think ... therefore we are (not sure)
198
203
  sse.close
199
204
  end
@@ -214,7 +219,7 @@ module CPEE
214
219
  class SSE < Riddl::SSEImplementation #{{{
215
220
  def onopen
216
221
  @opts = @a[1]
217
- @id = @a[0]
222
+ @id = @a[0].to_s
218
223
  @key = @r[-2]
219
224
  if CPEE::Persistence::exists_handler?(@id,@opts,@key)
220
225
  @opts[:sse_connections][@id] ||= {}