infopark_fiona_connector 7.0.1.5.2.3.rc4 → 7.0.1.5.2.3.rc5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/cms_controller.rb +1 -1
  3. data/app/controllers/rails_connector/default_cms_controller.rb +0 -2
  4. data/app/helpers/cms_helper.rb +1 -1
  5. data/app/helpers/cms_routing_helper.rb +1 -1
  6. data/app/helpers/rails_connector/cms_asset_helper.rb +4 -5
  7. data/app/helpers/rails_connector/cms_tag_helper.rb +0 -3
  8. data/app/helpers/rails_connector/default_cms_helper.rb +0 -2
  9. data/app/helpers/rails_connector/default_cms_routing_helper.rb +15 -16
  10. data/app/helpers/rails_connector/display_helper.rb +31 -33
  11. data/app/helpers/rails_connector/editing_helper.rb +2 -8
  12. data/app/helpers/rails_connector/layout_helper.rb +2 -5
  13. data/app/helpers/rails_connector/marker_helper.rb +63 -64
  14. data/app/helpers/rails_connector/table_of_contents_helper.rb +1 -3
  15. data/config/cms_routes.rb +15 -15
  16. data/lib/gem_dependencies.rb +8 -7
  17. data/lib/generators/rails_connector/install/install_generator.rb +6 -6
  18. data/lib/generators/rails_connector/install/templates/initializers/rails_connector.rb +1 -1
  19. data/lib/infopark_fiona_connector.rb +9 -9
  20. data/lib/rails_connector/attr_dict.rb +26 -18
  21. data/lib/rails_connector/attribute.rb +18 -21
  22. data/lib/rails_connector/authenticable.rb +12 -5
  23. data/lib/rails_connector/basic_obj.rb +64 -57
  24. data/lib/rails_connector/blob.rb +2 -5
  25. data/lib/rails_connector/blob_mapping.rb +2 -3
  26. data/lib/rails_connector/blob_mysql.rb +3 -5
  27. data/lib/rails_connector/blob_oracle.rb +5 -7
  28. data/lib/rails_connector/channel.rb +5 -6
  29. data/lib/rails_connector/cms_accessible.rb +16 -17
  30. data/lib/rails_connector/cms_base_model.rb +2 -4
  31. data/lib/rails_connector/cms_dispatch_controller.rb +3 -6
  32. data/lib/rails_connector/cms_env.rb +4 -7
  33. data/lib/rails_connector/cms_test_request.rb +1 -1
  34. data/lib/rails_connector/configuration.rb +12 -16
  35. data/lib/rails_connector/content.rb +0 -4
  36. data/lib/rails_connector/core_extensions/time.rb +3 -4
  37. data/lib/rails_connector/date_attribute.rb +1 -3
  38. data/lib/rails_connector/default_search_request.rb +1 -1
  39. data/lib/rails_connector/engine.rb +18 -21
  40. data/lib/rails_connector/errors.rb +2 -5
  41. data/lib/rails_connector/fiona_datetime.rb +2 -2
  42. data/lib/rails_connector/fiona_engine.rb +3 -4
  43. data/lib/rails_connector/html_string.rb +0 -2
  44. data/lib/rails_connector/job.rb +0 -3
  45. data/lib/rails_connector/link.rb +7 -4
  46. data/lib/rails_connector/link_list.rb +1 -5
  47. data/lib/rails_connector/link_resolvable.rb +1 -5
  48. data/lib/rails_connector/lucene_search_request.rb +20 -24
  49. data/lib/rails_connector/markdown_string.rb +0 -2
  50. data/lib/rails_connector/meta.rb +25 -30
  51. data/lib/rails_connector/meta/eager_loader.rb +14 -12
  52. data/lib/rails_connector/named_link.rb +12 -16
  53. data/lib/rails_connector/news.rb +3 -3
  54. data/lib/rails_connector/obj_class.rb +23 -25
  55. data/lib/rails_connector/obj_class_attr.rb +1 -1
  56. data/lib/rails_connector/object_with_meta_data.rb +0 -5
  57. data/lib/rails_connector/permission.rb +2 -6
  58. data/lib/rails_connector/ses.rb +3 -8
  59. data/lib/rails_connector/ses/verity_accessor.rb +43 -46
  60. data/lib/rails_connector/string_tagging.rb +0 -3
  61. data/lib/rails_connector/verity_search_request.rb +6 -9
  62. data/lib/search_request.rb +1 -1
  63. data/lib/version.rb +1 -1
  64. metadata +2 -2
