infopark_reactor 1.26.0 → 1.27.0.rc9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) 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 +23 -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 +23 -25
  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 +43 -51
  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 -53
  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 +6 -6
  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 +3 -4
  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 +3 -6
  76. data/lib/reactor/plans/delete_group.rb +2 -9
  77. data/lib/reactor/plans/delete_job.rb +3 -5
  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 +4 -8
  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 +27 -33
  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 +11 -14
  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 +76 -40
  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/job.rb +0 -14
  125. data/app/models/rails_connector/obj_class.rb +0 -158
  126. data/app/models/rails_connector/obj_class_attr.rb +0 -5
  127. data/app/models/rails_connector/object_with_meta_data.rb +0 -18
  128. data/lib/rails_connector/meta/eager_loader.rb +0 -91
  129. data/lib/reactor/rails_connector_meta.rb +0 -149
  130. data/lib/reactor/session_helper.rb +0 -72
@@ -1,12 +1,14 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'reactor/cm/multi_xml_request'
1
+ require "reactor/cm/multi_xml_request"
3
2
 
4
3
  module Reactor
5
4
  module Cm
6
5
  class Obj
7
6
  attr_reader :obj_id
8
- OBJ_ATTRS = [:permalink, :objClass, :workflowName, :name, :suppressExport, :parent]
9
- ATTR_LENGTH_CONSTRAINT = {:name => 250, :title => 250}
7
+
8
+ OBJ_ATTRS = %i(permalink objClass workflowName name suppressExport parent).freeze
9
+ PREDEFINED_ATTRS = %i(blob body channels title).freeze
10
+
11
+ ATTR_LENGTH_CONSTRAINT = { name: 250, title: 250 }.freeze
10
12
 
11
13
  def self.create(name, parent, objClass)
12
14
  obj = Obj.new(name)
@@ -18,14 +20,14 @@ module Reactor
18
20
  obj = Obj.new
19
21
  begin
20
22
  obj.send(:load, path_or_id).ok?
21
- rescue
22
- return false
23
+ rescue StandardError
24
+ false
23
25
  end
24
26
  end
25
27
 
26
28
  def self.load(id)
27
29
  obj = Obj.new
28
- obj.instance_variable_set('@obj_id', id)
30
+ obj.instance_variable_set("@obj_id", id)
29
31
  obj
30
32
  end
31
33
 
@@ -37,8 +39,7 @@ module Reactor
37
39
 
38
40
  def self.delete_where(conditions)
39
41
  request = XmlRequest.prepare do |xml|
40
-
41
- xml.tag!('obj-where') do
42
+ xml.tag!("obj-where") do
42
43
  conditions.each do |key, value|
43
44
  xml.tag!(key, value)
44
45
  end
@@ -49,29 +50,29 @@ module Reactor
49
50
  end
50
51
 
51
52
  def upload(data_or_io, extension)
52
- data = (data_or_io.kind_of?IO) ? data_or_io.read : data_or_io
53
+ data = (data_or_io.is_a? IO) ? data_or_io.read : data_or_io
53
54
  base64_data = Base64.encode64(data)
54
55
 
55
56
  set(:contentType, extension)
56
- set(:blob, {base64_data=>{:encoding=>'base64'}})
57
+ set(:blob, { base64_data => { encoding: "base64" } })
57
58
  end
58
59
 
59
60
  def get(key)
60
61
  request = XmlRequest.prepare do |xml|
61
- xml.where_key_tag!(base_name, 'id', @obj_id)
62
+ xml.where_key_tag!(base_name, "id", @obj_id)
62
63
  xml.get_key_tag!(base_name, key)
63
64
  end
64
65
  response = request.execute!
65
66
  result = response.xpath("//#{key}")
66
- if result.children.map {|i| i.respond_to?(:name) && (i.name == "listitem") }.reduce(:&)
67
- result.children.map {|i| i.text.to_s }
67
+ if result.children.map { |i| i.respond_to?(:name) && (i.name == "listitem") }.reduce(:&)
68
+ result.children.map { |i| i.text.to_s }
68
69
  else
69
70
  result = result.text unless result.is_a? Array
70
71
  result
71
72
  end
