Class: UcbDeployer::ConfluenceDeployer

Inherits:
Deployer
  • Object
show all
Defined in:
lib/ucb_deployer/confluence_deployer.rb

Constant Summary

Constants inherited from Deployer

Deployer::CONFIG_OPTIONS

Instance Attribute Summary

Attributes inherited from Deployer

#debug_mode, #version

Instance Method Summary collapse

Methods inherited from Deployer

#debug, #deployer_home, #disable_web, #enable_web, #info, #load_config, #maintenance_template, #resources_dir

Constructor Details

#initialize(config_file = "#{ENV['HOME']}/.ucb_deployer/config/confluence/deploy.yml") ⇒ ConfluenceDeployer

Returns a new instance of ConfluenceDeployer.



5
6
7
8
# File 'lib/ucb_deployer/confluence_deployer.rb', line 5

def initialize(config_file = "#{ENV['HOME']}/.ucb_deployer/config/confluence/deploy.yml")
  self.debug("Using config file: #{config_file}")
  self.load_config(config_file)
end

Instance Method Details

#buildObject



28
29
30
31
32
# File 'lib/ucb_deployer/confluence_deployer.rb', line 28

def build()
  Dir.chdir("#{build_dir}/src") do
    `sh #{build_dir}/src/build.sh`
  end
end

#cas_authenticator_classObject



87
88
89
# File 'lib/ucb_deployer/confluence_deployer.rb', line 87

def cas_authenticator_class()
  "org.soulwing.cas.apps.atlassian.ConfluenceCasAuthenticator"
end

#config_confluence_init_propertiesObject

Sets the confluence.home property in the file: confluence-init.properties.



137
138
139
140
141
# File 'lib/ucb_deployer/confluence_deployer.rb', line 137

def config_confluence_init_properties()
  File.open(self.confluence_init_properties, "w") do |io|
    io.puts("confluence.home=#{data_dir}")
  end
end

#config_seraph_config_xmlObject

Updates the confluence seraph_config.xml file with the soulwing authenticator.



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/ucb_deployer/confluence_deployer.rb', line 116

