From 7b782accbe75eff707eae4734fa64ad17ff8de06 Mon Sep 17 00:00:00 2001
From: Markus Guenther <markus@sgalinski.de>
Date: Wed, 7 Sep 2016 15:04:06 +0200
Subject: [PATCH] [FEATURE] Install tika server

---
 attributes/default.rb |  3 ++-
 providers/app.rb      | 10 ++++++++++
 recipes/default.rb    |  7 +++++++
 resources/app.rb      |  1 +
 4 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/attributes/default.rb b/attributes/default.rb
index dc14841..8046442 100644
--- a/attributes/default.rb
+++ b/attributes/default.rb
@@ -22,4 +22,5 @@ default['tomcat']['work_dir'] = "/var/cache/tomcat#{node['tomcat']['base_version
 default['tomcat']['context_dir'] = "#{node['tomcat']['config_dir']}/Catalina/localhost"
 default['tomcat']['webapp_dir'] = "/var/lib/tomcat#{node['tomcat']['base_version']}/webapps"
 
-default['typo3_solr']['solr']['solr_home'] = '/srv/solr'
\ No newline at end of file
+default['typo3_solr']['solr']['solr_home'] = '/srv/solr'
+default['typo3_solr']['solr']['tika_home'] = '/srv/tika'
\ No newline at end of file
diff --git a/providers/app.rb b/providers/app.rb
index 0a42920..3102744 100644
--- a/providers/app.rb
+++ b/providers/app.rb
@@ -18,6 +18,7 @@ action :add do
 
 	ext_solr_uri = "https://raw.githubusercontent.com/TYPO3-Solr/ext-solr/#{remote_branch}/#{resources_path}"
 	plugin_uri = "https://github.com/TYPO3-Solr/solr-typo3-plugin/releases/download/release-#{new_resource.plugin}"
+	tika_server_uri = "http://mirror.dkd.de/apache/tika"
 
 	service 'tomcat' do
 		service_name node['tomcat']['base_instance']
@@ -221,6 +222,15 @@ action :add do
 		only_if { Gem::Version.new(new_resource.plugin_lang) > Gem::Version.new('0.0.0') }
 	end
 
+	# tika server
+	remote_file "#{node['typo3_solr']['solr']['tika_home']}/tika-server-#{new_resource.tika_server}" do
+		source "#{tika_server_uri}/tika-server-#{new_resource.tika_server}.jar"
+		mode 0550
+		notifies :restart, 'service[tomcat]', :immediately
+		only_if { Gem::Version.new(new_resource.tika_server) > Gem::Version.new('0.0.0') }
+	end
+
+
 	# reset directory access restrictions
 
 	execute "chown - #{new_resource.name}" do
diff --git a/recipes/default.rb b/recipes/default.rb
index d883bd7..e1f6723 100644
--- a/recipes/default.rb
+++ b/recipes/default.rb
@@ -29,4 +29,11 @@ directory node['typo3_solr']['solr']['solr_home'] do
 	group 'root'
 	mode 0770
 	action :create
+end
+
+directory node['typo3_solr']['solr']['tika_home'] do
+	owner node['tomcat']['user']
+	group 'root'
+	mode 0770
+	action :create
 end
\ No newline at end of file
diff --git a/resources/app.rb b/resources/app.rb
index d489a30..dba9701 100644
--- a/resources/app.rb
+++ b/resources/app.rb
@@ -2,6 +2,7 @@ actions :add, :remove
 
 attribute :name, :kind_of => String, :name_attribute => true
 attribute :solr, :kind_of => String, :default => '3.6.2'
+attribute :tika_server, :kind_of => String, :default => '0.0.0'
 attribute :extension, :kind_of => String, :default => '2.8'
 attribute :plugin, :kind_of => String, :default => '0.0.0'
 attribute :plugin_access, :kind_of => String, :default => '0.0.0'
-- 
GitLab