72
73
  end
73
74
 
74
- def set(key, value, options={})
75
+ def set(key, value, options = {})
75
76
  key = key.to_sym
76
77
  value = value[0, ATTR_LENGTH_CONSTRAINT[key]] if ATTR_LENGTH_CONSTRAINT[key] && value
77
78
  if OBJ_ATTRS.include?(key) then @obj_attrs[key] = value
@@ -83,9 +84,9 @@ module Reactor
83
84
 
84
85
  def permission_granted_to(user, permission)
85
86
  request = XmlRequest.prepare do |xml|
86
- xml.where_key_tag!(base_name, 'id', @obj_id)
87
+ xml.where_key_tag!(base_name, "id", @obj_id)
87
88
  xml.get_tag!(base_name) do
88
- xml.tag!('permissionGrantedTo', :permission => permission, :user => user)
89
+ xml.tag!("permissionGrantedTo", permission: permission, user: user)
89
90
  end
90
91
  end
91
92
  response = request.execute!
@@ -97,8 +98,8 @@ module Reactor
97
98
  xml.where_key_tag!(base_name, :id, @obj_id)
98
99
 
99
100
  options = {
100
- :permission => permission,
101
- :type => :list,
101
+ permission: permission,
102
+ type: :list
102
103
  }
103
104
 
104
105
  xml.set_key_tag!(base_name, :permission, groups, options)
@@ -108,19 +109,19 @@ module Reactor
108
109
  end
109
110
 
110
111
  def permission_grant(permission, groups)
111
- self.permission_command('GrantTo', permission, groups)
112
+ permission_command("GrantTo", permission, groups)
112
113
  end
113
114
 
114
115
  def permission_revoke(permission, groups)
115
- self.permission_command('RevokeFrom', permission, groups)
116
+ permission_command("RevokeFrom", permission, groups)
116
117
  end
117
118
 
118
119
  def permission_clear(permission)
119
- self.permission_set(permission, [])
120
+ permission_set(permission, [])
120
121
  end
121
122
 
122
123
  def get_links(attr)
123
- get_link_ids(attr).map {|id| Link.get(id)}
124
+ get_link_ids(attr).map { |id| Link.get(id) }
124
125
  end
125
126
 
126
127
  def set_links(attr, new_links_as_hashes)
@@ -143,10 +144,10 @@ module Reactor
143
144
  end
144
145
 
145
146
  def set_multiple(attrs)
146
- attrs.each {|a,(v,o)| set(a,v,o||{}) }
147
+ attrs.each { |a, (v, o)| set(a, v, o || {}) }
147
148
  end
148
149
 
149
- def composite_save(attrs, links_to_add, links_to_remove, links_to_set, links_modified=false)
150
+ def composite_save(attrs, links_to_add, links_to_remove, links_to_set, links_modified = false)
150
151
  set_multiple(attrs)
151
152
 
152
153
  skip_version_creation = @attrs.empty? && links_to_remove.empty? && links_to_set.empty? && !links_modified
@@ -201,90 +202,98 @@ module Reactor
201
202
  # The solution is based on the precise source-code level knowledge
202
203
  # of the CM internals.
203
204
  resp = MultiXmlRequest.execute do |reqs|
204
- reqs.optional {|xml| SimpleCommandRequest.build(xml, @obj_id, 'take') } unless skip_version_creation
205
- reqs.optional {|xml| SimpleCommandRequest.build(xml, @obj_id, 'edit') } unless skip_version_creation
206
-
207
-
208
- reqs.mandatory {|xml| ObjSetRequest.build(xml, @obj_id, @obj_attrs) } unless @obj_attrs.empty? #important! requires different permissions
209
- reqs.mandatory {|xml| ContentSetRequest.build(xml, @obj_id, @attrs, @attr_options) } unless skip_version_creation
210
- reqs.mandatory {|xml| ResolveRefsRequest.build(xml, @obj_id) } unless skip_version_creation
205
+ reqs.optional { |xml| SimpleCommandRequest.build(xml, @obj_id, "take") } unless skip_version_creation
206
+ reqs.optional { |xml| SimpleCommandRequest.build(xml, @obj_id, "edit") } unless skip_version_creation
207
+
208
+ unless @obj_attrs.empty?
209
+ reqs.mandatory { |xml| ObjSetRequest.build(xml, @obj_id, @obj_attrs) }
210
+ end # important! requires different permissions
211
+ unless skip_version_creation
212
+ reqs.mandatory { |xml| ContentSetRequest.build(xml, @obj_id, @attrs, @attr_options) }
213
+ end
214
+ reqs.mandatory { |xml| ResolveRefsRequest.build(xml, @obj_id) } unless skip_version_creation
211
215
  end
