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.
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 +92 -268
  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 +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 +159 -154
  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 +6 -7
  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 +16 -17
  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 +104 -178
  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 +64 -28
  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,149 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- module RailsConnector
3
-
4
- module Meta
5
-
6
- # This method is an equivalent of Rails.logger.silence, which has been deprecated
7
- def self.hello_im_rails_and_im_retarted_so_please_be_patient(&block)
8
- begin
9
- old_logger_level, Rails.logger.level = Rails.logger.level, Logger::ERROR
10
- yield self
11
- ensure
12
- Rails.logger.level = old_logger_level
13
- end
14
- end
15
-
16
- def self.included(base) #:nodoc:
17
- # Class enhancements
18
- base.extend(ClassMethods)
19
- end
20
-
21
- # The RailsConnector::ObjClass object for this file format.
22
- # This will always return a proper object, even if no custom
23
- # Ruby class exists.
24
- def obj_class_definition
25
- @obj_class_definition ||= RailsConnector::Meta::EagerLoader.instance.obj_class(self.obj_class)
26
- end
27
- alias_method :obj_class_def, :obj_class_definition
28
-
29
- # Returns true, if there is a custom Ruby class defined for the object
30
- # or false, if it is represented by RailsConnector::Obj
31
- def has_custom_ruby_class?
32
- self.class.is_custom_ruby_class?
33
- end
34
-
35
- # Returns the custom attributes in the form of a Hash.
36
- def custom_attributes
37
- self.obj_class_definition.custom_attributes
38
- end
39
-
40
- # Returns true, if the file format has an attribute of the given name.
41
- def custom_attribute?(attr)
42
- self.obj_class_definition.custom_attribute?(attr)
43
- end
44
-
45
- # Returns an Array of String of all mandatory attributes, no mather if it's
46
- # custom or built-in. Built-in attributes are underscored (valid_from,
47
- # not validFrom).
48
- # Possible +options+ are:
49
- # <tt>:only_custom_attributes</tt>:: Return only custom attributes, omit
50
- # built-in attributes like content_type or valid_from.
51
- def mandatory_attribute_names(options = {})
52
- self.obj_class_definition.mandatory_attribute_names(options)
53
- end
54
-
55
- # Returns true, if the file format has an mandatory attribute of the given name.
56
- def mandatory_attribute?(attr)
57
- self.obj_class_definition.mandatory_attribute?(attr)
58
- end
59
-
60
- # Returns the version of this object. This number is increased every time
61
- # this object is released.
62
- def version
63
- load_meta_details
64
- @object_with_meta_data.version.presence.to_i || 0
65
- end
66
-
67
- # Returns the time of the reminder, if it is set.
68
- def reminder_from
69
- load_meta_details
70
- @object_with_meta_data.reminder_from.presence &&
71
- ::RailsConnector::DateAttribute.parse(@object_with_meta_data.reminder_from)
72
- end
73
-
74
- # Returns the reminder comment, if a reminder is set.
75
- def reminder_comment
76
- load_meta_details
77
- @object_with_meta_data.reminder_comment
78
- end
79
-
80
- # Return the name of the workflow, that is assigned to this object.
81
- def workflow_name
82
- load_meta_details
83
- @object_with_meta_data.workflow_name
84
- end
85
-
86
- # Return the current editor as a String. If there is no edited content,
87
- # which is always the case in live mode, an empty String is returned.
88
- # The 'contents' table is queried for this information.
89
- def editor
90
- return @editor if @editor
91
-
92
- load_meta_details
93
-
94
- content_id = if self.edited?
95
- @object_with_meta_data.edited_content_id
96
- else
97
- @object_with_meta_data.released_cont_id
98
- end
99
-
100
- if content_id
101
- content = RailsConnector::Content.find(content_id)
102
- @editor = content.editor
103
- else
104
- @editor = ''
105
- end
106
- end
107
-
108
- def committed?
109
- load_meta_details
110
- !@object_with_meta_data.committed_cont_id.nil?
111
- end
112
-
113
- private
114
-
115
- # Load the objects details from the `objects' tables.
116
- def load_meta_details #:nodoc:
117
- return if @object_with_meta_data
118
-
119
- @object_with_meta_data = RailsConnector::ObjectWithMetaData.find(self.id)
120
-
121
- # reset depending instance variables
122
- @editor = nil
123
- end
124
-
125
-
126
- # the methods in this module will become class methods
127
- module ClassMethods
128
-
129
- # The RailsConnector::ObjClass object for this file format.
130
- # This will only return a proper object if a custom Ruby class exists
131
- # and will throw a RuntimeError otherwise.
132
- def obj_class_definition
133
- raise "Obtaining the obj_class_definition of an Obj without custom Ruby class " \
134
- "is logically impossible." unless is_custom_ruby_class?
135
- # @obj_class_definition ||= RailsConnector::ObjClass.find_by_name(self.name)
136
- @obj_class_definition ||= RailsConnector::Meta::EagerLoader.instance.obj_class(self.name)
137
- end
138
- alias_method :obj_class_def, :obj_class_definition
139
-
140
- # RailsConnector::AbstractObj returns false, everything else true.
141
- def is_custom_ruby_class?
142
- self != RailsConnector::AbstractObj
143
- end
144
-
145
- end
146
-
147
- end
148
-
149
- end
@@ -1,72 +0,0 @@
1
- module Reactor
2
- module SessionHelper
3
- module AuthHelper
4
- def rsession_auth
5
- if RailsConnector::Configuration.mode == :editor && (jsessionid = cookies['JSESSIONID']).present?
6
- # Why the gsub? It's a dirty hack! Reason: JSESSIONIDs are unescaped
7
- # when read through Rails and hence all + are converted into spaces.
8
- # CM Kernel though stores escaped IDs.
9
- # From the possible generated characters only the + seems to be
10
- # problematic.
11
- # CGI.escape would be the solution, but it's deprecated
12
- # URI.escape does too much
13
- jsessionid.gsub!(' ','+')
14
-
15
- Rails.logger.info "Trying to log in at #{Reactor::Configuration.xml_access[:host]}:#{Reactor::Configuration.xml_access[:port]} with JSESSIONID=#{jsessionid}."
16
- rsession.login(jsessionid)
17
- if rsession.user?
18
- Rails.logger.info %|Logged in as "#{rsession.user_name}".|
19
- end
20
- else
21
- rsession.destroy
22
- end
23
- end
24
-
25
- def self.included(base)
26
- base.__send__(:before_filter, :rsession_auth)
27
- end
28
- end
29
-
30
- module RsessionHelper
31
- def rsession
32
- @__rsession ||= RsessionHelper.from_session(self.session)
33
- end
34
-
35
- def self.from_session(session)
36
- Reactor::Session.new(
37
- # This passes the very powerfull rails session object
38
- SessionState.new(session)
39
- )
40
- end
41
- end
42
-
43
- class SessionState < Reactor::Session::State
44
- USER_NAME_KEY = "rsession$user_name"
45
- SESSION_ID_KEY = "rsession$session_id"
46
-
47
- def initialize(session)
48
- self.session = session
49
- super(session[USER_NAME_KEY], session[SESSION_ID_KEY])
50
- end
51
-
52
- def user_name=(new_user_name)
53
- super
54
- # this is a little bit of magic: it will trigger
55
- # the the session serialization routine, and will
56
- # persist the new information after processing the request
57
- self.session[USER_NAME_KEY] = new_user_name
58
- new_user_name
59
- end
60
-
61
- def session_id=(new_session_id)
62
- super
63
- # see above
64
- self.session[SESSION_ID_KEY] = new_session_id
65
- new_session_id
66
- end
67
-
68
- protected
69
- attr_accessor :session
70
- end
71
- end
72
- end