@@ -1,6 +1,5 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'singleton'
3
- require 'set'
1
+ require "singleton"
2
+ require "set"
4
3
 
5
4
  module RailsConnector
6
5
  module Meta
@@ -32,6 +31,7 @@ module RailsConnector
32
31
  end
33
32
 
34
33
  protected
34
+
35
35
  def preload_attribute_blobs
36
36
  attribute_names = Set.new
37
37
  @obj_classes.each do |_, obj_class|
@@ -40,15 +40,15 @@ module RailsConnector
40
40
  end
41
41
  end
42
42
 
43
- blob_names = attribute_names.map {|attribute_name| "#{attribute_name}.jsonAttributeDict" }
43
+ blob_names = attribute_names.map { |attribute_name| "#{attribute_name}.jsonAttributeDict" }
44
44
  # Fiona >= 6.8
45
45
  if RailsConnector::BlobMapping.exists?
46
- blob_names = attribute_names.map {|attribute_name| "#{attribute_name}.jsonAttributeDict" }
46
+ blob_names = attribute_names.map { |attribute_name| "#{attribute_name}.jsonAttributeDict" }
47
47
  fingerprint_map = RailsConnector::BlobMapping.get_fingerprint_map(blob_names)
48
48
  blob_fingerprints = fingerprint_map.values
49
49
  # NOTE: this is correct!
50
- blobs = RailsConnector::Blob.where(:blob_name => blob_fingerprints).to_a
51
- blob_map = Hash[blobs.map {|b| [b.blob_name, b]}]
50
+ blobs = RailsConnector::Blob.where(blob_name: blob_fingerprints).to_a
51
+ blob_map = Hash[blobs.map { |b| [b.blob_name, b] }]
52
52
 
53
53
  @obj_classes.each do |_, obj_class|
54
54
  obj_class.custom_attributes.each do |_, attribute|
@@ -56,22 +56,24 @@ module RailsConnector
56
56
  fingerprint = fingerprint_map[blob_name]
57
57
  blob = blob_map[fingerprint]
58
58
 
59
- next unless blob && blob.blob_data?
59
+ next unless blob&.blob_data?
60
+
60
61
  attribute.instance_variable_set(:@blob_data, ::JSON.parse(blob.blob_data))
61
62
  end
62
63
  end
63
64
  # Fiona = 6.7
64
65
  else
65
- blob_names = attribute_names.map {|attribute_name| "#{attribute_name}.jsonAttributeDict" }
66
- blobs = RailsConnector::Blob.where(:blob_name => blob_names).to_a
67
- blob_map = Hash[blobs.map {|b| [b.blob_name, b]}]
66
+ blob_names = attribute_names.map { |attribute_name| "#{attribute_name}.jsonAttributeDict" }
67
+ blobs = RailsConnector::Blob.where(blob_name: blob_names).to_a
68
+ blob_map = Hash[blobs.map { |b| [b.blob_name, b] }]
68
69
 
69
70
  @obj_classes.each do |_, obj_class|
70
71
  obj_class.custom_attributes.each do |_, attribute|
71
72
  blob_name = "#{attribute.name}.jsonAttributeDict"
72
73
  blob = blob_map[blob_name]
73
74
 
74
- next unless blob && blob.blob_data?
75
+ next unless blob&.blob_data?
76
+
75
77
  attribute.instance_variable_set(:@blob_data, ::JSON.parse(blob.blob_data))
76
78
  end
77
79
  end
@@ -1,11 +1,9 @@
1
1
  module RailsConnector