212
216
 
213
217
  resp.assert_success
214
218
 
215
219
  yield(attrs, links_to_add, links_to_remove, links_to_set) if block_given?
216
220
 
217
- resp = MultiXmlRequest.execute do |reqs|
218
- reqs.optional {|xml| SimpleCommandRequest.build(xml, @obj_id, 'take') }
219
- reqs.optional {|xml| SimpleCommandRequest.build(xml, @obj_id, 'edit') }
221
+ unless skip_version_creation || (links_to_remove.empty? && links_to_add.empty? && links_to_set.empty?)
222
+ resp = MultiXmlRequest.execute do |reqs|
223
+ reqs.optional { |xml| SimpleCommandRequest.build(xml, @obj_id, "take") }
224
+ reqs.optional { |xml| SimpleCommandRequest.build(xml, @obj_id, "edit") }
220
225
 
221
- links_to_remove.each do |link_id|
222
- reqs.mandatory {|xml| LinkDeleteRequest.build(xml, link_id) }
223
- end
226
+ links_to_remove.each do |link_id|
227
+ reqs.mandatory { |xml| LinkDeleteRequest.build(xml, link_id) }
228
+ end
224
229
 
225
- links_to_set.each do |(link_id, link)|
226
- reqs.mandatory {|xml| LinkSetRequest.build(xml, link_id, link) }
227
- end
230
+ links_to_set.each do |(link_id, link)|
231
+ reqs.mandatory { |xml| LinkSetRequest.build(xml, link_id, link) }
232
+ end
228
233
 
229
- links_to_add.each do |(attr, link)|
230
- reqs.mandatory {|xml| LinkAddRequest.build(xml, @obj_id, attr, link) }
234
+ links_to_add.each do |(attr, link)|
235
+ reqs.mandatory { |xml| LinkAddRequest.build(xml, @obj_id, attr, link) }
236
+ end
231
237
  end
232
- end unless skip_version_creation || (links_to_remove.empty? && links_to_add.empty? && links_to_set.empty?)
238
+ end
233
239
 
234
240
  resp.assert_success
235
241
  end
236
242
 
237
243
  def save!
238
- links_to_remove = @removed_links.map {|l| l.link_id}
244
+ links_to_remove = @removed_links.map { |l| l.link_id }
239
245
  links_to_add = @links.map do |attr, links|
240
246
  links.map do |link|
241
- [attr, {:destination_url => link.dest_url, :title => link.title, :target => link.target, :position => link.position}]
247
+ [attr, { destination_url: link.dest_url, title: link.title, target: link.target, position: link.position }]
242
248
  end.flatten
243
249
  end
244
250
  composite_save([], links_to_add, links_to_remove, [])
245
251
  end
246
252
 
253
+ def release!(msg = nil)
254
+ simple_command("release", msg)
255
+ end
247
256
 
248
- def release!(msg=nil)
249
- simple_command("release",msg)
257
+ def unrelease!(msg = nil)
258
+ simple_command("unrelease", msg)
250
259
  end
251
260
 
252
- def edit!(msg=nil)
253
- simple_command("edit",msg)
261
+ def edit!(msg = nil)
262
+ simple_command("edit", msg)
254
263
  end
255
264
 
256
- def take!(msg=nil)
257
- simple_command("take",msg)
265
+ def take!(msg = nil)
266
+ simple_command("take", msg)
258
267
  end
259
268
 
260
- def forward!(msg=nil)
261
- simple_command("forward",msg)
269
+ def forward!(msg = nil)
270
+ simple_command("forward", msg)
262
271
  end
263
272
 
