|
| 1 | +buildscript { |
| 2 | + repositories { |
| 3 | + jcenter() |
| 4 | + // Needed for mlcp dependency: XCC |
| 5 | + maven { url "http://developer.marklogic.com/maven2/" } |
| 6 | + } |
| 7 | + dependencies { |
| 8 | + classpath "com.marklogic:marklogic-contentpump:9.0.3" |
| 9 | + classpath "com.marklogic:ml-gradle:3.0.0" |
| 10 | + } |
| 11 | +} |
| 12 | + |
| 13 | +apply plugin: "com.marklogic.ml-gradle" |
| 14 | + |
| 15 | +repositories { |
| 16 | + jcenter() |
| 17 | + // Needed for mlcp dependency |
| 18 | + maven { url "http://developer.marklogic.com/maven2/" } |
| 19 | + maven { url "http://repository.cloudera.com/artifactory/cloudera-repos/" } |
| 20 | +} |
| 21 | + |
| 22 | +configurations { |
| 23 | + mlcp { |
| 24 | + resolutionStrategy { |
| 25 | + force "xml-apis:xml-apis:1.4.01" |
| 26 | + } |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | + |
| 31 | +dependencies { |
| 32 | + mlcp "com.marklogic:mlcp:9.0.3" |
| 33 | + mlcp files("lib") |
| 34 | +} |
| 35 | + |
| 36 | +/*************************************************************** |
| 37 | + Optional tasks to test redaction of data |
| 38 | +***************************************************************/ |
| 39 | + |
| 40 | +/* |
| 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" |
| 55 | +} |
| 56 | + |
| 57 | + |
| 58 | +/* |
| 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 | +
|
| 83 | + */ |
| 84 | + |
| 85 | +} |
| 86 | + |
| 87 | + |
0 commit comments