mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 13:36:15 +02:00
Refactored xml_console_controller
This commit is contained in:
parent
30d7fcb26d
commit
48616ec3cd
1 changed files with 14 additions and 19 deletions
|
@ -7,12 +7,14 @@ module Repp
|
||||||
THROTTLED_ACTIONS = %i[load_xml].freeze
|
THROTTLED_ACTIONS = %i[load_xml].freeze
|
||||||
include Shunter::Integration::Throttle
|
include Shunter::Integration::Throttle
|
||||||
|
|
||||||
PREFS = %w[
|
PREFS = %w[domain-ee contact-ee eis epp-ee].freeze
|
||||||
domain-ee
|
|
||||||
contact-ee
|
SCHEMA_VERSIONS = {
|
||||||
eis
|
'epp-ee' => '1.0',
|
||||||
epp-ee
|
'eis' => '1.0',
|
||||||
].freeze
|
'contact-ee' => '1.1',
|
||||||
|
'default' => '1.2',
|
||||||
|
}.freeze
|
||||||
|
|
||||||
def load_xml
|
def load_xml
|
||||||
cl_trid = "#{current_user.username}-#{Time.zone.now.to_i}"
|
cl_trid = "#{current_user.username}-#{Time.zone.now.to_i}"
|
||||||
|
@ -37,23 +39,16 @@ module Repp
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_schema_by_prefix(pref, xml)
|
def load_schema_by_prefix(pref, xml)
|
||||||
case pref
|
version = version_by_prefix(pref)
|
||||||
when 'epp-ee'
|
|
||||||
insert_prefix_and_version(xml, pref, '1.0')
|
|
||||||
when 'eis'
|
|
||||||
insert_prefix_and_version(xml, pref, '1.0')
|
|
||||||
when 'contact-ee'
|
|
||||||
insert_prefix_and_version(xml, pref, '1.1')
|
|
||||||
else
|
|
||||||
insert_prefix_and_version(xml, pref, '1.2')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def insert_prefix_and_version(xml, pref, version)
|
|
||||||
xml.gsub!("\"#{pref}\"",
|
xml.gsub!("\"#{pref}\"",
|
||||||
"\"#{Xsd::Schema.filename(for_prefix: pref.to_s, for_version: version)}\"")
|
"\"#{Xsd::Schema.filename(for_prefix: pref.to_s, for_version: version)}\"")
|
||||||
xml
|
xml
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def version_by_prefix(pref)
|
||||||
|
key = SCHEMA_VERSIONS.key?(pref) ? pref : 'default'
|
||||||
|
SCHEMA_VERSIONS[key]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue