File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
src/main/groovy/com/marklogic/gradle/task/client Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ package com.marklogic.gradle.task.client
2+
3+ import com.marklogic.client.DatabaseClient
4+ import com.marklogic.gradle.task.MarkLogicTask
5+ import org.gradle.api.tasks.TaskAction
6+
7+ /**
8+ * Addresses a problem common to DHF options where search options are loaded via the final server and thus only
9+ * available via that server, but a user would like to use them via the staging server too.
10+ */
11+ class CopySearchOptionsTask extends MarkLogicTask {
12+
13+ DatabaseClient client
14+ String group = " Default"
15+ String sourceServer
16+ String targetServer
17+ String optionsFilename
18+
19+ @TaskAction
20+ void copySearchOptions () {
21+ DatabaseClient databaseClient
22+ if (client != null ) {
23+ databaseClient = client
24+ } else {
25+ databaseClient = getAppConfig(). newModulesDatabaseClient()
26+ }
27+
28+ def script = " declareUpdate();\n const uri = '/${ group} /${ sourceServer} /rest-api/options/${ optionsFilename} ';\n "
29+ script + = " xdmp.documentInsert('/${ group} /${ targetServer} /rest-api/options/${ optionsFilename} ', cts.doc(uri), " +
30+ " xdmp.documentGetPermissions(uri), xdmp.documentGetCollections(uri))" ;
31+ println " Copying search options via:\n " + script
32+ databaseClient. newServerEval(). javascript(script). eval()
33+ }
34+
35+ }
You can’t perform that action at this time.
0 commit comments