openwferu 0.9.15 → 0.9.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data/README.txt +4 -2
  2. data/lib/openwfe/engine/engine.rb +143 -25
  3. data/lib/openwfe/engine/file_persisted_engine.rb +3 -3
  4. data/lib/openwfe/expool/errorjournal.rb +48 -25
  5. data/lib/openwfe/expool/expressionpool.rb +77 -106
  6. data/lib/openwfe/expool/expstorage.rb +6 -5
  7. data/lib/openwfe/expool/threadedexpstorage.rb +190 -0
  8. data/lib/openwfe/expool/yamlexpstorage.rb +5 -150
  9. data/lib/openwfe/expressions/condition.rb +6 -6
  10. data/lib/openwfe/expressions/environment.rb +7 -2
  11. data/lib/openwfe/expressions/expressionmap.rb +14 -0
  12. data/lib/openwfe/expressions/fe_command.rb +2 -1
  13. data/lib/openwfe/expressions/fe_concurrence.rb +40 -18
  14. data/lib/openwfe/expressions/fe_cron.rb +14 -11
  15. data/lib/openwfe/expressions/fe_cursor.rb +2 -3
  16. data/lib/openwfe/expressions/fe_define.rb +34 -31
  17. data/lib/openwfe/expressions/fe_equals.rb +11 -21
  18. data/lib/openwfe/expressions/fe_filter_definition.rb +0 -2
  19. data/lib/openwfe/expressions/fe_fqv.rb +1 -3
  20. data/lib/openwfe/expressions/fe_if.rb +37 -12
  21. data/lib/openwfe/expressions/fe_iterator.rb +1 -1
  22. data/lib/openwfe/expressions/fe_listen.rb +147 -28
  23. data/lib/openwfe/expressions/fe_losfor.rb +13 -1
  24. data/lib/openwfe/expressions/fe_misc.rb +70 -11
  25. data/lib/openwfe/expressions/fe_participant.rb +3 -3
  26. data/lib/openwfe/expressions/fe_reserve.rb +1 -1
  27. data/lib/openwfe/expressions/fe_save.rb +11 -12
  28. data/lib/openwfe/expressions/fe_sequence.rb +22 -29
  29. data/lib/openwfe/expressions/fe_sleep.rb +11 -7
  30. data/lib/openwfe/expressions/fe_subprocess.rb +24 -10
  31. data/lib/openwfe/expressions/fe_value.rb +35 -15
  32. data/lib/openwfe/expressions/fe_when.rb +2 -4
  33. data/lib/openwfe/expressions/flowexpression.rb +73 -37
  34. data/lib/openwfe/expressions/merge.rb +2 -4
  35. data/lib/openwfe/expressions/raw.rb +40 -31
  36. data/lib/openwfe/expressions/raw_prog.rb +18 -9
  37. data/lib/openwfe/expressions/raw_xml.rb +1 -8
  38. data/lib/openwfe/expressions/simplerep.rb +27 -5
  39. data/lib/openwfe/expressions/time.rb +45 -15
  40. data/lib/openwfe/expressions/timeout.rb +2 -1
  41. data/lib/openwfe/expressions/wtemplate.rb +2 -2
  42. data/lib/openwfe/flowexpressionid.rb +62 -16
  43. data/lib/openwfe/listeners/listener.rb +28 -37
  44. data/lib/openwfe/listeners/listeners.rb +1 -1
  45. data/lib/openwfe/listeners/socketlisteners.rb +7 -15
  46. data/lib/openwfe/logging.rb +5 -4
  47. data/lib/openwfe/{rest → orest}/controlclient.rb +3 -5
  48. data/lib/openwfe/{rest → orest}/definitions.rb +0 -2
  49. data/lib/openwfe/{rest → orest}/exception.rb +0 -0
  50. data/lib/openwfe/{rest → orest}/oldrestservlet.rb +1 -1
  51. data/lib/openwfe/{rest → orest}/osocket.rb +1 -1
  52. data/lib/openwfe/{rest → orest}/restclient.rb +0 -2
  53. data/lib/openwfe/orest/workitem.rb +206 -0
  54. data/lib/openwfe/{rest → orest}/worklistclient.rb +15 -5
  55. data/lib/openwfe/{rest → orest}/xmlcodec.rb +4 -1
  56. data/lib/openwfe/participants/enoparticipants.rb +4 -14
  57. data/lib/openwfe/participants/participantmap.rb +16 -12
  58. data/lib/openwfe/participants/participants.rb +46 -1
  59. data/lib/openwfe/participants/socketparticipants.rb +1 -6
  60. data/lib/openwfe/service.rb +15 -6
  61. data/lib/openwfe/storage/yamlcustom.rb +3 -0
  62. data/lib/openwfe/storage/yamlfilestorage.rb +3 -1
  63. data/lib/openwfe/util/dollar.rb +21 -14
  64. data/lib/openwfe/util/lru.rb +29 -10
  65. data/lib/openwfe/util/observable.rb +4 -1
  66. data/lib/openwfe/util/otime.rb +3 -0
  67. data/lib/openwfe/util/scheduler.rb +346 -114
  68. data/lib/openwfe/utils.rb +67 -13
  69. data/lib/openwfe/version.rb +1 -1
  70. data/lib/openwfe/workitem.rb +22 -165
  71. data/lib/openwfe/worklist/oldrest.rb +2 -2
  72. data/test/bm/bm_1_xml_vs_prog.rb +56 -0
  73. data/test/{ft_26_load.rb → bm/ft_26_load.rb} +0 -0
  74. data/test/{ft_26b_load.rb → bm/ft_26b_load.rb} +0 -0
  75. data/test/{ft_26c_load.rb → bm/ft_26c_load.rb} +16 -4
  76. data/test/clone_test.rb +62 -0
  77. data/test/cron_test.rb +56 -1
  78. data/test/cronline_test.rb +17 -8
  79. data/test/description_test.rb +57 -0
  80. data/test/dollar_test.rb +17 -6
  81. data/test/eno_test.rb +22 -9
  82. data/test/fe_lookup_att_test.rb +50 -0
  83. data/test/fei_test.rb +18 -9
  84. data/test/flowtestbase.rb +24 -2
  85. data/test/ft_0.rb +10 -12
  86. data/test/ft_0e_multibody.rb +34 -0
  87. data/test/ft_10_loop.rb +4 -6
  88. data/test/ft_11_ppd.rb +5 -20
  89. data/test/ft_14b_subprocess.rb +2 -2
  90. data/test/ft_15_iterator.rb +56 -4
  91. data/test/ft_15b_iterator.rb +48 -0
  92. data/test/ft_16_fqv.rb +18 -3
  93. data/test/ft_23c_wait.rb +7 -5
  94. data/test/ft_25_cancel.rb +5 -3
  95. data/test/ft_27_getflowpos.rb +14 -11
  96. data/test/ft_28_fileparticipant.rb +3 -4
  97. data/test/ft_2_concurrence.rb +8 -12
  98. data/test/ft_2b_concurrence.rb +3 -2
  99. data/test/ft_30_socketlistener.rb +5 -6
  100. data/test/ft_32c_journal.rb +2 -2
  101. data/test/ft_32d_journal.rb +5 -6
  102. data/test/ft_33_description.rb +8 -3
  103. data/test/ft_34_cancelwfid.rb +3 -3
  104. data/test/ft_38_tag.rb +7 -10
  105. data/test/ft_39_reserve.rb +4 -2
  106. data/test/ft_3_equals.rb +18 -13
  107. data/test/ft_44b_restore.rb +2 -6
  108. data/test/ft_49_condition.rb +16 -12
  109. data/test/ft_4_misc.rb +51 -12
  110. data/test/ft_50_xml_attribute.rb +1 -1
  111. data/test/ft_54_listen.rb +96 -10
  112. data/test/ft_54b_listen.rb +68 -0
  113. data/test/ft_55_ptimeout.rb +1 -2
  114. data/test/ft_58_ejournal.rb +8 -33
  115. data/test/ft_59_ps.rb +2 -3
  116. data/test/ft_59b_ps_for_pat.rb +59 -0
  117. data/test/ft_5_time.rb +45 -4
  118. data/test/ft_60_ecancel.rb +7 -7
  119. data/test/ft_61_elsub.rb +1 -1
  120. data/test/ft_64_alias.rb +1 -1
  121. data/test/ft_67_schedlaunch.rb +29 -16
  122. data/test/ft_69_cancelmissing.rb +1 -1
  123. data/test/ft_6_lambda.rb +8 -6
  124. data/test/ft_70_lookupvar.rb +2 -2
  125. data/test/ft_71_log.rb +60 -0
  126. data/test/ft_72_lookup_processes.rb +79 -0
  127. data/test/ft_73_cancel_sub.rb +144 -0
  128. data/test/ft_74_block_and_workitem_dup.rb +63 -0
  129. data/test/ft_75_ruby_attributes.rb +87 -0
  130. data/test/ft_76_merge_isolate.rb +90 -0
  131. data/test/ft_7_lose.rb +2 -1
  132. data/test/ft_tests.rb +9 -0
  133. data/test/lookup_att_test.rb +90 -0
  134. data/test/misc_test.rb +33 -50
  135. data/test/orest_test.rb +1 -1
  136. data/test/participant_test.rb +32 -8
  137. data/test/pending.rb +6 -7
  138. data/test/rake_ltest.rb +3 -0
  139. data/test/rake_qtest.rb +4 -1
  140. data/test/raw_prog_test.rb +1 -1
  141. data/test/restart_cron_test.rb +6 -6
  142. data/test/restart_sleep_test.rb +8 -8
  143. data/test/ruby_procdef_test.rb +2 -2
  144. data/test/rutest_utils.rb +9 -3
  145. data/test/scheduler_1_test.rb +88 -0
  146. data/test/scheduler_test.rb +49 -4
  147. data/test/sec_test.rb +18 -11
  148. metadata +51 -34
  149. data/test/cron_test_2.rb +0 -50
