Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 56a5237

Browse files
committed
Merge branch 'issue_96' of https://github.com/paxtonhare/ml-app-deployer into paxtonhare-issue_96
Conflicts: src/main/java/com/marklogic/rest/util/RestConfig.java
2 parents 8dc410b + 958cafc commit 56a5237

File tree

14 files changed

+229
-9
lines changed

14 files changed

+229
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
src/test/resources/user.properties
99
setenv.bat
1010
src/test/resources/scaffold-test/
11+
.DS_Store

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: java
2+
jdk:
3+
- oraclejdk7
4+
sudo: true
5+
before_install:
6+
- echo 'America/Los_Angeles' | sudo tee /etc/timezone
7+
- sudo dpkg-reconfigure --frontend noninteractive tzdata
8+
install:
9+
- ./shared/dev-tasks/install-dependencies.sh
10+
script:
11+
- ./shared/dev-tasks/run-tests.sh
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
if [ "${TRAVIS_SECURE_ENV_VARS}" = "true" ] ; then
4+
./shared/dev-tasks/travis-install-ml.sh release
5+
./shared/dev-tasks/setup-marklogic.sh
6+
fi

shared/dev-tasks/run-tests.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
if [ "${TRAVIS_SECURE_ENV_VARS}" = "true" ] ; then
4+
cd ${TRAVIS_BUILD_DIR}
5+
./gradlew test -i
6+
fi

shared/dev-tasks/setup-marklogic.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
sudo /etc/init.d/MarkLogic start
4+
sleep 10
5+
curl -X POST -d "" http://localhost:8001/admin/v1/init
6+
sleep 10
7+
curl -X POST -H "Content-type: application/x-www-form-urlencoded" \
8+
--data "admin-username=admin" \
9+
--data "admin-password=admin" \
10+
--data "realm=public" \
11+
"http://localhost:8001/admin/v1/instance-admin"
12+
sleep 10