2
-
3
2
  # This class provides methods used to retrieve objects from CMS based an entry
4
3
  # in CMS of the obj_class <tt>NamedLink</tt>.
5
4
  # @api public
6
5
  class NamedLink
7
-
8
- LINKLIST_NAME = 'related_links'
6
+ LINKLIST_NAME = "related_links".freeze
9
7
 
10
8
  # @api public
11
9
  class NotFound < StandardError
@@ -33,21 +31,20 @@ module RailsConnector
33
31
  return nil
34
32
  end
35
33
 
36
- found_objects = BasicObj.where(obj_class: 'NamedLink')
34
+ found_objects = BasicObj.where(obj_class: "NamedLink")
37
35
  Rails.logger.warn "Couldn't find NamedLink CMS Object!" if found_objects.empty?
38
36
  Rails.logger.warn "More than one NamedLink CMS Object found!" if found_objects.size > 1
39
37
 
40
- @@named_links_cache = found_objects.
41
- sort_by(&:valid_from).
42
- reverse.
43
- map(&:related_links).
44
- flatten(1).
45
- each_with_object({}) do |link_obj, temp|
46
- temp[link_obj.title] = link_obj.destination_object
47
- end
38
+ @@named_links_cache = found_objects
39
+ .sort_by(&:valid_from)
40
+ .reverse
41
+ .flat_map(&:related_links)
42
+ .each_with_object({}) do |link_obj, temp|
43
+ temp[link_obj.title] = link_obj.destination_object
44
+ end
48
45
 
49
46
  @@updated_at = Time.now
50
- return nil
47
+ nil
51
48
  end
52
49
 
53
50
  # Sets the time in minutes after which the cache will be expired.
@@ -71,7 +68,8 @@ module RailsConnector
71
68
  # @api public
72
69
  def self.get_object(title, options = {})
73
70
  object = named_links[title.to_s]
74
- raise NotFound, "The NamedLink '#{title.to_s}' does not exist" if object.nil?
71
+ raise NotFound, "The NamedLink '#{title}' does not exist" if object.nil?
72
+
75
73
  options[:cache] == false ? object.reload : object
76
74
  end
77
75
 
@@ -88,7 +86,5 @@ module RailsConnector
88
86
  def self.named_links_cache
89
87
  @@named_links_cache
90
88
  end
91
-
92
89
  end
93
-
94
90
  end
@@ -7,14 +7,14 @@ module RailsConnector
7
7
  class News < CmsBaseModel
8
8
  self.primary_key = "news_id"
9
9
 
10
- belongs_to :object, :class_name => 'Obj', :foreign_key => 'object_id'
10
+ belongs_to :object, class_name: "Obj", foreign_key: "object_id"
11
11
 
12
12
  def self.table_name
13
13
  "#{table_name_prefix}" "news"
14
14
  end
15
15
 
16
- scope :active, -> { where('? BETWEEN valid_from AND valid_until', Time.now.to_s(:number))}
16
+ scope :active, -> { where("? BETWEEN valid_from AND valid_until", Time.now.to_s(:number)) }
17
17
 
18
- scope :for_channel, ->(channel_name) {where(channel_name: channel_name)}
18
+ scope :for_channel, ->(channel_name) { where(channel_name: channel_name) }
19
19
  end
20
20
  end
@@ -1,15 +1,13 @@
1
1
  module RailsConnector
2
-
3
2
  # This class is used to read out the custom attributes,
4
3
  # mandatory attributes and titles of an Obj.
5
4
  # Warning: Dependent on the setup of your DB replication, most tables
6
5
  # with meta information will not be available on your live system!
7
6
  class ObjClass < CmsBaseModel
8
-
9
7
  self.primary_key = :obj_class_id
10
8
 
