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

Commit 91a4597

Browse files
committed
#81 Merging in @grechaw work for loading schemas
1 parent 09ca0de commit 91a4597

File tree

18 files changed

+295
-111
lines changed

18 files changed

+295
-111
lines changed

build.gradle

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ targetCompatibility = "1.7"
1111

1212
repositories {
1313
jcenter()
14+
mavenLocal()
1415
}
1516

1617
dependencies {
17-
compile 'com.marklogic:ml-javaclient-util:2.5'
18+
compile 'com.marklogic:ml-javaclient-util:2.8.0'
1819
compile 'jaxen:jaxen:1.1.6'
1920
compile 'org.apache.httpcomponents:httpclient:4.3.5'
2021
compile 'org.springframework:spring-web:4.1.5.RELEASE'
@@ -64,4 +65,10 @@ if (project.hasProperty("myBintrayUser")) {
6465
}
6566
}
6667
}
67-
}
68+
}
69+
70+
71+
72+
task wrapper(type: Wrapper) {
73+
gradleVersion = '2.12'
74+
}

gradle/wrapper/gradle-wrapper.jar

2.56 KB
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon May 25 15:31:23 EDT 2015
1+
#Tue Mar 22 14:27:38 EDT 2016
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-bin.zip

gradlew

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ case "`uname`" in
4242
;;
4343
esac
4444

45-
# For Cygwin, ensure paths are in UNIX format before anything is touched.
46-
if $cygwin ; then
47-
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48-
fi
49-
5045
# Attempt to set APP_HOME
5146
# Resolve links: $0 may be a link
5247
PRG="$0"
@@ -61,9 +56,9 @@ while [ -h "$PRG" ] ; do
6156
fi
6257
done
6358
SAVED="`pwd`"
64-
cd "`dirname \"$PRG\"`/" >&-
59+
cd "`dirname \"$PRG\"`/" >/dev/null
6560
APP_HOME="`pwd -P`"
66-
cd "$SAVED" >&-
61+
cd "$SAVED" >/dev/null
6762

6863
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
6964

@@ -114,6 +109,7 @@ fi
114109
if $cygwin ; then
115110
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116111
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112+
JAVACMD=`cygpath --unix "$JAVACMD"`
117113

