infopark_reactor 1.25.0 → 1.27.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +25 -0
  3. data/.rubocop_todo.yml +363 -0
  4. data/Rakefile +10 -13
  5. data/app/models/rails_connector/abstract_obj.rb +2 -1
  6. data/config/routes.rb +0 -1
  7. data/infopark_reactor.gemspec +16 -15
  8. data/lib/generators/cm/migration/migration_generator.rb +4 -8
  9. data/lib/infopark_reactor.rb +43 -69
  10. data/lib/reactor/already_released.rb +1 -2
  11. data/lib/reactor/attributes.rb +94 -270
  12. data/lib/reactor/attributes/date_serializer.rb +20 -16
  13. data/lib/reactor/attributes/html_serializer.rb +6 -5
  14. data/lib/reactor/attributes/link_list_extender.rb +10 -8
  15. data/lib/reactor/attributes/link_list_from_accessor.rb +2 -1
  16. data/lib/reactor/attributes/link_list_from_attr_values.rb +2 -1
  17. data/lib/reactor/attributes/link_list_serializer.rb +8 -7
  18. data/lib/reactor/attributes_handlers.rb +164 -0
  19. data/lib/reactor/cache/permission.rb +6 -9
  20. data/lib/reactor/cache/user.rb +3 -6
  21. data/lib/reactor/cm/attribute.rb +16 -16
  22. data/lib/reactor/cm/attribute_group.rb +18 -21
  23. data/lib/reactor/cm/blob_too_small_error.rb +2 -2
  24. data/lib/reactor/cm/bridge.rb +6 -9
  25. data/lib/reactor/cm/channel.rb +3 -4
  26. data/lib/reactor/cm/editorial_group.rb +2 -9
  27. data/lib/reactor/cm/group.rb +30 -43
  28. data/lib/reactor/cm/job.rb +77 -0
  29. data/lib/reactor/cm/language.rb +21 -22
  30. data/lib/reactor/cm/link.rb +38 -40
  31. data/lib/reactor/cm/live_group.rb +2 -9
  32. data/lib/reactor/cm/log_entry.rb +22 -21
  33. data/lib/reactor/cm/missing_credentials.rb +3 -2
  34. data/lib/reactor/cm/multi_xml_request.rb +22 -25
  35. data/lib/reactor/cm/obj.rb +161 -152
  36. data/lib/reactor/cm/obj_class.rb +52 -51
  37. data/lib/reactor/cm/object_base.rb +26 -21
  38. data/lib/reactor/cm/permissions.rb +7 -7
  39. data/lib/reactor/cm/user.rb +63 -46
  40. data/lib/reactor/cm/workflow.rb +11 -12
  41. data/lib/reactor/cm/xml_attribute.rb +10 -19
  42. data/lib/reactor/cm/xml_markup.rb +7 -10
  43. data/lib/reactor/cm/xml_multi_request_error.rb +1 -3
  44. data/lib/reactor/cm/xml_request.rb +21 -29
  45. data/lib/reactor/cm/xml_request_error.rb +1 -3
  46. data/lib/reactor/cm/xml_response.rb +8 -16
  47. data/lib/reactor/cm/xml_single_request_error.rb +3 -5
  48. data/lib/reactor/configuration.rb +1 -3
  49. data/lib/reactor/engine.rb +5 -10
  50. data/lib/reactor/legacy.rb +8 -9
  51. data/lib/reactor/link/external.rb +8 -5
  52. data/lib/reactor/link/internal.rb +8 -5
  53. data/lib/reactor/link/temporary_link.rb +18 -19
  54. data/lib/reactor/main.rb +11 -15
  55. data/lib/reactor/migration.rb +52 -47
  56. data/lib/reactor/no_working_version.rb +1 -2
  57. data/lib/reactor/not_permitted.rb +1 -2
  58. data/lib/reactor/permission.rb +36 -38
  59. data/lib/reactor/persistence.rb +105 -159
  60. data/lib/reactor/plans/common_attribute.rb +7 -7
  61. data/lib/reactor/plans/common_attribute_group.rb +6 -6
  62. data/lib/reactor/plans/common_channel.rb +6 -6
  63. data/lib/reactor/plans/common_group.rb +7 -14
  64. data/lib/reactor/plans/common_job.rb +32 -0
  65. data/lib/reactor/plans/common_obj_class.rb +11 -11
  66. data/lib/reactor/plans/create_attribute.rb +1 -3
  67. data/lib/reactor/plans/create_attribute_group.rb +1 -3
  68. data/lib/reactor/plans/create_channel.rb +2 -3
  69. data/lib/reactor/plans/create_group.rb +3 -10
  70. data/lib/reactor/plans/create_job.rb +22 -0
  71. data/lib/reactor/plans/create_obj.rb +12 -14
  72. data/lib/reactor/plans/create_obj_class.rb +1 -2
  73. data/lib/reactor/plans/delete_attribute.rb +1 -3
  74. data/lib/reactor/plans/delete_attribute_group.rb +2 -4
  75. data/lib/reactor/plans/delete_channel.rb +4 -4
  76. data/lib/reactor/plans/delete_group.rb +2 -9
  77. data/lib/reactor/plans/delete_job.rb +23 -0
  78. data/lib/reactor/plans/delete_obj.rb +3 -4
  79. data/lib/reactor/plans/delete_obj_class.rb +1 -2
  80. data/lib/reactor/plans/prepared.rb +3 -4
  81. data/lib/reactor/plans/rename_group.rb +4 -11
  82. data/lib/reactor/plans/rename_obj_class.rb +1 -2
  83. data/lib/reactor/plans/update_attribute.rb +1 -3
  84. data/lib/reactor/plans/update_attribute_group.rb +2 -4
  85. data/lib/reactor/plans/update_group.rb +2 -9
  86. data/lib/reactor/plans/update_job.rb +27 -0
  87. data/lib/reactor/plans/update_obj.rb +6 -7
  88. data/lib/reactor/plans/update_obj_class.rb +0 -2
  89. data/lib/reactor/rc_independent.rb +0 -1
  90. data/lib/reactor/session.rb +27 -31
  91. data/lib/reactor/session/observers.rb +3 -5
  92. data/lib/reactor/session/user.rb +6 -7
  93. data/lib/reactor/session_helper/auth_filter.rb +9 -0
  94. data/lib/reactor/session_helper/auth_helper.rb +24 -0
  95. data/lib/reactor/session_helper/rsession_helper.rb +16 -0
  96. data/lib/reactor/session_helper/session_state.rb +31 -0
  97. data/lib/reactor/streaming_upload.rb +0 -1
  98. data/lib/reactor/sudo.rb +2 -3
  99. data/lib/reactor/support/link_matcher.rb +8 -7
  100. data/lib/reactor/tools/migrator.rb +30 -35
  101. data/lib/reactor/tools/response_handler/xml_attribute.rb +37 -27
  102. data/lib/reactor/tools/smart_xml_logger.rb +20 -22
  103. data/lib/reactor/tools/sower.rb +22 -23
  104. data/lib/reactor/tools/uploader.rb +12 -17
  105. data/lib/reactor/tools/versioner.rb +29 -30
  106. data/lib/reactor/tools/where_query.rb +12 -13
  107. data/lib/reactor/tools/workflow_generator.rb +26 -28
  108. data/lib/reactor/tools/xml_attributes.rb +7 -14
  109. data/lib/reactor/tools/xpath_extractor.rb +2 -1
  110. data/lib/reactor/validations.rb +20 -16
  111. data/lib/reactor/version.rb +1 -2
  112. data/lib/reactor/workflow.rb +10 -33
  113. data/lib/reactor/workflow/comment.rb +28 -0
  114. data/lib/reactor/workflow/empty.rb +0 -1
  115. data/lib/reactor/workflow/standard.rb +4 -3
  116. data/lib/tasks/cm_migrate.rake +3 -3
  117. data/lib/tasks/cm_seeds.rake +9 -16
  118. metadata +77 -35
  119. data/app/models/rails_connector/abstract_model.rb +0 -7
  120. data/app/models/rails_connector/attribute.rb +0 -94
  121. data/app/models/rails_connector/blob_mapping.rb +0 -16
  122. data/app/models/rails_connector/channel.rb +0 -41
  123. data/app/models/rails_connector/content.rb +0 -12
  124. data/app/models/rails_connector/obj_class.rb +0 -158
  125. data/app/models/rails_connector/obj_class_attr.rb +0 -5
  126. data/app/models/rails_connector/object_with_meta_data.rb +0 -18
  127. data/lib/rails_connector/meta/eager_loader.rb +0 -91
  128. data/lib/reactor/rails_connector_meta.rb +0 -149
  129. data/lib/reactor/session_helper.rb +0 -70
