xmlconv 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +4 -0
- data/lib/xmlconv/state/login.rb +3 -2
- data/lib/xmlconv/util/application.rb +16 -8
- data/lib/xmlconv/util/mail.rb +2 -1
- data/lib/xmlconv/util/polling_manager.rb +8 -1
- data/lib/xmlconv/util/rack_interface.rb +1 -1
- data/lib/xmlconv/util/transaction.rb +6 -3
- data/lib/xmlconv/version.rb +1 -1
- data/test/test_util/application.rb +3 -0
- data/xmlconv.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b944e983c5846919a052589ef034b9f3213f87a7
|
4
|
+
data.tar.gz: 886ccc0284adc4c66a48efd6f0a5f9f59ce5866f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34d6f9ca0710e0c360f36e4167626c6afea002881ee15eacc31b786300f5f41d8aee21a649e392e4c4f865457cbe7a10cec27f778d7b882ebf94b53e14d88979
|
7
|
+
data.tar.gz: b9a1eee2de8c25e0507da64e8621850126bae94b86a54a38c580b25703ac205b3c9859a50677fe7b9250335d7003f7224d9dc2411ec7b2f25ffe33e90338368c
|
data/History.txt
CHANGED
data/lib/xmlconv/state/login.rb
CHANGED
@@ -12,8 +12,9 @@ module XmlConv
|
|
12
12
|
VIEW = View::Login
|
13
13
|
def initialize(session, model)
|
14
14
|
if session.request_method.eql?('POST')
|
15
|
-
session.
|
16
|
-
|
15
|
+
xml_src = session.post_content
|
16
|
+
SBSM.debug "XmlConv::State::Login POST params were #{session.request_params}"
|
17
|
+
SBSM.debug " xml_src now #{xml_src}"
|
17
18
|
unless xml_src.length == 0
|
18
19
|
transaction = XmlConv::Util::Transaction.new
|
19
20
|
transaction.domain = session.server_name
|
@@ -38,18 +38,26 @@ module XmlConv
|
|
38
38
|
rescue Exception => error
|
39
39
|
## survive notification failure
|
40
40
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
transaction.
|
45
|
-
|
46
|
-
|
41
|
+
def _execute(transaction)
|
42
|
+
has_error = false
|
43
|
+
transaction.transaction_id = next_transaction_id
|
44
|
+
SBSM.info "Starting_transaction #{transaction.transaction_id}"
|
45
|
+
transaction.execute
|
46
|
+
res = transaction.postprocess
|
47
|
+
SBSM.info "Postprocessed_transaction #{transaction.transaction_id} res #{res.class}"
|
48
|
+
res
|
49
|
+
rescue Exception => error
|
50
|
+
has_error = true
|
51
|
+
SBSM.info "error_transaction #{transaction.transaction_id} error #{error} \n#{error.backtrace}"
|
52
|
+
transaction.error = error
|
47
53
|
ensure
|
48
|
-
ODBA.transaction {
|
54
|
+
res = ODBA.transaction {
|
49
55
|
transaction.odba_store
|
50
56
|
@transactions.push(transaction)
|
51
57
|
@transactions.odba_isolated_store
|
52
58
|
}
|
59
|
+
SBSM.info "has_error_transaction is #{has_error} #{transaction.transaction_id} res is #{res.class}" if has_error
|
60
|
+
res
|
53
61
|
end
|
54
62
|
def next_transaction_id
|
55
63
|
@id_mutex.synchronize {
|
@@ -122,7 +130,7 @@ class XmlConvApp < SBSM::AdminServer
|
|
122
130
|
POLLING_INTERVAL = 60 #* 15
|
123
131
|
def initialize(app: XmlConv::Util::RackInterface.new)
|
124
132
|
@rack_app = app
|
125
|
-
super(app: app)
|
133
|
+
super(app: app) # TODO?? , multi_threaded: true)
|
126
134
|
@persistence_layer = ODBA.cache.fetch_named('XmlConv', self) do XmlConv::Util::Application.new end
|
127
135
|
@persistence_layer.init
|
128
136
|
@dispatch_queue = Queue.new
|
data/lib/xmlconv/util/mail.rb
CHANGED
@@ -12,7 +12,6 @@ module Mail
|
|
12
12
|
recipients.compact!
|
13
13
|
recipients.uniq!
|
14
14
|
return if(recipients.empty?)
|
15
|
-
puts "XmlConv::Util::Mail.notify #{ XmlConv::CONFIG.mail_from} -> #{recipients} subject: #{my_subject}"
|
16
15
|
options = { :address => XmlConv::CONFIG.smtp_server,
|
17
16
|
:port => XmlConv::CONFIG.smtp_port,
|
18
17
|
:domain => XmlConv::CONFIG.smtp_domain,
|
@@ -24,6 +23,8 @@ module Mail
|
|
24
23
|
::Mail.defaults do
|
25
24
|
delivery_method :smtp, options
|
26
25
|
end unless ::Mail.delivery_method.is_a?(::Mail::TestMailer)
|
26
|
+
msg = "XmlConv::Util::Mail.notify #{ XmlConv::CONFIG.mail_from} -> #{recipients} subject: #{my_subject}\n #{options}"
|
27
|
+
puts msg; SBSM.info(msg)
|
27
28
|
mail = ::Mail.deliver do
|
28
29
|
from XmlConv::CONFIG.mail_from
|
29
30
|
to recipients
|
@@ -173,7 +173,11 @@ module XmlConv
|
|
173
173
|
def initialize(system)
|
174
174
|
@system = system
|
175
175
|
end
|
176
|
-
|
176
|
+
def load_sources(&block)
|
177
|
+
unless File.exist?(CONFIG.polling_file)
|
178
|
+
SBSM.warn("Could not find #{CONFIG.polling_file}. Skip polling")
|
179
|
+
return
|
180
|
+
end
|
177
181
|
file = File.open(CONFIG.polling_file)
|
178
182
|
YAML.load_documents(file) { |mission|
|
179
183
|
block.call(mission)
|
@@ -182,8 +186,10 @@ module XmlConv
|
|
182
186
|
file.close if(file)
|
183
187
|
end
|
184
188
|
def poll_sources
|
189
|
+
@@showed_content ||= false
|
185
190
|
load_sources do |source|
|
186
191
|
begin
|
192
|
+
SBSM.info "PollingManage has source #{source.inspect}" unless @@showed_content
|
187
193
|
source.poll { |transaction|
|
188
194
|
@system.execute(transaction)
|
189
195
|
}
|
@@ -197,6 +203,7 @@ module XmlConv
|
|
197
203
|
Util::Mail.notify source.error_recipients, subject, body
|
198
204
|
end
|
199
205
|
end
|
206
|
+
@@showed_content = true
|
200
207
|
end
|
201
208
|
end
|
202
209
|
end
|
@@ -37,6 +37,7 @@ module XmlConv
|
|
37
37
|
@model = reader_instance.convert(input_model, *@arguments)
|
38
38
|
output_model = writer_instance.convert(@model, *@arguments)
|
39
39
|
@output = output_model.is_a?(Array) ? output_model.join("\n").to_s : output_model.to_s
|
40
|
+
SBSM.info("_execute #{input_model.class} => #{@output} #{@destination.inspect}")
|
40
41
|
@destination.deliver(output_model)
|
41
42
|
@commit_time = Time.now
|
42
43
|
@output
|
@@ -103,11 +104,13 @@ Output:
|
|
103
104
|
end
|
104
105
|
def postprocess
|
105
106
|
if(@postprocs.respond_to?(:each))
|
106
|
-
@postprocs.each
|
107
|
+
@postprocs.each do |klass, *args|
|
107
108
|
next if args.empty?
|
109
|
+
SBSM.info(msg = "Postprocess calling for klass #{klass} #{args.inspect}")
|
108
110
|
args.push(self)
|
109
|
-
PostProcess.const_get(klass).send(*args)
|
110
|
-
|
111
|
+
res = PostProcess.const_get(klass).send(*args)
|
112
|
+
SBSM.info(msg = "Postprocess returned #{res} for klass #{klass}")
|
113
|
+
end
|
111
114
|
end
|
112
115
|
end
|
113
116
|
def respond delivery, response
|
data/lib/xmlconv/version.rb
CHANGED
@@ -38,6 +38,7 @@ module XmlConv
|
|
38
38
|
cache.should_receive(:store).with(@app.transactions)
|
39
39
|
ODBA.cache = cache
|
40
40
|
transaction.should_receive(:transaction_id=).with(1)
|
41
|
+
transaction.should_receive(:transaction_id)
|
41
42
|
transaction.should_receive(:execute).once.and_return(transaction)
|
42
43
|
transaction.should_receive(:postprocess).once
|
43
44
|
transaction.should_receive(:error=).never
|
@@ -57,6 +58,7 @@ module XmlConv
|
|
57
58
|
cache.should_receive(:store).with(@app.transactions)
|
58
59
|
ODBA.cache = cache
|
59
60
|
transaction.should_receive(:transaction_id=).with(1)
|
61
|
+
transaction.should_receive(:transaction_id)
|
60
62
|
transaction.should_receive(:execute).once.and_raise(Net::SMTPFatalError, 'could not send email')
|
61
63
|
transaction.should_receive(:postprocess).never
|
62
64
|
transaction.should_receive(:error=).never
|
@@ -75,6 +77,7 @@ module XmlConv
|
|
75
77
|
cache.should_receive(:store).with(@app.transactions)
|
76
78
|
ODBA.cache = cache
|
77
79
|
transaction.should_receive(:transaction_id=).with(1)
|
80
|
+
transaction.should_receive(:transaction_id)
|
78
81
|
transaction.should_receive(:execute).and_raise 'oops, something went wrong'
|
79
82
|
transaction.should_receive(:postprocess).never
|
80
83
|
transaction.should_receive(:error=).once
|
data/xmlconv.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency "ydbd-pg", '>= 0.5.1'
|
22
22
|
spec.add_dependency "ydbi", '>= 0.5.1'
|
23
23
|
spec.add_dependency "json"
|
24
|
-
spec.add_dependency "sbsm", '>= 1.4.
|
24
|
+
spec.add_dependency "sbsm", '>= 1.4.5'
|
25
25
|
spec.add_dependency "htmlgrid"
|
26
26
|
spec.add_dependency "ydim"
|
27
27
|
spec.add_dependency "syck"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xmlconv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaomi Hatakeyama, Zeno R.R. Davatz, Niklaus Giger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: odba
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.4.
|
75
|
+
version: 1.4.5
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.4.
|
82
|
+
version: 1.4.5
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: htmlgrid
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|