@@ -30,8 +30,6 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
- #
35
33
 
36
34
  #
37
35
  # "made in Japan"
@@ -44,61 +42,54 @@ require 'openwfe/workitem'
44
42
  require 'openwfe/contextual'
45
43
 
46
44
 
47
- #
48
- # some base listener implementation
49
- #
50
45
  module OpenWFE
51
46
 
52
47
  #
53
- # The only thing this mixin module provides is a #reply_to_engine method.
54
- # The details on how the workitems arrive are left to the implementations.
48
+ # this mixin module provides two protected methods, handle_item() and
49
+ # filter_item(). They can be easily overriden to add some special
50
+ # behaviours.
55
51
  #
56
52
  module WorkItemListener
57
53
  include Contextual, Logging, OwfeServiceLocator
58
54
 
59
- @accept_launchitems = true
60
-
61
- #
62
- # Determines if the listener should accept or not incoming
63
- # launchitems.
64
- #
65
- def accept_launchitems= (b)
66
- raise ArgumentError.new("boolean value expected") \
67
- if b != true and b != false
68
- @accept_launchitems = b
69
- end
70
-
71
- #
72
- # Returns true if the listener accepts workitems.
73
- # If launchitems are not accepted, the listener will simply
74
- # discard them (with a log info message).
75
- #
76
- def accept_launchitems?
77
- @accept_launchitems
78
- end
79
-
80
55
  protected
