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/obj.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
|
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
|
-
|
9
|
-
|
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
|
-
|
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(
|
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.
|
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=>{:
|
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,
|
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,
|
87
|
+
xml.where_key_tag!(base_name, "id", @obj_id)
|
87
88
|
xml.get_tag!(base_name) do
|
88
|
-
xml.tag!(
|
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
|
-
:
|
101
|
-
:
|
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
|
-
|
112
|
+
permission_command("GrantTo", permission, groups)
|
112
113
|
end
|
113
114
|
|
114
115
|
def permission_revoke(permission, groups)
|
115
|
-
|
116
|
+
permission_command("RevokeFrom", permission, groups)
|
116
117
|
end
|
117
118
|
|
118
119
|
def permission_clear(permission)
|
119
|
-
|
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,94 +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,
|
205
|
-
reqs.optional {|xml| SimpleCommandRequest.build(xml, @obj_id,
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
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
|
-
|
218
|
-
|
219
|
-
|
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
|
-
|
222
|
-
|
223
|
-
|
226
|
+
links_to_remove.each do |link_id|
|
227
|
+
reqs.mandatory { |xml| LinkDeleteRequest.build(xml, link_id) }
|
228
|
+
end
|
224
229
|
|
225
|
-
|
226
|
-
|
227
|
-
|
230
|
+
links_to_set.each do |(link_id, link)|
|
231
|
+
reqs.mandatory { |xml| LinkSetRequest.build(xml, link_id, link) }
|
232
|
+
end
|
228
233
|
|
229
|
-
|
230
|
-
|
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
|
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, {:
|
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
|
|
247
|
-
|
248
|
-
|
249
|
-
simple_command("release",msg)
|
253
|
+
def release!(msg = nil)
|
254
|
+
simple_command("release", msg)
|
250
255
|
end
|
251
256
|
|
252
|
-
def unrelease!(msg=nil)
|
253
|
-
simple_command("unrelease",msg)
|
257
|
+
def unrelease!(msg = nil)
|
258
|
+
simple_command("unrelease", msg)
|
254
259
|
end
|
255
260
|
|
256
|
-
def edit!(msg=nil)
|
257
|
-
simple_command("edit",msg)
|
261
|
+
def edit!(msg = nil)
|
262
|
+
simple_command("edit", msg)
|
258
263
|
end
|
259
264
|
|
260
|
-
def take!(msg=nil)
|
261
|
-
simple_command("take",msg)
|
265
|
+
def take!(msg = nil)
|
266
|
+
simple_command("take", msg)
|
262
267
|
end
|
263
268
|
|
264
|
-
def forward!(msg=nil)
|
265
|
-
simple_command("forward",msg)
|
269
|
+
def forward!(msg = nil)
|
270
|
+
simple_command("forward", msg)
|
266
271
|
end
|
267
272
|
|
268
|
-
def commit!(msg=nil)
|
269
|
-
simple_command("commit",msg)
|
273
|
+
def commit!(msg = nil)
|
274
|
+
simple_command("commit", msg)
|
270
275
|
end
|
271
276
|
|
272
|
-
def reject!(msg=nil)
|
273
|
-
simple_command("reject",msg)
|
277
|
+
def reject!(msg = nil)
|
278
|
+
simple_command("reject", msg)
|
274
279
|
end
|
275
280
|
|
276
|
-
def revert!(msg=nil)
|
277
|
-
simple_command("revert",msg)
|
281
|
+
def revert!(msg = nil)
|
282
|
+
simple_command("revert", msg)
|
278
283
|
end
|
279
284
|
|
280
|
-
def sign!(msg=nil)
|
281
|
-
simple_command("sign",msg)
|
285
|
+
def sign!(msg = nil)
|
286
|
+
simple_command("sign", msg)
|
282
287
|
end
|
283
288
|
|
284
289
|
def valid_actions
|
285
|
-
vcak = get(
|
290
|
+
vcak = get("validControlActionKeys")
|
286
291
|
(vcak || []).map(&:to_s)
|
287
292
|
end
|
288
293
|
|
289
294
|
def copy(new_parent, recursive = false, new_name = nil)
|
290
295
|
request = XmlRequest.prepare do |xml|
|
291
|
-
xml.tag!(
|
296
|
+
xml.tag!("obj-where") do
|
292
297
|
xml.tag!("id", @obj_id)
|
293
298
|
end
|
294
299
|
xml.tag!("obj-copy") do
|
@@ -315,19 +320,19 @@ module Reactor
|
|
315
320
|
|
316
321
|
def resolve_refs!
|
317
322
|
request = XmlRequest.prepare do |xml|
|
318
|
-
xml.tag!(
|
319
|
-
xml.tag!(
|
320
|
-
xml.tag!(
|
323
|
+
xml.tag!("content-where") do
|
324
|
+
xml.tag!("objectId", @obj_id)
|
325
|
+
xml.tag!("state", "edited")
|
321
326
|
end
|
322
|
-
xml.tag!(
|
327
|
+
xml.tag!("content-resolveRefs")
|
323
328
|
end
|
324
329
|
request.execute!
|
325
330
|
end
|
326
331
|
|
327
332
|
def path
|
328
333
|
request = XmlRequest.prepare do |xml|
|
329
|
-
xml.where_key_tag!(base_name,
|
330
|
-
xml.get_key_tag!(base_name,
|
334
|
+
xml.where_key_tag!(base_name, "id", @obj_id)
|
335
|
+
xml.get_key_tag!(base_name, "path")
|
331
336
|
end
|
332
337
|
response = request.execute!
|
333
338
|
response.xpath("//obj/path").text
|
@@ -335,8 +340,8 @@ module Reactor
|
|
335
340
|
|
336
341
|
def edited?
|
337
342
|
request = XmlRequest.prepare do |xml|
|
338
|
-
xml.where_key_tag!(base_name,
|
339
|
-
xml.get_key_tag!(base_name,
|
343
|
+
xml.where_key_tag!(base_name, "id", @obj_id)
|
344
|
+
xml.get_key_tag!(base_name, "isEdited")
|
340
345
|
end
|
341
346
|
response = request.execute!
|
342
347
|
response.xpath("//isEdited").text == "1"
|
@@ -344,96 +349,96 @@ module Reactor
|
|
344
349
|
|
345
350
|
def reasons_for_incomplete_state
|
346
351
|
request = XmlRequest.prepare do |xml|
|
347
|
-
xml.tag!(
|
348
|
-
xml.tag!(
|
349
|
-
xml.tag!(
|
352
|
+
xml.tag!("content-where") do
|
353
|
+
xml.tag!("objectId", @obj_id)
|
354
|
+
xml.tag!("state", "edited")
|
350
355
|
end
|
351
|
-
xml.get_key_tag!(
|
356
|
+
xml.get_key_tag!("content", "reasonsForIncompleteState")
|
352
357
|
end
|
353
358
|
response = request.execute!
|
354
|
-
result = response.xpath(
|
355
|
-
result.
|
359
|
+
result = response.xpath("//reasonsForIncompleteState/*")
|
360
|
+
result.is_a?(Array) ? result.map(&:text).map(&:to_s) : [result.to_s]
|
356
361
|
end
|
357
362
|
|
358
363
|
def workflow_comment
|
359
364
|
request = XmlRequest.prepare do |xml|
|
360
|
-
xml.tag!(
|
361
|
-
xml.tag!(
|
362
|
-
xml.tag!(
|
365
|
+
xml.tag!("content-where") do
|
366
|
+
xml.tag!("objectId", @obj_id)
|
367
|
+
xml.tag!("state", "released")
|
363
368
|
end
|
364
|
-
xml.get_key_tag!(
|
369
|
+
xml.get_key_tag!("content", "workflowComment")
|
365
370
|
end
|
366
371
|
response = request.execute!
|
367
|
-
response.xpath(
|
372
|
+
response.xpath("//workflowComment/*").map { |x| x.text.to_s }.first
|
368
373
|
end
|
369
374
|
|
370
375
|
def editor
|
371
376
|
request = XmlRequest.prepare do |xml|
|
372
|
-
xml.tag!(
|
373
|
-
xml.tag!(
|
374
|
-
xml.tag!(
|
377
|
+
xml.tag!("content-where") do
|
378
|
+
xml.tag!("objectId", @obj_id)
|
379
|
+
xml.tag!("state", "edited")
|
375
380
|
end
|
376
|
-
xml.get_key_tag!(
|
381
|
+
xml.get_key_tag!("content", "editor")
|
377
382
|
end
|
378
383
|
response = request.execute!
|
379
|
-
response.xpath(
|
384
|
+
response.xpath("//editor").text
|
380
385
|
end
|
381
386
|
|
382
|
-
def blob_ticket_id(content=
|
387
|
+
def blob_ticket_id(content = "edited")
|
383
388
|
request = XmlRequest.prepare do |xml|
|
384
|
-
xml.tag!(
|
385
|
-
xml.tag!(
|
386
|
-
xml.tag!(
|
389
|
+
xml.tag!("content-where") do
|
390
|
+
xml.tag!("objectId", @obj_id)
|
391
|
+
xml.tag!("state", content)
|
387
392
|
end
|
388
|
-
xml.tag!(
|
389
|
-
xml.tag!(
|
393
|
+
xml.tag!("content-get") do
|
394
|
+
xml.tag!("blob")
|
390
395
|
end
|
391
396
|
end
|
392
397
|
response = request.execute!
|
393
|
-
possible_ticket_id = response.xpath(
|
394
|
-
encoding = response.xpath(
|
398
|
+
possible_ticket_id = response.xpath("//blob").text
|
399
|
+
encoding = response.xpath("//blob/@encoding").to_s
|
395
400
|
# blob is smaller than
|
396
401
|
# [systemConfig getKeys tuning.minStreamingDataLength]
|
397
402
|
# and thus it is returned in-line
|
398
|
-
if encoding !=
|
399
|
-
|
400
|
-
end
|
403
|
+
raise Reactor::Cm::BlobTooSmallError if encoding != "stream"
|
404
|
+
|
401
405
|
possible_ticket_id
|
402
406
|
end
|
403
407
|
|
404
408
|
def edited_content
|
405
409
|
request = XmlRequest.prepare do |xml|
|
406
|
-
xml.where_key_tag!(base_name,
|
407
|
-
xml.get_key_tag!(base_name,
|
410
|
+
xml.where_key_tag!(base_name, "id", @obj_id)
|
411
|
+
xml.get_key_tag!(base_name, "editedContent")
|
408
412
|
end
|
409
413
|
response = request.execute!
|
410
414
|
response.xpath("//editedContent").text
|
411
415
|
end
|
412
416
|
|
413
417
|
protected
|
414
|
-
|
415
|
-
|
416
|
-
|
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)
|
417
422
|
if comment
|
418
423
|
xml.tag!("#{base_name}-#{cmd_name}") do
|
419
|
-
xml.tag!(
|
424
|
+
xml.tag!("comment", comment)
|
420
425
|
end
|
421
426
|
else
|
422
427
|
xml.tag!("#{base_name}-#{cmd_name}")
|
423
428
|
end
|
424
429
|
end
|
425
|
-
|
430
|
+
request.execute!
|
426
431
|
end
|
427
432
|
|
428
433
|
def base_name
|
429
|
-
|
434
|
+
"obj"
|
430
435
|
end
|
431
436
|
|
432
437
|
def get_content_attr_text(attr)
|
433
438
|
content = edited_content
|
434
439
|
request = XmlRequest.prepare do |xml|
|
435
|
-
xml.where_key_tag!(
|
436
|
-
xml.get_tag!(
|
440
|
+
xml.where_key_tag!("content", "id", content)
|
441
|
+
xml.get_tag!("content") do
|
437
442
|
xml.tag!(attr.to_s)
|
438
443
|
end
|
439
444
|
end
|
@@ -445,12 +450,12 @@ module Reactor
|
|
445
450
|
def get_link_ids(attr)
|
446
451
|
content = edited_content
|
447
452
|
request = XmlRequest.prepare do |xml|
|
448
|
-
xml.where_key_tag!(
|
449
|
-
xml.get_key_tag!(
|
453
|
+
xml.where_key_tag!("content", "id", content)
|
454
|
+
xml.get_key_tag!("content", attr.to_s)
|
450
455
|
end
|
451
456
|
response = request.execute!
|
452
457
|
result = response.xpath("//listitem/text()")
|
453
|
-
result.
|
458
|
+
result.is_a?(Array) ? result : [result]
|
454
459
|
rescue XmlRequestError
|
455
460
|
[]
|
456
461
|
end
|
@@ -459,7 +464,7 @@ module Reactor
|
|
459
464
|
response.xpath("//obj/id").text
|
460
465
|
end
|
461
466
|
|
462
|
-
def initialize(name=nil)
|
467
|
+
def initialize(name = nil)
|
463
468
|
@name = name
|
464
469
|
@attrs = {}
|
465
470
|
@obj_attrs = {}
|
@@ -469,40 +474,40 @@ module Reactor
|
|
469
474
|
end
|
470
475
|
|
471
476
|
def create(parent, objClass)
|
472
|
-
|
473
|
-
xml.where_key_tag!(base_name,
|
477
|
+
request = XmlRequest.prepare do |xml|
|
478
|
+
xml.where_key_tag!(base_name, "path", parent)
|
474
479
|
xml.create_tag!(base_name) do
|
475
|
-
xml.tag!(
|
480
|
+
xml.tag!("objClass") do
|
476
481
|
xml.text!(objClass)
|
477
482
|
end
|
478
|
-
xml.tag!(
|
483
|
+
xml.tag!("name") do
|
479
484
|
xml.text!(@name)
|
480
485
|
end
|
481
486
|
end
|
482
487
|
end
|
483
|
-
response =
|
488
|
+
response = request.execute!
|
484
489
|
@obj_id = self.class.extract_id(response)
|
485
490
|
response
|
486
491
|
end
|
487
492
|
|
488
493
|
def load(path_or_id)
|
489
|
-
key = (
|
494
|
+
key = %r{^/}.match?(path_or_id.to_s) ? "path" : "id"
|
490
495
|
value = path_or_id
|
491
496
|
|
492
|
-
|
497
|
+
request = XmlRequest.prepare do |xml|
|
493
498
|
xml.where_key_tag!(base_name, key.to_s, value.to_s)
|
494
|
-
xml.get_key_tag!(base_name,
|
499
|
+
xml.get_key_tag!(base_name, "id")
|
495
500
|
end
|
496
|
-
response =
|
501
|
+
response = request.execute!
|
497
502
|
@obj_id = self.class.extract_id(response)
|
498
503
|
response
|
499
504
|
end
|
500
505
|
|
501
506
|
def permission_command(type, permission, groups)
|
502
507
|
request = XmlRequest.prepare do |xml|
|
503
|
-
xml.where_key_tag!(base_name,
|
508
|
+
xml.where_key_tag!(base_name, "id", @obj_id)
|
504
509
|
|
505
|
-
xml.tag!("#{base_name}-permission#{type}", :
|
510
|
+
xml.tag!("#{base_name}-permission#{type}", permission: permission) do
|
506
511
|
groups.each do |name|
|
507
512
|
xml.tag!(:group, name)
|
508
513
|
end
|
@@ -520,16 +525,16 @@ module Reactor
|
|
520
525
|
end
|
521
526
|
|
522
527
|
def self.build(xml, *args)
|
523
|
-
|
528
|
+
new(xml).build(*args)
|
524
529
|
end
|
525
530
|
end
|
526
531
|
|
527
532
|
class SimpleCommandRequest < Request
|
528
533
|
def build(obj_id, cmd_name, comment = nil)
|
529
|
-
xml.where_key_tag!(
|
534
|
+
xml.where_key_tag!("obj", "id", obj_id)
|
530
535
|
if comment
|
531
536
|
xml.tag!("obj-#{cmd_name}") do
|
532
|
-
xml.tag!(
|
537
|
+
xml.tag!("comment", comment)
|
533
538
|
end
|
534
539
|
else
|
535
540
|
xml.tag!("obj-#{cmd_name}")
|
@@ -539,8 +544,8 @@ module Reactor
|
|
539
544
|
|
540
545
|
class ObjSetRequest < Request
|
541
546
|
def build(obj_id, obj_attrs)
|
542
|
-
xml.where_key_tag!(
|
543
|
-
xml.set_tag!(
|
547
|
+
xml.where_key_tag!("obj", "id", obj_id)
|
548
|
+
xml.set_tag!("obj") do
|
544
549
|
obj_attrs.each do |key, value|
|
545
550
|
xml.value_tag!(key, value)
|
546
551
|
end
|
@@ -550,9 +555,9 @@ module Reactor
|
|
550
555
|
|
551
556
|
class ContentSetRequest < Request
|
552
557
|
def build(id, attrs, attr_options)
|
553
|
-
xml.tag!(
|
554
|
-
xml.tag!(
|
555
|
-
xml.tag!(
|
558
|
+
xml.tag!("content-where") do
|
559
|
+
xml.tag!("objectId", id.to_s)
|
560
|
+
xml.tag!("state", "edited")
|
556
561
|
end
|
557
562
|
xml.tag!("content-set") do
|
558
563
|
attrs.each do |key, value|
|
@@ -570,7 +575,7 @@ module Reactor
|
|
570
575
|
|
571
576
|
class LinkDeleteRequest < Request
|
572
577
|
def build(link_id)
|
573
|
-
xml.where_key_tag!(
|
578
|
+
xml.where_key_tag!("link", "id", link_id)
|
574
579
|
xml.tag!("link-delete")
|
575
580
|
end
|
576
581
|
end
|
@@ -579,15 +584,15 @@ module Reactor
|
|
579
584
|
def build(obj_id, attr, link_data)
|
580
585
|
title = link_data[:title]
|
581
586
|
target = link_data[:target]
|
582
|
-
xml.tag!(
|
583
|
-
xml.tag!(
|
584
|
-
xml.tag!(
|
587
|
+
xml.tag!("content-where") do
|
588
|
+
xml.tag!("objectId", obj_id.to_s)
|
589
|
+
xml.tag!("state", "edited")
|
585
590
|
end
|
586
|
-
xml.tag!(
|
587
|
-
xml.tag!(
|
588
|
-
xml.tag!(
|
589
|
-
xml.tag!(
|
590
|
-
xml.tag!(
|
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
|
591
596
|
end
|
592
597
|
end
|
593
598
|
end
|
@@ -596,24 +601,24 @@ module Reactor
|
|
596
601
|
def build(link_id, link_data)
|
597
602
|
title = link_data[:title]
|
598
603
|
target = link_data[:target]
|
599
|
-
xml.tag!(
|
600
|
-
xml.tag!(
|
604
|
+
xml.tag!("link-where") do
|
605
|
+
xml.tag!("id", link_id)
|
601
606
|
end
|
602
|
-
xml.tag!(
|
603
|
-
xml.tag!(
|
604
|
-
xml.tag!(
|
605
|
-
xml.tag!(
|
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)
|
606
611
|
end
|
607
612
|
end
|
608
613
|
end
|
609
614
|
|
610
615
|
class ResolveRefsRequest < Request
|
611
616
|
def build(obj_id)
|
612
|
-
xml.tag!(
|
613
|
-
xml.tag!(
|
614
|
-
xml.tag!(
|
617
|
+
xml.tag!("content-where") do
|
618
|
+
xml.tag!("objectId", obj_id.to_s)
|
619
|
+
xml.tag!("state", "edited")
|
615
620
|
end
|
616
|
-
xml.tag!(
|
621
|
+
xml.tag!("content-resolveRefs")
|
617
622
|
end
|
618
623
|
end
|
619
624
|
end
|