From cc7388bd794a40a48d498d53d4d5e023ba7df6d8 Mon Sep 17 00:00:00 2001 From: Josh Meekhof Date: Fri, 30 Oct 2015 11:41:16 -0400 Subject: [PATCH] FIX for issue #514. Add to pull request #518 Update to allow non-admin users to deploy. --- deploy/lib/server_config.rb | 80 ++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/deploy/lib/server_config.rb b/deploy/lib/server_config.rb index cb4372ed..d18acf11 100644 --- a/deploy/lib/server_config.rb +++ b/deploy/lib/server_config.rb @@ -554,7 +554,7 @@ def merge end return true end - + def merge_db(target_db) logger.info "Merging #{target_db} on #{@hostname}" @@ -583,19 +583,19 @@ def reindex end return true end - + def reindex_db(target_db) logger.info "Reindexing #{target_db} on #{@hostname}" r = execute_query %Q{ xquery version "1.0-ml"; - import module namespace admin = "http://marklogic.com/xdmp/admin" + import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy"; admin:save-configuration-without-restart( admin:database-set-reindexer-timestamp( - admin:get-configuration(), + admin:get-configuration(), xdmp:database("#{target_db}"), xdmp:request-timestamp() ) @@ -1150,7 +1150,7 @@ def mlcp jars = Dir.glob(ServerConfig.expand_path("#{mlcp_home}/lib/*.jar")) confdir = ServerConfig.expand_path("#{mlcp_home}/conf") classpath = "#{confdir}#{path_separator}#{jars.join(path_separator)}" - + vmargs = %Q{"-DCONTENTPUMP_HOME=#{mlcp_home}" -Dfile.encoding=UTF-8 -Dxcc.txn.compatible=true "-Djava.library.path=#{mlcp_home}/lib/native" #{@properties['ml.mlcp-vmargs']} } ARGV.each do |arg| @@ -1367,7 +1367,7 @@ def save_files_to_fs(target_db, target_dir) for $uri in cts:uris() order by $uri return $uri - + } catch ($ignore) { (: In case URI lexicon has not been enabled :) for $doc in collection() @@ -1524,23 +1524,23 @@ def deploy_src folders_to_ignore = @properties['ml.ignore-folders'] if @properties['ml.save-commit-info'] == 'true' - + if File.exists? ".svn" svn_info_file = File.new("#{xquery_dir}/svn-info.xml", "w") svn_info_file.puts(`svn info --xml`) svn_info_file.close @logger.info "Saved commit info as #{xquery_dir}/svn-info.xml" - + elsif File.exists? ".git" git_info_file = File.new("#{xquery_dir}/git-info.xml", "w") git_info_file.puts(`git log -1 --pretty=format:"%H%an%ai%s%b"`) git_info_file.close @logger.info "Saved commit info as #{xquery_dir}/git-info.xml" - + else @logger.warn "Only SVN and GIT supported for save-commit-info" end - + end modules_databases.each do |dest_db| @@ -1555,7 +1555,7 @@ def deploy_src ignore_us << "^#{test_config_file}$" ignore_us << "^#{folders_to_ignore}$" unless folders_to_ignore.blank? - src_permissions = permissions(@properties['ml.app-role'], Roxy::ContentCapability::ER) + src_permissions = permissions(@properties['ml.app-role'], Roxy::ContentCapability::ERU) if ['rest', 'hybrid'].include? @properties["ml.app-type"] # This app uses the REST API, so grant permissions to the rest roles. This allows REST extensions to call @@ -2048,7 +2048,7 @@ def conditional_prop(prop, default_prop) value end - + def triggers_db_xml %Q{ @@ -2059,7 +2059,7 @@ def triggers_db_xml } end - + def triggers_assignment %Q{ @@ -2080,7 +2080,7 @@ def xdbc_server } end - + def odbc_server odbc_auth_method = conditional_prop('ml.odbc-authentication-method', 'ml.authentication-method') %Q{ @@ -2093,7 +2093,7 @@ def odbc_server } end - + def schemas_db_xml %Q{ @@ -2112,7 +2112,7 @@ def schemas_assignment } end - + def test_content_db_xml %Q{ @@ -2123,7 +2123,7 @@ def test_content_db_xml } end - + def test_content_db_assignment %Q{ @@ -2131,7 +2131,7 @@ def test_content_db_assignment } end - + def test_appserver # The modules database for the test server can be different from the app one test_modules_db = conditional_prop('ml.test-modules-db', 'ml.app-modules-db') @@ -2149,7 +2149,7 @@ def test_appserver } end - + def test_modules_db_xml %Q{ @@ -2168,7 +2168,7 @@ def test_modules_db_assignment } end - + def rest_appserver rest_modules_db = conditional_prop('ml.rest-modules-db', 'ml.app-modules-db') rest_auth_method = conditional_prop('ml.rest-authentication-method', 'ml.authentication-method') @@ -2179,10 +2179,10 @@ def rest_appserver rest_url_rewriter = @properties['ml.rest-url-rewriter'] elsif @server_version > 7 rest_url_rewriter = '/MarkLogic/rest-api/rewriter.xml' - else + else rest_url_rewriter = '/MarkLogic/rest-api/rewriter.xqy' end - + %Q{ @ml.app-name-rest @@ -2197,10 +2197,10 @@ def rest_appserver } end - + def rest_modules_db_xml rest_modules_db = conditional_prop('ml.rest-modules-db', 'ml.app-modules-db') - + %Q{ #{rest_modules_db} @@ -2210,17 +2210,17 @@ def rest_modules_db_xml } end - + def rest_modules_db_assignment rest_modules_db = conditional_prop('ml.rest-modules-db', 'ml.app-modules-db') - + %Q{ #{rest_modules_db} } end - + def ssl_certificate_xml %Q{ @@ -2242,7 +2242,7 @@ def build_config(config_files) # Build the triggers db if it is provided if @properties['ml.triggers-db'].present? - + if @properties['ml.triggers-db'] != @properties['ml.app-modules-db'] config.gsub!("@ml.triggers-db-xml", triggers_db_xml) config.gsub!("@ml.triggers-assignment", triggers_assignment) @@ -2255,7 +2255,7 @@ def build_config(config_files) %Q{ }) - + else config.gsub!("@ml.triggers-db-xml", "") config.gsub!("@ml.triggers-assignment", "") @@ -2276,7 +2276,7 @@ def build_config(config_files) # Build the schemas db if it is provided if @properties['ml.schemas-db'].present? - + if @properties['ml.schemas-db'] != @properties['ml.app-modules-db'] config.gsub!("@ml.schemas-db-xml", schemas_db_xml) config.gsub!("@ml.schemas-assignment", schemas_assignment) @@ -2304,7 +2304,7 @@ def build_config(config_files) config.gsub!("@ml.test-content-db-xml", test_content_db_xml) config.gsub!("@ml.test-content-db-assignment", test_content_db_assignment) config.gsub!("@ml.test-appserver", test_appserver) - + else config.gsub!("@ml.test-content-db-xml", "") config.gsub!("@ml.test-content-db-assignment", "") @@ -2314,10 +2314,10 @@ def build_config(config_files) # Build the test modules db if it is different from the app modules db if @properties['ml.test-modules-db'].present? && @properties['ml.test-modules-db'] != @properties['ml.app-modules-db'] - + config.gsub!("@ml.test-modules-db-xml", test_modules_db_xml) config.gsub!("@ml.test-modules-db-assignment", test_modules_db_assignment) - + else config.gsub!("@ml.test-modules-db-xml", "") config.gsub!("@ml.test-modules-db-assignment", "") @@ -2327,7 +2327,7 @@ def build_config(config_files) # Set up a REST API app server, distinct from the main application. config.gsub!("@ml.rest-appserver", rest_appserver) - + if @properties['ml.rest-modules-db'].present? && @properties['ml.rest-modules-db'] != @properties['ml.app-modules-db'] config.gsub!("@ml.rest-modules-db-xml", rest_modules_db_xml) @@ -2365,15 +2365,15 @@ def build_config(config_files) else config.gsub!("@ml.rewrite-resolves-globally", "") end - + if @properties['ml.ssl-certificate-template'].present? config.gsub!("@ml.ssl-certificate-xml", ssl_certificate_xml) else config.gsub!("@ml.ssl-certificate-xml", "") end - + replace_properties(config, File.basename(config_file)) - + # escape unresolved braces, they have special meaning in XQuery config.gsub!("{", "{{") config.gsub!("}", "}}") @@ -2383,7 +2383,7 @@ def build_config(config_files) %Q{(#{configs.join(", ")})} end - + def replace_properties(contents, name) # make sure to apply descending order to replace @ml.foo-bar before @ml.foo @properties.sort {|x,y| y <=> x}.each do |k, v| @@ -2391,11 +2391,11 @@ def replace_properties(contents, name) n = k.sub("ml.", "") contents.gsub!("@{#{n}}", v) contents.gsub!("${#{n}}", v) - + # backwards compat, old syntax: @ml.app-name contents.gsub!("@#{k}", v) end - + # warn for unresolved properties contents.scan(/[@$]\{[^}]+\}/).each do |match| logger.warn("Unresolved property #{match} in #{name}")