81
56
 
82
57
  #
83
58
  # Simply considers the object as a workitem and feeds it to the
84
59
  # engine.
85
60
  #
86
- def handle_object (object)
61
+ def handle_item (item)
87
62
 
88
- return nil if filter_out_launchitems(object)
63
+ filter_items item
89
64
 
90
- get_engine.reply(object)
65
+ get_engine.reply item
91
66
  end
92
67
 
93
68
  #
94
- # Returns true if the listener doesn't accept LaunchItem instances
95
- # and the item is one of them.
69
+ # The base implementation is just empty, feel free to override it
70
+ # if you need to filter workitems.
96
71
  #
97
- def filter_out_launchitems (item)
98
-
99
- return false unless item.is_a? OpenWFE::LaunchItem
72
+ # One example :
73
+ #
74
+ # class MyListener
75
+ # include WorkItemListener
76
+ #
77
+ # protected
78
+ #
79
+ # #
80
+ # # MyListener doesn't accept launchitems
81
+ # #
82
+ # def filter_items (item)
83
+ # raise "launchitems not allowed" \
84
+ # if item.is_a?(OpenWFE::LaunchItem)
85
+ # end
86
+ # end
87
+ #
88
+ def filter_items (item)
100
89
 
101
- return (not accept_launchitems?)
90
+ #raise(
91
+ # "listener of class '#{self.class.name}' "+
92
+ # "doesn't accept launchitems")
102
93
  end