def config_seraph_config_xml()
  seraph_xml = File.readlines(self.seraph_config_xml)
  
  seraph_xml = seraph_xml.map do |line|
    if m = /(#{Regexp.quote(seraph_config_xml_token)})/.match(line)
      debug(m[0])
      debug("#{m.pre_match}#{cas_authenticator_class}#{m.post_match}")
      "#{m.pre_match}#{cas_authenticator_class}#{m.post_match}"
    else
      line
    end
  end
  
  File.open(self.seraph_config_xml, "w") do |io|
    seraph_xml.each { |line| io.puts(line) }
  end
end

#config_web_xmlObject

Updates the confluence web.xml file with the soulwing (CAS library) authentication configuration



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/ucb_deployer/confluence_deployer.rb', line 95

def config_web_xml()
  web_xml = File.readlines(self.web_xml)
  
  web_xml = web_xml.map do |line|
    if line =~ /#{web_xml_token}/
      template = File.open("#{DEPLOYER_HOME}/resources/confluence_cas_web.xml") { |f| f.read }
      ERB.new(template).result(self.send(:binding))
    else
      line
    end
  end
  
  File.open(self.web_xml, "w") do |io|
    web_xml.each { |line| io.puts(line) }
  end
end

#config_xwork_xmlObject

Alter xwork.xml so soulwing authenticator works with CAS



153
154
155
156
157
158
# File 'lib/ucb_deployer/confluence_deployer.rb', line 153

def config_xwork_xml()
  template = File.open("#{UcbDeployer::RESOURCES_DIR}/xwork.xml") { |f| f.read }
  xml = ERB.new(template).result(self.send(:binding))
  FileUtils.touch(xwork_xml())
  File.open(xwork_xml(), "w") { |io| io.puts(xml) }
end

#configureObject



20
21
22
23
24
25
26
# File 'lib/ucb_deployer/confluence_deployer.rb', line 20

def configure()
  config_web_xml()
  config_seraph_config_xml()
  config_confluence_init_properties()
  config_xwork_xml()
  reshuffle_jars()
end

#confluence_init_propertiesObject

Shortcut to confluence confluence-init.properties file



75
76
77
# File 'lib/ucb_deployer/confluence_deployer.rb', line 75

def confluence_init_properties()
  "#{build_dir}/src/confluence/WEB-INF/classes/confluence-init.properties"
end

#deployObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ucb_deployer/confluence_deployer.rb', line 34

def deploy()
  if File.exists?("#{deploy_dir}/#{war_name}")
    FileUtils.rm_rf(Dir["#{deploy_dir}/#{war_name}"])
  end

  FileUtils.mkdir("#{deploy_dir}/#{war_name}")
  FileUtils.mv("#{build_dir}/src/dist/confluence-#{version}.war",
               "#{deploy_dir}/#{war_name}/#{war_name}.war")

  `cd #{deploy_dir}/#{war_name}/ && jar -xvf #{war_name}.war`
  FileUtils.rm("#{deploy_dir}/#{war_name}/#{war_name}.war")
end

#exportObject



10
11
12
13
14
15
16
17
18
# File 'lib/ucb_deployer/confluence_deployer.rb', line 10

def export()
  UcbDeployer.debug("Exporting from: #{svn_project_url}/confluence-#{version}")
  Dir.chdir("#{build_dir}") do
    FileUtils.rm_rf("#{build_dir}/src")
    `svn export #{svn_project_url}/confluence-#{version}`
    FileUtils.mv("confluence-#{version}", "src")
  end
  $stdout.puts("Export Completed")
end

#reshuffle_jarsObject

Remove application jars that have been installed at the container level.



163
164
165
166
167
168
169
170
# File 'lib/ucb_deployer/confluence_deployer.rb', line 163

def reshuffle_jars()
  FileUtils.cp(Dir["#{UcbDeployer::RESOURCES_DIR}/soulwing-casclient-*"],
               "#{build_dir}/src/confluence/WEB-INF/lib/")
  # Remove the jars that are installed at the container level
  ["postgresql", "activation", "mail"].each do |jar|
    FileUtils.rm_rf(Dir["#{build_dir}/src/confluence/WEB-INF/lib/#{jar}-*"])
  end
end

#rollbackObject



47
48
# File 'lib/ucb_deployer/confluence_deployer.rb', line 47

def rollback()
end

#seraph_config_xmlObject

Shortcut to confluence seraph-config.xml file



68
69
70
# File 'lib/ucb_deployer/confluence_deployer.rb', line 68

def seraph_config_xml()
  "#{build_dir}/src/confluence/WEB-INF/classes/seraph-config.xml"
end

#seraph_config_xml_tokenObject



83
84
85
# File 'lib/ucb_deployer/confluence_deployer.rb', line 83

def seraph_config_xml_token()
  "com.atlassian.confluence.user.ConfluenceAuthenticator"
end

#svn_base_urlObject



54
55
56
# File 'lib/ucb_deployer/confluence_deployer.rb', line 54

def svn_base_url()
  @svn_base_url || "svn.berkeley.edu/svn/ist-svn/berkeley/projects/ist/as/webapps/confluence_archives"
end

#svn_usernameObject



50
51
52
# File 'lib/ucb_deployer/confluence_deployer.rb', line 50

def svn_username()
  @svn_username || "app_relmgt"
end

#web_xmlObject

Shortcut to confluence web.xml file



61
62
63
# File 'lib/ucb_deployer/confluence_deployer.rb', line 61

def web_xml()
  "#{build_dir}/src/confluence/WEB-INF/web.xml"
end

#web_xml_tokenObject



79
80
81
# File 'lib/ucb_deployer/confluence_deployer.rb', line 79

def web_xml_token()
  "<!-- Uncomment the following to disable the space export long running task. -->"
end

#xwork_xmlObject

Shortcut to xwork.xml file



146
147
148
# File 'lib/ucb_deployer/confluence_deployer.rb', line 146

def xwork_xml()
  "#{build_dir}/src/confluence/WEB-INF/classes/xwork.xml"
end