infopark_reactor 1.26.1 → 1.27.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +25 -0
- data/.rubocop_todo.yml +363 -0
- data/Rakefile +10 -13
- data/app/models/rails_connector/abstract_obj.rb +2 -1
- data/config/routes.rb +0 -1
- data/infopark_reactor.gemspec +16 -15
- data/lib/generators/cm/migration/migration_generator.rb +4 -8
- data/lib/infopark_reactor.rb +43 -69
- data/lib/reactor/already_released.rb +1 -2
- data/lib/reactor/attributes.rb +92 -268
- data/lib/reactor/attributes/date_serializer.rb +20 -16
- data/lib/reactor/attributes/html_serializer.rb +6 -5
- data/lib/reactor/attributes/link_list_extender.rb +10 -8
- data/lib/reactor/attributes/link_list_from_accessor.rb +2 -1
- data/lib/reactor/attributes/link_list_from_attr_values.rb +2 -1
- data/lib/reactor/attributes/link_list_serializer.rb +8 -7
- data/lib/reactor/attributes_handlers.rb +164 -0
- data/lib/reactor/cache/permission.rb +6 -9
- data/lib/reactor/cache/user.rb +3 -6
- data/lib/reactor/cm/attribute.rb +16 -16
- data/lib/reactor/cm/attribute_group.rb +18 -21
- data/lib/reactor/cm/blob_too_small_error.rb +2 -2
- data/lib/reactor/cm/bridge.rb +6 -9
- data/lib/reactor/cm/channel.rb +3 -4
- data/lib/reactor/cm/editorial_group.rb +2 -9
- data/lib/reactor/cm/group.rb +30 -43
- data/lib/reactor/cm/job.rb +23 -25
- data/lib/reactor/cm/language.rb +21 -22
- data/lib/reactor/cm/link.rb +38 -40
- data/lib/reactor/cm/live_group.rb +2 -9
- data/lib/reactor/cm/log_entry.rb +22 -21
- data/lib/reactor/cm/missing_credentials.rb +3 -2
- data/lib/reactor/cm/multi_xml_request.rb +22 -25
- data/lib/reactor/cm/obj.rb +159 -154
- data/lib/reactor/cm/obj_class.rb +52 -51
- data/lib/reactor/cm/object_base.rb +26 -21
- data/lib/reactor/cm/permissions.rb +7 -7
- data/lib/reactor/cm/user.rb +43 -51
- data/lib/reactor/cm/workflow.rb +11 -12
- data/lib/reactor/cm/xml_attribute.rb +10 -19
- data/lib/reactor/cm/xml_markup.rb +7 -10
- data/lib/reactor/cm/xml_multi_request_error.rb +1 -3
- data/lib/reactor/cm/xml_request.rb +21 -29
- data/lib/reactor/cm/xml_request_error.rb +1 -3
- data/lib/reactor/cm/xml_response.rb +8 -16
- data/lib/reactor/cm/xml_single_request_error.rb +3 -5
- data/lib/reactor/configuration.rb +1 -3
- data/lib/reactor/engine.rb +5 -10
- data/lib/reactor/legacy.rb +6 -7
- data/lib/reactor/link/external.rb +8 -5
- data/lib/reactor/link/internal.rb +8 -5
- data/lib/reactor/link/temporary_link.rb +16 -17
- data/lib/reactor/main.rb +11 -15
- data/lib/reactor/migration.rb +52 -53
- data/lib/reactor/no_working_version.rb +1 -2
- data/lib/reactor/not_permitted.rb +1 -2
- data/lib/reactor/permission.rb +36 -38
- data/lib/reactor/persistence.rb +104 -178
- data/lib/reactor/plans/common_attribute.rb +7 -7
- data/lib/reactor/plans/common_attribute_group.rb +6 -6
- data/lib/reactor/plans/common_channel.rb +6 -6
- data/lib/reactor/plans/common_group.rb +7 -14
- data/lib/reactor/plans/common_job.rb +6 -6
- data/lib/reactor/plans/common_obj_class.rb +11 -11
- data/lib/reactor/plans/create_attribute.rb +1 -3
- data/lib/reactor/plans/create_attribute_group.rb +1 -3
- data/lib/reactor/plans/create_channel.rb +2 -3
- data/lib/reactor/plans/create_group.rb +3 -10
- data/lib/reactor/plans/create_job.rb +3 -4
- data/lib/reactor/plans/create_obj.rb +12 -14
- data/lib/reactor/plans/create_obj_class.rb +1 -2
- data/lib/reactor/plans/delete_attribute.rb +1 -3
- data/lib/reactor/plans/delete_attribute_group.rb +2 -4
- data/lib/reactor/plans/delete_channel.rb +3 -6
- data/lib/reactor/plans/delete_group.rb +2 -9
- data/lib/reactor/plans/delete_job.rb +3 -5
- data/lib/reactor/plans/delete_obj.rb +3 -4
- data/lib/reactor/plans/delete_obj_class.rb +1 -2
- data/lib/reactor/plans/prepared.rb +3 -4
- data/lib/reactor/plans/rename_group.rb +4 -11
- data/lib/reactor/plans/rename_obj_class.rb +1 -2
- data/lib/reactor/plans/update_attribute.rb +1 -3
- data/lib/reactor/plans/update_attribute_group.rb +2 -4
- data/lib/reactor/plans/update_group.rb +2 -9
- data/lib/reactor/plans/update_job.rb +4 -8
- data/lib/reactor/plans/update_obj.rb +6 -7
- data/lib/reactor/plans/update_obj_class.rb +0 -2
- data/lib/reactor/rc_independent.rb +0 -1
- data/lib/reactor/session.rb +27 -31
- data/lib/reactor/session/observers.rb +3 -5
- data/lib/reactor/session/user.rb +6 -7
- data/lib/reactor/session_helper/auth_filter.rb +9 -0
- data/lib/reactor/session_helper/auth_helper.rb +24 -0
- data/lib/reactor/session_helper/rsession_helper.rb +16 -0
- data/lib/reactor/session_helper/session_state.rb +31 -0
- data/lib/reactor/streaming_upload.rb +0 -1
- data/lib/reactor/sudo.rb +2 -3
- data/lib/reactor/support/link_matcher.rb +8 -7
- data/lib/reactor/tools/migrator.rb +30 -35
- data/lib/reactor/tools/response_handler/xml_attribute.rb +27 -33
- data/lib/reactor/tools/smart_xml_logger.rb +20 -22
- data/lib/reactor/tools/sower.rb +22 -23
- data/lib/reactor/tools/uploader.rb +12 -17
- data/lib/reactor/tools/versioner.rb +29 -30
- data/lib/reactor/tools/where_query.rb +11 -14
- data/lib/reactor/tools/workflow_generator.rb +26 -28
- data/lib/reactor/tools/xml_attributes.rb +7 -14
- data/lib/reactor/tools/xpath_extractor.rb +2 -1
- data/lib/reactor/validations.rb +20 -16
- data/lib/reactor/version.rb +1 -2
- data/lib/reactor/workflow.rb +10 -33
- data/lib/reactor/workflow/comment.rb +28 -0
- data/lib/reactor/workflow/empty.rb +0 -1
- data/lib/reactor/workflow/standard.rb +4 -3
- data/lib/tasks/cm_migrate.rake +3 -3
- data/lib/tasks/cm_seeds.rake +9 -16
- metadata +64 -28
- data/app/models/rails_connector/abstract_model.rb +0 -7
- data/app/models/rails_connector/attribute.rb +0 -94
- data/app/models/rails_connector/blob_mapping.rb +0 -16
- data/app/models/rails_connector/channel.rb +0 -41
- data/app/models/rails_connector/content.rb +0 -12
- data/app/models/rails_connector/job.rb +0 -14
- data/app/models/rails_connector/obj_class.rb +0 -158
- data/app/models/rails_connector/obj_class_attr.rb +0 -5
- data/app/models/rails_connector/object_with_meta_data.rb +0 -18
- data/lib/rails_connector/meta/eager_loader.rb +0 -91
- data/lib/reactor/rails_connector_meta.rb +0 -149
- data/lib/reactor/session_helper.rb +0 -72
data/lib/reactor/cm/language.rb
CHANGED
@@ -1,45 +1,45 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
1
|
module Reactor
|
3
2
|
module Cm
|
4
3
|
class Language
|
5
4
|
def self.get(username = nil)
|
6
5
|
begin
|
7
6
|
options = {}
|
8
|
-
options = {:
|
7
|
+
options = { login: username } if username
|
9
8
|
request = XmlRequest.prepare do |xml|
|
10
|
-
xml.tag!(
|
11
|
-
xml.tag!(
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
xml.tag!("userConfig-getTexts", options) do
|
10
|
+
xml.tag!("listitem") do
|
11
|
+
xml.text!("languages.language")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
16
15
|
response = request.execute!
|
17
|
-
response.xpath(
|
18
|
-
rescue
|
19
|
-
|
16
|
+
response.xpath("//listitem").text
|
17
|
+
rescue StandardError
|
18
|
+
nil
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
22
|
# FIXME: broken ([011003] Die Klasse '%s' wird nicht unterstützt.)
|
24
23
|
def self.set(*args)
|
25
24
|
username = language = nil
|
26
|
-
raise ArgumentError
|
25
|
+
raise ArgumentError, "set requires one or two parameters" unless [1, 2].include? args.length
|
27
26
|
|
28
27
|
username, language = *args if args.length == 2
|
29
28
|
language = *args if args.length == 1
|
30
29
|
|
31
|
-
raise ArgumentError
|
30
|
+
raise ArgumentError, "language cannot be nil" if language.nil?
|
31
|
+
|
32
32
|
options = {}
|
33
|
-
options = {:
|
33
|
+
options = { login: username } if username
|
34
34
|
|
35
35
|
begin
|
36
36
|
request = XmlRequest.prepare do |xml|
|
37
|
-
xml.tag!(
|
38
|
-
xml.tag!(
|
39
|
-
xml.tag!(
|
40
|
-
xml.text!(
|
37
|
+
xml.tag!("userConfig.setTexts", options) do
|
38
|
+
xml.tag!("dictitem") do
|
39
|
+
xml.tag!("key") do
|
40
|
+
xml.text!("languages.language")
|
41
41
|
end
|
42
|
-
xml.tag!(
|
42
|
+
xml.tag!("value") do
|
43
43
|
xml.text!(language)
|
44
44
|
end
|
45
45
|
end
|
@@ -47,11 +47,10 @@ module Reactor
|
|
47
47
|
end
|
48
48
|
response = request.execute!
|
49
49
|
response.ok?
|
50
|
-
rescue
|
51
|
-
|
50
|
+
rescue StandardError
|
51
|
+
false
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
55
54
|
end
|
56
55
|
end
|
57
56
|
end
|
data/lib/reactor/cm/link.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
1
|
module Reactor
|
3
2
|
module Cm
|
4
3
|
class Link
|
@@ -6,22 +5,22 @@ module Reactor
|
|
6
5
|
attr_accessor :title, :target, :position
|
7
6
|
|
8
7
|
def self.exists?(id)
|
9
|
-
|
10
|
-
rescue XmlRequestError
|
11
|
-
|
8
|
+
!Link.get(id).nil?
|
9
|
+
rescue XmlRequestError
|
10
|
+
false
|
12
11
|
end
|
13
12
|
|
14
13
|
def self.get(id)
|
15
14
|
link = Link.new
|
16
|
-
link.send(:get,id)
|
15
|
+
link.send(:get, id)
|
17
16
|
link
|
18
17
|
end
|
19
18
|
|
20
|
-
def self.create_inside(obj, attr, url, title=nil, target=nil)
|
19
|
+
def self.create_inside(obj, attr, url, title = nil, target = nil)
|
21
20
|
create(obj.edited_content, attr, url, title, target)
|
22
21
|
end
|
23
22
|
|
24
|
-
def self.create(content, attr, url, title=nil, target=nil)
|
23
|
+
def self.create(content, attr, url, title = nil, target = nil)
|
25
24
|
link = Link.new
|
26
25
|
link.send(:create, content, attr, url, title, target)
|
27
26
|
link
|
@@ -42,65 +41,64 @@ module Reactor
|
|
42
41
|
end
|
43
42
|
|
44
43
|
def dest_url=(url)
|
45
|
-
@is_external = (
|
44
|
+
@is_external = (%r{^/} =~ url).nil?
|
46
45
|
@dest_obj_id = Obj.get(url).obj_id unless @is_external
|
47
46
|
@dest_url = url
|
48
47
|
end
|
49
48
|
|
50
49
|
def save!
|
51
50
|
request = XmlRequest.prepare do |xml|
|
52
|
-
xml.where_key_tag!(base_name,
|
51
|
+
xml.where_key_tag!(base_name, "id", @link_id)
|
53
52
|
xml.set_tag!(base_name) do
|
54
|
-
xml.tag!(
|
55
|
-
xml.tag!(
|
56
|
-
xml.tag!(
|
57
|
-
xml.tag!(
|
53
|
+
xml.tag!("target", @target) if @target
|
54
|
+
xml.tag!("title", @title) if @title
|
55
|
+
xml.tag!("destinationUrl", @dest_url) if @dest_url
|
56
|
+
xml.tag!("position", @position) if @position
|
58
57
|
end
|
59
58
|
end
|
60
|
-
|
59
|
+
request.execute!
|
61
60
|
end
|
62
61
|
|
63
62
|
def hash
|
64
63
|
# yes, to_s.to_is is neccesary,
|
65
64
|
# because self.link_id is of type REXML::Text for the most of the time
|
66
|
-
|
65
|
+
link_id.to_s.to_i
|
67
66
|
end
|
68
67
|
|
69
|
-
|
70
68
|
def eql?(other)
|
71
|
-
|
69
|
+
link_id == other.link_id
|
72
70
|
end
|
73
71
|
|
74
72
|
def delete!
|
75
73
|
request = XmlRequest.prepare do |xml|
|
76
|
-
xml.where_key_tag!(base_name,
|
74
|
+
xml.where_key_tag!(base_name, "id", @link_id)
|
77
75
|
xml.tag!("#{base_name}-delete")
|
78
76
|
end
|
79
|
-
|
77
|
+
request.execute!
|
80
78
|
end
|
81
79
|
|
82
80
|
protected
|
83
|
-
|
84
|
-
end
|
81
|
+
|
82
|
+
def initialize; end
|
85
83
|
|
86
84
|
def base_name
|
87
|
-
|
85
|
+
"link"
|
88
86
|
end
|
89
87
|
|
90
88
|
def get(id)
|
91
89
|
request = XmlRequest.prepare do |xml|
|
92
|
-
xml.where_key_tag!(base_name,
|
93
|
-
xml.get_key_tag!(base_name,
|
90
|
+
xml.where_key_tag!(base_name, "id", id)
|
91
|
+
xml.get_key_tag!(base_name, %w(id isExternalLink target title destination destinationUrl position))
|
94
92
|
end
|
95
|
-
response
|
93
|
+
response = request.execute!
|
96
94
|
|
97
|
-
@link_id = response.xpath(
|
98
|
-
@is_external = response.xpath(
|
99
|
-
@target = response.xpath(
|
100
|
-
@title = response.xpath(
|
101
|
-
@dest_obj_id = response.xpath(
|
102
|
-
@dest_url = response.xpath(
|
103
|
-
@position = response.xpath(
|
95
|
+
@link_id = response.xpath("//id/text()")
|
96
|
+
@is_external = response.xpath("//isExternalLink/text()") == "1"
|
97
|
+
@target = response.xpath("//target/text()").presence
|
98
|
+
@title = response.xpath("//title/text()").presence
|
99
|
+
@dest_obj_id = response.xpath("//destination/text()").presence
|
100
|
+
@dest_url = response.xpath("//destinationUrl/text()").presence
|
101
|
+
@position = response.xpath("//position/text()").presence
|
104
102
|
|
105
103
|
self
|
106
104
|
end
|
@@ -108,25 +106,25 @@ module Reactor
|
|
108
106
|
def create(content, attr, url, title = nil, target = nil)
|
109
107
|
request = XmlRequest.prepare do |xml|
|
110
108
|
xml.create_tag!(base_name) do
|
111
|
-
xml.tag!(
|
112
|
-
xml.tag!(
|
113
|
-
xml.tag!(
|
109
|
+
xml.tag!("attributeName", attr.to_s)
|
110
|
+
xml.tag!("sourceContent", content.to_s)
|
111
|
+
xml.tag!("destinationUrl", url.to_s)
|
114
112
|
end
|
115
113
|
end
|
116
114
|
response = request.execute!
|
117
115
|
|
118
|
-
id = response.xpath(
|
116
|
+
id = response.xpath("//id/text()")
|
119
117
|
get(id)
|
120
118
|
|
121
119
|
if !title.nil? || !target.nil?
|
122
120
|
request = XmlRequest.prepare do |xml|
|
123
|
-
xml.where_key_tag!(base_name,
|
121
|
+
xml.where_key_tag!(base_name, "id", id)
|
124
122
|
xml.set_tag!(base_name) do
|
125
|
-
xml.value_tag!(
|
126
|
-
xml.value_tag!(
|
123
|
+
xml.value_tag!("title", title) if title
|
124
|
+
xml.value_tag!("target", target) if target
|
127
125
|
end
|
128
126
|
end
|
129
|
-
|
127
|
+
request.execute!
|
130
128
|
end
|
131
129
|
|
132
130
|
self
|
@@ -1,14 +1,10 @@
|
|
1
|
-
|
2
|
-
require 'reactor/cm/group'
|
1
|
+
require "reactor/cm/group"
|
3
2
|
|
4
3
|
module Reactor
|
5
|
-
|
6
4
|
module Cm
|
7
|
-
|
8
5
|
# The LiveGroup class respects the user management configured in the content manager and
|
9
6
|
# handles all live groups. See @Group for further details.
|
10
7
|
class LiveGroup < Group
|
11
|
-
|
12
8
|
protected
|
13
9
|
|
14
10
|
# Overwritten method from +Group+.
|
@@ -17,11 +13,8 @@ module Reactor
|
|
17
13
|
end
|
18
14
|
|
19
15
|
def self.base_name
|
20
|
-
|
16
|
+
"secondaryGroupProxy"
|
21
17
|
end
|
22
|
-
|
23
18
|
end
|
24
|
-
|
25
19
|
end
|
26
|
-
|
27
20
|
end
|
data/lib/reactor/cm/log_entry.rb
CHANGED
@@ -5,37 +5,37 @@ module Reactor
|
|
5
5
|
def where(conditions = {})
|
6
6
|
request = XmlRequest.prepare do |xml|
|
7
7
|
where_part(xml, conditions)
|
8
|
-
xml.tag!(
|
9
|
-
xml.tag!(
|
10
|
-
xml.tag!(
|
11
|
-
xml.tag!(
|
12
|
-
xml.tag!(
|
13
|
-
xml.tag!(
|
14
|
-
xml.tag!(
|
8
|
+
xml.tag!("logEntry-get") do
|
9
|
+
xml.tag!("logTime")
|
10
|
+
xml.tag!("logText")
|
11
|
+
xml.tag!("logType")
|
12
|
+
xml.tag!("objectId")
|
13
|
+
xml.tag!("receiver")
|
14
|
+
xml.tag!("userLogin")
|
15
15
|
end
|
16
16
|
end
|
17
17
|
response = request.execute!
|
18
|
-
|
18
|
+
|
19
19
|
result = []
|
20
|
-
log_entries = response.xpath(
|
21
|
-
log_entries = [log_entries] unless log_entries.
|
20
|
+
log_entries = response.xpath("//logEntry")
|
21
|
+
log_entries = [log_entries] unless log_entries.is_a?(Array)
|
22
22
|
log_entries.each do |log_entry_node|
|
23
23
|
dict = {}
|
24
24
|
log_entry_node.each_element do |value_node|
|
25
|
-
if value_node.name ==
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
dict[value_node.name] = if value_node.name == "logTime"
|
26
|
+
value_node.elements["isoDateTime"].text.to_s
|
27
|
+
else
|
28
|
+
value_node.text.to_s
|
29
|
+
end
|
30
30
|
end
|
31
31
|
|
32
32
|
result << dict
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
result
|
36
36
|
rescue Reactor::Cm::XmlRequestError => e
|
37
|
-
if
|
38
|
-
|
37
|
+
if /#{Regexp.escape('[060001] Es wurde kein Eintrag gefunden.')}/.match?(e.message)
|
38
|
+
[]
|
39
39
|
else
|
40
40
|
raise e
|
41
41
|
end
|
@@ -44,15 +44,16 @@ module Reactor
|
|
44
44
|
def delete(conditions)
|
45
45
|
request = XmlRequest.prepare do |xml|
|
46
46
|
where_part(xml, conditions)
|
47
|
-
xml.tag!(
|
47
|
+
xml.tag!("logEntry-delete")
|
48
48
|
end
|
49
49
|
response = request.execute!
|
50
|
-
|
50
|
+
response.xpath("//deleteLogEntriesCount").map { |x| x.text.to_s }.first
|
51
51
|
end
|
52
52
|
|
53
53
|
protected
|
54
|
+
|
54
55
|
def where_part(xml, conditions)
|
55
|
-
xml.tag!(
|
56
|
+
xml.tag!("logEntry-where") do
|
56
57
|
conditions.each do |key, value|
|
57
58
|
xml.tag!(key.to_s, value.to_s)
|
58
59
|
end
|
@@ -1,8 +1,9 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
1
|
module Reactor
|
3
2
|
module Cm
|
4
3
|
class MissingCredentials < StandardError
|
5
|
-
def initialize
|
4
|
+
def initialize
|
5
|
+
super("CM access credentials are missing. Check your configuration or supplied credentials.")
|
6
|
+
end
|
6
7
|
end
|
7
8
|
end
|
8
9
|
end
|
@@ -1,13 +1,11 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require 'nokogiri'
|
1
|
+
require "net/http"
|
2
|
+
require "reactor/cm/xml_response"
|
3
|
+
require "reactor/cm/xml_multi_request_error"
|
4
|
+
require "reactor/cm/xml_markup"
|
5
|
+
require "nokogiri"
|
7
6
|
|
8
7
|
module Reactor
|
9
8
|
module Cm
|
10
|
-
|
11
9
|
class MultiXmlRequest
|
12
10
|
def self.timeout
|
13
11
|
Reactor::Cm::XmlRequest.timeout
|
@@ -18,59 +16,56 @@ module Reactor
|
|
18
16
|
end
|
19
17
|
|
20
18
|
def self.execute
|
21
|
-
access = Configuration
|
19
|
+
access = Configuration.xml_access
|
22
20
|
sanity_check(access)
|
23
21
|
xml = XmlMarkup.new
|
24
|
-
xml2 = nil
|
25
|
-
ret = nil
|
26
22
|
xml.instruct!
|
27
23
|
req = nil
|
28
|
-
ret = xml.tag!(
|
29
|
-
xml.tag!(
|
30
|
-
xml.tag!(
|
31
|
-
xml.tag!(
|
24
|
+
ret = xml.tag!("cm-payload", "payload-id" => "abcabc", "timestamp" => Time.now.getutc.strftime("%Y%m%d%H%M%S"), "version" => "6.7.3") do
|
25
|
+
xml.tag!("cm-header") do
|
26
|
+
xml.tag!("cm-sender", "sender-id" => access[:id], "name" => "ruby-simple-client")
|
27
|
+
xml.tag!("cm-authentication", "login" => access[:username], "token" => token(access[:username], access[:secret]))
|
32
28
|
end
|
33
|
-
req =
|
29
|
+
req = new(xml).tap do |instance|
|
34
30
|
yield instance
|
35
31
|
end
|
36
32
|
end
|
37
33
|
req.execute!(ret)
|
38
34
|
end
|
39
35
|
|
40
|
-
def mandatory
|
36
|
+
def mandatory
|
41
37
|
req_id = self.class.generate_id
|
42
38
|
@mandatory << req_id
|
43
|
-
@builder.tag!(
|
39
|
+
@builder.tag!("cm-request", "request-id" => req_id, "preclusive" => "true") do |xml2|
|
44
40
|
yield xml2
|
45
41
|
end
|
46
42
|
end
|
47
43
|
|
48
|
-
def optional
|
44
|
+
def optional
|
49
45
|
req_id = self.class.generate_id
|
50
46
|
@optional << req_id
|
51
|
-
@builder.tag!(
|
47
|
+
@builder.tag!("cm-request", "request-id" => req_id, "preclusive" => "false") do |xml2|
|
52
48
|
yield xml2
|
53
49
|
end
|
54
50
|
end
|
55
51
|
|
56
52
|
def execute!(xml)
|
57
|
-
access = Configuration
|
53
|
+
access = Configuration.xml_access
|
58
54
|
payload = xml
|
59
55
|
|
60
56
|
res = Net::HTTP.new(access[:host], access[:port]).start do |http|
|
61
57
|
http.read_timeout = self.class.timeout
|
62
|
-
req = Net::HTTP::Post.new(
|
58
|
+
req = Net::HTTP::Post.new("/xml")
|
63
59
|
req.body = payload
|
64
60
|
http.request(req)
|
65
61
|
end
|
66
62
|
|
67
|
-
|
63
|
+
MultiXmlResponse.new(res.body, @mandatory, @optional)
|
68
64
|
end
|
69
65
|
|
70
66
|
class << self
|
71
|
-
|
72
67
|
def generate_id
|
73
|
-
rand(
|
68
|
+
rand(10_000)
|
74
69
|
end
|
75
70
|
|
76
71
|
protected
|
@@ -90,7 +85,9 @@ module Reactor
|
|
90
85
|
|
91
86
|
class MultiXmlResponse
|
92
87
|
def initialize(xml, mandatory, optional)
|
93
|
-
@xml
|
88
|
+
@xml = xml
|
89
|
+
@mandatory = mandatory
|
90
|
+
@optional = optional
|
94
91
|
@n = Nokogiri::XML.parse(@xml)
|
95
92
|
end
|
96
93
|
|