Skip to content

Commit 98f3f60

Browse files
committed
updated min 9.x to 9.0-1.1
1 parent a9c6ffd commit 98f3f60

File tree

35 files changed

+311
-189
lines changed

35 files changed

+311
-189
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This project allows you to deploy a skeleton Data Hub into MarkLogic. With some
2424
You need these to get started
2525

2626
- Java 8 JDK
27-
- MarkLogic 8.2 or greater, or 9.0 or greater
27+
- MarkLogic 8.0-7 or greater, or 9.0-1.1 or greater
2828
- Gradle 3.4 or greater **(Optional)**
2929

3030
### TL;DR

marklogic-data-hub/build.gradle

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
id 'java'
44
id 'maven-publish'
55
id 'com.jfrog.bintray' version '1.7.2'
6-
id 'com.marklogic.ml-gradle' version '3.1-alpha1'
6+
id 'com.marklogic.ml-gradle' version '3.1-alpha3'
77
id 'com.moowork.node' version '1.1.1'
88
}
99

@@ -25,11 +25,8 @@ ext.junitJupiterVersion = '5.0.0-RC3'
2525

2626
dependencies {
2727
compile 'com.marklogic:marklogic-client-api:4.0.2'
28-
compile('com.marklogic:ml-javaclient-util:3.1-alpha2')
2928
compile("com.marklogic:mlcp-util:0.3.0")
30-
compile ('com.marklogic:ml-app-deployer:3.1-alpha1') {
31-
exclude group: 'com.marklogic', module: 'ml-javaclient-util'
32-
}
29+
compile ('com.marklogic:ml-app-deployer:3.1-alpha3')
3330
compile 'commons-io:commons-io:2.4'
3431
compile 'org.apache.commons:commons-text:1.1'
3532

@@ -52,7 +49,7 @@ dependencies {
5249
testCompile 'org.easymock:easymock:3.4'
5350
testCompile 'ch.qos.logback:logback-classic:1.1.11'
5451
testCompile("com.marklogic:mlcp-util:0.3.0")
55-
testCompile("com.marklogic:mlcp:9.0.2") {
52+
testCompile("com.marklogic:mlcp:9.0.3") {
5653
exclude group: 'org.apache.avro', module: 'avro-tools'
5754
}
5855
}

marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import com.marklogic.mgmt.resource.databases.DatabaseManager;
4545
import com.marklogic.rest.util.Fragment;
4646
import com.marklogic.rest.util.ResourcesFragment;
47+
import org.apache.commons.lang3.StringUtils;
4748
import org.slf4j.Logger;
4849
import org.slf4j.LoggerFactory;
4950
import org.springframework.core.io.Resource;
@@ -160,10 +161,30 @@ public void validateServer() throws ServerValidationException {
160161
try {
161162
String versionString = getAdminManager().getServerVersion();
162163
int major = Integer.parseInt(versionString.replaceAll("([^.]+)\\..*", "$1"));
163-
if (major < 9) {
164+
if (major < 8) {
164165
throw new ServerValidationException("Invalid MarkLogic Server Version: " + versionString);
165166
}
166167
boolean isNightly = versionString.matches("[^-]+-(\\d{4})(\\d{2})(\\d{2})");
168+
if (major == 8) {
169+
String alteredString = versionString.replaceAll("[^\\d]+", "");
170+
if (alteredString.length() < 4) {
171+
alteredString = StringUtils.rightPad(alteredString, 4, "0");
172+
}
173+
int ver = Integer.parseInt(alteredString.substring(0, 4));
174+
if (!isNightly && ver < 8070) {
175+
throw new ServerValidationException("Invalid MarkLogic Server Version: " + versionString);
176+
}
177+
}
178+
if (major == 9) {
179+
String alteredString = versionString.replaceAll("[^\\d]+", "");
180+
if (alteredString.length() < 4) {
181+
alteredString = StringUtils.rightPad(alteredString, 4, "0");
182+
}
183+
int ver = Integer.parseInt(alteredString.substring(0, 4));
184+
if (!isNightly && ver < 9011) {
185+
throw new ServerValidationException("Invalid MarkLogic Server Version: " + versionString);
186+
}
187+
}
167188
if (isNightly) {
168189
String dateString = versionString.replaceAll("[^-]+-(\\d{4})(\\d{2})(\\d{2})", "$1-$2-$3");
169190
Date minDate = new GregorianCalendar(2017, 6, 1).getTime();
@@ -201,6 +222,12 @@ public void clearUserModules() {
201222
for (Resource r : resolver.getResources("classpath*:/ml-modules/options/*.xml")) {
202223
options.add(r.getFilename().replace(".xml", ""));
203224
}
225+
for (Resource r : resolver.getResources("classpath*:/ml-modules-traces/options/*.xml")) {
226+
options.add(r.getFilename().replace(".xml", ""));
227+
}
228+
for (Resource r : resolver.getResources("classpath*:/ml-modules-jobs/options/*.xml")) {
229+
options.add(r.getFilename().replace(".xml", ""));
230+
}
204231

205232
ArrayList<String> services = new ArrayList<>();
206233
for (Resource r : resolver.getResources("classpath*:/ml-modules/services/*.xqy")) {

marklogic-data-hub/src/main/java/com/marklogic/hub/Debugging.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.marklogic.client.extensions.ResourceManager;
55
import com.marklogic.client.extensions.ResourceServices.ServiceResult;
66
import com.marklogic.client.extensions.ResourceServices.ServiceResultIterator;
7+
import com.marklogic.client.io.Format;
78
import com.marklogic.client.io.StringHandle;
89
import com.marklogic.client.util.RequestParameters;
910

@@ -21,7 +22,7 @@ public Debugging(DatabaseClient client) {
2122
public void enable() {
2223
RequestParameters params = new RequestParameters();
2324
params.add("enable", "true");
24-
this.getServices().post(params, new StringHandle("{}"));
25+
this.getServices().post(params, new StringHandle("{}").withFormat(Format.JSON));
2526
}
2627

2728
/**
@@ -30,7 +31,7 @@ public void enable() {
3031
public void disable() {
3132
RequestParameters params = new RequestParameters();
3233
params.add("enable", "false");
33-
this.getServices().post(params, new StringHandle("{}"));
34+
this.getServices().post(params, new StringHandle("{}").withFormat(Format.JSON));
3435
}
3536

3637
/**

marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,12 @@ public HubProject getHubProject() {
201201
return this.hubProject;
202202
}
203203

204-
public File getHubModulesDeployTimestampFile() {
205-
return Paths.get(projectDir, ".tmp", HUB_MODULES_DEPLOY_TIMESTAMPS_PROPERTIES).toFile();
204+
public String getHubModulesDeployTimestampFile() {
205+
return Paths.get(projectDir, ".tmp", HUB_MODULES_DEPLOY_TIMESTAMPS_PROPERTIES).toString();
206206
}
207207

208-
public File getUserModulesDeployTimestampFile() {
209-
return Paths.get(projectDir, ".tmp", USER_MODULES_DEPLOY_TIMESTAMPS_PROPERTIES).toFile();
208+
public String getUserModulesDeployTimestampFile() {
209+
return Paths.get(projectDir, ".tmp", USER_MODULES_DEPLOY_TIMESTAMPS_PROPERTIES).toString();
210210
}
211211

212212
public File getUserContentDeployTimestampFile() {

marklogic-data-hub/src/main/java/com/marklogic/hub/Tracing.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.marklogic.client.extensions.ResourceManager;
55
import com.marklogic.client.extensions.ResourceServices.ServiceResult;
66
import com.marklogic.client.extensions.ResourceServices.ServiceResultIterator;
7+
import com.marklogic.client.io.Format;
78
import com.marklogic.client.io.StringHandle;
89
import com.marklogic.client.util.RequestParameters;
910

@@ -21,7 +22,7 @@ public Tracing(DatabaseClient client) {
2122
public void enable() {
2223
RequestParameters params = new RequestParameters();
2324
params.add("enable", "true");
24-
this.getServices().post(params, new StringHandle("{}"));
25+
this.getServices().post(params, new StringHandle("{}").withFormat(Format.JSON));
2526
}
2627

2728
/**
@@ -30,7 +31,7 @@ public void enable() {
3031
public void disable() {
3132
RequestParameters params = new RequestParameters();
3233
params.add("enable", "false");
33-
this.getServices().post(params, new StringHandle("{}"));
34+
this.getServices().post(params, new StringHandle("{}").withFormat(Format.JSON));
3435
}
3536

3637
/**

marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/LoadHubModulesCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private TokenReplacer buildModuleTokenReplacer(AppConfig appConfig) {
5050

5151
@Override
5252
public void execute(CommandContext context) {
53-
File timestampFile = hubConfig.getHubModulesDeployTimestampFile();
53+
String timestampFile = hubConfig.getHubModulesDeployTimestampFile();
5454
PropertiesModuleManager propsManager = new PropertiesModuleManager(timestampFile);
5555
propsManager.deletePropertiesFile();
5656

marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/LoadUserModulesCommand.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,39 +56,38 @@ public void setForceLoad(boolean forceLoad) {
5656
public LoadUserModulesCommand(HubConfig hubConfig) {
5757
setExecuteSortOrder(SortOrderConstants.LOAD_MODULES + 1);
5858
this.hubConfig = hubConfig;
59+
60+
this.threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
61+
this.threadPoolTaskExecutor.setCorePoolSize(16);
62+
// 10 minutes should be plenty of time to wait for REST API modules to be loaded
63+
this.threadPoolTaskExecutor.setAwaitTerminationSeconds(60 * 10);
64+
this.threadPoolTaskExecutor.setWaitForTasksToCompleteOnShutdown(true);
65+
this.threadPoolTaskExecutor.afterPropertiesSet();
5966
}
6067

6168
private PropertiesModuleManager getModulesManager() {
62-
File timestampFile = hubConfig.getUserModulesDeployTimestampFile();
69+
String timestampFile = hubConfig.getUserModulesDeployTimestampFile();
6370
PropertiesModuleManager pmm = new PropertiesModuleManager(timestampFile);
6471
if (forceLoad) {
6572
pmm.deletePropertiesFile();
6673
}
6774
return pmm;
6875
}
6976

70-
private AssetFileLoader getAssetLoader(AppConfig config) {
71-
AssetFileLoader assetFileLoader = new AssetFileLoader(hubConfig.newModulesDbClient());
77+
private AssetFileLoader getAssetFileLoader(AppConfig config, PropertiesModuleManager moduleManager) {
78+
AssetFileLoader assetFileLoader = new AssetFileLoader(hubConfig.newModulesDbClient(), moduleManager);
7279
assetFileLoader.addDocumentFileProcessor(new CacheBusterDocumentFileProcessor());
80+
assetFileLoader.addFileFilter(new HubFileFilter());
81+
assetFileLoader.setPermissions(config.getModulePermissions());
7382
return assetFileLoader;
7483
}
7584

7685
private DefaultModulesLoader getStagingModulesLoader(AppConfig config) {
77-
AssetFileLoader assetLoader = getAssetLoader(config);
78-
assetLoader.addFileFilter(new HubFileFilter());
79-
assetLoader.setPermissions(config.getModulePermissions());
80-
81-
this.threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
82-
this.threadPoolTaskExecutor.setCorePoolSize(16);
83-
84-
// 10 minutes should be plenty of time to wait for REST API modules to be loaded
85-
this.threadPoolTaskExecutor.setAwaitTerminationSeconds(60 * 10);
86-
this.threadPoolTaskExecutor.setWaitForTasksToCompleteOnShutdown(true);
87-
88-
this.threadPoolTaskExecutor.afterPropertiesSet();
86+
PropertiesModuleManager moduleManager = getModulesManager();
87+
AssetFileLoader assetFileLoader = getAssetFileLoader(config, moduleManager);
8988

90-
DefaultModulesLoader modulesLoader = new DefaultModulesLoader(assetLoader);
91-
modulesLoader.setModulesManager(getModulesManager());
89+
DefaultModulesLoader modulesLoader = new DefaultModulesLoader(assetFileLoader);
90+
modulesLoader.setModulesManager(moduleManager);
9291
modulesLoader.setTaskExecutor(this.threadPoolTaskExecutor);
9392
modulesLoader.setShutdownTaskExecutorAfterLoadingModules(false);
9493

marklogic-data-hub/src/main/java/com/marklogic/hub/flow/impl/FlowRunnerImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.marklogic.client.datamovement.impl.QueryBatcherImpl;
2525
import com.marklogic.client.extensions.ResourceManager;
2626
import com.marklogic.client.extensions.ResourceServices;
27+
import com.marklogic.client.io.Format;
2728
import com.marklogic.client.io.StringHandle;
2829
import com.marklogic.client.util.RequestParameters;
2930
import com.marklogic.hub.HubConfig;
@@ -341,7 +342,7 @@ public RunFlowResponse run(String jobId, String[] items, Map<String, Object> opt
341342
ObjectMapper objectMapper = new ObjectMapper();
342343
params.put("options", objectMapper.writeValueAsString(options));
343344
}
344-
ResourceServices.ServiceResultIterator resultItr = this.getServices().post(params, new StringHandle("{}"));
345+
ResourceServices.ServiceResultIterator resultItr = this.getServices().post(params, new StringHandle("{}").withFormat(Format.JSON));
345346
if (resultItr == null || ! resultItr.hasNext()) {
346347
resp = new RunFlowResponse();
347348
}

marklogic-data-hub/src/main/resources/ml-modules/root/com.marklogic.hub/dhf.xqy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ declare function dhf:run-writer(
9898
$options as map:map)
9999
{
100100
trace:set-plugin-label("writer"),
101+
trace:reset-plugin-input(),
101102
trace:set-plugin-input("envelope", $envelope),
102103
flow:run-writer($writer-function, $id, $envelope, $options)
103104
};

0 commit comments

Comments
 (0)