|
1 | 1 | buildscript { |
2 | 2 | repositories { |
3 | 3 | jcenter() |
4 | | - // Needed for corb dependency: XCC |
| 4 | + // Needed for mlcp dependency: XCC |
5 | 5 | maven { url "http://developer.marklogic.com/maven2/" } |
6 | 6 | } |
7 | 7 | dependencies { |
8 | | - //Needed for CorbTask below |
9 | | - classpath 'com.marklogic:marklogic-corb:2.3.2' |
| 8 | + classpath "com.marklogic:marklogic-contentpump:9.0.3" |
| 9 | + classpath "com.marklogic:ml-gradle:3.0.0" |
10 | 10 | } |
11 | 11 | } |
12 | 12 |
|
13 | | -plugins { |
14 | | - id "com.marklogic.ml-gradle" version "3.0.0" |
15 | | -} |
| 13 | +apply plugin: "com.marklogic.ml-gradle" |
16 | 14 |
|
17 | 15 | repositories { |
18 | 16 | jcenter() |
19 | | - |
20 | | - // Needed for corb dependency: XCC |
| 17 | + // Needed for mlcp dependency |
21 | 18 | maven { url "http://developer.marklogic.com/maven2/" } |
| 19 | + maven { url "http://repository.cloudera.com/artifactory/cloudera-repos/" } |
22 | 20 | } |
23 | 21 |
|
24 | 22 | configurations { |
25 | | - // Needed to run corb task below. |
26 | | - corb |
| 23 | + mlcp { |
| 24 | + resolutionStrategy { |
| 25 | + force "xml-apis:xml-apis:1.4.01" |
| 26 | + } |
| 27 | + } |
27 | 28 | } |
| 29 | + |
| 30 | + |
28 | 31 | dependencies { |
29 | | - // required to run CoRB2 |
30 | | - corb 'com.marklogic:marklogic-corb:2.3.2' |
31 | | - // optional |
| 32 | + mlcp "com.marklogic:mlcp:9.0.3" |
| 33 | + mlcp files("lib") |
32 | 34 | } |
| 35 | + |
| 36 | +/*************************************************************** |
| 37 | + Optional tasks to test redaction of data |
| 38 | +***************************************************************/ |
| 39 | + |
33 | 40 | /* |
34 | | - * ml-gradle adds an instance of com.marklogic.appdeployer.AppConfig to the Gradle project under the key "mlAppConfig". |
35 | | - * This instance can be modified to affect the behavior of ml-gradle. |
36 | | - */ |
37 | | -ext { |
38 | | - mlAppConfig { |
39 | | - // XCC URL for running corb task below |
40 | | - contentXccUrl = "xcc://${mlUsername}:${mlPassword}@${mlHost}:${mlRestPort}" |
41 | | - } |
| 41 | +* The import task below is an example of using the built-in MLCP Task in ml-gradle and will import sample JSON |
| 42 | +* documents to the specified content database while applying the applicable collections to the content so that |
| 43 | +* the redaction rules can be applied |
| 44 | +* */ |
| 45 | +task importSampleRedactionData(type: com.marklogic.gradle.task.MlcpTask) { |
| 46 | + description = "Example of using mlcp and MlcpTask to import documents to test redaction rules" |
| 47 | + classpath = configurations.mlcp |
| 48 | + command = "IMPORT" |
| 49 | + database = mlAppConfig.contentDatabaseName |
| 50 | + input_file_path = "data/import" |
| 51 | + output_collections = "security-rules,pii-rules,email-rules" |
| 52 | + output_permissions = "rest-reader,read,rest-writer,update" |
| 53 | + output_uri_replace = ".*import,'/import'" |
| 54 | + logOutputUri = "/redaction.txt" |
42 | 55 | } |
43 | 56 |
|
| 57 | + |
44 | 58 | /* |
45 | | - * This optional task demonstrates validating redaction rules via a locally run CORB process. |
46 | | - * To execute this task simply run it after you have successfully deployed the redaction rulesets (via mlAppDeploy or mlLoadSchemas). |
| 59 | +* The export task below shows an example of using JavaExec inside Gradle to invoke MLCP to export the documents. |
| 60 | +* This task, while a useful example, must be invoked this way because the built-in MLCP task does not yet recognize |
| 61 | +* the "redaction" option being passed. This will be addressed in a future release. |
| 62 | +* Exported documents will be within this project folder under /data/export |
| 63 | +* */ |
| 64 | +task exportSampleRedactionData(type: JavaExec) { |
| 65 | + classpath = configurations.mlcp |
| 66 | + main = 'com.marklogic.contentpump.ContentPump' |
| 67 | + |
| 68 | + args = [ |
| 69 | + "EXPORT", |
| 70 | + "-host", "${mlHost}", |
| 71 | + "-port", "8130", |
| 72 | + "-username", "${mlUsername}", |
| 73 | + "-password", "${mlPassword}", |
| 74 | + "-database", mlAppConfig.contentDatabaseName, |
| 75 | + "-output_file_path", "data/export", |
| 76 | + "-collection_filter", "security-rules", |
| 77 | + "-redaction", "security-rules"] |
| 78 | + /* |
| 79 | + * Applying "security-rules" as the redaction collection will redact both email and SSN fields in the documents |
| 80 | + * You may also redact just the email or ths SSN fields individually by applying only those specific collections |
| 81 | + * i.e. "pii-rules" OR "email-rules" |
| 82 | +
|
47 | 83 | */ |
48 | | -task validateRedactionRulesetsAdhoc(type: com.marklogic.gradle.task.CorbTask) { |
49 | | - xccConnectionUri = contentXccUrl |
50 | | - urisModule = "src/main/ml-modules/ext/redaction-ruleset-validation/corb/redaction-rules-uris.xqy|ADHOC" |
51 | | - processModule = "src/main/ml-modules/ext/redaction-ruleset-validation/corb/validate-redaction-rules.xqy|ADHOC" |
52 | 84 |
|
53 | 85 | } |
54 | 86 |
|
| 87 | + |
0 commit comments