@@ -1,7 +1,6 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'reactor/cm/xml_request'
3
- require 'reactor/cm/xml_response'
4
- require 'reactor/cm/xml_request_error'
1
+ require "reactor/cm/xml_request"
2
+ require "reactor/cm/xml_response"
3
+ require "reactor/cm/xml_request_error"
5
4
 
6
5
  module Reactor
7
6
  module Cm
@@ -9,15 +8,15 @@ module Reactor
9
8
  def self.exists?(name)
10
9
  klass = ObjClass.new
11
10
  begin
12
- return klass.send(:get, name).ok?
13
- rescue
14
- return false
11
+ klass.send(:get, name).ok?
12
+ rescue StandardError
13
+ false
15
14
  end
16
15
  end
17
16
 
18
17
  def self.create(name, type)
19
18
  klass = ObjClass.new
20
- klass.send(:create,name, type)
19
+ klass.send(:create, name, type)
21
20
  klass
22
21
  end
23
22
 
@@ -29,17 +28,17 @@ module Reactor
29
28
 
30
29
  def self.rename(current_name, new_name)
31
30
  request = XmlRequest.prepare do |xml|
32
- xml.tag!('objClass-where') do
33
- xml.tag!('name', current_name)
31
+ xml.tag!("objClass-where") do
32
+ xml.tag!("name", current_name)
34
33
  end