264
- def commit!(msg=nil)
265
- simple_command("commit",msg)
273
+ def commit!(msg = nil)
274
+ simple_command("commit", msg)
266
275
  end
267
276
 
268
- def reject!(msg=nil)
269
- simple_command("reject",msg)
277
+ def reject!(msg = nil)
278
+ simple_command("reject", msg)
270
279
  end
271
280
 
272
- def revert!(msg=nil)
273
- simple_command("revert",msg)
281
+ def revert!(msg = nil)
282
+ simple_command("revert", msg)
274
283
  end
275
284
 
276
- def sign!(msg=nil)
277
- simple_command("sign",msg)
285
+ def sign!(msg = nil)
286
+ simple_command("sign", msg)
278
287
  end
279
288
 
280
289
  def valid_actions
281
- vcak = get('validControlActionKeys')
290
+ vcak = get("validControlActionKeys")
282
291
  (vcak || []).map(&:to_s)
283
292
  end
284
293
 
285
294
  def copy(new_parent, recursive = false, new_name = nil)
286
295
  request = XmlRequest.prepare do |xml|
287
- xml.tag!('obj-where') do
296
+ xml.tag!("obj-where") do
288
297
  xml.tag!("id", @obj_id)
289
298
  end
290
299
  xml.tag!("obj-copy") do
@@ -311,19 +320,19 @@ module Reactor
311
320
 
312
321
  def resolve_refs!
313
322
  request = XmlRequest.prepare do |xml|
314
- xml.tag!('content-where') do
315
- xml.tag!('objectId', @obj_id)
316
- xml.tag!('state', 'edited')
323
+ xml.tag!("content-where") do
324
+ xml.tag!("objectId", @obj_id)
325
+ xml.tag!("state", "edited")
317
326
  end
318
- xml.tag!('content-resolveRefs')
327
+ xml.tag!("content-resolveRefs")
319
328
  end
320
- response = request.execute!
329
+ request.execute!
321
330
  end
322
331
 
323
332
  def path
324
333
  request = XmlRequest.prepare do |xml|
325
- xml.where_key_tag!(base_name, 'id', @obj_id)
326
- xml.get_key_tag!(base_name, 'path')
334
+ xml.where_key_tag!(base_name, "id", @obj_id)
335
+ xml.get_key_tag!(base_name, "path")
327
336
  end
328
337
  response = request.execute!
329
338
  response.xpath("//obj/path").text
@@ -331,8 +340,8 @@ module Reactor
331
340
 
332
341
  def edited?
333
342
  request = XmlRequest.prepare do |xml|
334
- xml.where_key_tag!(base_name, 'id', @obj_id)
335
- xml.get_key_tag!(base_name, 'isEdited')
343
+ xml.where_key_tag!(base_name, "id", @obj_id)
344
+ xml.get_key_tag!(base_name, "isEdited")
336
345
  end
337
346
  response = request.execute!
338
347
  response.xpath("//isEdited").text == "1"
@@ -340,96 +349,96 @@ module Reactor
340
349
 
341
350
  def reasons_for_incomplete_state
342
351
  request = XmlRequest.prepare do |xml|
343
- xml.tag!('content-where') do
344
- xml.tag!('objectId', @obj_id)
345
- xml.tag!('state', 'edited')
352
+ xml.tag!("content-where") do
353
+ xml.tag!("objectId", @obj_id)
354
+ xml.tag!("state", "edited")
346
355
  end
347
- xml.get_key_tag!('content', 'reasonsForIncompleteState')
356
+ xml.get_key_tag!("content", "reasonsForIncompleteState")
348
357
  end
349
358
  response = request.execute!
350
- result = response.xpath('//reasonsForIncompleteState/*')
351
- result.kind_of?(Array) ? result.map(&:text).map(&:to_s) : [result.to_s]
359
+ result = response.xpath("//reasonsForIncompleteState/*")
360
+ result.is_a?(Array) ? result.map(&:text).map(&:to_s) : [result.to_s]
352
361
  end
353
362
 
354
363
  def workflow_comment
355
364
  request = XmlRequest.prepare do |xml|