shared/dev-tasks/travis-install-ml.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
3+
# runs command from parameters and exits with the eoror code of the command
4+
# if it fails
5+
function successOrExit {
6+
"$@"
7+
local status=$?
8+
if [ $status -ne 0 ]; then
9+
echo "$1 exited with error: $status"
10+
exit $status
11+
fi
12+
}
13+
14+
set | grep TRAVIS
15+
16+
test $1 && arg1=$1
17+
if [[ $arg1 = 'release' ]]; then
18+
ver=${ML_VERSION}
19+
fname=MarkLogic-RHEL6-${ver}.x86_64.rpm
20+
fnamedeb="marklogic_"
21+
fnamedeb=$fnamedeb$ver
22+
suff="_amd64.deb"
23+
fnamedeb=$fnamedeb$suff
24+
25+
curl -c cookies.txt --data "email=${MLBUILD_USER}&password=${MLBUILD_PASSWORD}" https://developer.marklogic.com/login
26+
dl_link=$(curl -b cookies.txt --data "download=/download/binaries/8.0/${fname}" https://developer.marklogic.com/get-download-url | perl -pe 's/.*"path":"([^"]+).*/\1/')
27+
url="https://developer.marklogic.com${dl_link}"
28+
29+
echo "********* Downloading MarkLogic $ver"
30+
31+
successOrExit curl -k -o ./$fname $url
32+
33+
fname=$(pwd)/$fname
34+
35+
sudo apt-get update
36+
sudo apt-get install wajig alien rpm lsb-base dpkg-dev debhelper build-essential
37+
(cd /etc && sudo ln -s default sysconfig)
38+
sudo wajig rpminstall $fname
39+
40+
echo "********* MarkLogic $ver installed"
41+
else
42+
# find today
43+
day=$(date +"%Y%m%d")
44+
45+
# if the user passed a day string as a param then use it instead
46+
test $1 && day=$1
47+
# make a version number out of the date
48+
ver="8.0-$day"
49+
50+
echo "********* Downloading MarkLogic nightly $ver"
51+
52+
# fetch/install ML nightly
53+
fname="MarkLogic-$ver.x86_64.rpm"
54+
fnamedeb="marklogic_"
55+
fnamedeb=$fnamedeb$ver
56+
suff="_amd64.deb"
57+
fnamedeb=$fnamedeb$suff
58+
59+
url="https://root.marklogic.com/nightly/builds/linux64/rh6-intel64-80-test-1.marklogic.com/b8_0/pkgs.$day/$fname"
60+
61+
status=$(curl -k --anyauth -u $MLBUILD_USER:$MLBUILD_PASSWORD --head --write-out %{http_code} --silent --output /dev/null $url)
62+
if [[ $status = 200 ]]; then
63+
successOrExit curl -k --anyauth -u $MLBUILD_USER:$MLBUILD_PASSWORD -o ./$fname $url
64+
65+
fname=$(pwd)/$fname
66+
67+
sudo apt-get update
68+
sudo apt-get install alien dpkg-dev debhelper build-essential
69+
sudo alien -d -k $fname
70+
sudo dpkg -i $fnamedeb
71+
72+
echo "********* MarkLogic nightly $ver installed"
73+
else
74+
echo "CANNOT DOWNLOAD: status = $status for date $day (URL=\"$url\")"
75+
exit 1
76+
fi
77+
fi

src/main/java/com/marklogic/appdeployer/command/appservers/UpdateRestApiServersCommand.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,24 @@
1313
*/
1414
public class UpdateRestApiServersCommand extends AbstractCommand {
1515

16+
private String restApiFilename;
17+
1618
public UpdateRestApiServersCommand() {
1719
setExecuteSortOrder(SortOrderConstants.UPDATE_REST_API_SERVERS);
1820
}
1921

22+
public UpdateRestApiServersCommand(String restApiFilename) {
23+
this();
24+
this.restApiFilename = restApiFilename;
25+
}
26+
2027
/**
2128
* This uses a different file than that of creating a REST API, as the payload for /v1/rest-apis differs from that
2229
* of the /manage/v2/servers endpoint.
2330
*/
2431
@Override
2532
public void execute(CommandContext context) {
26-
File f = context.getAppConfig().getConfigDir().getRestApiServerFile();
33+
File f = findRestApiConfigFile(context);
2734
if (f.exists()) {
2835
AppConfig appConfig = context.getAppConfig();
2936

@@ -43,4 +50,11 @@ public void execute(CommandContext context) {
4350
}
4451
}
4552

53+
protected File findRestApiConfigFile(CommandContext context) {
54+
if (restApiFilename != null) {
55+
return new File(context.getAppConfig().getConfigDir().getBaseDir(), restApiFilename);
56+
} else {
57+
return context.getAppConfig().getConfigDir().getRestApiServerFile();
58+
}
59+
}
4660
}

src/main/java/com/marklogic/mgmt/security/AmpManager.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,33 @@ protected String[] getUpdateResourceParams(String payload) {
7979
return params.toArray(new String[] {});
8080
}
8181

82+
/**
83+
* In ML 8.0-5.1 deleting an amp fails if the database is specified on the
84+
* delete url
85+
*/
86+
@Override
87+
protected String[] getDeleteResourceParams(String payload) {
88+
List<String> params = new ArrayList<String>();
89+
params.add("document-uri");
90+
if (payloadParser.isJsonPayload(payload)) {
91+
JsonNode node = payloadParser.parseJson(payload);
92+
params.add(node.get("document-uri").asText());
93+
if (node.has("namespace")) {
94+
params.add("namespace");
95+
params.add(node.get("namespace").asText());
96+
}
97+
} else {
98+
Fragment f = new Fragment(payload);
99+
params.add(f.getElementValue("/node()/*[local-name(.) = 'document-uri']"));
100+
101+
String val = f.getElementValue("/node()/*[local-name(.) = 'namespace']");
102+
if (val != null) {
103+
params.add("namespace");
104+
params.add(val);
105+
}
106+
}
107+
return params.toArray(new String[] {}); }
108+
82109
public void setNamespace(String namespace) {
83110
this.namespace = namespace;
84111
}

src/main/java/com/marklogic/rest/util/RestConfig.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,13 @@ public String toString() {
3131
* e.g. when a mimetype has a plus in it, that plus needs to be encoded, but doing as %2B will result in the % being
3232
* double encoded. Unfortunately, it seems some encoding is still needed - e.g. for a pipeline like "Flexible Replication"
3333
* with a space in its name, the space must be encoded properly as a "+".
34-
*
34+
*
3535
* @param path
3636
* @return
3737
*/
3838
public URI buildUri(String path) {
39-
if (path.contains(" ")) {
40-
path = path.replace(" ", "+");
41-
}
4239
try {
43-
return new URI(String.format("%s://%s:%d%s", getScheme(), getHost(), getPort(), path));
40+
return new URI(String.format("%s://%s:%d%s", getScheme(), getHost(), getPort(), path.replace(" ", "+")));
4441
} catch (URISyntaxException ex) {
4542
throw new RuntimeException("Unable to build URI for path: " + path + "; cause: " + ex.getMessage(), ex);
4643
}

src/test/java/com/marklogic/appdeployer/command/admin/RequireAtLeastMl8Test.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.marklogic.appdeployer.command.admin;
22

33
import org.junit.Test;
4+
import org.junit.After;
45

56
import com.marklogic.appdeployer.AbstractAppDeployerTest;
67

@@ -11,4 +12,9 @@ public void testThatNoExceptionIsThrown() {
1112
initializeAppDeployer(new RequireAtLeastMl8Command());
1213
appDeployer.deploy(appConfig);
1314
}
15+
16+
@After
17+
public void teardown() {
18+
undeploySampleApp();
19+
}
1420
}

0 commit comments

Comments
 (0)