103
94
  end
104
95
 
@@ -102,7 +102,7 @@ module OpenWFE
102
102
 
103
103
  object = load_object(path)
104
104
 
105
- handle_object(object) if object
105
+ handle_item(object) if object
106
106
 
107
107
  rescue Exception => e
108
108
 
@@ -44,7 +44,7 @@ require 'openwfe/utils'
44
44
  require 'openwfe/service'
45
45
  require 'openwfe/workitem'
46
46
  require 'openwfe/rudefinitions'
47
- require 'openwfe/rest/xmlcodec'
47
+ require 'openwfe/orest/xmlcodec'
48
48
  require 'openwfe/listeners/listener'
49
49
 
50
50
 
@@ -166,6 +166,7 @@ module OpenWFE
166
166
  # and maybe only allow a certain range of hosts...
167
167
  #
168
168
  def is_allowed? (socket)
169
+
169
170
  true
170
171
  end
171
172
 
@@ -191,7 +192,7 @@ module OpenWFE
191
192
  return unless socket
192
193
 
193
194
  OpenWFE.call_in_thread(@service_name, self) do
194
- handle_socket(socket) if socket and is_allowed? socket
195
+ handle_socket(socket) if socket and is_allowed?(socket)
195
196
  end
196
197
  end
197
198
  end
@@ -226,17 +227,6 @@ module OpenWFE
226
227
  socket.close
227
228
  return
228
229
 
229
- elsif wi.kind_of? InFlowWorkItem
230
-
231
- ldebug do
232
- "handle_socket() received wi for #{wi.fei.to_debug_s}"
233
- end
234
-
235
- elsif wi.kind_of? LaunchItem
236
-
237
- ldebug do
238
- "handle_socket() received li for #{wi.wfdurl}"
239
- end
240
230
  else
241
231
 
242
232
  ldebug do
@@ -249,7 +239,8 @@ module OpenWFE
249
239
 
250
240
  begin
251
241
 
252
- result = get_engine.reply(wi)
242
+ #result = get_engine.reply(wi)
243
+ result = handle_item(wi)
253
244
 
254
245
  ldebug { "handle_socket() result is >>#{result}<<" }
255
246
 
@@ -267,9 +258,10 @@ module OpenWFE
267
258
  end
268
259
 
269
260
  def pop_line (s)
261
+
270
262
  i = s.index("\n")
271
263
  return s unless i
272
- return s[i+1..-1]
264
+ s[i+1..-1]
273
265
  end
274
266
  end
275
267
 
@@ -30,8 +30,6 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
- #
35
33
 
36
34
  #
37
35
  # "made in Japan"
@@ -41,7 +39,6 @@
41
39
 
42
40
  require 'logger'
43
41
  require 'openwfe/utils'
44
- #require 'openwfe/rudefinitions'
45
42
 
46
43
 
47
44
  module OpenWFE
@@ -75,6 +72,10 @@ module OpenWFE
75
72
  do_log(:unknown, message, &block)
76
73
  end
77
74
 
75
+ def llog (level, message=nil, &block)
76
+ do_log(level, message, &block)
77
+ end
78
+
78
79
  #
79
80
  # A simplification of caller_to_s for direct usage when debugging
80
81
  #
@@ -100,7 +101,7 @@ module OpenWFE
100
101
  end
101
102
 
102
103
  def log_prepare (message)
103
- return log_author() if not message
104
+ return log_author() unless message
104
105
  return "#{log_author} - #{message}"
105
106
  end
