cpee 1.3.121 → 1.3.122

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,214 +0,0 @@
1
- # This file is part of CPEE.
2
- #
3
- # CPEE is free software: you can redistribute it and/or modify it under the terms
4
- # of the GNU General Public License as published by the Free Software Foundation,
5
- # either version 3 of the License, or (at your option) any later version.
6
- #
7
- # CPEE is distributed in the hope that it will be useful, but WITHOUT ANY
8
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
9
- # PARTICULAR PURPOSE. See the GNU General Public License for more details.
10
- #
11
- # You should have received a copy of the GNU General Public License along with
12
- # CPEE (file COPYING in the main directory). If not, see
13
- # <http://www.gnu.org/licenses/>.
14
-
15
- require 'time'
16
- require 'date'
17
- require 'cgi'
18
- # require 'savon'
19
-
20
- class RescueHash < Hash
21
- def self::new_from_obj(obj)
22
- RescueHash.new.merge(obj)
23
- end
24
-
25
- def value(key)
26
- results = []
27
- self.each do |k,v|
28
- results << v.value(key) if v.class == RescueHash
29
- results << v if k == key
30
- end
31
- results.length != 1 ? results.flatten : results[0]
32
- end
33
- end
34
-
35
- module Kernel
36
- def neq(value)
37
- self != value
38
- end
39
- end
40
-
41
- Result = Struct.new(:data, :status)
42
-
43
- class RescueHandlerWrapper < WEEL::HandlerWrapperBase
44
- def initialize(arguments,endpoint=nil,position=nil,continue=nil)
45
- @controller = arguments[0]
46
- @url = arguments[1]
47
- @handler_stopped = false
48
- @handler_continue = continue
49
- @handler_endpoint = endpoint
50
- @handler_position = position
51
- @handler_returnValue = nil
52
- end
53
-
54
- # executes a ws-call to the given endpoint with the given parameters. the call
55
- def activity_handle(passthrough, parameters)
56
- @controller.notify("running/activity_calling", :instance => "#{@url}/#{@controller.id}", :activity => @handler_position, :passthrough => passthrough, :endpoint => @handler_endpoint, :parameters => parameters)
57
-
58
- params = []
59
- if parameters.key?(:info) && parameters[:info] == 'true' # {{{
60
- parameters[:parameters] = Array.new if (parameters.include?(:parameters) == false) || parameters[:parameters].nil?
61
- parameters[:parameters] << {'call-instance-uri' => "#{@url}/#{@controller.id}"}
62
- parameters[:parameters] << {'call-activity' => @handler_position}
63
- parameters[:parameters] << {'call-endpoint' => @handler_endpoint}
64
- parameters[:parameters] << {'call-oid' => parameters[:'call-oid']} if parameters.include?(:'call-oid')
65
- end # }}}
66
- if parameters.include?(:templates) # {{{
67
- parameters[:parameters] << {'templates-uri' => parameters[:templates][0][:uri]}
68
- parameters[:parameters] << {'template-name' => parameters[:templates][1][:name]}
69
- parameters[:parameters] << {'template-lang' => parameters[:templates][2][:lang]}
70
- end # }}}
71
- if parameters.key?(:service) # {{{
72
- injection_handler_uri = parameters[:service][1][:injection_handler]
73
- # Give postion to injection-handler
74
- @handler_returnValue = nil
75
- injection_handler = Riddl::Client.new(injection_handler_uri)
76
- status, resp = injection_handler.post [
77
- Riddl::Parameter::Simple.new('activity', @handler_position),
78
- Riddl::Parameter::Simple.new('instance', "#{@url}/#{@controller.id}")
79
- ] # here could be consumer, producer secrets
80
- raise "Subscription to injection-handler at #{injection_handler_uri} failed with status #{status}" unless status == 200
81
- raise WEEL::Signal::SkipManipulate # }}}
82
- elsif parameters.key?(:method) #{{{
83
- client = Riddl::Client.new(@handler_endpoint)
84
- type = parameters[:method]
85
- (parameters[:parameters] || {}).each do |h|
86
- if h.class == Hash
87
- h.each do |k,v|
88
- params << (parameters[:method].downcase == 'get' ? Riddl::Parameter::Simple.new("#{k}","#{v}", :query) : Riddl::Parameter::Simple.new("#{k}","#{v}"))
89
- end
90
- end
91
- end
92
- callback = Digest::MD5.hexdigest(Kernel::rand().to_s)
93
- params << Riddl::Header.new("CPEE_BASE",@url)
94
- params << Riddl::Header.new("CPEE_INSTANCE","#{@url}/#{@controller.id}")
95
- params << Riddl::Header.new("CPEE_CALLBACK",callback)
96
- status, result, headers = client.request type => params
97
- if(not(type == "get" and status == 200) and not(type == "post" and status == 201))
98
- raise "Could not perform http-#{type} on URI: #{@handler_endpoint} - Status: #{status}"
99
- end
100
- if headers["CPEE_CALLBACK"] && headers["CPEE_CALLBACK"] == 'true'
101
- @controller.callbacks[callback] = CPEE::Callback.new("callback activity: #{@handler_position}",self,:callback,nil,nil,:http)
102
- return
103
- end
104
- # Make rescue-hash here
105
- @handler_returnValue = Result.new(result, status)# }}}
106
- # TODO
107
- # Georg: Check log if color freeze (unmark)
108
- # When stopping the unmark command may be ignored
109
- # instance.js at the beginning (moz-websocket)
110
- elsif parameters.key?(:soap_operation)# {{{
111
- begin
112
- pp parameters
113
- client = Savon.client do
114
- wsdl parameters[:wsdl]
115
- log false
116
- log_level :info
117
- soap_header(
118
- "CPEE_BASE" => @url,
119
- "CPEE_INSTANCE" => "#{@url}/#{@controller.id}",
120
- )
121
- end
122
- params = {}
123
- (parameters[:parameters] || {}).each do |h|
124
- if h.class == Hash
125
- h.each do |k,v|
126
- params[k] = v
127
- end
128
- end
129
- end
130
- response = client.call parameters[:soap_operation].to_sym, params
131
- @handler_returnValue = Result.new(XML::Smart.new(response.to_doc), 200)
132
- rescue Savon::Error => error
133
- @handler_returnValue = error.to_s
134
- end
135
- end# }}}
136
- @handler_continue.continue
137
- end
138
-
139
- def activity_result_status
140
- WEEL::Status.new(1, "everything okay")
141
- end
142
-
143
- # returns the result of the last handled call
144
- def activity_result_value
145
- @handler_returnValue
146
- end
147
-
148
- def activity_stop
149
- @handler_stopped = true
150
- end
151
- def activity_passthrough_value
152
- nil
153
- end
154
-
155
- def activity_no_longer_necessary
156
- @handler_stopped = true
157
- end
158
-
159
- def inform_activity_done
160
- @controller.notify("running/activity_done", :endpoint => @handler_endpoint, :instance => "#{@url}/#{@controller.id}", :activity => @handler_position)
161
- end
162
- def inform_activity_manipulate
163
- @controller.notify("running/activity_manipulating", :endpoint => @handler_endpoint, :instance => "#{@url}/#{@controller.id}", :activity => @handler_position)
164
- end
165
- def inform_activity_failed(err)
166
- puts err.message
167
- puts err.backtrace
168
- @controller.notify("running/activity_failed", :endpoint => @handler_endpoint, :instance => "#{@url}/#{@controller.id}", :activity => @handler_position, :message => err.message, :line => err.backtrace[0].match(/(.*?):(\d+):/)[2], :where => err.backtrace[0].match(/(.*?):(\d+):/)[1])
169
- end
170
-
171
- def inform_syntax_error(err,code)
172
- puts err.message
173
- puts err.backtrace
174
- @controller.notify("properties/description/error", :instance => "#{@url}/#{@controller.id}", :message => err.message, :line => err.backtrace[0].match(/(.*?):(\d+):/)[2], :code => code, :where => err.backtrace[0].match(/(.*?):(\d+):/)[1])
175
- end
176
- def inform_manipulate_change(status,dataelements,endpoints)
177
- unless status.nil?
178
- @controller.serialize_status!
179
- @controller.notify("properties/status/change", :endpoint => @handler_endpoint, :instance => "#{@url}/#{@controller.id}", :activity => @handler_position, :id => status.id, :message => status.message)
180
- end
181
- unless dataelements.nil?
182
- @controller.serialize_dataelements!
183
- @controller.notify("properties/dataelements/change", :endpoint => @handler_endpoint, :instance => "#{@url}/#{@controller.id}", :activity => @handler_position, :changed => dataelements)
184
- end
185
- unless endpoints.nil?
186
- @controller.serialize_endpoints!
187
- @controller.notify("properties/endpoints/change", :endpoint => @handler_endpoint, :instance => "#{@url}/#{@controller.id}", :activity => @handler_position, :changed => endpoints)
188
- end
189
- end
190
- def inform_position_change(ipc={})
191
- @controller.serialize_positions!
192
- ipc[:instance] = "#{@url}/#{@controller.id}"
193
- @controller.notify("properties/position/change", ipc)
194
- end
195
- def inform_state_change(newstate)
196
- if @controller
197
- @controller.serialize_state!
198
- @controller.notify("properties/state/change", :instance => "#{@url}/#{@controller.id}", :state => newstate)
199
- end
200
- end
201
-
202
- def vote_sync_after
203
- @controller.call_vote("running/syncing_after", :endpoint => @handler_endpoint, :instance => "#{@url}/#{@controller.id}", :activity => @handler_position)
204
- end
205
- def vote_sync_before
206
- @controller.call_vote("running/syncing_before", :endpoint => @handler_endpoint, :instance => "#{@url}/#{@controller.id}", :activity => @handler_position)
207
- end
208
-
209
- def callback(result)
210
- @handler_returnValue = Result.new(result,nil)
211
- @handler_continue.continue
212
- end
213
-
214
- end
@@ -1,109 +0,0 @@
1
- <properties xmlns="http://riddl.org/ns/common-patterns/properties/1.0">
2
- <info>Enter info here</info>
3
- <state>ready</state>
4
- <handlerwrapper>DefaultHandlerWrapper</handlerwrapper>
5
- <positions>
6
- <a1>after</a1>
7
- </positions>
8
- <dataelements>
9
- <x/>
10
- </dataelements>
11
- <endpoints>
12
- <timeout>http://gruppe.wst.univie.ac.at/~mangler/services/timeout.php</timeout>
13
- </endpoints>
14
- <dsl>call :a1, :timeout, { :method =&gt; "post", :parameters =&gt; { :timeout =&gt; 2 } }, &lt;&lt;-end
15
- data.x += "a1,"
16
- end
17
- call :a2, :timeout, { :method =&gt; "post", :parameters =&gt; { :timeout =&gt; 4 } }, &lt;&lt;-end
18
- data.x += "a2,"
19
- end
20
- call :a3, :timeout, { :method =&gt; "post", :parameters =&gt; { :timeout =&gt; 4 } }, &lt;&lt;-end
21
- data.x += "a3,"
22
- end
23
- </dsl>
24
- <dslx>
25
- <description xmlns="http://cpee.org/ns/description/1.0">
26
- <!--{{{-->
27
- <call id="a1" endpoint="timeout">
28
- <parameters>
29
- <!--{{{-->
30
- <method>post</method>
31
- <parameters>
32
- <timeout>2</timeout>
33
- </parameters>
34
- </parameters>
35
- <!--}}}-->
36
- <manipulate output="result"> data.x += "a1,"</manipulate>
37
- </call>
38
- <call id="a2" endpoint="timeout">
39
- <parameters>
40
- <!--{{{-->
41
- <method>post</method>
42
- <parameters>
43
- <timeout>4</timeout>
44
- </parameters>
45
- </parameters>
46
- <!--}}}-->
47
- <manipulate output="result"> data.x += "a2,"</manipulate>
48
- </call>
49
- <call id="a3" endpoint="timeout">
50
- <parameters>
51
- <!--{{{-->
52
- <method>post</method>
53
- <parameters>
54
- <timeout>4</timeout>
55
- </parameters>
56
- </parameters>
57
- <!--}}}-->
58
- <manipulate output="result"> data.x += "a3,"</manipulate>
59
- </call>
60
- </description>
61
- </dslx>
62
- <status>
63
- <id>0</id>
64
- <message>undefined</message>
65
- </status>
66
- <description>
67
- <description xmlns="http://cpee.org/ns/description/1.0">
68
- <!--{{{-->
69
- <call id="a1" endpoint="timeout">
70
- <parameters>
71
- <!--{{{-->
72
- <method>post</method>
73
- <parameters>
74
- <timeout>2</timeout>
75
- </parameters>
76
- </parameters>
77
- <!--}}}-->
78
- <manipulate output="result"> data.x += "a1,"</manipulate>
79
- </call>
80
- <call id="a2" endpoint="timeout">
81
- <parameters>
82
- <!--{{{-->
83
- <method>post</method>
84
- <parameters>
85
- <timeout>4</timeout>
86
- </parameters>
87
- </parameters>
88
- <!--}}}-->
89
- <manipulate output="result"> data.x += "a2,"</manipulate>
90
- </call>
91
- <call id="a3" endpoint="timeout">
92
- <parameters>
93
- <!--{{{-->
94
- <method>post</method>
95
- <parameters>
96
- <timeout>4</timeout>
97
- </parameters>
98
- </parameters>
99
- <!--}}}-->
100
- <manipulate output="result"> data.x += "a3,"</manipulate>
101
- </call>
102
- </description>
103
- </description>
104
- <transformation>
105
- <description type="copy"/>
106
- <dataelements type="rest"/>
107
- <endpoints type="rest"/>
108
- </transformation>
109
- </properties>
@@ -1,109 +0,0 @@
1
- <properties xmlns="http://riddl.org/ns/common-patterns/properties/1.0">
2
- <info/>
3
- <state>ready</state>
4
- <handlerwrapper>DefaultHandlerWrapper</handlerwrapper>
5
- <positions>
6
- <a1>after</a1>
7
- </positions>
8
- <dataelements>
9
- <x/>
10
- </dataelements>
11
- <endpoints>
12
- <timeout>http://gruppe.wst.univie.ac.at/~mangler/services/timeout.php</timeout>
13
- </endpoints>
14
- <dsl>call :a1, :timeout, { :method =&gt; "post", :parameters =&gt; { :timeout =&gt; 2 } }, &lt;&lt;-end
15
- data.x += "a1,"
16
- end
17
- call :a2, :timeout, { :method =&gt; "post", :parameters =&gt; { :timeout =&gt; 4 } }, &lt;&lt;-end
18
- data.x += "a2,"
19
- end
20
- call :a3, :timeout, { :method =&gt; "post", :parameters =&gt; { :timeout =&gt; 4 } }, &lt;&lt;-end
21
- data.x += "a3,"
22
- end
23
- </dsl>
24
- <dslx>
25
- <description xmlns="http://cpee.org/ns/description/1.0">
26
- <!--{{{-->
27
- <call id="a1" endpoint="timeout">
28
- <parameters>
29
- <!--{{{-->
30
- <method>post</method>
31
- <parameters>
32
- <timeout>2</timeout>
33
- </parameters>
34
- </parameters>
35
- <!--}}}-->
36
- <manipulate output="result"> data.x += "a1,"</manipulate>
37
- </call>
38
- <call id="a2" endpoint="timeout">
39
- <parameters>
40
- <!--{{{-->
41
- <method>post</method>
42
- <parameters>
43
- <timeout>4</timeout>
44
- </parameters>
45
- </parameters>
46
- <!--}}}-->
47
- <manipulate output="result"> data.x += "a2,"</manipulate>
48
- </call>
49
- <call id="a3" endpoint="timeout">
50
- <parameters>
51
- <!--{{{-->
52
- <method>post</method>
53
- <parameters>
54
- <timeout>4</timeout>
55
- </parameters>
56
- </parameters>
57
- <!--}}}-->
58
- <manipulate output="result"> data.x += "a3,"</manipulate>
59
- </call>
60
- </description>
61
- </dslx>
62
- <status>
63
- <id>0</id>
64
- <message>undefined</message>
65
- </status>
66
- <description>
67
- <description xmlns="http://cpee.org/ns/description/1.0">
68
- <!--{{{-->
69
- <call id="a1" endpoint="timeout">
70
- <parameters>
71
- <!--{{{-->
72
- <method>post</method>
73
- <parameters>
74
- <timeout>2</timeout>
75
- </parameters>
76
- </parameters>
77
- <!--}}}-->
78
- <manipulate output="result"> data.x += "a1,"</manipulate>
79
- </call>
80
- <call id="a2" endpoint="timeout">
81
- <parameters>
82
- <!--{{{-->
83
- <method>post</method>
84
- <parameters>
85
- <timeout>4</timeout>
86
- </parameters>
87
- </parameters>
88
- <!--}}}-->
89
- <manipulate output="result"> data.x += "a2,"</manipulate>
90
- </call>
91
- <call id="a3" endpoint="timeout">
92
- <parameters>
93
- <!--{{{-->
94
- <method>post</method>
95
- <parameters>
96
- <timeout>4</timeout>
97
- </parameters>
98
- </parameters>
99
- <!--}}}-->
100
- <manipulate output="result"> data.x += "a3,"</manipulate>
101
- </call>
102
- </description>
103
- </description>
104
- <transformation>
105
- <description type="copy"/>
106
- <dataelements type="rest"/>
107
- <endpoints type="rest"/>
108
- </transformation>
109
- </properties>
@@ -1,83 +0,0 @@
1
- <properties xmlns="http://riddl.org/ns/common-patterns/properties/1.0">
2
- <info>Enter info here</info>
3
- <state>finished</state>
4
- <handlerwrapper>DefaultHandlerWrapper</handlerwrapper>
5
- <positions/>
6
- <dataelements>
7
- <json>{"lv":"Workflow Technologies","id":{"lvnr":"050311","gruppe":1}}</json>
8
- <json_lv>Workflow Technologies</json_lv>
9
- <json_lvnr/>
10
- <xml_lv>Workflow Technologies</xml_lv>
11
- <xml_lvnr>050311</xml_lvnr>
12
- </dataelements>
13
- <endpoints>
14
- <timeout>http://gruppe.wst.univie.ac.at/~mangler/services/timeout.php</timeout>
15
- <json>http://cpee.org/services/json.php</json>
16
- <xml>http://cpee.org/services/xml.php</xml>
17
- </endpoints>
18
- <dsl>call :a1, :json, { :label =&gt; "Get JSON", :method =&gt; "get", :parameters =&gt; nil }, &lt;&lt;-end
19
- data.json = result
20
- data.json_lv = result['lv']
21
- data.json_lvnr = result['lv']['lvnr']
22
- end
23
- call :a2, :xml, { :label =&gt; "Get XML", :method =&gt; "get", :parameters =&gt; nil }, &lt;&lt;-end
24
- data.xml_lv = result.find('string(/data/lv)')
25
- data.xml_lvnr = result.find('string(/data/lv/@id)')
26
- end
27
- </dsl>
28
- <dslx>
29
- <description xmlns="http://cpee.org/ns/description/1.0">
30
- <call id="a1" endpoint="json" svg-label="Get JSON">
31
- <parameters>
32
- <label>Get JSON</label>
33
- <method>get</method>
34
- <parameters/>
35
- </parameters>
36
- <manipulate>data.json = result
37
- data.json_lv = result['lv']
38
- data.json_lvnr = result['lv']['lvnr']</manipulate>
39
- </call>
40
- <call id="a2" endpoint="xml">
41
- <parameters>
42
- <label>Get XML</label>
43
- <method>get</method>
44
- <parameters/>
45
- </parameters>
46
- <manipulate>data.xml_lv = result.find('string(/data/lv)')
47
- data.xml_lvnr = result.find('string(/data/lv/@id)')</manipulate>
48
- </call>
49
- </description>
50
- </dslx>
51
- <status>
52
- <id>0</id>
53
- <message>undefined</message>
54
- </status>
55
- <description>
56
- <description xmlns="http://cpee.org/ns/description/1.0">
57
- <call id="a1" endpoint="json" svg-label="Get JSON">
58
- <parameters>
59
- <label>Get JSON</label>
60
- <method>get</method>
61
- <parameters/>
62
- </parameters>
63
- <manipulate>data.json = result
64
- data.json_lv = result['lv']
65
- data.json_lvnr = result['lv']['lvnr']</manipulate>
66
- </call>
67
- <call id="a2" endpoint="xml">
68
- <parameters>
69
- <label>Get XML</label>
70
- <method>get</method>
71
- <parameters/>
72
- </parameters>
73
- <manipulate>data.xml_lv = result.find('string(/data/lv)')
74
- data.xml_lvnr = result.find('string(/data/lv/@id)')</manipulate>
75
- </call>
76
- </description>
77
- </description>
78
- <transformation>
79
- <description type="copy"/>
80
- <dataelements type="xslt"/>
81
- <endpoints type="xslt"/>
82
- </transformation>
83
- </properties>