Class: AtlConfig::ConfluenceCfg
- Inherits:
-
Object
- Object
- AtlConfig::ConfluenceCfg
- Defined in:
- lib/atl_config/confluencecfg.rb
Class Method Summary collapse
-
.dbinfo(cfgxml) ⇒ DBInfo
Extracts database info from Confluence
confluence.cfg.xml
files.
Class Method Details
.dbinfo(cfgxml) ⇒ DBInfo
Extracts database info from Confluence confluence.cfg.xml
files.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/atl_config/confluencecfg.rb', line 7 def self.dbinfo(cfgxml) config = Nokogiri::XML(cfgxml) r = DBInfo.new r.datasource = config.xpath("/confluence-configuration/properties/property[@name='hibernate.connection.datasource']/text()").first&.to_s if !r.datasource then base = config.xpath("/confluence-configuration/properties") r.user = base.xpath("property[@name='hibernate.connection.username']/text()").first&.to_s r.password = base.xpath("property[@name='hibernate.connection.password']/text()").first&.to_s # jdbcurl is the URL in Java/JDBC format. dburl is the URL in Ruby format r.jdbcurl = base.xpath("property[@name='hibernate.connection.url']/text()").first&.to_s # FIXME: it's probably more complex than this.. r.dburl = r.jdbcurl.gsub("jdbc:postgresql", "postgres") urlparts = AtlConfig::JDBCURL.parse(r.jdbcurl) r.dbtype = urlparts[:dbtype] r.host = urlparts[:host] r.port = if urlparts[:port] then urlparts[:port].to_i else case @dbtype when 'postgresql' 5432 when 'mysql' 3306 else raise "Unhandled db type #{dbtype}" end end r.database = urlparts[:database] end r end |