118114
# We build the pattern for arguments to be converted via cygpath
119115
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`

gradlew.bat

Lines changed: 90 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,90 @@
1-
@if "%DEBUG%" == "" @echo off
2-
@rem ##########################################################################
3-
@rem
4-
@rem Gradle startup script for Windows
5-
@rem
6-
@rem ##########################################################################
7-
8-
@rem Set local scope for the variables with windows NT shell
9-
if "%OS%"=="Windows_NT" setlocal
10-
11-
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12-
set DEFAULT_JVM_OPTS=
13-
14-
set DIRNAME=%~dp0
15-
if "%DIRNAME%" == "" set DIRNAME=.
16-
set APP_BASE_NAME=%~n0
17-
set APP_HOME=%DIRNAME%
18-
19-
@rem Find java.exe
20-
if defined JAVA_HOME goto findJavaFromJavaHome
21-
22-
set JAVA_EXE=java.exe
23-
%JAVA_EXE% -version >NUL 2>&1
24-
if "%ERRORLEVEL%" == "0" goto init
25-
26-
echo.
27-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28-
echo.
29-
echo Please set the JAVA_HOME variable in your environment to match the
30-
echo location of your Java installation.
31-
32-
goto fail
33-
34-
:findJavaFromJavaHome
35-
set JAVA_HOME=%JAVA_HOME:"=%
36-
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37-
38-
if exist "%JAVA_EXE%" goto init
39-
40-
echo.
41-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42-
echo.
43-
echo Please set the JAVA_HOME variable in your environment to match the
44-
echo location of your Java installation.
45-
46-
goto fail
47-
48-
:init
49-
@rem Get command-line arguments, handling Windowz variants
50-
51-
if not "%OS%" == "Windows_NT" goto win9xME_args
52-
if "%@eval[2+2]" == "4" goto 4NT_args
53-
54-
:win9xME_args
55-
@rem Slurp the command line arguments.
56-
set CMD_LINE_ARGS=
57-
set _SKIP=2
58-
59-
:win9xME_args_slurp
60-
if "x%~1" == "x" goto execute
61-
62-
set CMD_LINE_ARGS=%*
63-
goto execute
64-
65-
:4NT_args
66-
@rem Get arguments from the 4NT Shell from JP Software
67-
set CMD_LINE_ARGS=%$
68-
69-
:execute
70-
@rem Setup the command line
71-
72-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73-
74-
@rem Execute Gradle
75-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76-
77-
:end
78-
@rem End local scope for the variables with windows NT shell
79-
if "%ERRORLEVEL%"=="0" goto mainEnd
80-
81-
:fail
82-
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83-
rem the _cmd.exe /c_ return code!
84-
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85-
exit /b 1
86-
87-
:mainEnd
88-
if "%OS%"=="Windows_NT" endlocal
89-
90-
:omega
1+
@if "%DEBUG%" == "" @echo off
2+
@rem ##########################################################################
3+
@rem
4+
@rem Gradle startup script for Windows
5+
@rem
6+
@rem ##########################################################################
7+
8+
@rem Set local scope for the variables with windows NT shell
9+
if "%OS%"=="Windows_NT" setlocal
10+
11+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12+
set DEFAULT_JVM_OPTS=
13+
14+
set DIRNAME=%~dp0
15+
if "%DIRNAME%" == "" set DIRNAME=.
16+
set APP_BASE_NAME=%~n0
17+
set APP_HOME=%DIRNAME%
18+
19+
@rem Find java.exe
20+
if defined JAVA_HOME goto findJavaFromJavaHome
21+
22+
set JAVA_EXE=java.exe
23+
%JAVA_EXE% -version >NUL 2>&1
24+
if "%ERRORLEVEL%" == "0" goto init
25+
26+
echo.
27+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28+
echo.
29+
echo Please set the JAVA_HOME variable in your environment to match the
30+
echo location of your Java installation.
31+
32+
goto fail
33+
34+
:findJavaFromJavaHome
35+
set JAVA_HOME=%JAVA_HOME:"=%
36+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37+
38+
if exist "%JAVA_EXE%" goto init
39+
40+
echo.
41+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42+
echo.
43+
echo Please set the JAVA_HOME variable in your environment to match the
44+
echo location of your Java installation.
45+
46+
goto fail
47+
48+
:init
49+
@rem Get command-line arguments, handling Windows variants
50+
51+
if not "%OS%" == "Windows_NT" goto win9xME_args
52+
if "%@eval[2+2]" == "4" goto 4NT_args
53+
54+
:win9xME_args
55+
@rem Slurp the command line arguments.
56+
set CMD_LINE_ARGS=
57+
set _SKIP=2
58+
59+
:win9xME_args_slurp
60+
if "x%~1" == "x" goto execute
61+
62+
set CMD_LINE_ARGS=%*
63+
goto execute
64+
65+
:4NT_args
66+
@rem Get arguments from the 4NT Shell from JP Software
67+
set CMD_LINE_ARGS=%$
68+
69+
:execute
70+
@rem Setup the command line
71+
72+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73+
74+
@rem Execute Gradle
75+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76+
77+
:end
78+
@rem End local scope for the variables with windows NT shell
79+
if "%ERRORLEVEL%"=="0" goto mainEnd
80+
81+
:fail
82+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83+
rem the _cmd.exe /c_ return code!
84+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85+
exit /b 1
86+
87+
:mainEnd
88+
if "%OS%"=="Windows_NT" endlocal
89+
90+
:omega

src/main/java/com/marklogic/appdeployer/AppConfig.java

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@ public class AppConfig {
5050
* The default path from which modules will be loaded into a modules database.
5151
*/
5252
public final static String DEFAULT_MODULES_PATH = "src/main/ml-modules";
53+
public final static String DEFAULT_SCHEMAS_PATH = "src/main/ml-schemas";
5354

5455
public final static String DEFAULT_HOST = "localhost";
5556
public final static String DEFAULT_GROUP = "Default";
5657

5758
private String name = DEFAULT_APP_NAME;
5859
private String host = DEFAULT_HOST;
59-
60+
6061
// Username/password combo for using the client REST API - e.g. to load modules
6162
private String restAdminUsername = DEFAULT_USERNAME;
6263
private String restAdminPassword = DEFAULT_PASSWORD;
@@ -78,6 +79,7 @@ public class AppConfig {
7879
private String schemasDatabaseName;
7980

8081
private List<String> modulePaths;
82+
private String schemasPath;
8183
private ConfigDir configDir;
8284

8385
// Passed into the TokenReplacer that subclasses of AbstractCommand use
@@ -100,14 +102,20 @@ public class AppConfig {
100102
// Comma-delimited string used for configuring forest replicas
101103
private String databaseNamesAndReplicaCounts;
102104

103-
public AppConfig() {
104-
this(DEFAULT_MODULES_PATH);
105+
106+
public AppConfig() {
107+
this(DEFAULT_MODULES_PATH, DEFAULT_SCHEMAS_PATH);
105108
}
106109

107-
public AppConfig(String defaultModulePath) {
110+
public AppConfig(String defaultModulePath) {
111+
this(defaultModulePath, DEFAULT_SCHEMAS_PATH);
112+
}
113+
114+
public AppConfig(String defaultModulePath, String defaultSchemasPath) {
108115
modulePaths = new ArrayList<String>();
109116
modulePaths.add(defaultModulePath);
110117
configDir = new ConfigDir();
118+
schemasPath = defaultSchemasPath;
111119
}
112120

113121
public void setSimpleSslConfig() {
@@ -135,6 +143,18 @@ public DatabaseClient newTestDatabaseClient() {
135143
return DatabaseClientFactory.newClient(getHost(), getTestRestPort(), getRestAdminUsername(),
136144
getRestAdminPassword(), getRestAuthentication(), getRestSslContext(), getRestSslHostnameVerifier());
137145
}
146+
147+
/**
148+
* Like newDatabaseClient, but connects to schemas database.
149+
*
150+
* @return
151+
*/
152+
public DatabaseClient newSchemasDatabaseClient() {
153+
return DatabaseClientFactory.newClient(getHost(), getRestPort(), getSchemasDatabaseName(),
154+
getRestAdminUsername(), getRestAdminPassword(), getRestAuthentication(),
155+
getRestSslContext(), getRestSslHostnameVerifier());
156+
}
157+
138158

139159
/**
140160
* @return an XccAssetLoader based on the configuration properties in this class
@@ -225,7 +245,7 @@ public String getTriggersDatabaseName() {
225245
public String getSchemasDatabaseName() {
226246
return schemasDatabaseName != null ? schemasDatabaseName : name + "-schemas";
227247
}
228-
248+
229249
/**
230250
* @return the name of the application, which is then used to generate app server and database names unless those
231251
* are set via their respective properties
@@ -294,6 +314,17 @@ public void setTestRestPort(Integer testRestPort) {
294314
this.testRestPort = testRestPort;
295315
}
296316

317+
/**
318+
* @return a list of all the paths from which modules should be loaded into a REST API server modules database
319+
*/
320+
public String getSchemasPath() {
321+
return schemasPath;
322+
}
323+
324+
public void setSchemasPath(String schemasPath) {
325+
this.schemasPath = schemasPath;
326+
}
327+
297328
/**
298329
* @return a list of all the paths from which modules should be loaded into a REST API server modules database
299330
*/
@@ -458,5 +489,4 @@ public FileFilter getAssetFileFilter() {
458489
public void setAssetFileFilter(FileFilter assetFileFilter) {
459490
this.assetFileFilter = assetFileFilter;
460491
}
461-
462492
}

src/main/java/com/marklogic/appdeployer/DefaultAppConfigFactory.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ public AppConfig newAppConfig() {
3535
logger.info("Config dir: " + prop);
3636
c.setConfigDir(new ConfigDir(new File(prop)));
3737
}
38+
39+
prop = getProperty("mlSchemasPath");
40+
if (prop != null) {
41+
logger.info("Schemas path: " + prop);
42+
c.setSchemasPath(prop);
43+
}
3844

3945
prop = getProperty("mlHost");
4046
if (prop != null) {

src/main/java/com/marklogic/appdeployer/command/SortOrderConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public abstract class SortOrderConstants {
2424
public static Integer UPDATE_REST_API_SERVERS = 250;
2525
public static Integer DEPLOY_OTHER_SERVERS = 300;
2626

27+
// Module code may depend on schemas, but not vice-versa.
28+
public static Integer LOAD_SCHEMAS = 350;
29+
2730
// Modules have to be loaded after the REST API server has been updated, for if the deployer is expecting to load
2831
// modules via SSL, then the REST API server must already be configured with a certificate template
2932
public static Integer LOAD_MODULES = 400;

src/main/java/com/marklogic/appdeployer/command/modules/LoadModulesCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ protected void loadModulesIntoTestServer(CommandContext context) {
9494
}
9595

9696
protected ModulesLoader buildTestModulesLoader(CommandContext context) {
97-
// Don't need an XccAssetLoader here, as only options/properties are loaded for the test server
98-
DefaultModulesLoader l = new DefaultModulesLoader(null);
97+
// Don't need an asset loader here, as only options/properties are loaded for the test server
98+
DefaultModulesLoader l = new DefaultModulesLoader();
9999
l.setModulesManager(null);
100100
return l;
101101
}

0 commit comments

Comments
 (0)