35
- xml.tag!('objClass-set') do
36
- xml.tag!('name', new_name)
34
+ xml.tag!("objClass-set") do
35
+ xml.tag!("name", new_name)
37
36
  end
38
37
  end
39
38
  request.execute!
40
39
  end
41
40
 
42
- def set(key, value, options={})
41
+ def set(key, value, options = {})
43
42
  @params_options[key.to_sym] = (!options.nil? && !options.empty? && options) || {}
44
43
  @params[key.to_sym] = value
45
44
  end
@@ -50,28 +49,27 @@ module Reactor
50
49
 
51
50
  def preset_attributes
52
51
  request = XmlRequest.prepare do |xml|
53
- xml.where_key_tag!(base_name, 'name', @name)
54
- xml.get_key_tag!(base_name, 'presetAttributes')
52
+ xml.where_key_tag!(base_name, "name", @name)
53
+ xml.get_key_tag!(base_name, "presetAttributes")
55
54
  end
56
55
  response = request.execute!
57
- result = response.xpath('//dictitem')
58
- result = [result] unless result.kind_of?(Array)
56
+ result = response.xpath("//dictitem")
57
+ result = [result] unless result.is_a?(Array)
59
58
  result.map do |dictitem|
60
- key = dictitem.children.detect {|c| c.name == 'key'}.text
61
- raw_value = dictitem.children.detect {|c| c.name == 'value'}
62
- if raw_value.children.detect {|c| c.kind_of?(::REXML::Text) }
63
- value = raw_value.text
64
- else
65
- value = raw_value.children.map {|c| c.text }
66
- end
67
- {key => value}
59
+ key = dictitem.children.detect { |c| c.name == "key" }.text
60
+ raw_value = dictitem.children.detect { |c| c.name == "value" }
61
+ value = if raw_value.children.detect { |c| c.is_a?(::REXML::Text) }
62
+ raw_value.text
63
+ else
64
+ raw_value.children.map { |c| c.text }
65
+ end
66
+ { key => value }
68
67
  end.inject({}, &:merge)