356
- xml.tag!('content-where') do
357
- xml.tag!('objectId', @obj_id)
358
- xml.tag!('state', 'released')
365
+ xml.tag!("content-where") do
366
+ xml.tag!("objectId", @obj_id)
367
+ xml.tag!("state", "released")
359
368
  end
360
- xml.get_key_tag!('content', 'workflowComment')
369
+ xml.get_key_tag!("content", "workflowComment")
361
370
  end
362
371
  response = request.execute!
363
- result = response.xpath('//workflowComment/*').map {|x| x.text.to_s}.first
372
+ response.xpath("//workflowComment/*").map { |x| x.text.to_s }.first
364
373
  end
365
374
 
366
375
  def editor
367
376
  request = XmlRequest.prepare do |xml|
368
- xml.tag!('content-where') do
369
- xml.tag!('objectId', @obj_id)
370
- xml.tag!('state', 'edited')
377
+ xml.tag!("content-where") do
378
+ xml.tag!("objectId", @obj_id)
379
+ xml.tag!("state", "edited")
371
380
  end
372
- xml.get_key_tag!('content', 'editor')
381
+ xml.get_key_tag!("content", "editor")
373
382
  end
374
383
  response = request.execute!
375
- response.xpath('//editor').text
384
+ response.xpath("//editor").text
376
385
  end
377
386
 
378
- def blob_ticket_id(content='edited')
387
+ def blob_ticket_id(content = "edited")
379
388
  request = XmlRequest.prepare do |xml|
380
- xml.tag!('content-where') do
381
- xml.tag!('objectId', @obj_id)
382
- xml.tag!('state', content)
389
+ xml.tag!("content-where") do
390
+ xml.tag!("objectId", @obj_id)
391
+ xml.tag!("state", content)
383
392
  end
384
- xml.tag!('content-get') do
385
- xml.tag!('blob')
393
+ xml.tag!("content-get") do
394
+ xml.tag!("blob")
386
395
  end
387
396
  end
388
397
  response = request.execute!
389
- possible_ticket_id = response.xpath('//blob').text
390
- encoding = response.xpath('//blob/@encoding').to_s
398
+ possible_ticket_id = response.xpath("//blob").text
399
+ encoding = response.xpath("//blob/@encoding").to_s
391
400
  # blob is smaller than
392
401
  # [systemConfig getKeys tuning.minStreamingDataLength]
393
402
  # and thus it is returned in-line
394
- if encoding != 'stream'
395
- raise Reactor::Cm::BlobTooSmallError
396
- end
403
+ raise Reactor::Cm::BlobTooSmallError if encoding != "stream"
404
+
397
405
  possible_ticket_id
398
406
  end
399
407
 
400
408
  def edited_content
401
409
  request = XmlRequest.prepare do |xml|
402
- xml.where_key_tag!(base_name, 'id', @obj_id)
403
- xml.get_key_tag!(base_name, 'editedContent')
410
+ xml.where_key_tag!(base_name, "id", @obj_id)
411
+ xml.get_key_tag!(base_name, "editedContent")
404
412
  end
405
413
  response = request.execute!
406
414
  response.xpath("//editedContent").text
407
415
  end
408
416
 
409
417
  protected
410
- def simple_command(cmd_name, comment=nil)
411
- @request = XmlRequest.prepare do |xml|
412
- xml.where_key_tag!(base_name, 'id', @obj_id)
418
+
419
+ def simple_command(cmd_name, comment = nil)
420
+ request = XmlRequest.prepare do |xml|
421
+ xml.where_key_tag!(base_name, "id", @obj_id)
413
422
  if comment
414
423
  xml.tag!("#{base_name}-#{cmd_name}") do
415
- xml.tag!('comment', comment)
424
+ xml.tag!("comment", comment)
416
425
  end
417
426
  else
418
427
  xml.tag!("#{base_name}-#{cmd_name}")
419
428
  end
420
429
  end
421
- response = @request.execute!
430
+ request.execute!
422
431
  end
423
432
 
424
433
  def base_name
425
- 'obj'
434
+ "obj"
426
435
  end
427
436
 
428
437
  def get_content_attr_text(attr)
429
438
  content = edited_content
430
439
  request = XmlRequest.prepare do |xml|
