13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/liferay_database_config_reader.rb', line 13
def self.init! path = File.expand_path(WEB_INF_CLASSES + PROPERTIES_EXT_FILE)
log "RAILS_ENV=#{ENV['RAILS_ENV']}"
log "reading #{path}"
properties = Properties.new
properties.load(FileInputStream.new(path))
url = properties.getProperty("jdbc.default.url")
@@properties[:username] = properties.getProperty("jdbc.default.username")
@@properties[:password] = properties.getProperty("jdbc.default.password")
fragments = url.split /\/+/
raise "Fail to check adapter, host and database in liferay config file" if fragments.nil? or fragments.size < 3
@@properties[:adapter] = fragments[0].gsub(':', '')
@@properties[:host], @@properties[:port] = fragments[1].split(':')
@@properties[:database] = fragments[2]
log "adapter: #{attr[:adapter]}, host: #{attr[:host]}:#{attr[:port]}, database: #{attr[:database]}\n"
end
|