69
68
  end
70
69
 
71
-
72
70
  def save!
73
71
  request = XmlRequest.prepare do |xml|
74
- xml.where_key_tag!(base_name, 'name', @name)
72
+ xml.where_key_tag!(base_name, "name", @name)
75
73
  xml.set_tag!(base_name) do
76
74
  @params.each do |key, value|
77
75
  if @params_options[key][:cdata]
@@ -83,17 +81,17 @@ module Reactor
83
81
  end
84
82
  end
85
83
  unless @preset.empty?
86
- all_preset = (preset_attributes.merge(@preset))
87
- xml.tag!('presetAttributes') do
84
+ preset_attributes.merge(@preset)
85
+ xml.tag!("presetAttributes") do
88
86
  @preset.each do |key, value|
89
- xml.tag!('dictitem') do
90
- xml.tag!('key') do
87
+ xml.tag!("dictitem") do
88
+ xml.tag!("key") do
91
89
  xml.text!(key.to_s)
92
90
  end
93
- xml.tag!('value') do
94
- if value.kind_of?(Array)
91
+ xml.tag!("value") do
92
+ if value.is_a?(Array)
95
93
  value.each do |item|
96
- xml.tag!('listitem') do
94
+ xml.tag!("listitem") do
97
95
  xml.text!(item.to_s)
98
96
  end
99
97
  end
@@ -107,7 +105,7 @@ module Reactor
107
105
  end
108
106
  end
109
107
  end
110
- response = request.execute!
108
+ request.execute!
111
109
  end
112
110
 
113
111
  def has_attribute?(attr_name)
@@ -115,35 +113,36 @@ module Reactor
115
113
  end
116
114
 
117
115
  def attributes
118
- __attributes_get('attributes')
116
+ __attributes_get("attributes")
119
117
  end
120
118
 
121
119
  def attributes=(attr_arr)
122
- __attributes_set('attributes', attr_arr)
120
+ __attributes_set("attributes", attr_arr)
123
121
  end
124
122
 
125
123
  def mandatory_attributes
126
- __attributes_get('mandatoryAttributes')
124
+ __attributes_get("mandatoryAttributes")
127
125
  end
128
126
 
129
127
  def mandatory_attributes=(attr_arr)
130
- __attributes_set('mandatoryAttributes', attr_arr)
128
+ __attributes_set("mandatoryAttributes", attr_arr)
131
129
  end
132
130
 
133
131
  def delete!
134
132
  request = XmlRequest.prepare do |xml|
135
- xml.where_key_tag!(base_name, 'name', @name)
133
+ xml.where_key_tag!(base_name, "name", @name)
136
134
  xml.tag!("#{base_name}-delete")
137
135
  end
138
- response = request.execute!
136
+ request.execute!
139
137
  end
140
138
 
141
139
  protected
140
+
142
141
  def base_name
143
- 'objClass'
142
+ "objClass"
144
143
  end
145
144
 
146
- def initialize(name=nil)
145
+ def initialize(name = nil)
147
146
  @name = name
148
147
  @params = {}
149
148
  @params_options = {}
@@ -152,8 +151,8 @@ module Reactor
152
151
 
153
152
  def get(name)
154
153
  request = XmlRequest.prepare do |xml|
155
- xml.where_key_tag!(base_name, 'name', name)
156
- xml.get_key_tag!(base_name, 'name')
154
+ xml.where_key_tag!(base_name, "name", name)
155
+ xml.get_key_tag!(base_name, "name")
157
156
  end
158
157
  response = request.execute!
159
158
  @name = name
@@ -163,10 +162,10 @@ module Reactor
163
162
  def create(name, type)
164
163
  request = XmlRequest.prepare do |xml|
165
164
  xml.create_tag!(base_name) do |xml|
166
- xml.tag!('name') do
165
+ xml.tag!("name") do
167
166
  xml.text!(name)
168
167
  end
169
- xml.tag!('objType') do
168
+ xml.tag!("objType") do
170
169
  xml.text!(type)
171
170
  end
172
171
  end
@@ -177,23 +176,25 @@ module Reactor
177
176
  end
178
177
 
179
178
  private
179
+
180
180
  def __attributes_get(field)
181
181
  request = XmlRequest.prepare do |xml|
182
- xml.where_key_tag!(base_name, 'name', @name)
182
+ xml.where_key_tag!(base_name, "name", @name)
183
183
  xml.get_key_tag!(base_name, field)
184
184
  end
185
185
  response = request.execute!
186
186
  items = response.xpath("//listitem/text()")
187
- return [items.to_s] unless items.kind_of?(Array)
187
+ return [items.to_s] unless items.is_a?(Array)
188
+
188
189
  items.map(&:to_s)
189
190
  end
190
191
 
191
192
  def __attributes_set(field, attr_arr)
192
193
  request = XmlRequest.prepare do |xml|
193
- xml.where_key_tag!(base_name, 'name', @name)
194
+ xml.where_key_tag!(base_name, "name", @name)
194
195
  xml.set_key_tag!(base_name, field, attr_arr)
195
196
  end
196
- response = request.execute!
197
+ request.execute!
197
198
  end
198
199
  end
199
200
  end
@@ -1,5 +1,4 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'reactor/tools/xml_attributes'
1
+ require "reactor/tools/xml_attributes"
3
2
 
4
3
  module Reactor
5
4
  module Cm
@@ -12,7 +11,7 @@ module Reactor
12
11
 
13
12
  # Default base_name is lowercased class name (without namespaces)
14
13
  def self.base_name
15
- self.name.split('::').last.downcase
14
+ name.split("::").last.downcase
16
15
  end
17
16
 
18
17
  def base_name
@@ -24,9 +23,9 @@ module Reactor
24
23
  # set_base_name 'obj'
25
24
  # end
26
25
  def self.set_base_name(base_name_value)
27
- # we us evaluation of a string in this case, because
26
+ # we us evaluation of a string in this case, because
28
27
  # define_method cannot handle default values
29
- self.class_eval <<-EOH
28
+ class_eval <<-EOH
30
29
  def self.base_name
31
30
  '#{base_name_value}'
32
31
  end
@@ -50,7 +49,7 @@ module Reactor
50
49
  response = request.execute!
51
50
 
52
51
  self.class.attributes.each do |attr_name, attr_def|
53
- self.send(:"#{attr_name}=", self.class.response_handler.get(response, attr_def))
52
+ send(:"#{attr_name}=", self.class.response_handler.get(response, attr_def))
54
53
  end
55
54
 
56
55
  self
@@ -62,23 +61,24 @@ module Reactor
62
61
  xml.where_key_tag!(base_name, primary_key, primary_key_value)
63
62
  xml.set_tag!(base_name) do
64
63
  self.class.attributes(:set).each do |name, xml_attribute|
65
- value = self.send(name)
64
+ value = send(name)
66
65
  serialize_attribute_to_xml(xml, xml_attribute, value)
67
66
  end
68
67
  end
69
68
  end
70
69
 
71
70
  response = request.execute!
72
-
73
71
  response.ok?
74
72
  end
75
73
 
76
74
  # Alias for #save!
77
- def save ; save! ; end
75
+ def save
76
+ save!
77
+ end
78
78
 
79
79
  # Proxy method. @see .delete!(login)
80
80
  def delete!
81
- self.class.delete!(self.primary_key_value)
81
+ self.class.delete!(primary_key_value)
82
82
  end
83
83
 
84
84
  def serialize_attribute_to_xml(xml, xml_attribute, value)
@@ -99,10 +99,9 @@ module Reactor
99
99
 
100
100
  response = request.execute!
101
101
 
102
- return response.ok?
103
-
104
- rescue XmlRequestError => e
105
- return false
102
+ response.ok?
103
+ rescue XmlRequestError
104
+ false
106
105
  end
107
106
 
108
107
  # Returns an instance of the class for object with given primary key
@@ -122,43 +121,49 @@ module Reactor
122
121
  xml.delete_tag!(base_name)
123
122
  end
124
123
 
125
- return request.execute!.ok?
124
+ request.execute!.ok?
126
125
  end
126
+
127
127
  # Alias for #delete!
128
- def delete ; delete! ; end
128
+ def delete
129
+ delete!
130
+ end
129
131
 
130
132
  class << self
131
133
  # This method should never be called directly. It should always be overriden!
132
134
  # pk_value is the value of primary key, it should have its double in attributes hash
133
135
  # attributes is a hash of attributes set on creation {:name => 'value'}
136
+
134
137
  protected
138
+
135
139
  def create(pk_value, attributes)
136
140
  request = XmlRequest.prepare do |xml|
137
141
  xml.create_tag!(base_name) do
138
142
  attributes.each do |attr_name, attr_value|
139
- #serialize_attribute_to_xml(xml, xml_attribute, value)
143
+ # serialize_attribute_to_xml(xml, xml_attribute, value)
140
144
  xml.value_tag!(attr_name, attr_value)
141
145
  end
142
146
  end
143
147
  end
144
148
 
145
- response = request.execute!
149
+ request.execute!
146
150
 
147
- return get(pk_value)
151
+ get(pk_value)
148
152
  end
149
153
  end
150
154
 
151
155
  protected
156
+
152
157
  def primary_key
153
158
  self.class.primary_key
154
159
  end
155
160
 
156
161
  def primary_key_value
157
- instance_variable_get("@#{self.primary_key}")
162
+ instance_variable_get("@#{primary_key}")
158
163
  end
159
164
 
160
165
  def primary_key_value_set(value)
161
- instance_variable_set("@#{self.primary_key}", value)
166
+ instance_variable_set("@#{primary_key}", value)
162
167
  end
163
168
  end
164
169
  end
@@ -3,27 +3,27 @@ module Reactor
3
3
  module Permissions
4
4
  def self.included(base)
5
5
  base.instance_eval do
6
- attribute :global_permissions, :name => :globalPermissions, :type => :list
6
+ attribute :global_permissions, name: :globalPermissions, type: :list
7
7
  end
8
8
  end
9
9
 
10
10
  # Returns true, if a global permission with the given +name+ exists, false otherwise.
11
11
  def global_permission?(name)
12
- self.global_permissions.include?(name.to_s)
12
+ global_permissions.include?(name.to_s)
13
13
  end
14
14
 
15
15
  # Add the given +permissions+ to the current set of group permissions.
16
16
  def grant_global_permissions!(permissions)
17
- permissions = permissions.kind_of?(Array) ? permissions : [permissions]
18
- permissions = self.global_permissions | permissions
17
+ permissions = permissions.is_a?(Array) ? permissions : [permissions]
18
+ permissions = global_permissions | permissions
19
19
 
20
20
  set_global_permissions!(permissions)
21
21
  end
22
22
 
23
23
  # Take away the given +permissions+ from the current set of group permissions.
24
24
  def revoke_global_permissions!(permissions)
25
- permissions = permissions.kind_of?(Array) ? permissions : [permissions]
26
- permissions = self.global_permissions - permissions
25
+ permissions = permissions.is_a?(Array) ? permissions : [permissions]
26
+ permissions = global_permissions - permissions
27
27
 
28
28
  set_global_permissions(permissions)
29
29
  end
@@ -31,7 +31,7 @@ module Reactor
31
31
  # Set the group permissions to the given +permissions+.
32
32
  def set_global_permissions!(permissions)
33
33
  request = XmlRequest.prepare do |xml|
34
- xml.where_key_tag!(base_name, self.class.primary_key, self.name)
34
+ xml.where_key_tag!(base_name, self.class.primary_key, name)
35
35
  xml.set_key_tag!(base_name, self.class.xml_attribute(:global_permissions).name, permissions)
36
36
  end
37
37
 
