openwferu 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/mano_tracker.rb +11 -13
- data/lib/openwfe.rb +2 -4
- data/lib/openwfe/contextual.rb +8 -2
- data/lib/openwfe/engine/engine.rb +118 -2
- data/lib/openwfe/expool/expressionpool.rb +148 -53
- data/lib/openwfe/expool/expstorage.rb +36 -4
- data/lib/openwfe/expool/yamlexpstorage.rb +18 -0
- data/lib/openwfe/expressions/environment.rb +1 -1
- data/lib/openwfe/expressions/fe_misc.rb +14 -2
- data/lib/openwfe/expressions/fe_raw.rb +27 -11
- data/lib/openwfe/expressions/fe_subprocess.rb +45 -12
- data/lib/openwfe/expressions/fe_utils.rb +1 -1
- data/lib/openwfe/expressions/flowexpression.rb +5 -1
- data/lib/openwfe/expressions/raw_prog.rb +80 -32
- data/lib/openwfe/expressions/raw_xml.rb +10 -0
- data/lib/openwfe/flowexpressionid.rb +28 -7
- data/lib/openwfe/listeners/listener.rb +106 -0
- data/lib/openwfe/listeners/listeners.rb +140 -0
- data/lib/openwfe/listeners/socketlisteners.rb +239 -0
- data/lib/openwfe/listeners/sqslisteners.rb +145 -0
- data/lib/openwfe/participants/{csvparticipant.rb → csvparticipants.rb} +0 -0
- data/lib/openwfe/participants/{enoparticipant.rb → enoparticipants.rb} +1 -1
- data/lib/openwfe/participants/participantmap.rb +33 -1
- data/lib/openwfe/participants/participants.rb +99 -11
- data/lib/openwfe/participants/soapparticipants.rb +28 -8
- data/lib/openwfe/participants/socketparticipants.rb +172 -0
- data/lib/openwfe/participants/sqsparticipants.rb +121 -0
- data/lib/openwfe/rest/definitions.rb +1 -1
- data/lib/openwfe/{osocket.rb → rest/osocket.rb} +16 -8
- data/lib/openwfe/rest/xmlcodec.rb +41 -5
- data/lib/openwfe/storage/yamlfilestorage.rb +10 -13
- data/lib/openwfe/util/dollar.rb +23 -2
- data/lib/openwfe/util/otime.rb +1 -1
- data/lib/openwfe/util/safe.rb +149 -0
- data/lib/openwfe/util/scheduler.rb +47 -5
- data/lib/openwfe/util/sqs.rb +582 -0
- data/lib/openwfe/utils.rb +23 -0
- data/lib/openwfe/version.rb +1 -1
- data/lib/openwfe/workitem.rb +86 -3
- data/lib/openwfe/worklist/storeparticipant.rb +44 -4
- data/test/csv_test.rb +1 -1
- data/test/eno_test.rb +1 -1
- data/test/fei_test.rb +2 -15
- data/test/flowtestbase.rb +6 -2
- data/test/ft_11_ppd.rb +31 -0
- data/test/ft_13_eno.rb +1 -1
- data/test/ft_14b_subprocess.rb +74 -0
- data/test/ft_15_iterator.rb +0 -1
- data/test/ft_19_csv.rb +1 -1
- data/test/ft_20_cron.rb +1 -1
- data/test/ft_21_cron.rb +1 -1
- data/test/ft_27_getflowpos.rb +89 -0
- data/test/ft_28_fileparticipant.rb +65 -0
- data/test/ft_29_httprb.rb +95 -0
- data/test/ft_30_socketlistener.rb +197 -0
- data/test/ft_4_misc.rb +2 -1
- data/test/hash_test.rb +75 -0
- data/test/rake_qtest.rb +5 -4
- data/test/raw_prog_test.rb +205 -0
- data/test/rutest_utils.rb +16 -0
- data/test/safely_test.rb +89 -0
- data/test/scheduler_test.rb +71 -0
- data/test/sqs_test.rb +103 -0
- metadata +21 -6
- data/test/journal_persistence_test.rb +0 -147
@@ -58,6 +58,14 @@ module OpenWFE
|
|
58
58
|
class CacheExpressionStorage
|
59
59
|
include ServiceMixin, OwfeServiceLocator
|
60
60
|
|
61
|
+
#
|
62
|
+
# under 20 stored expressions, the unit tests for the
|
63
|
+
# CachedFilePersistedEngine do fail because the persistent storage
|
64
|
+
# behind the cache hasn't the time to flush its work queue.
|
65
|
+
# a min size limit has been set to 77.
|
66
|
+
#
|
67
|
+
MIN_SIZE = 77
|
68
|
+
|
61
69
|
DEFAULT_SIZE = 5000
|
62
70
|
|
63
71
|
def initialize (service_name, application_context)
|
@@ -68,6 +76,7 @@ module OpenWFE
|
|
68
76
|
|
69
77
|
size = @application_context[:expression_cache_size]
|
70
78
|
size = DEFAULT_SIZE unless size
|
79
|
+
size = MIN_SIZE unless size > MIN_SIZE
|
71
80
|
|
72
81
|
linfo { "new() size is #{size}" }
|
73
82
|
|
@@ -100,7 +109,10 @@ module OpenWFE
|
|
100
109
|
|
101
110
|
fe = get_real_storage[fei]
|
102
111
|
|
103
|
-
|
112
|
+
unless fe
|
113
|
+
#ldebug { "[] (reload) miss for #{fei.to_debug_s}" }
|
114
|
+
return nil
|
115
|
+
end
|
104
116
|
|
105
117
|
@cache[fei] = fe
|
106
118
|
|
@@ -137,17 +149,35 @@ module OpenWFE
|
|
137
149
|
end
|
138
150
|
|
139
151
|
def each (&block)
|
140
|
-
|
141
|
-
|
142
|
-
end
|
152
|
+
#@cache.each do |k, v|
|
153
|
+
# block.call(k, v)
|
154
|
+
#end
|
155
|
+
@cache.each(&block)
|
156
|
+
end
|
157
|
+
|
158
|
+
#
|
159
|
+
# This each() just delegates to the real storage each() method.
|
160
|
+
#
|
161
|
+
def real_each (&block)
|
162
|
+
#@cache.each do |k, v|
|
163
|
+
# block.call(k, v)
|
164
|
+
#end
|
165
|
+
get_real_storage.each(&block)
|
143
166
|
end
|
144
167
|
|
168
|
+
#
|
169
|
+
# Displays a human-friendly view on this storage
|
170
|
+
#
|
145
171
|
def to_s
|
146
172
|
expstorage_to_s(self)
|
147
173
|
end
|
148
174
|
|
149
175
|
protected
|
150
176
|
|
177
|
+
#
|
178
|
+
# Returns the "real storage" i.e. the storage that does the real
|
179
|
+
# persistence behind this "cache storage".
|
180
|
+
#
|
151
181
|
def get_real_storage
|
152
182
|
|
153
183
|
return @real_storage if @real_storage
|
@@ -197,6 +227,8 @@ module OpenWFE
|
|
197
227
|
def to_s
|
198
228
|
expstorage_to_s(self)
|
199
229
|
end
|
230
|
+
|
231
|
+
alias :real_each :each
|
200
232
|
|
201
233
|
end
|
202
234
|
|
@@ -136,6 +136,14 @@ module OpenWFE
|
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
|
+
def each (&block)
|
140
|
+
each_object do |flow_expression|
|
141
|
+
block.call(flow_expression.fei, flow_expression)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
alias :real_each :each
|
146
|
+
|
139
147
|
def to_s
|
140
148
|
|
141
149
|
s = "\n\n==== #{self.class} ===="
|
@@ -237,6 +245,16 @@ module OpenWFE
|
|
237
245
|
super
|
238
246
|
end
|
239
247
|
|
248
|
+
#
|
249
|
+
# calls process_queue() before the call the super class each()
|
250
|
+
# method
|
251
|
+
#
|
252
|
+
def each (&block)
|
253
|
+
|
254
|
+
process_queue()
|
255
|
+
super
|
256
|
+
end
|
257
|
+
|
240
258
|
protected
|
241
259
|
|
242
260
|
def start_processing_thread
|
@@ -39,6 +39,7 @@
|
|
39
39
|
# John Mettraux at openwfe.org
|
40
40
|
#
|
41
41
|
|
42
|
+
require 'openwfe/util/safe'
|
42
43
|
require 'openwfe/expressions/flowexpression'
|
43
44
|
require 'openwfe/expressions/fe_utils'
|
44
45
|
|
@@ -77,10 +78,18 @@ module OpenWFE
|
|
77
78
|
# <reval/>
|
78
79
|
#
|
79
80
|
# Evals some Ruby code contained within the process definition
|
80
|
-
# or within the workitem
|
81
|
+
# or within the workitem.
|
82
|
+
#
|
83
|
+
# The code is evaluated at a SAFE level of 1.
|
81
84
|
#
|
82
85
|
class RevalExpression < FlowExpression
|
83
86
|
|
87
|
+
#
|
88
|
+
# See for an explanation on Ruby safety levels :
|
89
|
+
# http://www.rubycentral.com/book/taint.html
|
90
|
+
#
|
91
|
+
SAFETY_LEVEL = 3
|
92
|
+
|
84
93
|
def apply (workitem)
|
85
94
|
|
86
95
|
escape = lookup_boolean_attribute('escape', workitem, false)
|
@@ -90,7 +99,10 @@ module OpenWFE
|
|
90
99
|
code = OpenWFE::fetch_text_content(self, workitem, escape) \
|
91
100
|
unless code
|
92
101
|
|
93
|
-
|
102
|
+
code = code.to_s
|
103
|
+
|
104
|
+
#result = eval(code)
|
105
|
+
result = OpenWFE::eval_safely(code, SAFETY_LEVEL, binding())
|
94
106
|
|
95
107
|
OpenWFE::set_result(workitem, result) \
|
96
108
|
if result != nil # 'false' is a valid result
|
@@ -55,9 +55,6 @@ module OpenWFE
|
|
55
55
|
#
|
56
56
|
class RawExpression < FlowExpression
|
57
57
|
|
58
|
-
#attr_accessor \
|
59
|
-
# :raw_representation
|
60
|
-
|
61
58
|
def initialize \
|
62
59
|
(fei, parent_id, env_id, application_context, raw_representation)
|
63
60
|
|
@@ -65,7 +62,9 @@ module OpenWFE
|
|
65
62
|
|
66
63
|
@raw_representation = raw_representation
|
67
64
|
|
68
|
-
new_environment() if not @environment_id
|
65
|
+
#new_environment() if not @environment_id
|
66
|
+
#
|
67
|
+
# now done in the launch methods of the expression pool
|
69
68
|
end
|
70
69
|
|
71
70
|
def instantiate_real_expression \
|
@@ -139,6 +138,8 @@ module OpenWFE
|
|
139
138
|
expression = instantiate_real_expression(
|
140
139
|
workitem, exp_class, attributes)
|
141
140
|
|
141
|
+
expression.apply_time = OpenWFE::now()
|
142
|
+
|
142
143
|
expression.apply(workitem)
|
143
144
|
end
|
144
145
|
|
@@ -172,20 +173,35 @@ module OpenWFE
|
|
172
173
|
#pp attributes
|
173
174
|
#pp lookup_attributes(workitem, attributes)
|
174
175
|
|
176
|
+
# TODO : do not use extract_children() !!!!!!!!
|
177
|
+
#self.children = extract_children()
|
178
|
+
#params = lookup_attributes(workitem)
|
179
|
+
#text = OpenWFE::fetch_text_content(self, workitem, false)
|
180
|
+
#params["0"] = text if text
|
181
|
+
|
182
|
+
params = lookup_attributes(workitem)
|
183
|
+
|
184
|
+
extract_text_children.each_with_index do |value, index|
|
185
|
+
params[index.to_s] = value
|
186
|
+
end
|
187
|
+
|
175
188
|
get_expression_pool().launch_template(
|
176
189
|
self,
|
177
190
|
0,
|
178
191
|
template,
|
179
192
|
workitem,
|
180
|
-
|
193
|
+
params)
|
181
194
|
end
|
182
195
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
196
|
+
def extract_attributes ()
|
197
|
+
raise NotImplementedError.new("'abstract method' sorry")
|
198
|
+
end
|
199
|
+
def extract_children ()
|
200
|
+
raise NotImplementedError.new("'abstract method' sorry")
|
201
|
+
end
|
202
|
+
def extract_text_children ()
|
203
|
+
raise NotImplementedError.new("'abstract method' sorry")
|
204
|
+
end
|
189
205
|
end
|
190
206
|
|
191
207
|
end
|
@@ -39,6 +39,9 @@
|
|
39
39
|
# John Mettraux at openwfe.org
|
40
40
|
#
|
41
41
|
|
42
|
+
#require 'uri'
|
43
|
+
|
44
|
+
require 'openwfe/utils'
|
42
45
|
require 'openwfe/expressions/fe_utils'
|
43
46
|
|
44
47
|
|
@@ -65,6 +68,19 @@ module OpenWFE
|
|
65
68
|
#
|
66
69
|
# </process-definition>
|
67
70
|
#
|
71
|
+
# It's totally OK to have URLs as referenced processes :
|
72
|
+
#
|
73
|
+
# require 'openwfe/def'
|
74
|
+
#
|
75
|
+
# class AnotherDefinition0 < OpenWFE::ProcessDefinition
|
76
|
+
# def make
|
77
|
+
# sequence do
|
78
|
+
# participant ref => "toto"
|
79
|
+
# subprocess ref => "http://company.process.server/def0.rb"
|
80
|
+
# end
|
81
|
+
# end
|
82
|
+
# end
|
83
|
+
#
|
68
84
|
class SubProcessRefExpression < FlowExpression
|
69
85
|
|
70
86
|
#
|
@@ -74,14 +90,20 @@ module OpenWFE
|
|
74
90
|
|
75
91
|
ref = OpenWFE::lookup_ref(self, workitem)
|
76
92
|
|
77
|
-
raise "'subprocess' expression misses a 'ref', 'field-ref' or 'variable-ref' attribute"
|
93
|
+
raise "'subprocess' expression misses a 'ref', 'field-ref' or 'variable-ref' attribute" unless ref
|
94
|
+
|
95
|
+
template_uri = parse_uri(ref)
|
78
96
|
|
79
|
-
|
97
|
+
template = if template_uri
|
98
|
+
template_uri
|
99
|
+
else
|
100
|
+
lookup_variable(ref)
|
101
|
+
end
|
80
102
|
|
81
103
|
#template_fei = lookup_participant(ref) if not template_fei
|
82
104
|
|
83
105
|
raise "did not find any subprocess named '#{ref}'" \
|
84
|
-
if not
|
106
|
+
if not template
|
85
107
|
|
86
108
|
forget = lookup_boolean_attribute(:forget, workitem)
|
87
109
|
|
@@ -90,22 +112,33 @@ module OpenWFE
|
|
90
112
|
|
91
113
|
params = lookup_attributes(workitem)
|
92
114
|
|
93
|
-
|
115
|
+
text = OpenWFE::fetch_text_content(self, workitem, false)
|
116
|
+
params["0"] = text if text
|
117
|
+
|
118
|
+
#puts " ... params are #{params.keys.join(', ')}"
|
94
119
|
|
95
120
|
get_expression_pool()\
|
96
|
-
.launch_template(requester, 0,
|
121
|
+
.launch_template(requester, 0, template, workitem, params)
|
97
122
|
end
|
98
123
|
|
99
124
|
#def reply (workitem)
|
100
125
|
#end
|
101
126
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
127
|
+
protected
|
128
|
+
|
129
|
+
def parse_uri (ref)
|
130
|
+
|
131
|
+
uri = OpenWFE::parse_uri(ref)
|
132
|
+
|
133
|
+
return nil unless uri
|
134
|
+
|
135
|
+
return uri if uri.scheme == "http"
|
136
|
+
return uri if uri.scheme == "https"
|
137
|
+
return uri if uri.scheme == "ftp"
|
138
|
+
# what else ...
|
139
|
+
|
140
|
+
return nil
|
141
|
+
end
|
109
142
|
end
|
110
143
|
|
111
144
|
end
|
@@ -183,7 +183,11 @@ module OpenWFE
|
|
183
183
|
#
|
184
184
|
def owns_its_environment? ()
|
185
185
|
|
186
|
-
#ldebug
|
186
|
+
#ldebug do
|
187
|
+
# "owns_its_environment?()\n" +
|
188
|
+
# " #{@fei.to_debug_s}\n" +
|
189
|
+
# " #{@environment_id.to_debug_s}"
|
190
|
+
#end
|
187
191
|
|
188
192
|
return false if not @environment_id
|
189
193
|
|
@@ -55,7 +55,9 @@ module OpenWFE
|
|
55
55
|
|
56
56
|
attr_reader \
|
57
57
|
:name,
|
58
|
-
:attributes
|
58
|
+
:attributes
|
59
|
+
|
60
|
+
attr_accessor \
|
59
61
|
:children
|
60
62
|
|
61
63
|
def initialize (name, attributes)
|
@@ -75,7 +77,7 @@ module OpenWFE
|
|
75
77
|
#
|
76
78
|
# Always return the ProgRawExpression class.
|
77
79
|
#
|
78
|
-
def
|
80
|
+
def raw_expression_class
|
79
81
|
return ProgRawExpression
|
80
82
|
end
|
81
83
|
|
@@ -175,29 +177,14 @@ module OpenWFE
|
|
175
177
|
#
|
176
178
|
class ProcessDefinition
|
177
179
|
|
180
|
+
attr_reader :top_expressions
|
181
|
+
|
178
182
|
#def initialize (exp_names=nil)
|
179
183
|
def initialize ()
|
180
184
|
|
181
185
|
super()
|
182
186
|
|
183
|
-
|
184
|
-
# exp_names = $EXPRESSION_NAMES if $EXPRESSION_NAMES
|
185
|
-
#else
|
186
|
-
# if exp_names.kind_of? ExpressionMap
|
187
|
-
# exp_names = exp_names.expression_names
|
188
|
-
# elsif exp_names.kind_of? Engine
|
189
|
-
# exp_names = exp_names.get_expression_map.expression_names
|
190
|
-
# elsif exp_names.kind_of? Hash
|
191
|
-
# exp_names = exp_names[S_EXPRESSION_MAP].expression_names
|
192
|
-
# elsif not exp_names.kind_of? Array
|
193
|
-
# exp_names = $EXPRESSION_NAMES
|
194
|
-
# end
|
195
|
-
#end
|
196
|
-
#if not exp_names
|
197
|
-
# raise "no expression names found, please provide them"
|
198
|
-
#end
|
199
|
-
#@exp_names = exp_names
|
200
|
-
|
187
|
+
@top_expressions = []
|
201
188
|
@previous_parent_expression = []
|
202
189
|
end
|
203
190
|
|
@@ -207,16 +194,9 @@ module OpenWFE
|
|
207
194
|
|
208
195
|
expname = OpenWFE.to_expression_name(methodname)
|
209
196
|
|
210
|
-
|
211
|
-
# #raise "No expression named '#{methodname}' (#{expname}) found"
|
212
|
-
# #raise "No expression named '#{expname}' found"
|
213
|
-
# params = args[0]
|
214
|
-
# params = {} if not params
|
215
|
-
# params["ref"] = methodname
|
216
|
-
# return make_expression("subprocess", params, &block)
|
217
|
-
#end
|
197
|
+
args = pack_args(args)
|
218
198
|
|
219
|
-
make_expression(expname, args
|
199
|
+
make_expression(expname, args, &block)
|
220
200
|
end
|
221
201
|
|
222
202
|
#
|
@@ -250,8 +230,11 @@ module OpenWFE
|
|
250
230
|
exp.children << string_child \
|
251
231
|
if string_child
|
252
232
|
|
253
|
-
@parent_expression
|
254
|
-
|
233
|
+
if @parent_expression
|
234
|
+
@parent_expression << exp
|
235
|
+
else
|
236
|
+
@top_expressions << exp
|
237
|
+
end
|
255
238
|
|
256
239
|
return exp if not block
|
257
240
|
|
@@ -280,8 +263,66 @@ module OpenWFE
|
|
280
263
|
# segment raw representation
|
281
264
|
#
|
282
265
|
def ProcessDefinition.do_make ()
|
283
|
-
|
266
|
+
|
267
|
+
pdef = self.new
|
268
|
+
exp = pdef.make
|
269
|
+
|
270
|
+
if pdef.top_expressions.size == 1 and \
|
271
|
+
exp.name == "process-definition"
|
272
|
+
|
273
|
+
return exp
|
274
|
+
end
|
275
|
+
|
276
|
+
name, revision = extract_name_and_revision(pdef.class.name)
|
277
|
+
attributes = {}
|
278
|
+
attributes["name"] = name
|
279
|
+
attributes["revision"] = revision
|
280
|
+
|
281
|
+
top_expression = ProgExpRepresentation.new(
|
282
|
+
"process-definition", attributes)
|
283
|
+
|
284
|
+
top_expression.children = pdef.top_expressions
|
285
|
+
|
286
|
+
top_expression
|
284
287
|
end
|
288
|
+
|
289
|
+
protected
|
290
|
+
|
291
|
+
def pack_args (args)
|
292
|
+
return args[0] if args.length == 1
|
293
|
+
a = {}
|
294
|
+
args.each_with_index do |arg, index|
|
295
|
+
if arg.is_a? Hash
|
296
|
+
a = a.merge(arg)
|
297
|
+
break
|
298
|
+
end
|
299
|
+
a[index.to_s] = arg
|
300
|
+
end
|
301
|
+
a
|
302
|
+
end
|
303
|
+
|
304
|
+
def ProcessDefinition.extract_name_and_revision (s)
|
305
|
+
|
306
|
+
#puts "s is >#{s}<"
|
307
|
+
|
308
|
+
m = Regexp.compile(".*::([^0-9_]*)_*([0-9][0-9_]*)$").match(s)
|
309
|
+
return [ as_name(m[1]), as_revision(m[2]) ] if m
|
310
|
+
|
311
|
+
m = Regexp.compile(".*::(.*$)").match(s)
|
312
|
+
return [ as_name(m[1]), '0' ] if m
|
313
|
+
|
314
|
+
return [ as_name(s), '0' ]
|
315
|
+
end
|
316
|
+
|
317
|
+
def ProcessDefinition.as_name (s)
|
318
|
+
|
319
|
+
return s[0..-11] if s.match(".*Definition$")
|
320
|
+
return s
|
321
|
+
end
|
322
|
+
|
323
|
+
def ProcessDefinition.as_revision (s)
|
324
|
+
s.gsub("_", ".")
|
325
|
+
end
|
285
326
|
end
|
286
327
|
|
287
328
|
#
|
@@ -337,6 +378,13 @@ module OpenWFE
|
|
337
378
|
end
|
338
379
|
end
|
339
380
|
end
|
381
|
+
|
382
|
+
def extract_text_children ()
|
383
|
+
raw_representation.children.collect do |child|
|
384
|
+
next if child.is_a? ProgExpRepresentation
|
385
|
+
child.to_s
|
386
|
+
end
|
387
|
+
end
|
340
388
|
end
|
341
389
|
|
342
390
|
private
|