@@ -1046,6 +1046,8 @@ def deploy
10461046 deploy_triggers
10471047 when 'rest-config'
10481048 deploy_rest_config
1049+ when 'config'
1050+ deploy_config
10491051 else
10501052 raise HelpException . new ( "deploy" , "Invalid WHAT" )
10511053 end
@@ -1863,12 +1865,12 @@ def modules_databases
18631865 def deploy_modules
18641866 deploy_src ( )
18651867 deploy_rest ( )
1868+ deploy_config ( )
18661869 end
18671870
18681871 def deploy_src
18691872 test_dir = @properties [ 'ml.xquery-test.dir' ]
18701873 xquery_dir = @properties [ 'ml.xquery.dir' ]
1871- # modules_db = @properties['ml.modules-db']
18721874 app_config_file = File . join xquery_dir , "/app/config/config.xqy"
18731875 test_config_file = File . join test_dir , "/test-config.xqy"
18741876 load_html_as_xml = @properties [ 'ml.load-html-as-xml' ]
@@ -1971,6 +1973,54 @@ def deploy_src
19711973 end
19721974 end
19731975
1976+ def deploy_config
1977+ xquery_dir = @properties [ 'ml.xquery.dir' ]
1978+ app_configs = @properties [ 'ml.application-conf-file' ]
1979+ total_count = 0
1980+
1981+ modules_databases . each do |dest_db |
1982+ if dest_db == "filesystem"
1983+ logger . info "Skipping deployment of configurations to #{ dest_db } .."
1984+ break
1985+ end
1986+
1987+ src_permissions = permissions ( @properties [ 'ml.app-role' ] , Roxy ::ContentCapability ::ERU )
1988+
1989+ if [ 'rest' , 'hybrid' ] . include? @properties [ "ml.app-type" ]
1990+ # This app uses the REST API, so grant permissions to the rest roles. This allows REST extensions to call
1991+ # modules not deployed through the REST API.
1992+ # These roles are present in MarkLogic 6+.
1993+ src_permissions . push permissions ( 'rest-admin' , Roxy ::ContentCapability ::RU )
1994+ src_permissions . push permissions ( 'rest-extension-user' , Roxy ::ContentCapability ::EXECUTE )
1995+ src_permissions . flatten!
1996+ end
1997+
1998+ @logger . debug ( "source permissions: #{ src_permissions } " )
1999+
2000+ if app_configs . present?
2001+ logger . info "Deploying application configurations"
2002+ app_configs . split ( ',' ) . each do |item |
2003+ buffer = File . read item
2004+ replace_properties ( buffer , File . basename ( item ) )
2005+ item_name = item
2006+ if item . start_with? ( "src/" )
2007+ item_name = item [ 4 , item . length ]
2008+ end
2009+ item_name = '/' + item_name
2010+ logger . info "deploying application configuration #{ item } with name #{ item_name } on #{ dest_db } "
2011+ total_count += xcc . load_buffer item_name ,
2012+ buffer ,
2013+ :db => dest_db ,
2014+ :add_prefix => File . join ( @properties [ "ml.modules-root" ] , "app/config/" ) ,
2015+ :permissions => src_permissions
2016+ end
2017+ logger . info "Done deploying application configurations"
2018+ end
2019+
2020+ logger . info "\n Loaded #{ total_count } #{ pluralize ( total_count , "document" , "documents" ) } from #{ xquery_dir } to #{ xcc . hostname } :#{ xcc . port } /#{ dest_db } at #{ DateTime . now . strftime ( '%m/%d/%Y %I:%M:%S %P' ) } \n "
2021+ end
2022+ end
2023+
19742024 def deploy_rest
19752025 # Deploy options, extensions to the REST API server
19762026 if [ 'rest' , 'hybrid' ] . include? @properties [ "ml.app-type" ]
0 commit comments