Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
#188 Correcting the way properties files are deployed. Note that the …
Browse files Browse the repository at this point in the history
…format of the properties.xml file is different and will need to be updated for existing projects.
  • Loading branch information
dmcassel committed Mar 10, 2014
1 parent f84222a commit 4787694
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 25 deletions.
26 changes: 26 additions & 0 deletions deploy/lib/ml_rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,32 @@ def get_files(path, data = [])
data
end

def install_properties(path)
if (File.exists?(path))
headers = {
'Content-Type' => 'application/xml'
}

data = [path]

data.each_with_index do |d, i|
file = open(d, "rb")
contents = file.read

# @logger.debug "methods: #{methods}"
url = "http://#{@hostname}:#{@port}/v1/config/properties"

@logger.debug "url: #{url}"
r = go url, "put", headers, nil, contents
if (r.code.to_i < 200 && r.code.to_i > 206)
@logger.error("code: #{r.code.to_i} body:#{r.body}")
end
end
else
@logger.error "#{path} does not exist"
end
end

def install_extensions(path)
if (File.exists?(path))
headers = {
Expand Down
8 changes: 7 additions & 1 deletion deploy/lib/server_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,8 @@ def deploy_modules
end

# REST API applications need some files put into a collection.
# Note that this is for extensions and transforms captured as-is from a modules database. The normal
# deploy process takes care of this for files under rest-api/.
if ['rest', 'hybrid'].include? @properties["ml.app-type"]
r = execute_query %Q{
xquery version "1.0-ml";
Expand All @@ -915,7 +917,11 @@ def deploy_modules
end

if (@properties.has_key?('ml.rest-options.dir') && File.exist?(@properties['ml.rest-options.dir']))
load_data @properties['ml.rest-options.dir'],
prop_path = "#{@properties['ml.rest-options.dir']}/properties.xml"
if (File.exist?(prop_path))
mlRest.install_properties(ServerConfig.expand_path(prop_path))
end
load_data "#{@properties['ml.rest-options.dir']}/options",
:add_prefix => "/#{@properties['ml.group']}/#{@properties['ml.app-name']}/rest-api",
:remove_prefix => @properties['ml.rest-options.dir'],
:db => rest_modules_db
Expand Down
32 changes: 8 additions & 24 deletions deploy/sample/properties.sample.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<map:map xmlns:map="http://marklogic.com/xdmp/map" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<map:entry key="content-versions">
<map:value xsi:type="xs:string">none</map:value>
</map:entry>
<map:entry key="validate-options">
<map:value xsi:type="xs:boolean">true</map:value>
</map:entry>
<map:entry key="document-transform-out">
<map:value xsi:type="xs:string"/>
</map:entry>
<map:entry key="debug">
<map:value xsi:type="xs:boolean">false</map:value>
</map:entry>
<map:entry key="error-format">
<map:value xsi:type="xs:string">xml</map:value>
</map:entry>
<map:entry key="validate-queries">
<map:value xsi:type="xs:boolean">false</map:value>
</map:entry>
<map:entry key="can-copy">
<map:value xsi:type="xs:boolean">true</map:value>
</map:entry>
</map:map>
<properties xmlns="http://marklogic.com/rest-api">
<content-versions>none</content-versions>
<validate-options>true</validate-options>
<document-transform-out></document-transform-out>
<debug>false</debug>
<error-format>xml</error-format>
<validate-queries>false</validate-queries>
</properties>

0 comments on commit 4787694

Please sign in to comment.