431
- xml.where_key_tag!('content', 'id', content)
432
- xml.get_tag!('content') do
440
+ xml.where_key_tag!("content", "id", content)
441
+ xml.get_tag!("content") do
433
442
  xml.tag!(attr.to_s)
434
443
  end
435
444
  end
@@ -441,12 +450,12 @@ module Reactor
441
450
  def get_link_ids(attr)
442
451
  content = edited_content
443
452
  request = XmlRequest.prepare do |xml|
444
- xml.where_key_tag!('content', 'id', content)
445
- xml.get_key_tag!('content', attr.to_s)
453
+ xml.where_key_tag!("content", "id", content)
454
+ xml.get_key_tag!("content", attr.to_s)
446
455
  end
447
456
  response = request.execute!
448
457
  result = response.xpath("//listitem/text()")
449
- result.kind_of?(Array) ? result : [result]
458
+ result.is_a?(Array) ? result : [result]
450
459
  rescue XmlRequestError
451
460
  []
452
461
  end
@@ -455,7 +464,7 @@ module Reactor
455
464
  response.xpath("//obj/id").text
456
465
  end
457
466
 
458
- def initialize(name=nil)
467
+ def initialize(name = nil)
459
468
  @name = name
460
469
  @attrs = {}
461
470
  @obj_attrs = {}
@@ -465,40 +474,40 @@ module Reactor
465
474
  end
466
475
 
467
476
  def create(parent, objClass)
468
- @request = XmlRequest.prepare do |xml|
469
- xml.where_key_tag!(base_name, 'path', parent)
477
+ request = XmlRequest.prepare do |xml|
478
+ xml.where_key_tag!(base_name, "path", parent)
470
479
  xml.create_tag!(base_name) do
471
- xml.tag!('objClass') do
480
+ xml.tag!("objClass") do
472
481
  xml.text!(objClass)
473
482
  end
474
- xml.tag!('name') do
483
+ xml.tag!("name") do
475
484
  xml.text!(@name)
476
485
  end
477
486
  end
478
487
  end
479
- response = @request.execute!
488
+ response = request.execute!
480
489
  @obj_id = self.class.extract_id(response)
481
490
  response
482
491
  end
483
492
 
484
493
  def load(path_or_id)
