Skip to content

Commit 1bcf6b4

Browse files
committed
DHFPROD-3448: fix pass at trying to adapt 2.x to 9 latest
1 parent 49b38e5 commit 1bcf6b4

File tree

12 files changed

+4229
-2054
lines changed

12 files changed

+4229
-2054
lines changed

marklogic-data-hub/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ ext.junitJupiterVersion = '5.0.0-RC3'
2525

2626
dependencies {
2727
compile 'com.marklogic:marklogic-client-api:4.0.3.1'
28-
compile 'com.marklogic:mlcp-util:0.3.0'
29-
compile 'com.marklogic:ml-app-deployer:3.4.0'
28+
compile 'com.marklogic:mlcp-util:0.9.0'
29+
compile 'com.marklogic:ml-app-deployer:3.10.1'
3030
compile 'commons-io:commons-io:2.4'
3131
compile 'org.apache.commons:commons-text:1.1'
3232

@@ -48,8 +48,8 @@ dependencies {
4848
testCompile 'org.hamcrest:hamcrest-junit:2.0.0.0'
4949
testCompile 'org.easymock:easymock:3.4'
5050
testCompile 'ch.qos.logback:logback-classic:1.1.11'
51-
testCompile("com.marklogic:mlcp-util:0.3.0")
52-
testCompile("com.marklogic:mlcp:9.0.3") {
51+
testCompile("com.marklogic:mlcp-util:0.9.0")
52+
testCompile("com.marklogic:mlcp:10.0.2") {
5353
exclude group: 'org.apache.avro', module: 'avro-tools'
5454
}
5555
}

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

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,31 +152,46 @@ public boolean isServerVersionValid(String versionString) {
152152
versionString = new Versions(hubConfig).getMarkLogicVersion();
153153
}
154154
int major = Integer.parseInt(versionString.replaceAll("([^.]+)\\..*", "$1"));
155-
if (major < 9) {
155+
if (major != 9) {
156156
return false;
157157
}
158158
boolean isNightly = versionString.matches("[^-]+-(\\d{4})(\\d{2})(\\d{2})");
159-
if (major == 9) {
160-
String alteredString = versionString.replaceAll("[^\\d]+", "");
161-
if (alteredString.length() < 4) {
162-
alteredString = StringUtils.rightPad(alteredString, 4, "0");
163-
}
164-
int ver = Integer.parseInt(alteredString.substring(0, 4));
165-
if (!isNightly && ver < 9011) {
166-
return false;
167-
}
159+
160+
//Support any 9.0 version >= 9.1-1.
161+
int minor = 0;
162+
int hotFixNum = 0;
163+
164+
//Extract minor version in cases where versions is of type 9.0-6.2 or 9.0-6
165+
if(versionString.matches("^.*-(.+)\\.(.*)")) {
166+
minor = Integer.parseInt(versionString.replaceAll("^.*-(.+)\\..*", "$1"));
167+
hotFixNum = Integer.parseInt(versionString.replaceAll("^.*-(.+)\\.(.*)", "$2"));
168+
}
169+
else if(versionString.matches("^.*-(.+)$")){
170+
minor = Integer.parseInt(versionString.replaceAll("^.*-(.+)$", "$1"));
171+
}
172+
//left pad minor version with 0 if it is < 10
173+
String modifiedMinor = minor < 10 ? StringUtils.leftPad(String.valueOf(minor), 2, "0"):String.valueOf(minor) ;
174+
175+
//left pad hotFixNum with 0 if it is < 10
176+
String modifiedHotFixNum = hotFixNum < 10 ? StringUtils.leftPad(String.valueOf(hotFixNum), 2, "0"):String.valueOf(hotFixNum) ;
177+
String alteredString = StringUtils.join(modifiedMinor, modifiedHotFixNum);
178+
int ver = Integer.parseInt(alteredString);
179+
180+
//ver >= 500 => 9.1-1 and above is supported
181+
if (!isNightly && ver < 100) {
182+
return false;
168183
}
169184
if (isNightly) {
170185
String dateString = versionString.replaceAll("[^-]+-(\\d{4})(\\d{2})(\\d{2})", "$1-$2-$3");
171-
Date minDate = new GregorianCalendar(2017, 6, 1).getTime();
186+
//Support all 9.0-nightly on or after 5/5/2018
187+
Date minDate = new GregorianCalendar(2018, Calendar.MAY, 5).getTime();
172188
Date date = new SimpleDateFormat("y-M-d").parse(dateString);
173189
if (date.before(minDate)) {
174190
return false;
175191
}
176192
}
177193

178-
}
179-
catch(Exception e) {
194+
} catch (Exception e) {
180195
throw new ServerValidationException(e.toString());
181196
}
182197
return true;

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
@@ -66,7 +66,7 @@ public void execute(CommandContext context) {
6666
assetFileLoader.setDocumentFileReader(jarDocumentFileReader);
6767

6868
DefaultModulesLoader modulesLoader = new DefaultModulesLoader(assetFileLoader);
69-
modulesLoader.addFailureListener(throwable -> {
69+
modulesLoader.addFailureListener((throwable, client) -> {
7070
// ensure we throw the first exception
7171
if (caughtException == null) {
7272
caughtException = throwable;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ declare function flow:run-flow(
253253
$options as map:map)
254254
{
255255
(: assert that we are in query mode :)
256-
let $_must_run_in_query_mode as xs:unsignedLong := xdmp:request-timestamp()
256+
(: )let $_must_run_in_query_mode as xs:unsignedLong := xdmp:request-timestamp() :)
257257

258258
(: configure the run context :)
259259
let $_ := (

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ declare function hent:dump-search-options($entities as json:array)
103103
{
104104
let $uber-model := hent:uber-model(json:array-values($entities) ! xdmp:to-json(.)/object-node())
105105
return
106-
(: call fix-options because of https://github.com/marklogic/entity-services/issues/359 :)
107-
hent:fix-options(es:search-options-generate($uber-model))
106+
es:search-options-generate($uber-model)
108107
};
109108

110109
declare function hent:dump-indexes($entities as json:array)

marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,17 @@ public void testInvalidServer9nightly() {
146146

147147
@Test
148148
public void testValidateServer9() {
149-
assertFalse(dh.isServerVersionValid("9.0"));
149+
assertFalse(dh.isServerVersionValid("9.0-1"));
150150
}
151151

152152
@Test
153-
public void testValidateServer9011() {
154-
assertTrue(dh.isServerVersionValid("9.0-1.1"));
153+
public void testValidateServer90102() {
154+
assertTrue(dh.isServerVersionValid("9.0-10.2"));
155155
}
156156

157157
@Test
158158
public void testValidateServerBeyond9() {
159-
assertTrue(dh.isServerVersionValid("9.0-2"));
159+
assertTrue(dh.isServerVersionValid("9.0-20170719"));
160160
}
161161

162162
@Test

0 commit comments

Comments
 (0)