11
- has_many :custom_attributes_jt, :class_name => '::RailsConnector::ObjClassAttr', :foreign_key => 'obj_class_id', :primary_key => 'obj_class_id'
12
- has_many :custom_attributes_raw, :through => :custom_attributes_jt, :source => :custom_attributes_raw
9
+ has_many :custom_attributes_jt, class_name: "::RailsConnector::ObjClassAttr", foreign_key: "obj_class_id", primary_key: "obj_class_id"
10
+ has_many :custom_attributes_raw, through: :custom_attributes_jt, source: :custom_attributes_raw
13
11
 
14
12
  alias_attribute :name, :obj_class_name
15
13
  alias_attribute :type, :obj_type
@@ -18,10 +16,10 @@ module RailsConnector
18
16
  alias_attribute :enabled, :is_enabled
19
17
 
20
18
  %w(attributeGroupNames attributeGroups canCreateNewsItems completionCheck
21
- contentTypes createPermission workflowModification validSubObjClasses
22
- validSubObjClassCheck
23
- validContentTypes titles recordSetCallback presetFromParentAttributes
24
- presetAttributes).each do |key|
19
+ contentTypes createPermission workflowModification validSubObjClasses
20
+ validSubObjClassCheck
21
+ validContentTypes titles recordSetCallback presetFromParentAttributes
22
+ presetAttributes).each do |key|
25
23
  define_method(key.underscore) do
26
24
  load_blob_data
27
25
  @blob_data[key]
@@ -50,14 +48,14 @@ module RailsConnector
50
48
  # Returns the custom attributes in the form of a Hash.
51
49
  def custom_attributes
52
50
  # create a Hash (with indifferent access) out of an Array of ActiveRecord objects
53
- @custom_attributes ||= self.custom_attributes_raw.map do |attr|
54
- {attr.attribute_name => attr}
51
+ @custom_attributes ||= custom_attributes_raw.map do |attr|
52
+ { attr.attribute_name => attr }
55
53
  end.reduce(HashWithIndifferentAccess.new, &:merge)
56
54
  end
57
55
 
58
56
  # Returns true, if the Obj Class has an attribute of the given name.
59
57
  def custom_attribute?(attr)
60
- self.custom_attributes.key?(attr.to_s)
58
+ custom_attributes.key?(attr.to_s)
61
59
  end
62
60
 
63
61
  # Returns an Array of String of all mandatory attributes found for this ObjClass,
@@ -70,17 +68,18 @@ module RailsConnector
70
68
  only_custom_attributes ||= options[:only_custom_attributes] || false
71
69
  build_mandatory_attribute_arrays
72
70
  return @mandatory_custom_attributes if only_custom_attributes
71
+
73
72
  @mandatory_attributes
74
73
  end
75
74
 
76
75
  # Returns true, if the file format has an mandatory attribute of the given name.
77
76
  def mandatory_attribute?(attr)
78
- self.mandatory_attribute_names.include?(attr.to_s)
77
+ mandatory_attribute_names.include?(attr.to_s)
79
78
  end
80
79
 
81
80
  # Convenience method for find_by_obj_class_name
82
81
  def self.find_by_name(*args)
83
- self.find_by_obj_class_name(*args)
82
+ find_by_obj_class_name(*args)
84
83
  end
85
84
 
86
85
  # Reads a whole bunch of data, where only some of it is useful
@@ -90,17 +89,18 @@ module RailsConnector
90
89
  # presetAttributes, recordSetCallback, titles, validSubObjClassCheck,
91
90
  # workflowModification
92
91
  def self.read_blob_data(name) #:nodoc:
93
- blob = RailsConnector::Meta.hello_im_rails_and_im_retarted_so_please_be_patient do # these queries really pollute our logs!
94
- blob_name = if RailsConnector::BlobMapping.exists?
95
- RailsConnector::BlobMapping.get_fingerprint("#{name}.jsonObjClassDict")
96
- else
97
- "#{name}.jsonObjClassDict"
98
- end
92
+ blob = RailsConnector::Meta.hello_im_rails_and_im_retarted_so_please_be_patient do # these queries really pollute our logs!
93
+ blob_name =
94
+ if RailsConnector::BlobMapping.exists?
95
+ RailsConnector::BlobMapping.get_fingerprint("#{name}.jsonObjClassDict")
96
+ else
97
+ "#{name}.jsonObjClassDict"
98
+ end
99
99
 