106
107
 
@@ -30,16 +30,14 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id: controlclient.rb 3454 2006-10-08 16:51:00Z jmettraux $
34
- #
35
33
 
36
34
  #
37
35
  # "hecho en Costa Rica"
38
36
  #
39
37
 
40
- require 'openwfe/rest/xmlcodec'
41
- require 'openwfe/rest/restclient'
42
- require 'openwfe/rest/definitions'
38
+ require 'openwfe/orest/xmlcodec'
39
+ require 'openwfe/orest/restclient'
40
+ require 'openwfe/orest/definitions'
43
41
 
44
42
 
45
43
  module OpenWFE
@@ -30,8 +30,6 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id: definitions.rb 3454 2006-10-08 16:51:00Z jmettraux $
34
- #
35
33
 
36
34
  #
37
35
  # "hecho en Costa Rica"
File without changes
@@ -41,7 +41,7 @@
41
41
  require 'thread'
42
42
  require 'webrick'
43
43
  require 'rexml/document'
44
- require 'openwfe/rest/xmlcodec'
44
+ require 'openwfe/orest/xmlcodec'
45
45
 
46
46
 
47
47
  module OpenWFE
@@ -33,7 +33,7 @@
33
33
 
34
34
  require 'socket'
35
35
 
36
- require 'openwfe/rest/xmlcodec'
36
+ require 'openwfe/orest/xmlcodec'
37
37
 
38
38
 
39
39
  module OpenWFE
@@ -30,8 +30,6 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id: restclient.rb 3454 2006-10-08 16:51:00Z jmettraux $
34
- #
35
33
 
36
34
  #
37
35
  # "hecho en Costa Rica"