485
- key = (/^\// =~ path_or_id.to_s) ? 'path' : 'id'
494
+ key = %r{^/}.match?(path_or_id.to_s) ? "path" : "id"
486
495
  value = path_or_id
487
496
 
488
- @request = XmlRequest.prepare do |xml|
497
+ request = XmlRequest.prepare do |xml|
489
498
  xml.where_key_tag!(base_name, key.to_s, value.to_s)
490
- xml.get_key_tag!(base_name, 'id')
499
+ xml.get_key_tag!(base_name, "id")
491
500
  end
492
- response = @request.execute!
501
+ response = request.execute!
493
502
  @obj_id = self.class.extract_id(response)
494
503
  response
495
504
  end
496
505
 
497
506
  def permission_command(type, permission, groups)
498
507
  request = XmlRequest.prepare do |xml|
499
- xml.where_key_tag!(base_name, 'id', @obj_id)
508
+ xml.where_key_tag!(base_name, "id", @obj_id)
500
509
 
501
- xml.tag!("#{base_name}-permission#{type}", :permission => permission) do
510
+ xml.tag!("#{base_name}-permission#{type}", permission: permission) do
502
511
  groups.each do |name|
503
512
  xml.tag!(:group, name)
504
513
  end
@@ -516,16 +525,16 @@ module Reactor
516
525
  end
517
526
 
518
527
  def self.build(xml, *args)
519
- self.new(xml).build(*args)
528
+ new(xml).build(*args)
520
529
  end
521
530
  end
522
531
 
523
532
  class SimpleCommandRequest < Request
524
533
  def build(obj_id, cmd_name, comment = nil)
525
- xml.where_key_tag!('obj', 'id', obj_id)
534
+ xml.where_key_tag!("obj", "id", obj_id)
526
535
  if comment
527
536
  xml.tag!("obj-#{cmd_name}") do
528
- xml.tag!('comment', comment)
537
+ xml.tag!("comment", comment)
529
538
  end
530
539
  else
531
540
  xml.tag!("obj-#{cmd_name}")
@@ -535,8 +544,8 @@ module Reactor
535
544
 
536
545
  class ObjSetRequest < Request
537
546
  def build(obj_id, obj_attrs)
538
- xml.where_key_tag!('obj', 'id', obj_id)
539
- xml.set_tag!('obj') do
547
+ xml.where_key_tag!("obj", "id", obj_id)
548
+ xml.set_tag!("obj") do
540
549
  obj_attrs.each do |key, value|
541
550
  xml.value_tag!(key, value)
542
551
  end
@@ -546,9 +555,9 @@ module Reactor
546
555
 
547
556
  class ContentSetRequest < Request
548
557
  def build(id, attrs, attr_options)
549
- xml.tag!('content-where') do
550
- xml.tag!('objectId', id.to_s)
551
- xml.tag!('state', 'edited')
558
+ xml.tag!("content-where") do
559
+ xml.tag!("objectId", id.to_s)
560
+ xml.tag!("state", "edited")
552
561
  end
553
562
  xml.tag!("content-set") do
554
563
  attrs.each do |key, value|
@@ -566,7 +575,7 @@ module Reactor
566
575
 
567
576
  class LinkDeleteRequest < Request
568
577
  def build(link_id)
569
- xml.where_key_tag!('link', 'id', link_id)
578
+ xml.where_key_tag!("link", "id", link_id)
570
579
  xml.tag!("link-delete")
571
580
  end
572
581
  end
@@ -575,15 +584,15 @@ module Reactor
575
584
  def build(obj_id, attr, link_data)
576
585
  title = link_data[:title]
577
586
  target = link_data[:target]
578
- xml.tag!('content-where') do
579
- xml.tag!('objectId', obj_id.to_s)
580
- xml.tag!('state', 'edited')
587
+ xml.tag!("content-where") do
588
+ xml.tag!("objectId", obj_id.to_s)
589
+ xml.tag!("state", "edited")
581
590
  end
582
- xml.tag!('content-addLinkTo') do
583
- xml.tag!('attribute', attr.to_s)
584
- xml.tag!('destinationUrl', link_data[:destination_url].to_s)
585
- xml.tag!('title', title.to_s) if title
586
- xml.tag!('target', target.to_s) if target
591
+ xml.tag!("content-addLinkTo") do
592
+ xml.tag!("attribute", attr.to_s)
593
+ xml.tag!("destinationUrl", link_data[:destination_url].to_s)
594
+ xml.tag!("title", title.to_s) if title
595
+ xml.tag!("target", target.to_s) if target
587
596
  end
588
597
  end
589
598
  end
@@ -592,24 +601,24 @@ module Reactor
592
601
  def build(link_id, link_data)
593
602
  title = link_data[:title]
594
603
  target = link_data[:target]
595
- xml.tag!('link-where') do
596
- xml.tag!('id', link_id)
604
+ xml.tag!("link-where") do
605
+ xml.tag!("id", link_id)
597
606
  end
598
- xml.tag!('link-set') do
599
- xml.tag!('destinationUrl', link_data[:destination_url].to_s)
600
- xml.tag!('title', title.to_s)
601
- xml.tag!('target', target.to_s)
607
+ xml.tag!("link-set") do
608
+ xml.tag!("destinationUrl", link_data[:destination_url].to_s)
609
+ xml.tag!("title", title.to_s)
610
+ xml.tag!("target", target.to_s)
602
611
  end
603
612
  end
604
613
  end
605
614
 
606
615
  class ResolveRefsRequest < Request
607
616
  def build(obj_id)
608
- xml.tag!('content-where') do
609
- xml.tag!('objectId', obj_id.to_s)
610
- xml.tag!('state', 'edited')
617
+ xml.tag!("content-where") do
618
+ xml.tag!("objectId", obj_id.to_s)
619
+ xml.tag!("state", "edited")
611
620
  end
612
- xml.tag!('content-resolveRefs')
621
+ xml.tag!("content-resolveRefs")
613
622
  end
614
623
  end
615
624
  end