@@ -1,40 +1,36 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'reactor/cm/object_base'
3
- require 'reactor/configuration'
4
- require 'reactor/cm/language'
5
- require 'reactor/tools/xml_attributes'
6
- require 'reactor/tools/where_query'
1
+ require "reactor/cm/object_base"
2
+ require "reactor/configuration"
3
+ require "reactor/cm/language"
4
+ require "reactor/tools/xml_attributes"
5
+ require "reactor/tools/where_query"
7
6
 
8
- require 'reactor/cm/permissions'
7
+ require "reactor/cm/permissions"
9
8
 
10
9
  module Reactor
11
-
12
10
  module Cm
13
-
14
11
  class User
15
-
16
12
  class Internal < Reactor::Cm::ObjectBase
17
- set_base_name 'user'
13
+ set_base_name "user"
18
14
 
19
15
  # Attribute definitions
20
- attribute :login, :except => [:set]
21
- attribute :super_user, :except => [:set], :name => :isSuperUser
22
- attribute :default_group, :name => :defaultGroup
23
- attribute :groups, :type => :list
24
- attribute :real_name, :name => :realName
16
+ attribute :login, except: [:set]
17
+ attribute :super_user, except: [:set], name: :isSuperUser
18
+ attribute :default_group, name: :defaultGroup
19
+ attribute :groups, type: :list
20
+ attribute :real_name, name: :realName
25
21
  attribute :email
26
22
 
27
23
  include Permissions
28
24
 
29
25
  def name
30
- self.login
26
+ login
31
27
  end
32
28
 
33
29
  def change_password(new_password)
34
30
  request = XmlRequest.prepare do |xml|
35
31
  xml.where_key_tag!(base_name, primary_key, primary_key_value)
36
32
  xml.set_tag!(base_name) do
37
- xml.tag!('password', :verifyNewPassword => new_password) do
33
+ xml.tag!("password", verifyNewPassword: new_password) do
38
34
  xml.text!(new_password)
39
35
  end
40
36
  end
@@ -46,79 +42,81 @@ module Reactor
46
42
  end
47
43
 
48
44
  def has_password?(password)
49
- ::Reactor::Cm::User.new(self.login).has_password?(password)
45
+ ::Reactor::Cm::User.new(login).has_password?(password)
50
46
  end
51
47
 
52
48
  primary_key :login
53
49
 
54
50
  # Returns true if user is root, false otherwise
55
51
  def super_user?
56
- super_user == '1'
52
+ super_user == "1"
57
53
  end
58
54
 
59
55
  # Creates a user with given login and sets its default group
60
56
  # Returns instance of the class for user with given login
61
- def self.create(login, default_group)
62
- super(login, {:login => login, :defaultGroup => default_group})
63
- end
64
-
57
+ def self.create(login, default_group)
58
+ super(login, { login: login, defaultGroup: default_group })
59
+ end
65
60
  end
66
61
 
67
62
  include XmlAttributes
68
63
  extend WhereQuery
69
64
 
70
65
  attribute :login
71
- attribute :groups, :type => :list
72
- attribute :global_permissions, :name => :globalPermissions, :type => :list
66
+ attribute :groups, type: :list
67
+ attribute :global_permissions, name: :globalPermissions, type: :list
73
68
  attribute :email
74
- attribute :default_group, :name => :defaultGroup
75
- attribute :real_name, :name => :realName
69
+ attribute :default_group, name: :defaultGroup
70
+ attribute :real_name, name: :realName
76
71
 
77
- primary_key 'login'
72
+ primary_key "login"
78
73
 
79
74
  def initialize(name = nil)
80
75
  @login = name
81
76
  end
82
77
 
83
78
  def name
84
- self.login
79
+ login
85
80
  end
86
81
 
87
82
  def self.all(match = nil)
88
- self.where("userText", match)
83
+ where("userText", match)
89
84
  end
90
85
 
91
86
  def has_password?(password)
92
87
  request = XmlRequest.prepare do |xml|