100
100
  RailsConnector::Blob.find_without_excluded_blob_data(blob_name)
101
101
  end
102
102
 
103
- return {} unless blob && blob.blob_data?
103
+ return {} unless blob&.blob_data?
104
104
 
105
105
  JSON.parse(blob.blob_data)
106
106
  end
@@ -110,7 +110,7 @@ module RailsConnector
110
110
  def load_blob_data #:nodoc:
111
111
  return if @blob_data
112
112
 
113
- @blob_data = self.class.read_blob_data(self.name)
113
+ @blob_data = self.class.read_blob_data(name)
114
114
 
115
115
  # reset depending instance variables
116
116
  @mandatory_custom_attributes = @mandatory_attributes = nil
@@ -123,9 +123,9 @@ module RailsConnector
123
123
 
124
124
  @mandatory_custom_attributes = []
125
125
  @mandatory_attributes = []
126
- (@blob_data['mandatoryAttributes'] || []).each do |attr|
126
+ (@blob_data["mandatoryAttributes"] || []).each do |attr|
127
127
  attr_name = attr.to_s
128
- if self.custom_attribute?(attr_name)
128
+ if custom_attribute?(attr_name)
129
129
  @mandatory_custom_attributes << attr_name
130
130
  else
131
131
  # only modify built-in attributes; i.e. `validFrom` will become `valid_from`
@@ -134,7 +134,5 @@ module RailsConnector
134
134
  @mandatory_attributes << attr_name
135
135
  end
136
136
  end
137
-
138
137
  end
139
-
140
138
  end
@@ -1,5 +1,5 @@
1
1
  module RailsConnector
2
2
  class ObjClassAttr < CmsBaseModel
3
- has_many :custom_attributes_raw, :class_name => '::RailsConnector::Attribute', :foreign_key => 'attribute_id', :primary_key => 'attribute_id'
3
+ has_many :custom_attributes_raw, class_name: "::RailsConnector::Attribute", foreign_key: "attribute_id", primary_key: "attribute_id"
4
4
  end
5
5
  end
@@ -1,10 +1,7 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module RailsConnector
3
-
4
2
  # This class allows us to read out the version and
5
3
  # the reminder information of an Obj
6
4
  class ObjectWithMetaData < CmsBaseModel #:nodoc:
7
-
8
5
  # If we name the class Object, conflicts with the plain Ruby
9
6
  # objects inside the RailsConnector will occur.
10
7
  def self.table_name
@@ -12,7 +9,5 @@ module RailsConnector
12
9
  end
13
10
 
14
11
  self.primary_key = :object_id
15
-
16
12
  end
17
-
18
13
  end
@@ -1,8 +1,7 @@
1
1
  module RailsConnector
2
-
3
2
  # The permissions assigned to an Obj.
4
3
  class Permission < CmsBaseModel
5
- belongs_to :object, :class_name => 'Obj', :foreign_key => 'object_id'
4
+ belongs_to :object, class_name: "Obj", foreign_key: "object_id"
6
5
 
7
6
  # Returns the Array of the names of the user groups to which read permission has been granted.
8
7
  def self.read
@@ -29,13 +28,10 @@ module RailsConnector
29
28
  user_groups_for_permission_type(5)
30
29
  end
31
30
 
32
- private
33
-
34
31
  def self.user_groups_for_permission_type(permission_type)
35
32
  # Field name "user_login" is a legacy from CM tables.
36
33
  # Actually the field contains the user group.
37
- select(:user_login).where(:permission_type => permission_type).map(&:user_login)
34
+ select(:user_login).where(permission_type: permission_type).map(&:user_login)
38
35
  end
39
36
  end
40
-
41
37
  end
@@ -1,11 +1,9 @@
1
- require 'search_request'
1
+ require "search_request"
2
2
 
3
3
  module RailsConnector
4
-
5
4
  # This module accesses the Infopark Search Engine Server.
