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

Commit 9e32edd

Browse files
authored
Merge pull request #498 from marklogic/dev
Merging dev into master for 4.6.1
2 parents 6273b76 + 54c098a commit 9e32edd

File tree

7 files changed

+54
-21
lines changed

7 files changed

+54
-21
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ plugins {
88
}
99

1010
group = "com.marklogic"
11-
version = "4.6.0"
11+
version = "4.6.1"
1212

1313
java {
1414
sourceCompatibility = 1.8

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ It is not intended to be used to build this project.
1212
<modelVersion>4.0.0</modelVersion>
1313
<groupId>com.marklogic</groupId>
1414
<artifactId>ml-app-deployer</artifactId>
15-
<version>4.6.0</version>
15+
<version>4.6.1</version>
1616
<name>com.marklogic:ml-app-deployer</name>
1717
<description>Java client for the MarkLogic REST Management API and for deploying applications to MarkLogic</description>
1818
<url>https://github.com/marklogic/ml-app-deployer</url>

src/main/java/com/marklogic/appdeployer/command/forests/DeployCustomForestsCommand.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,19 @@ public DeployCustomForestsCommand() {
4949

5050
@Override
5151
public void execute(CommandContext context) {
52-
Configuration configuration = null;
53-
if (context.getAppConfig().getCmaConfig().isDeployForests()) {
54-
configuration = new Configuration();
55-
}
56-
5752
for (ConfigDir configDir : context.getAppConfig().getConfigDirs()) {
5853
File dir = new File(configDir.getBaseDir(), customForestsPath);
5954
if (dir != null && dir.exists()) {
6055
payloadParser = new PayloadParser();
6156
for (File f : dir.listFiles()) {
6257
if (f.isDirectory()) {
63-
processDirectory(f, context, configuration);
58+
processDirectory(f, context);
6459
}
6560
}
6661
} else {
6762
logResourceDirectoryNotFound(dir);
6863
}
6964
}
70-
71-
if (configuration != null) {
72-
deployConfiguration(context, configuration);
73-
}
7465
}
7566

7667
/**
@@ -79,7 +70,7 @@ public void execute(CommandContext context) {
7970
* @param dir
8071
* @param context
8172
*/
82-
protected void processDirectory(File dir, CommandContext context, Configuration configuration) {
73+
protected void processDirectory(File dir, CommandContext context) {
8374
if (logger.isInfoEnabled()) {
8475
logger.info("Processing custom forest files in directory: " + dir.getAbsolutePath());
8576
}
@@ -91,6 +82,11 @@ protected void processDirectory(File dir, CommandContext context, Configuration
9182
}
9283
String payload = readResourceFromFile(context, f);
9384

85+
// As of 4.6.1, create a CMA request per file so that the user has control over how many forests are
86+
// submitted in a single request, thus avoiding potential timeouts.
87+
Configuration configuration = context.getAppConfig().getCmaConfig().isDeployForests() ?
88+
new Configuration() : null;
89+
9490
if (payloadParser.isJsonPayload(payload)) {
9591
if (configuration != null) {
9692
addForestsToCmaConfiguration(context, payload, configuration);
@@ -104,6 +100,10 @@ protected void processDirectory(File dir, CommandContext context, Configuration
104100
mgr.save(payload);
105101
}
106102
}
103+
104+
if (configuration != null) {
105+
deployConfiguration(context, configuration);
106+
}
107107
}
108108
}
109109

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import com.marklogic.client.DatabaseClientBuilder;
1919
import com.marklogic.client.DatabaseClientFactory;
20+
import com.marklogic.client.DatabaseClientFactory.SSLHostnameVerifier;
2021
import com.marklogic.client.ext.modulesloader.ssl.SimpleX509TrustManager;
2122
import com.marklogic.client.ext.ssl.SslConfig;
2223
import com.marklogic.client.ext.ssl.SslUtil;
@@ -114,7 +115,8 @@ public DatabaseClientBuilder newDatabaseClientBuilder() {
114115
.withSSLContext(StringUtils.hasText(sslProtocol) ?
115116
SimpleX509TrustManager.newSSLContext(sslProtocol) :
116117
SimpleX509TrustManager.newSSLContext())
117-
.withTrustManager(new SimpleX509TrustManager());
118+
.withTrustManager(new SimpleX509TrustManager())
119+
.withSSLHostnameVerifier(SSLHostnameVerifier.ANY);
118120
} else {
119121
builder.withSSLProtocol(sslProtocol);
120122
}

src/test/java/com/marklogic/appdeployer/command/forests/DeployCustomForestsTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ public void test() {
5151
assertTrue(mgr.exists("sample-app-content-custom-3"));
5252
}
5353

54+
/**
55+
* Can examine logging to verify that one request is made per forest.
56+
*/
5457
@Test
55-
public void deployWithCma() {
56-
appConfig.getCmaConfig().enableAll();
58+
public void deployWithoutCMA() {
59+
appConfig.getCmaConfig().setDeployForests(false);
5760
test();
5861
}
5962
}

src/test/java/com/marklogic/mgmt/DefaultManageConfigFactoryTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.marklogic.mgmt;
1717

1818
import com.marklogic.client.DatabaseClientFactory;
19+
import com.marklogic.client.DatabaseClientFactory.SSLHostnameVerifier;
1920
import com.marklogic.mgmt.util.SimplePropertySource;
2021
import org.junit.jupiter.api.Test;
2122

@@ -104,6 +105,19 @@ public void sslProperties() {
104105
assertEquals("PKIX", config.getTrustManagementAlgorithm());
105106
}
106107

108+
@Test
109+
void simpleSsl() {
110+
ManageConfig config = configure(
111+
"mlManageSimpleSsl", "true",
112+
"mlUsername", "admin",
113+
"mlPassword", "admin"
114+
);
115+
116+
DatabaseClientFactory.Bean bean = config.newDatabaseClientBuilder().buildBean();
117+
SSLHostnameVerifier verifier = bean.getSecurityContext().getSSLHostnameVerifier();
118+
assertEquals(SSLHostnameVerifier.ANY, verifier, "simpleSsl should default to using the ANY hostname verifier");
119+
}
120+
107121
@Test
108122
public void mlHost() {
109123
ManageConfig config = configure("mlHost", "host1");

src/test/java/com/marklogic/mgmt/admin/DefaultAdminConfigFactoryTest.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
*/
1616
package com.marklogic.mgmt.admin;
1717

18-
import com.marklogic.client.DatabaseClientFactory;
19-
import com.marklogic.mgmt.util.SimplePropertySource;
20-
import org.junit.jupiter.api.Test;
21-
2218
import static org.junit.jupiter.api.Assertions.assertEquals;
23-
import static org.junit.jupiter.api.Assertions.assertNotNull;
2419
import static org.junit.jupiter.api.Assertions.assertThrows;
2520
import static org.junit.jupiter.api.Assertions.assertTrue;
2621

22+
import org.junit.jupiter.api.Test;
23+
24+
import com.marklogic.client.DatabaseClientFactory;
25+
import com.marklogic.client.DatabaseClientFactory.SSLHostnameVerifier;
26+
import com.marklogic.mgmt.util.SimplePropertySource;
27+
2728
public class DefaultAdminConfigFactoryTest {
2829

2930
@Test
@@ -75,6 +76,19 @@ public void sslProperties() {
7576
assertEquals("PKIX", config.getTrustManagementAlgorithm());
7677
}
7778

79+
@Test
80+
void simpleSsl() {
81+
AdminConfig config = configure(
82+
"mlAdminSimpleSsl", "true",
83+
"mlUsername", "admin",
84+
"mlPassword", "admin"
85+
);
86+
87+
DatabaseClientFactory.Bean bean = config.newDatabaseClientBuilder().buildBean();
88+
SSLHostnameVerifier verifier = bean.getSecurityContext().getSSLHostnameVerifier();
89+
assertEquals(SSLHostnameVerifier.ANY, verifier, "simpleSsl should default to using the ANY hostname verifier");
90+
}
91+
7892
@Test
7993
void cloudApiKeyAndBasePath() {
8094
AdminConfig config = configure(

0 commit comments

Comments
 (0)