diff --git a/deploy/lib/server_config.rb b/deploy/lib/server_config.rb
index 9b0b1ae2..9241b967 100644
--- a/deploy/lib/server_config.rb
+++ b/deploy/lib/server_config.rb
@@ -557,21 +557,6 @@ def config
def bootstrap
raise ExitException.new("Bootstrap requires the target environment's hostname to be defined") unless @hostname.present?
- if @server_version > 7 && @properties["ml.app-type"] == 'rest' && @properties["ml.url-rewriter"] == "/MarkLogic/rest-api/rewriter.xqy"
- @logger.info "WARN: XQuery REST rewriter has been deprecated since MarkLogic 8"
- @properties["ml.url-rewriter"] = "/MarkLogic/rest-api/rewriter.xml"
-
- elsif @server_version < 8 && @properties["ml.app-type"] == 'rest' && @properties["ml.url-rewriter"] == "/MarkLogic/rest-api/rewriter.xml"
- @logger.info "WARN: XML REST rewriter not supported on MarkLogic 7 or less"
- @properties["ml.url-rewriter"] = "/MarkLogic/rest-api/rewriter.xqy"
-
- elsif @server_version > 7 && @properties["ml.app-type"] == 'hybrid'
- @logger.info "WARN: Running the hybrid app-type with MarkLogic 8 is not recommended."
- @logger.info " Doing so requires manual patching of the Roxy rewriter."
- @logger.info " You will be unable to access all of the MarkLogic REST features."
- @logger.info " See https://github.com/marklogic/roxy/issues/416 for details."
- end
-
internals = find_arg(['--replicate-internals'])
if internals
@@ -1728,6 +1713,21 @@ def mlRest
end
def get_config
+ if @server_version > 7 && @properties["ml.app-type"] == 'rest' && @properties["ml.url-rewriter"] == "/MarkLogic/rest-api/rewriter.xqy"
+ @logger.info "WARN: XQuery REST rewriter has been deprecated since MarkLogic 8"
+ @properties["ml.url-rewriter"] = "/MarkLogic/rest-api/rewriter.xml"
+
+ elsif @server_version < 8 && @properties["ml.app-type"] == 'rest' && @properties["ml.url-rewriter"] == "/MarkLogic/rest-api/rewriter.xml"
+ @logger.info "WARN: XML REST rewriter not supported on MarkLogic 7 or less"
+ @properties["ml.url-rewriter"] = "/MarkLogic/rest-api/rewriter.xqy"
+
+ elsif @server_version > 7 && @properties["ml.app-type"] == 'hybrid'
+ @logger.info "WARN: Running the hybrid app-type with MarkLogic 8 is not recommended."
+ @logger.info " Doing so requires manual patching of the Roxy rewriter."
+ @logger.info " You will be unable to access all of the MarkLogic REST features."
+ @logger.info " See https://github.com/marklogic/roxy/issues/416 for details."
+ end
+
@config ||= build_config(@options[:config_file])
end
@@ -1949,95 +1949,245 @@ def conditional_prop(prop, default_prop)
value
end
+
+ def triggers_db_xml
+ %Q{
+
+ @ml.triggers-db
+
+
+
+
+ }
+ end
+
+ def triggers_assignment
+ %Q{
+
+ @ml.triggers-db
+
+ }
+ end
+
+ def xdbc_server
+ xdbc_auth_method = conditional_prop('ml.xdbc-authentication-method', 'ml.authentication-method')
+ %Q{
+
+ @ml.app-name-xcc
+ @ml.xcc-port
+
+
+ #{xdbc_auth_method}
+
+ }
+ end
+
+ def odbc_server
+ odbc_auth_method = conditional_prop('ml.odbc-authentication-method', 'ml.authentication-method')
+ %Q{
+
+ @ml.app-name-odbc
+ @ml.odbc-port
+
+
+ #{odbc_auth_method}
+
+ }
+ end
+
+ def schemas_db_xml
+ %Q{
+
+ @ml.schemas-db
+
+
+
+
+ }
+ end
+
+ def schemas_assignment
+ %Q{
+
+ @ml.schemas-db
+
+ }
+ end
+
+ def test_content_db_xml
+ %Q{
+
+ @ml.test-content-db
+
+
+
+
+ }
+ end
+
+ def test_content_db_assignment
+ %Q{
+
+ @ml.test-content-db
+
+ }
+ 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')
+ test_auth_method = conditional_prop('ml.test-authentication-method', 'ml.authentication-method')
+ test_default_user = conditional_prop('ml.test-default-user', 'ml.default-user')
+
+ %Q{
+
+ @ml.app-name-test
+ @ml.test-port
+
+
+ #{test_auth_method}
+
+
+ }
+ end
+
+ def test_modules_db_xml
+ %Q{
+
+ @ml.test-modules-db
+
+
+
+
+ }
+ end
+
+ def test_modules_db_assignment
+ %Q{
+
+ @ml.test-modules-db
+
+ }
+ 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')
+ rest_default_user = conditional_prop('ml.rest-default-user', 'ml.default-user')
+
+ rest_url_rewriter = nil
+ if @properties['ml.rest-url-rewriter'].present?
+ rest_url_rewriter = @properties['ml.rest-url-rewriter']
+ elsif @server_version > 7
+ rest_url_rewriter = '/MarkLogic/rest-api/rewriter.xml'
+ else
+ rest_url_rewriter = '/MarkLogic/rest-api/rewriter.xqy'
+ end
+
+ %Q{
+
+ @ml.app-name-rest
+ @ml.rest-port
+
+
+ #{rest_auth_method}
+
+ #{rest_url_rewriter}
+ /MarkLogic/rest-api/error-handler.xqy
+ true
+
+ }
+ end
+
+ def rest_modules_db_xml
+ rest_modules_db = conditional_prop('ml.rest-modules-db', 'ml.app-modules-db')
+
+ %Q{
+
+ #{rest_modules_db}
+
+
+
+
+ }
+ 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{
+
+ @ml.ssl-certificate-template
+ @ml.ssl-certificate-countryName
+ @ml.ssl-certificate-stateOrProvinceName
+ @ml.ssl-certificate-localityName
+ @ml.ssl-certificate-organizationName
+ @ml.ssl-certificate-organizationalUnitName
+ @ml.ssl-certificate-emailAddress
+
+ }
+ end
def build_config(config_file)
config = File.read(config_file)
# 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",
- %Q{
-
- @ml.triggers-db
-
-
-
-
- })
-
- config.gsub!("@ml.triggers-assignment",
- %Q{
-
- @ml.triggers-db
-
- })
+ config.gsub!("@ml.triggers-db-xml", triggers_db_xml)
+ config.gsub!("@ml.triggers-assignment", triggers_assignment)
else
config.gsub!("@ml.triggers-db-xml", "")
config.gsub!("@ml.triggers-assignment", "")
end
config.gsub!("@ml.triggers-mapping",
- %Q{
-
- })
+ %Q{
+
+ })
+
else
config.gsub!("@ml.triggers-db-xml", "")
config.gsub!("@ml.triggers-assignment", "")
config.gsub!("@ml.triggers-mapping", "")
end
+ if @properties['ml.xcc-port'].present? and @properties['ml.install-xcc'] != 'false'
+ config.gsub!("@ml.xdbc-server", xdbc_server)
+ else
+ config.gsub!("@ml.xdbc-server", "")
+ end
- config.gsub!("@ml.xdbc-server",
- %Q{
-
- @ml.app-name-xcc
- @ml.xcc-port
-
-
- digest
-
- }) if @properties['ml.xcc-port'].present? and @properties['ml.install-xcc'] != 'false'
-
- config.gsub!("@ml.odbc-server",
- %Q{
-
- @ml.app-name-odbc
- @ml.odbc-port
-
-
- digest
-
- }) if @properties['ml.odbc-port'].present?
+ if @properties['ml.odbc-port'].present?
+ config.gsub!("@ml.odbc-server", odbc_server)
+ else
+ config.gsub!("@ml.odbc-server", "")
+ end
# 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",
- %Q{
-
- @ml.schemas-db
-
-
-
-
- })
-
- config.gsub!("@ml.schemas-assignment",
- %Q{
-
- @ml.schemas-db
-
- })
+ config.gsub!("@ml.schemas-db-xml", schemas_db_xml)
+ config.gsub!("@ml.schemas-assignment", schemas_assignment)
else
config.gsub!("@ml.schemas-db-xml", "")
config.gsub!("@ml.schemas-assignment", "")
end
config.gsub!("@ml.schemas-mapping",
- %Q{
-
- })
+ %Q{
+
+ })
else
config.gsub!("@ml.schemas-db-xml", "")
@@ -2049,40 +2199,11 @@ def build_config(config_file)
if @properties['ml.test-content-db'].present? &&
@properties['ml.test-port'].present? &&
@environment != "prod"
- config.gsub!("@ml.test-content-db-xml",
- %Q{
-
- @ml.test-content-db
-
-
-
-
- })
-
- config.gsub!("@ml.test-content-db-assignment",
- %Q{
-
- @ml.test-content-db
-
- })
-
- # 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')
- test_auth_method = conditional_prop('ml.test-authentication-method', 'ml.authentication-method')
- test_default_user = conditional_prop('ml.test-default-user', 'ml.default-user')
-
- config.gsub!("@ml.test-appserver",
- %Q{
-
- @ml.app-name-test
- @ml.test-port
-
-
- #{test_auth_method}
-
-
- })
+ 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", "")
@@ -2092,84 +2213,43 @@ def build_config(config_file)
# 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",
- %Q{
-
- @ml.test-modules-db
-
-
-
-
- })
-
- config.gsub!("@ml.test-modules-db-assignment",
- %Q{
-
- @ml.test-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", "")
end
if @properties['ml.rest-port'].present?
- # Set up a REST API app server, distinct from the main application.
- rest_modules_db = conditional_prop('ml.rest-modules-db', 'ml.modules-db')
- rest_auth_method = conditional_prop('ml.rest-authentication-method', 'ml.authentication-method')
- rest_default_user = conditional_prop('ml.rest-default-user', 'ml.default-user')
-
- rest_url_rewriter = nil
- if @properties['ml.rest-url-rewriter'].present?
- rest_url_rewriter = @properties['ml.rest-url-rewriter']
- elsif @server_version > 7
- rest_url_rewriter = '/MarkLogic/rest-api/rewriter.xml'
- else
- rest_url_rewriter = '/MarkLogic/rest-api/rewriter.xqy'
+ # 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)
+ config.gsub!("@ml.rest-modules-db-assignment", rest_modules_db_assignment)
+ else
+ config.gsub!("@ml.rest-modules-db-xml", "")
+ config.gsub!("@ml.rest-modules-db-assignment", "")
end
- config.gsub!("@ml.rest-appserver",
- %Q{
-
- @ml.app-name-rest
- @ml.rest-port
-
-
- #{rest_auth_method}
-
- #{rest_url_rewriter}
- /MarkLogic/rest-api/error-handler.xqy
- true
-
- })
-
- config.gsub!("@ml.rest-modules-db-xml",
- %Q{
-
- #{rest_modules_db}
-
-
-
-
- })
-
- config.gsub!("@ml.rest-modules-db-assignment",
- %Q{
-
- #{rest_modules_db}
-
- })
-
else
config.gsub!("@ml.rest-appserver", "")
config.gsub!("@ml.rest-modules-db-xml", "")
config.gsub!("@ml.rest-modules-db-assignment", "")
end
- config.gsub!("@ml.forest-data-dir-xml",
- %Q{
- @ml.forest-data-dir
- }) if @properties['ml.forest-data-dir'].present?
+ if @properties['ml.forest-data-dir'].present?
+ config.gsub!("@ml.forest-data-dir-xml",
+ %Q{
+ @ml.forest-data-dir
+ })
+ else
+ config.gsub!("@ml.forest-data-dir-xml", "")
+ end
if !@properties['ml.rewrite-resolves-globally'].nil?
config.gsub!("@ml.rewrite-resolves-globally",
@@ -2184,6 +2264,13 @@ def build_config(config_file)
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
+
@properties.sort {|x,y| y <=> x}.each do |k, v|
config.gsub!("@#{k}", v)
end
diff --git a/deploy/lib/xquery/setup.xqy b/deploy/lib/xquery/setup.xqy
index c838b954..8eac1511 100644
--- a/deploy/lib/xquery/setup.xqy
+++ b/deploy/lib/xquery/setup.xqy
@@ -391,6 +391,19 @@ declare function setup:get-rollback-config()
}
};
+declare function setup:suppress-comments($nodes) {
+ for $node in $nodes
+ return
+ typeswitch ($node)
+ case element() return
+ element { fn:node-name($node) } {
+ $node/@*,
+ setup:suppress-comments($node/node())
+ }
+ case comment() return ()
+ default return $node
+};
+
(: for backwards-compatibility :)
declare function setup:rewrite-config($import-configs as element(configuration)+) as element(configuration)
{
@@ -401,8 +414,8 @@ declare function setup:rewrite-config($import-configs as element(configuration)+
{
let $default-group := ($import-configs/@default-group, "Default")[1]
for $group in fn:distinct-values(
- ($import-configs/(gr:http-servers/gr:http-server | gr:xdbc-servers/gr:xdbc-server |
- gr:odbc-servers/gr:odbc-server | gr:task-server | db:databases/db:database)/@group, $default-group))
+ ($import-configs/(gr:http-servers/gr:http-server, gr:xdbc-servers/gr:xdbc-server,
+ gr:odbc-servers/gr:odbc-server, gr:task-server, db:databases/db:database)/@group, $default-group))
let $http-servers := $import-configs/gr:http-servers/gr:http-server[@group = $group or ($group = $default-group and fn:empty(@group))]
let $xdbc-servers := $import-configs/gr:xdbc-servers/gr:xdbc-server[@group = $group or ($group = $default-group and fn:empty(@group))]
let $odbc-servers := $import-configs/gr:odbc-servers/gr:odbc-server[@group = $group or ($group = $default-group and fn:empty(@group))]
@@ -432,7 +445,7 @@ declare function setup:rewrite-config($import-configs as element(configuration)+
},
- $import-configs/(node() except (gr:groups | gr:http-servers | gr:xdbc-servers | gr:odbc-servers | gr:task-server))
+ $import-configs/(node() except (gr:groups, gr:http-servers, gr:xdbc-servers, gr:odbc-servers, gr:task-server))
}
(: Check config on group consistency! :)
@@ -446,7 +459,7 @@ declare function setup:rewrite-config($import-configs as element(configuration)+
fn:concat("No hosts assigned to group ", $group, ", needed for app servers and forests!"))
(: all good :)
- return $config
+ return setup:suppress-comments($config)
};
declare function setup:do-setup($import-config as element(configuration)+) as item()*
diff --git a/deploy/sample/ml-config.sample.xml b/deploy/sample/ml-config.sample.xml
index 2c75cac7..7dbe4e02 100644
--- a/deploy/sample/ml-config.sample.xml
+++ b/deploy/sample/ml-config.sample.xml
@@ -425,15 +425,7 @@
@ml.schemas-db-xml
-
- @ml.ssl-certificate-template
- @ml.ssl-certificate-countryName
- @ml.ssl-certificate-stateOrProvinceName
- @ml.ssl-certificate-localityName
- @ml.ssl-certificate-organizationName
- @ml.ssl-certificate-organizationalUnitName
- @ml.ssl-certificate-emailAddress
-
+ @ml.ssl-certificate-xml