6
5
  # @api public
7
6
  module SES
8
-
9
7
  autoload :VerityAccessor, "rails_connector/ses/verity_accessor"
10
8
 
11
9
  # This method enables Obj to perform searches using the SES Search Engine Server.
@@ -51,19 +49,17 @@ module RailsConnector
51
49
  class Hit
52
50
  # The ID of the found Obj.
53
51
  # @api public
54
- attr_reader :id
52
+ attr_reader :id, :score, :doc
55
53
 
56
54
  # The score of the hit.
57
55
  # @api public
58
- attr_reader :score
59
56
 
60
57
  # The raw result hash returned by the search engine, for a low-level access.
61
58
  # Don't use this unless you know what you're doing.
62
59
  # Be aware that this is not migration safe.
63
60
  # @api public
64
- attr_reader :doc
65
61
 
66
- def initialize(id, score, doc={}, obj=nil)
62
+ def initialize(id, score, doc = {}, obj = nil)
67
63
  @id = id
68
64
  @score = score
69
65
  @doc = doc
@@ -79,5 +75,4 @@ module RailsConnector
79
75
  end
80
76
  end
81
77
  end
82
-
83
78
  end
@@ -1,12 +1,10 @@
1
1
  require "builder"
2
2
 
3
3
  module RailsConnector
4
-
5
4
  module SES
6
-
7
5
  class VerityAccessor
8
- require 'net/http'
9
- require 'uri'
6
+ require "net/http"
7
+ require "uri"
10
8
  require "rexml/document"
11
9
 
12
10
  #--
@@ -15,16 +13,16 @@ module RailsConnector
15
13
  def initialize(query, options = {})
16
14
  @query = query
17
15
  @options = {
18
- :host => 'localhost',
19
- :port => 3011,
20
- :offset => 0,
21
- :limit => 10,
22
- :min_relevance => 50,
23
- :max_docs => 'unlimited',
24
- :parser => 'simple',
25
- :sort_order => [["score", "desc"], ["name", "asc"]],
26
- :collections => ['cm-contents'],
27
- :base_query => nil
16
+ host: "localhost",
17
+ port: 3011,
18
+ offset: 0,
19
+ limit: 10,
20
+ min_relevance: 50,
21
+ max_docs: "unlimited",
22
+ parser: "simple",
23
+ sort_order: [%w(score desc), %w(name asc)],
24
+ collections: ["cm-contents"],
25
+ base_query: nil
28
26
  }.merge(options)
29
27
  @options[:collections] = Array(options[:collection]).flatten if options.has_key?(:collection)
30
28
  end
@@ -43,44 +41,44 @@ module RailsConnector
43
41
  def build_request_payload
44
42
  x = Builder::XmlMarkup.new
45
43
  x.instruct!