@@ -0,0 +1,206 @@
1
+ #
2
+ #--
3
+ # Copyright (c) 2005-2007, John Mettraux, OpenWFE.org
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # . Redistributions of source code must retain the above copyright notice, this
10
+ # list of conditions and the following disclaimer.
11
+ #
12
+ # . Redistributions in binary form must reproduce the above copyright notice,
13
+ # this list of conditions and the following disclaimer in the documentation
14
+ # and/or other materials provided with the distribution.
15
+ #
16
+ # . Neither the name of the "OpenWFE" nor the names of its contributors may be
17
+ # used to endorse or promote products derived from this software without
18
+ # specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ # POSSIBILITY OF SUCH DAMAGE.
31
+ #++
32
+ #
33
+
34
+ #
35
+ # "hecho en Costa Rica"
36
+ #
37
+ # john.mettraux@openwfe.org
38
+ #
39
+
40
+ require 'base64'
41
+
42
+ require 'openwfe/utils'
43
+
44
+
45
+ module OpenWFE
46
+
47
+ #--
48
+ # HISTORY ITEM
49
+ #
50
+ # (currently not used in OpenWFEru itself :( )
51
+ #++
52
+
53
+ #
54
+ # HistoryItem instances are used to keep track of what happened to
55
+ # a workitem.
56
+ #
57
+ class HistoryItem
58
+
59
+ attr_accessor \
60
+ :date,
61
+ :author,
62
+ :host,
63
+ :text,
64
+ :wfd_name,
65
+ :wfd_revision,
66
+ :wf_instance_id,
67
+ :expression_id
68
+
69
+ def dup
70
+ OpenWFE::fulldup(self)
71
+ end
72
+ end
73
+
74
+
75
+ #--
76
+ # STORES
77
+ #++
78
+
79
+ #
80
+ # Models the information about a store as viewed by the current user
81
+ # (upon calling the listStores or getStoreNames methods)
82
+ #
83
+ class Store
84
+
85
+ attr_accessor :name, :workitem_count, :permissions
86
+
87
+ def initialize ()
88
+ super()
89
+ #@name = nil
90
+ #@workitem_count = nil
91
+ #@permissions = nil
92
+ end
93
+
94
+ #
95
+ # Returns true if the current user may read headers and workitems
96
+ # from this store
97
+ #
98
+ def may_read? ()
99
+ return @permissions.index('r') > -1
100
+ end
101
+
102
+ #
103
+ # Returns true if the current user may modify workitems (and at least
104
+ # proceed/forward them) in this store
105
+ #
106
+ def may_write? ()
107
+ @permissions.index('w') > -1
108
+ end
109
+
110
+ #
111
+ # Returns true if the current user may browse the headers of this
112
+ # store
113
+ #
114
+ def may_browse? ()
115
+ @permissions.index('b') > -1
116
+ end
117
+
118
+ #
119
+ # Returns true if the current user may delegate workitems to this store
120
+ #
121
+ def may_delegate? ()
122
+ @permissions.index('d') > -1
123
+ end
124
+ end
125
+
126
+ #
127
+ # A header is a summary of a workitem, returned by the getHeader
128
+ # worklist method.
129
+ #
130
+ # (Only used when accessing an OpenWFEja engine)
131
+ #
132
+ class Header < InFlowWorkItem
133
+
134
+ attr_accessor :locked
135
+ end
136
+
137
+
138
+ #--
139
+ # MISC ATTRIBUTES
140
+ #
141
+ # in openwfe-ruby, OpenWFE attributes are immediately mapped to
142
+ # Ruby instances, but some attributes still deserve their own class
143
+ #
144
+ # (Only used when accessing an OpenWFEja engine)
145
+ #++
146
+
147
+ #
148
+ # a wrapper for some binary content
149
+ #
150
+ class Base64Attribute
151
+
152
+ attr_accessor :content
153
+
154
+ def initialize (base64content)
155
+
156
+ @content = base64content
157
+ end
158
+
159
+ #
160
+ # dewraps (decode) the current content and returns it
161
+ #
162
+ def dewrap ()
163
+
164
+ Base64.decode64(@content)
165
+ end
166
+
167
+ #
168
+ # wraps some binary content and stores it in this attribute
169
+ # (class method)
170
+ #
171
+ def Base64Attribute.wrap (binaryData)
172
+
173
+ Base64Attribute.new(Base64.encode64(binaryData))
174
+ end
175
+ end
176
+
177
+
178
+ #--
179
+ # LAUNCHABLE
180
+ #++
181
+
182
+ #
183
+ # A worklist will return list of Launchable instances indicating
184
+ # what processes (URL) a user may launch on which engine.
185
+ #
186
+ # (Only used when accessing an OpenWFEja engine)
187
+ #
188
+ class Launchable
189
+
190
+ attr_accessor :url, :engine_id
191
+ end
192
+
193
+
194
+ #
195
+ # Expression, somehow equivalent to FlowExpression, but only used
196
+ # by the control interface.
197
+ #
198
+ # (Only used when accessing an OpenWFEja engine)
199
+ #
200
+ class Expression
201
+
202
+ attr_accessor :id, :apply_time, :state, :state_since
203
+ end
204
+
205
+ end
206
+
@@ -30,20 +30,30 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id: worklistclient.rb 3454 2006-10-08 16:51:00Z jmettraux $
34
- #
35
33
 
36
34
  #
37
35
  # "hecho en Costa Rica"
38
36
  #
39
37
 
40
- require 'openwfe/rest/xmlcodec'
41
- require 'openwfe/rest/definitions'
42
- require 'openwfe/rest/restclient'
38
+ require 'openwfe/workitem'
39
+ require 'openwfe/orest/xmlcodec'
40
+ require 'openwfe/orest/definitions'
41
+ require 'openwfe/orest/restclient'
43
42
 
44
43
 
45
44
  module OpenWFE
46
45
 
46
+ #
47
+ # Reopening WorkItem to set the MAP_TYPE (as it's used by OpenWFEja...)
48
+ #
49
+ class WorkItem
50
+ def initialize
51
+ @last_modified = nil
52
+ @attributes = {}
53
+ @attributes[MAP_TYPE] = E_SMAP
54
+ end
55
+ end
56
+
47
57
  #
48
58
  # a client to an OpenWFE worklists.
49
59
  #
@@ -41,7 +41,8 @@ require 'rexml/document'
41
41
  require 'openwfe/utils'
42
42
  require 'openwfe/workitem'
43
43
  require 'openwfe/flowexpressionid'