93
- xml.where_key_tag!(base_name, self.class.primary_key, self.login)
88
+ xml.where_key_tag!(base_name, self.class.primary_key, login)
94
89
  xml.get_tag!(base_name) do |xml3|
95
- xml3.tag!('hasPassword', :password => password)
90
+ xml3.tag!("hasPassword", password: password)
96
91
  end
97
92
  end
98
93
  response = request.execute!
99
- response.xpath('//hasPassword/text()') == '1'
94
+ response.xpath("//hasPassword/text()") == "1"
100
95
  end
101
96
 
102
97
  def is_root?
103
98
  request = XmlRequest.prepare do |xml|
104
- xml.where_key_tag!(base_name, self.class.primary_key, self.login)
105
- xml.get_key_tag!(base_name, 'isSuperUser')
99
+ xml.where_key_tag!(base_name, self.class.primary_key, login)
100
+ xml.get_key_tag!(base_name, "isSuperUser")
106
101
  end
107
102
 
108
103
  response = request.execute!
109
104
 
110
- response.xpath('//isSuperUser/text()') == '1'
105
+ response.xpath("//isSuperUser/text()") == "1"
111
106
  end
112
107
 
113
108
  def language
114
- Reactor::Cm::Language.get(self.login)
109
+ Reactor::Cm::Language.get(login)
115
110
  end
116
111
 
117
112
  def global_permissions
113
+ val = instance_variable_get(:@global_permissions)
114
+ return val unless val.nil?
115
+
118
116
  xml_attribute = self.class.xml_attribute(:global_permissions)
119
117
 
120
118
  request = XmlRequest.prepare do |xml|
121
- xml.where_key_tag!(base_name, self.class.primary_key, self.login)
119
+ xml.where_key_tag!(base_name, self.class.primary_key, login)
122
120
  xml.get_key_tag!(base_name, xml_attribute.name)
123
121
  end
124
122
 
@@ -128,10 +126,13 @@ module Reactor
128
126
  end
129
127
 
130
128
  def groups
129
+ val = instance_variable_get(:@groups)
130
+ return val unless val.nil?
131
+
131
132
  xml_attribute = self.class.xml_attribute(:groups)
132
133
 
133
134
  request = XmlRequest.prepare do |xml|
134
- xml.where_key_tag!(base_name, self.class.primary_key, self.login)
135
+ xml.where_key_tag!(base_name, self.class.primary_key, login)
135
136
  xml.get_key_tag!(base_name, xml_attribute.name)
136
137
  end
137
138
 
@@ -141,10 +142,29 @@ module Reactor
141
142
  end
142
143
 
143
144
  def email
145
+ val = instance_variable_get(:@email)
146
+ return val unless val.nil?
147
+
144
148
  xml_attribute = self.class.xml_attribute(:email)
145
149
 
146
150
  request = XmlRequest.prepare do |xml|
147
- xml.where_key_tag!(base_name, self.class.primary_key, self.login)
151
+ xml.where_key_tag!(base_name, self.class.primary_key, login)
152
+ xml.get_key_tag!(base_name, xml_attribute.name)
153
+ end
154
+
155
+ response = request.execute!
156
+
157
+ self.class.response_handler.get(response, xml_attribute)
158
+ end
159
+
160
+ def real_name
161
+ val = instance_variable_get(:@real_name)
162
+ return val unless val.nil?
163
+
164
+ xml_attribute = self.class.xml_attribute(:real_name)
165
+
166
+ request = XmlRequest.prepare do |xml|
167
+ xml.where_key_tag!(base_name, self.class.primary_key, login)
148
168
  xml.get_key_tag!(base_name, xml_attribute.name)
149
169
  end
150
170
 
@@ -154,17 +174,14 @@ module Reactor
154
174
  end
155
175
 
156
176
  protected
177
+
157
178
  def base_name
158
179
  self.class.base_name
159
-
160
180
  end
161
181
 
162
182
  def self.base_name
163
- 'userProxy'
183
+ "userProxy"
164
184
  end
165
-
166
185
  end
167
-
168
186
  end
169
-
170
187
  end