46
- x.tag!('ses-payload', 'payload-id' => 'd-1f6a64dec16aa328-00000020-i', 'timestamp' => Time.now.to_iso, 'version' => '6') {
47
- x.tag!('ses-header') {
48
- x.tag!('ses-sender', 'sender-id' => '42', 'name' => 'infopark-rails-connector')
49
- }
50
- x.tag!('ses-request', 'request-id' => 'd-1f6a64dec16aa328-00000021-j-1', 'preclusive' => 'false') {
51
- x.tag!('ses-search') {
52
- x.query @query, :parser => @options[:parser]
53
- x.resultRecord {
54
- x.resultField 'objId'
55
- x.resultField 'score'
56
- }
57
- x.offset {
44
+ x.tag!("ses-payload", "payload-id" => "d-1f6a64dec16aa328-00000020-i", "timestamp" => Time.now.to_iso, "version" => "6") do
45
+ x.tag!("ses-header") do
46
+ x.tag!("ses-sender", "sender-id" => "42", "name" => "infopark-rails-connector")
47
+ end
48
+ x.tag!("ses-request", "request-id" => "d-1f6a64dec16aa328-00000021-j-1", "preclusive" => "false") do
49
+ x.tag!("ses-search") do
50
+ x.query @query, parser: @options[:parser]
51
+ x.resultRecord do
52
+ x.resultField "objId"
53
+ x.resultField "score"
54
+ end
55
+ x.offset do
58
56
  x.start @options[:offset].to_i + 1
59
57
  x.length @options[:limit]
60
- }
58
+ end
61
59
  x.minRelevance @options[:min_relevance]
62
60
  x.maxDocs @options[:max_docs]
63
61
 
64
62
  unless @options[:sort_order].blank?
65
- x.sortOrder {
63
+ x.sortOrder do
66
64
  @options[:sort_order].each do |attribute, direction|
67
- x.sortField attribute, :direction => direction
65
+ x.sortField attribute, direction: direction
68
66
  end
69
- }
67
+ end
70
68
  end
71
69
 
72
- x.searchBase {
73
- @options[:collections].each {|item| x.collection item }
74
- x.query @options[:base_query], :parser => @options[:parser] if @options[:base_query]
75
- }
76
- }
77
- }
78
- }
70
+ x.searchBase do
71
+ @options[:collections].each { |item| x.collection item }
72
+ x.query @options[:base_query], parser: @options[:parser] if @options[:base_query]
73
+ end
74
+ end
75
+ end
76
+ end
79
77
  end
80
78
 
81
79
  def send_to_ses(payload)
82
80
  res = Net::HTTP.new(@options[:host], @options[:port].to_i).start do |http|
83
- req = Net::HTTP::Post.new('/xml')
81
+ req = Net::HTTP::Post.new("/xml")
84
82
  req.body = payload
85
83
  http.request(req)
86
84
  end
@@ -89,7 +87,7 @@ module RailsConnector
89
87
 
90
88
  def parse_response_payload(response)
91
89
  xml = REXML::Document.new(response)
92
- if xml.elements['/ses-payload/ses-response/ses-code'].attributes['numeric'] == "200"
90
+ if xml.elements["/ses-payload/ses-response/ses-code"].attributes["numeric"] == "200"
93
91
  build_successful_result(xml)
94
92
  else
95
93
  handle_error(xml)
@@ -97,13 +95,13 @@ module RailsConnector
97
95
  end
98
96
 
99
97
  def build_successful_result(response)
100
- result = SearchResult.new(response.elements['/ses-payload/ses-response/ses-code/searchResults'].attributes['hits'].to_i)
101
- response.elements.to_a('/ses-payload/ses-response/ses-code/searchResults/record').each do |record|
102
- hit = Hit.new(record.elements['objId'].text.to_i, record.elements['score'].text.to_f)
98
+ result = SearchResult.new(response.elements["/ses-payload/ses-response/ses-code/searchResults"].attributes["hits"].to_i)
99
+ response.elements.to_a("/ses-payload/ses-response/ses-code/searchResults/record").each do |record|
100
+ hit = Hit.new(record.elements["objId"].text.to_i, record.elements["score"].text.to_f)
103
101
  if hit.obj.present?
104
102
  result << hit
105
103
  else
106
- Rails.logger.warn("OBJ with ID ##{record.elements['objId'].text.to_i} not found: This search result will not be shown")
104
+ Rails.logger.warn("OBJ with ID ##{record.elements["objId"].text.to_i} not found: This search result will not be shown")
107
105
  end
108
106
  end
109
107
  result
@@ -118,13 +116,12 @@ module RailsConnector
118
116
  # 100177: ERROR_SYSTEM_SEARCHENGINE_BULKSUBMITFAILED
119
117
  def handle_error(response)
120
118
  msg = ""
121
- response.elements.each('/ses-payload/ses-response/ses-code/errorStack/error') do |error|
122
- msg << error.elements['phrase'].text
119
+ response.elements.each("/ses-payload/ses-response/ses-code/errorStack/error") do |error|
120
+ msg << error.elements["phrase"].text
123
121
  msg << "\n"
124
122
  end
125
123
  raise SearchError, msg
126
124
  end
127
125
  end
128
126
  end
129
-
130
127
  end