44
- require 'openwfe/rest/definitions'
44
+ require 'openwfe/orest/definitions'
45
+ require 'openwfe/orest/workitem'
45
46
 
46
47
 
47
48
  module OpenWFE
@@ -49,6 +50,8 @@ module OpenWFE
49
50
  #
50
51
  # Ugly XML codec for OpenWFE workitems
51
52
  #
53
+ # (one of the first things I wrote in Ruby...)
54
+ #
52
55
  module XmlCodec
53
56
 
54
57
  #
@@ -41,6 +41,7 @@
41
41
  require 'net/smtp'
42
42
 
43
43
  require 'openwfe/participants/participant'
44
+ require 'openwfe/participants/participants'
44
45
 
45
46
 
46
47
  module OpenWFE
@@ -89,6 +90,7 @@ module OpenWFE
89
90
  #
90
91
  class MailParticipant
91
92
  include LocalParticipant
93
+ include TemplateMixin
92
94
 
93
95
  def initialize (params, &block)
94
96
 
@@ -116,23 +118,11 @@ module OpenWFE
116
118
  #
117
119
  # 1. Expand variables
118
120
 
119
- msg = if @block_template
120
- #@block_template.call(fe, self, workitem)
121
- call_block @block_template, workitem
122
- elsif @template
123
- template = if @template.kind_of? File
124
- @template.readlines
125
- else
126
- @template.to_s
127
- end
128
- OpenWFE::dosub(template, fe, workitem)
129
- else
130
- "(no template given)"
131
- end
121
+ msg = eval_template workitem
132
122
 
133
123
  from_address = workitem.email_from rescue @from_address
134
124
 
135
- puts "msg >>>\n#{msg}<<<"
125
+ #puts "msg >>>\n#{msg}<<<"
136
126
 
137
127
  #
138
128
  # 2. Send message
@@ -61,7 +61,6 @@ module OpenWFE
61
61
  super
62
62
 
63
63
  @participants = []
64
-
65
64
  @observers = {}
66
65
  end
67
66
 
@@ -87,7 +86,7 @@ module OpenWFE
87
86
  raise "please provide a participant instance or a block" \
88
87
  if not block
89
88
 
90
- participant = BlockParticipant.new(block)
89
+ participant = BlockParticipant.new block
91
90
  end
92
91
 
93
92
  ldebug do
@@ -95,7 +94,7 @@ module OpenWFE
95
94
  "participant class is #{participant.class}"
96
95
  end
97
96
 
98
- if participant.kind_of? Class
97
+ if participant.kind_of?(Class)
99
98
 
100
99
  ldebug { "register_participant() class #{participant}" }
101
100
 
@@ -114,7 +113,9 @@ module OpenWFE
114
113
  end
115
114
  end
116
115
 
117
- unless regex.kind_of? Regexp
116
+ original_string = regex.to_s
117
+
118
+ unless regex.kind_of?(Regexp)
118
119
 
119
120
  regex = regex.to_s
120
121
  regex = "^" + regex unless regex[0, 1] == "^"
@@ -124,6 +125,11 @@ module OpenWFE
124
125
 
125
126
  regex = Regexp.new(regex)
126
127
  end
128
+
129
+ class << regex
130
+ attr_reader :original_string
131
+ end
132
+ regex.instance_variable_set '@original_string', original_string
127
133
 
128
134
  participant.application_context = @application_context \
129
135
  if participant.respond_to? :application_context=
@@ -155,16 +161,14 @@ module OpenWFE
155
161
  #
156
162
  def unregister_participant (participant_name)
157
163
 
158
- pos = -1
159
- @participants.each_with_index do |tuple, index|
160
- if tuple[0].match(participant_name)
161
- pos = index
162
- break
163
- end
164
+ participant_name = participant_name.to_s
165
+
166
+ p = @participants.find do |tuple|
167
+ tuple[0].original_string == participant_name
164
168
  end
165
- @participants.delete(pos) if pos > -1
169
+ @participants.delete(p) if p
166
170
 
167
- pos > -1
171
+ (p != nil)
168
172
  end
169
173
 
170
174
  #