File tree Expand file tree Collapse file tree 2 files changed +27
-9
lines changed
src/main/groovy/com/marklogic/gradle Expand file tree Collapse file tree 2 files changed +27
-9
lines changed Original file line number Diff line number Diff line change 11package com.marklogic.gradle.task
22
3+ import com.marklogic.xcc.ContentSource
4+ import com.marklogic.xcc.SecurityOptions
35import org.gradle.api.tasks.TaskAction
46
57import com.marklogic.gradle.xcc.XccHelper
@@ -10,10 +12,21 @@ import com.marklogic.gradle.xcc.XccHelper
1012class 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}
Original file line number Diff line number Diff line change 33import java .net .URI ;
44
55import 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 .*;
107import com .marklogic .xcc .exceptions .RequestException ;
118
129public 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 {
You can’t perform that action at this time.
0 commit comments