Skip to content

Commit 41beb82

Browse files
committed
#307 Added SSL support for XCC
1 parent 2fdeedc commit 41beb82

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

src/main/groovy/com/marklogic/gradle/task/XccTask.groovy

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.marklogic.gradle.task
22

3+
import com.marklogic.xcc.ContentSource
4+
import com.marklogic.xcc.SecurityOptions
35
import org.gradle.api.tasks.TaskAction
46

57
import com.marklogic.gradle.xcc.XccHelper
@@ -10,10 +12,21 @@ import com.marklogic.gradle.xcc.XccHelper
1012
class XccTask extends MarkLogicTask {
1113

1214
String xquery
15+
1316
String xccUrl
17+
SecurityOptions securityOptions
18+
ContentSource contentSource
1419

1520
@TaskAction
1621
void executeXcc() {
17-
new XccHelper(xccUrl).executeXquery(xquery)
22+
XccHelper helper = null
23+
if (contentSource != null) {
24+
helper = new XccHelper(contentSource)
25+
} else if (securityOptions != null) {
26+
helper = new XccHelper(xccUrl, securityOptions)
27+
} else {
28+
helper = new XccHelper(xccUrl)
29+
}
30+
helper.executeXquery(xquery)
1831
}
1932
}

src/main/groovy/com/marklogic/gradle/xcc/XccHelper.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,33 @@
33
import java.net.URI;
44

55
import com.marklogic.client.ext.helper.LoggingObject;
6-
import com.marklogic.xcc.AdhocQuery;
7-
import com.marklogic.xcc.ContentSource;
8-
import com.marklogic.xcc.ContentSourceFactory;
9-
import com.marklogic.xcc.Session;
6+
import com.marklogic.xcc.*;
107
import com.marklogic.xcc.exceptions.RequestException;
118

129
public class XccHelper extends LoggingObject {
1310

1411
private ContentSource contentSource;
1512

1613
public XccHelper(String uri) {
17-
if (logger.isDebugEnabled()) {
18-
// This will print the password!
19-
logger.debug("Connecting to XDBC server at ${uri}");
20-
}
2114
try {
2215
this.contentSource = ContentSourceFactory.newContentSource(new URI(uri));
2316
} catch (Exception ex) {
2417
throw new RuntimeException(ex);
2518
}
2619
}
2720

21+
public XccHelper(String uri, SecurityOptions securityOptions) {
22+
try {
23+
this.contentSource = ContentSourceFactory.newContentSource(new URI(uri), securityOptions);
24+
} catch (Exception ex) {
25+
throw new RuntimeException(ex);
26+
}
27+
}
28+
29+
public XccHelper(ContentSource contentSource) {
30+
this.contentSource = contentSource;
31+
}
32+
2833
public String executeXquery(String xquery) {
2934
Session session = contentSource.newSession();
3035
try {

0 commit comments

Comments
 (0)