infopark_reactor 1.24.1 → 1.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reactor/cm/editorial_group.rb +4 -0
- data/lib/reactor/cm/group.rb +9 -20
- data/lib/reactor/cm/live_group.rb +4 -0
- data/lib/reactor/cm/user.rb +26 -9
- data/lib/reactor/cm/xml_response.rb +3 -4
- data/lib/reactor/tools/response_handler/xml_attribute.rb +31 -7
- data/lib/reactor/tools/where_query.rb +36 -0
- data/lib/reactor/tools/xpath_extractor.rb +14 -0
- data/lib/reactor/version.rb +1 -1
- metadata +4 -4
- data/lib/reactor/tools/response_handler/base.rb +0 -23
- data/lib/reactor/tools/response_handler/string.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0239fbc0807b9a31e6fa80298930ca37465af29d
|
4
|
+
data.tar.gz: 73f6561b9a114871fce30a050ca677e828e6ecf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7bf7b6f924abb2bba8b8d6dd916641c407d99cd6644812005689a1e78cf288871a67e7393db59623e50a6cbc66faa6ecf9e5befa9b4009a628d901a7e230c4b
|
7
|
+
data.tar.gz: 4760a747861ac8d05d4b315cfddf3a3820a76213146eb11b08208ab03b98e120c5438abd3738b94337a65a2693d6c22a190f0569b1c9f4c6996a6fc728c3f8b0
|
data/lib/reactor/cm/group.rb
CHANGED
@@ -3,7 +3,8 @@ require 'reactor/cm/xml_request'
|
|
3
3
|
require 'reactor/cm/xml_response'
|
4
4
|
require 'reactor/cm/xml_request_error'
|
5
5
|
require 'reactor/tools/xml_attributes'
|
6
|
-
require 'reactor/tools/response_handler/
|
6
|
+
require 'reactor/tools/response_handler/xml_attribute'
|
7
|
+
require 'reactor/tools/where_query'
|
7
8
|
|
8
9
|
require 'reactor/cm/permissions'
|
9
10
|
|
@@ -19,6 +20,7 @@ module Reactor
|
|
19
20
|
class Group
|
20
21
|
|
21
22
|
include XmlAttributes
|
23
|
+
extend WhereQuery
|
22
24
|
|
23
25
|
class << self
|
24
26
|
|
@@ -34,25 +36,8 @@ module Reactor
|
|
34
36
|
end
|
35
37
|
|
36
38
|
# Returns all known group names as an array of strings.
|
37
|
-
def all(match =
|
38
|
-
|
39
|
-
|
40
|
-
base_name = object.send(:base_name)
|
41
|
-
|
42
|
-
request = XmlRequest.prepare do |xml|
|
43
|
-
xml.where_key_tag!(base_name, 'groupText', match)
|
44
|
-
xml.get_key_tag!(base_name, 'name')
|
45
|
-
end
|
46
|
-
|
47
|
-
begin
|
48
|
-
response = request.execute!
|
49
|
-
groups = ResponseHandler::String.new.get(response, "//#{base_name}/name/text()")
|
50
|
-
|
51
|
-
groups.is_a?(Array) ? groups : [groups]
|
52
|
-
rescue XmlRequestError
|
53
|
-
[]
|
54
|
-
end
|
55
|
-
|
39
|
+
def all(match = nil)
|
40
|
+
self.where("groupText", match)
|
56
41
|
end
|
57
42
|
|
58
43
|
# See @get.
|
@@ -173,6 +158,10 @@ module Reactor
|
|
173
158
|
# account. Use +EditorialGroup+ to work on editorial groups and +LiveGroup+ to work on live
|
174
159
|
# groups.
|
175
160
|
def base_name
|
161
|
+
self.class.base_name
|
162
|
+
end
|
163
|
+
|
164
|
+
def self.base_name
|
176
165
|
'group'
|
177
166
|
end
|
178
167
|
|
data/lib/reactor/cm/user.rb
CHANGED
@@ -3,6 +3,7 @@ require 'reactor/cm/object_base'
|
|
3
3
|
require 'reactor/configuration'
|
4
4
|
require 'reactor/cm/language'
|
5
5
|
require 'reactor/tools/xml_attributes'
|
6
|
+
require 'reactor/tools/where_query'
|
6
7
|
|
7
8
|
require 'reactor/cm/permissions'
|
8
9
|
|
@@ -64,21 +65,32 @@ module Reactor
|
|
64
65
|
end
|
65
66
|
|
66
67
|
include XmlAttributes
|
68
|
+
extend WhereQuery
|
67
69
|
|
68
|
-
attribute :
|
70
|
+
attribute :login
|
69
71
|
attribute :groups, :type => :list
|
70
72
|
attribute :global_permissions, :name => :globalPermissions, :type => :list
|
71
73
|
attribute :email
|
74
|
+
attribute :default_group, :name => :defaultGroup
|
75
|
+
attribute :real_name, :name => :realName
|
72
76
|
|
73
77
|
primary_key 'login'
|
74
78
|
|
75
|
-
def initialize(name)
|
76
|
-
@
|
79
|
+
def initialize(name = nil)
|
80
|
+
@login = name
|
81
|
+
end
|
82
|
+
|
83
|
+
def name
|
84
|
+
self.login
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.all(match = nil)
|
88
|
+
self.where("userText", match)
|
77
89
|
end
|
78
90
|
|
79
91
|
def has_password?(password)
|
80
92
|
request = XmlRequest.prepare do |xml|
|
81
|
-
xml.where_key_tag!(base_name, self.class.primary_key, self.
|
93
|
+
xml.where_key_tag!(base_name, self.class.primary_key, self.login)
|
82
94
|
xml.get_tag!(base_name) do |xml3|
|
83
95
|
xml3.tag!('hasPassword', :password => password)
|
84
96
|
end
|
@@ -89,7 +101,7 @@ module Reactor
|
|
89
101
|
|
90
102
|
def is_root?
|
91
103
|
request = XmlRequest.prepare do |xml|
|
92
|
-
xml.where_key_tag!(base_name, self.class.primary_key, self.
|
104
|
+
xml.where_key_tag!(base_name, self.class.primary_key, self.login)
|
93
105
|
xml.get_key_tag!(base_name, 'isSuperUser')
|
94
106
|
end
|
95
107
|
|
@@ -99,14 +111,14 @@ module Reactor
|
|
99
111
|
end
|
100
112
|
|
101
113
|
def language
|
102
|
-
Reactor::Cm::Language.get(self.
|
114
|
+
Reactor::Cm::Language.get(self.login)
|
103
115
|
end
|
104
116
|
|
105
117
|
def global_permissions
|
106
118
|
xml_attribute = self.class.xml_attribute(:global_permissions)
|
107
119
|
|
108
120
|
request = XmlRequest.prepare do |xml|
|
109
|
-
xml.where_key_tag!(base_name, self.class.primary_key, self.
|
121
|
+
xml.where_key_tag!(base_name, self.class.primary_key, self.login)
|
110
122
|
xml.get_key_tag!(base_name, xml_attribute.name)
|
111
123
|
end
|
112
124
|
|
@@ -119,7 +131,7 @@ module Reactor
|
|
119
131
|
xml_attribute = self.class.xml_attribute(:groups)
|
120
132
|
|
121
133
|
request = XmlRequest.prepare do |xml|
|
122
|
-
xml.where_key_tag!(base_name, self.class.primary_key, self.
|
134
|
+
xml.where_key_tag!(base_name, self.class.primary_key, self.login)
|
123
135
|
xml.get_key_tag!(base_name, xml_attribute.name)
|
124
136
|
end
|
125
137
|
|
@@ -132,7 +144,7 @@ module Reactor
|
|
132
144
|
xml_attribute = self.class.xml_attribute(:email)
|
133
145
|
|
134
146
|
request = XmlRequest.prepare do |xml|
|
135
|
-
xml.where_key_tag!(base_name, self.class.primary_key, self.
|
147
|
+
xml.where_key_tag!(base_name, self.class.primary_key, self.login)
|
136
148
|
xml.get_key_tag!(base_name, xml_attribute.name)
|
137
149
|
end
|
138
150
|
|
@@ -143,6 +155,11 @@ module Reactor
|
|
143
155
|
|
144
156
|
protected
|
145
157
|
def base_name
|
158
|
+
self.class.base_name
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
def self.base_name
|
146
163
|
'userProxy'
|
147
164
|
end
|
148
165
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
require 'reactor/tools/response_handler/xml_attribute'
|
3
|
+
require 'reactor/tools/xpath_extractor'
|
3
4
|
require 'rexml/document'
|
4
5
|
|
5
6
|
module Reactor
|
@@ -15,13 +16,11 @@ module Reactor
|
|
15
16
|
@xml_str = xml
|
16
17
|
@xml = REXML::Document.new(xml)
|
17
18
|
@handler = Reactor::ResponseHandler::XmlAttribute.new
|
19
|
+
@xpath = Reactor::XPathExtractor.new(@xml)
|
18
20
|
end
|
19
21
|
|
20
22
|
def xpath(expr)
|
21
|
-
|
22
|
-
|
23
|
-
return arr.first if arr.length == 1
|
24
|
-
return arr
|
23
|
+
@xpath.match(expr)
|
25
24
|
end
|
26
25
|
|
27
26
|
def ok?
|
@@ -1,14 +1,16 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
require 'reactor/tools/
|
3
|
-
|
2
|
+
require 'reactor/tools/xpath_extractor'
|
4
3
|
module Reactor
|
5
4
|
|
6
5
|
module ResponseHandler
|
7
6
|
|
8
|
-
class XmlAttribute
|
7
|
+
class XmlAttribute
|
8
|
+
attr_accessor :response
|
9
|
+
attr_accessor :context
|
9
10
|
|
10
11
|
def get(response, attribute)
|
11
|
-
|
12
|
+
@response = response
|
13
|
+
@context = context
|
12
14
|
|
13
15
|
name = attribute.name
|
14
16
|
type = attribute.type
|
@@ -18,11 +20,19 @@ module Reactor
|
|
18
20
|
self.send(method_name, name)
|
19
21
|
end
|
20
22
|
|
23
|
+
def multiple(elem, attributes)
|
24
|
+
values = {}
|
25
|
+
attributes.each do |attribute|
|
26
|
+
values[attribute.name] = self.get(elem, attribute)
|
27
|
+
end
|
28
|
+
values
|
29
|
+
end
|
30
|
+
|
21
31
|
private
|
22
32
|
|
23
33
|
# Extracts a string value with the given +name+ and returns a string.
|
24
34
|
def extract_string(name)
|
25
|
-
result = self.
|
35
|
+
result = self.xpath(".//#{name}/text()")
|
26
36
|
if result.kind_of?(Array)
|
27
37
|
return result.first
|
28
38
|
else
|
@@ -32,7 +42,7 @@ module Reactor
|
|
32
42
|
|
33
43
|
# Extracts a list value with the given +name+ and returns an array of strings.
|
34
44
|
def extract_list(name)
|
35
|
-
result = self.
|
45
|
+
result = self.xpath(".//#{name}/listitem/text()")
|
36
46
|
result = result.kind_of?(Array) ? result : [result]
|
37
47
|
|
38
48
|
result.map(&:to_s)
|
@@ -41,7 +51,7 @@ module Reactor
|
|
41
51
|
# This shit will break with the slightest change of the CM.
|
42
52
|
def extract_signaturelist(name)
|
43
53
|
signatures = []
|
44
|
-
self.
|
54
|
+
self.xpath(".//#{name}/").each do |potential_signature|
|
45
55
|
if (potential_signature.name.to_s == "listitem")
|
46
56
|
attribute = potential_signature.children.first.text.to_s
|
47
57
|
group = potential_signature.children.last.text.to_s
|
@@ -51,6 +61,20 @@ module Reactor
|
|
51
61
|
signatures
|
52
62
|
end
|
53
63
|
|
64
|
+
protected
|
65
|
+
def node
|
66
|
+
# TODO: clean up this bullshit
|
67
|
+
if self.response.kind_of?(Reactor::Cm::XmlResponse)
|
68
|
+
self.response.xml
|
69
|
+
else
|
70
|
+
self.response
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def xpath(expr)
|
75
|
+
Reactor::XPathExtractor.new(self.node).match(expr)
|
76
|
+
end
|
77
|
+
|
54
78
|
end
|
55
79
|
|
56
80
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Reactor
|
2
|
+
module WhereQuery
|
3
|
+
def where(key, value)
|
4
|
+
request = Cm::XmlRequest.prepare do |xml|
|
5
|
+
xml.where_tag!(self.base_name) do
|
6
|
+
xml.tag!(key) do
|
7
|
+
if value
|
8
|
+
xml.text!(value)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
xml.get_tag!(self.base_name) do
|
14
|
+
self.attributes.each do |_, xml_attribute|
|
15
|
+
xml.tag!(xml_attribute.name)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
response = request.execute!
|
21
|
+
result = response.xpath("//#{self.base_name}")
|
22
|
+
result = [result] unless result.kind_of?(Array)
|
23
|
+
result.map do |elem|
|
24
|
+
values = {}
|
25
|
+
values = self.response_handler.multiple(elem, self.attributes.values)
|
26
|
+
instance = self.new
|
27
|
+
values.each do |name, value|
|
28
|
+
instance.instance_variable_set(:"@#{name}", value)
|
29
|
+
end
|
30
|
+
instance
|
31
|
+
end
|
32
|
+
rescue Cm::XmlRequestError
|
33
|
+
[]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/reactor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infopark_reactor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomasz Przedmojski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -183,15 +183,15 @@ files:
|
|
183
183
|
- lib/reactor/sudo.rb
|
184
184
|
- lib/reactor/support/link_matcher.rb
|
185
185
|
- lib/reactor/tools/migrator.rb
|
186
|
-
- lib/reactor/tools/response_handler/base.rb
|
187
|
-
- lib/reactor/tools/response_handler/string.rb
|
188
186
|
- lib/reactor/tools/response_handler/xml_attribute.rb
|
189
187
|
- lib/reactor/tools/smart_xml_logger.rb
|
190
188
|
- lib/reactor/tools/sower.rb
|
191
189
|
- lib/reactor/tools/uploader.rb
|
192
190
|
- lib/reactor/tools/versioner.rb
|
191
|
+
- lib/reactor/tools/where_query.rb
|
193
192
|
- lib/reactor/tools/workflow_generator.rb
|
194
193
|
- lib/reactor/tools/xml_attributes.rb
|
194
|
+
- lib/reactor/tools/xpath_extractor.rb
|
195
195
|
- lib/reactor/validations.rb
|
196
196
|
- lib/reactor/version.rb
|
197
197
|
- lib/reactor/workflow.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Reactor
|
3
|
-
|
4
|
-
module ResponseHandler
|
5
|
-
|
6
|
-
# Common base class to handle a xml response. Provides helper methods to extract the content
|
7
|
-
# from a xml response.
|
8
|
-
class Base
|
9
|
-
|
10
|
-
attr_accessor :response
|
11
|
-
attr_accessor :context
|
12
|
-
|
13
|
-
# Common strategy method for each sub class.
|
14
|
-
def get(response, context)
|
15
|
-
@response = response
|
16
|
-
@context = context
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
require 'reactor/tools/response_handler/base'
|
3
|
-
|
4
|
-
module Reactor
|
5
|
-
|
6
|
-
module ResponseHandler
|
7
|
-
|
8
|
-
class String < Base
|
9
|
-
|
10
|
-
def get(response, string)
|
11
|
-
super(response, string)
|
12
|
-
|
13
|
-
self.response.xpath(string)
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|