-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMlcpBean.java
928 lines (725 loc) · 20.4 KB
/
MlcpBean.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
package com.marklogic.contentpump.bean;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Provides a bean-like interface for using mlcp programmatically. See the README in this project to see what
* the typical usage is like.
*/
public class MlcpBean {
// import/export connection options
private String host;
private Integer port;
private String username;
private String password;
private String database;
// copy connection options
private String input_host;
private Integer input_port;
private String input_username;
private String input_password;
private String input_database;
private String output_host;
private Integer output_port;
private String output_username;
private String output_password;
private String output_database;
private String command = "IMPORT";
private String aggregate_record_element;
private String aggregate_record_namespace;
private Boolean archive_metadata_optional;
private Integer batch_size;
private String collection_filter;
private Boolean compress;
private String conf;
private String content_encoding;
// TODO these should all be booleans
private String copy_collections;
private String copy_metadata;
private String copy_permissions;
private String copy_properties;
private String copy_quality;
private String data_type;
private String delimiter;
private String delimited_root_name;
private String directory_filter;
private String document_selector;
private String document_type;
private Boolean fastload;
private String filename_as_collection;
private Boolean generate_uri;
private String hadoop_conf_dir;
private Boolean indented;
private Boolean input_compressed;
private String input_compression_codec;
private String input_file_path;
private String input_file_pattern;
private String input_file_type;
private Boolean input_ssl;
private Integer max_split_size;
private Integer min_split_size;
private String mode;
private String modules;
private String modules_root;
private String namespace;
private String options_file;
private Boolean output_cleandir;
private String output_collections;
private String output_directory;
private String output_file_path;
private String output_graph;
private String output_language;
private String output_override_graph;
private String output_partition;
private String output_permissions;
private String output_quality;
private Boolean output_ssl;
private String output_type;
private String output_uri_prefix;
private String output_uri_replace;
private String output_uri_suffix;
private String path_namespace;
private String query_filter;
private String redaction;
private Boolean restrict_hosts;
private Boolean restrict_input_hosts;
private Boolean restrict_output_hosts;
private String sequencefile_key_class;
private String sequencefile_value_class;
private String sequencefile_value_type;
private Boolean snapshot;
private Boolean split_input;
private Boolean ssl;
private Boolean streaming;
private String temporal_collection;
private Integer thread_count;
private Integer thread_count_per_split;
private Boolean tolerate_errors;
private String transform_function;
private String transform_module;
private String transform_namespace;
private String transform_param;
private Integer transaction_size;
private String type_filter;
private String uri_id;
private String xml_repair_level;
// Just in case, e.g. for when mlcp is upgraded and this library doesn't yet match it
private Map<String, String> additionalOptions = new HashMap<>();
/**
* Uses Spring's BeanWrapper to build up a list of arguments that can be fed into mlcp's
* OptionsFileUtil.expandArguments method.
*
* @return array of arguments
*/
public String[] buildArgs() {
List<String> l = new ArrayList<String>();
l.add(command);
BeanWrapper bw = new BeanWrapperImpl(this);
for (PropertyDescriptor pd : bw.getPropertyDescriptors()) {
String name = pd.getName();
if (pd.getReadMethod() != null && pd.getWriteMethod() != null && !"command".equals(name)
&& !"additionalOptions".equals(name)) {
Object value = bw.getPropertyValue(name);
if (value != null && value.toString().trim().length() > 0) {
l.add("-" + name);
l.add(value.toString());
}
}
}
if (additionalOptions != null) {
for (String key : additionalOptions.keySet()) {
String value = additionalOptions.get(key);
if (value != null) {
l.add("-" + key);
l.add(value);
}
}
}
return l.toArray(new String[]{});
}
/**
* Returns a string of all the args, excluding the password - useful for passing into a log method.
*
* @param args the arguments to be fed to MLCP
* @return string representation of the args, minus the password
*/
public String viewArgs(String[] args) {
List<String> argList = new ArrayList<String>();
for (int i = 0; i < args.length; i++) {
if ("-password".equals(args[i]) && (i + 1 <= args.length)) {
i++;
continue;
}
argList.add(args[i]);
}
return "Content Pump args (not showing password): " + argList;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getDatabase() {
return database;
}
public void setDatabase(String database) {
this.database = database;
}
public String getCommand() {
return command;
}
public void setCommand(String command) {
this.command = command;
}
public String getInput_file_path() {
return input_file_path;
}
public void setInput_file_path(String input_file_path) {
this.input_file_path = input_file_path;
}
public String getInput_file_type() {
return input_file_type;
}
public void setInput_file_type(String input_file_type) {
this.input_file_type = input_file_type;
}
public String getInput_file_pattern() {
return input_file_pattern;
}
public void setInput_file_pattern(String input_file_pattern) {
this.input_file_pattern = input_file_pattern;
}
public Boolean getInput_compressed() {
return input_compressed;
}
public void setInput_compressed(Boolean input_compressed) {
this.input_compressed = input_compressed;
}
public String getDocument_type() {
return document_type;
}
public void setDocument_type(String document_type) {
this.document_type = document_type;
}
public String getOutput_collections() {
return output_collections;
}
public void setOutput_collections(String output_collections) {
this.output_collections = output_collections;
}
public String getDelimited_root_name() {
return delimited_root_name;
}
public void setDelimited_root_name(String delimited_root_name) {
this.delimited_root_name = delimited_root_name;
}
public String getNamespace() {
return namespace;
}
public void setNamespace(String namespace) {
this.namespace = namespace;
}
public String getOptions_file() {
return options_file;
}
public void setOptions_file(String options_file) {
this.options_file = options_file;
}
public String getOutput_uri_prefix() {
return output_uri_prefix;
}
public void setOutput_uri_prefix(String output_uri_prefix) {
this.output_uri_prefix = output_uri_prefix;
}
public String getOutput_uri_replace() {
return output_uri_replace;
}
public void setOutput_uri_replace(String output_uri_replace) {
this.output_uri_replace = output_uri_replace;
}
public String getOutput_permissions() {
return output_permissions;
}
public void setOutput_permissions(String output_permissions) {
this.output_permissions = output_permissions;
}
public String getTransform_module() {
return transform_module;
}
public void setTransform_module(String transform_module) {
this.transform_module = transform_module;
}
public String getTransform_namespace() {
return transform_namespace;
}
public void setTransform_namespace(String transform_namespace) {
this.transform_namespace = transform_namespace;
}
public String getTransform_param() {
return transform_param;
}
public void setTransform_param(String transform_param) {
this.transform_param = transform_param;
}
public Integer getThread_count() {
return thread_count;
}
public void setThread_count(Integer thread_count) {
this.thread_count = thread_count;
}
public Boolean getGenerate_uri() {
return generate_uri;
}
public void setGenerate_uri(Boolean generate_uri) {
this.generate_uri = generate_uri;
}
public String getOutput_uri_suffix() {
return output_uri_suffix;
}
public void setOutput_uri_suffix(String output_uri_suffix) {
this.output_uri_suffix = output_uri_suffix;
}
public Boolean getSplit_input() {
return split_input;
}
public void setSplit_input(Boolean split_input) {
this.split_input = split_input;
}
public Integer getBatch_size() {
return batch_size;
}
public void setBatch_size(Integer batch_size) {
this.batch_size = batch_size;
}
public String getXml_repair_level() {
return xml_repair_level;
}
public void setXml_repair_level(String xml_repair_level) {
this.xml_repair_level = xml_repair_level;
}
public String getAggregate_record_element() {
return aggregate_record_element;
}
public void setAggregate_record_element(String aggregate_record_element) {
this.aggregate_record_element = aggregate_record_element;
}
public String getAggregate_record_namespace() {
return aggregate_record_namespace;
}
public void setAggregate_record_namespace(String aggregate_record_namespace) {
this.aggregate_record_namespace = aggregate_record_namespace;
}
public String getCollection_filter() {
return collection_filter;
}
public void setCollection_filter(String collection_filter) {
this.collection_filter = collection_filter;
}
public String getConf() {
return conf;
}
public void setConf(String conf) {
this.conf = conf;
}
public String getContent_encoding() {
return content_encoding;
}
public void setContent_encoding(String content_encoding) {
this.content_encoding = content_encoding;
}
public String getCopy_collections() {
return copy_collections;
}
public void setCopy_collections(String copy_collections) {
this.copy_collections = copy_collections;
}
public String getCopy_permissions() {
return copy_permissions;
}
public void setCopy_permissions(String copy_permissions) {
this.copy_permissions = copy_permissions;
}
public String getCopy_properties() {
return copy_properties;
}
public void setCopy_properties(String copy_properties) {
this.copy_properties = copy_properties;
}
public String getCopy_quality() {
return copy_quality;
}
public void setCopy_quality(String copy_quality) {
this.copy_quality = copy_quality;
}
public String getData_type() {
return data_type;
}
public void setData_type(String data_type) {
this.data_type = data_type;
}
public String getDelimiter() {
return delimiter;
}
public void setDelimiter(String delimiter) {
this.delimiter = delimiter;
}
public String getDirectory_filter() {
return directory_filter;
}
public void setDirectory_filter(String directory_filter) {
this.directory_filter = directory_filter;
}
public Boolean getFastload() {
return fastload;
}
public void setFastload(Boolean fastload) {
this.fastload = fastload;
}
public String getFilename_as_collection() {
return filename_as_collection;
}
public void setFilename_as_collection(String filename_as_collection) {
this.filename_as_collection = filename_as_collection;
}
public String getHadoop_conf_dir() {
return hadoop_conf_dir;
}
public void setHadoop_conf_dir(String hadoop_conf_dir) {
this.hadoop_conf_dir = hadoop_conf_dir;
}
public Boolean getArchive_metadata_optional() {
return archive_metadata_optional;
}
public void setArchive_metadata_optional(Boolean archive_metadata_optional) {
this.archive_metadata_optional = archive_metadata_optional;
}
public String getInput_compression_codec() {
return input_compression_codec;
}
public void setInput_compression_codec(String input_compression_codec) {
this.input_compression_codec = input_compression_codec;
}
public String getSequencefile_key_class() {
return sequencefile_key_class;
}
public void setSequencefile_key_class(String sequencefile_key_class) {
this.sequencefile_key_class = sequencefile_key_class;
}
public String getSequencefile_value_class() {
return sequencefile_value_class;
}
public void setSequencefile_value_class(String sequencefile_value_class) {
this.sequencefile_value_class = sequencefile_value_class;
}
public String getSequencefile_value_type() {
return sequencefile_value_type;
}
public void setSequencefile_value_type(String sequencefile_value_type) {
this.sequencefile_value_type = sequencefile_value_type;
}
public Integer getMax_split_size() {
return max_split_size;
}
public void setMax_split_size(Integer max_split_size) {
this.max_split_size = max_split_size;
}
public Integer getMin_split_size() {
return min_split_size;
}
public void setMin_split_size(Integer min_split_size) {
this.min_split_size = min_split_size;
}
public String getMode() {
return mode;
}
public void setMode(String mode) {
this.mode = mode;
}
public Boolean getOutput_cleandir() {
return output_cleandir;
}
public void setOutput_cleandir(Boolean output_cleandir) {
this.output_cleandir = output_cleandir;
}
public String getOutput_directory() {
return output_directory;
}
public void setOutput_directory(String output_directory) {
this.output_directory = output_directory;
}
public String getOutput_graph() {
return output_graph;
}
public void setOutput_graph(String output_graph) {
this.output_graph = output_graph;
}
public String getOutput_language() {
return output_language;
}
public void setOutput_language(String output_language) {
this.output_language = output_language;
}
public String getOutput_partition() {
return output_partition;
}
public void setOutput_partition(String output_partition) {
this.output_partition = output_partition;
}
public String getOutput_override_graph() {
return output_override_graph;
}
public void setOutput_override_graph(String output_override_graph) {
this.output_override_graph = output_override_graph;
}
public String getOutput_quality() {
return output_quality;
}
public void setOutput_quality(String output_quality) {
this.output_quality = output_quality;
}
public Boolean getStreaming() {
return streaming;
}
public void setStreaming(Boolean streaming) {
this.streaming = streaming;
}
public String getTemporal_collection() {
return temporal_collection;
}
public void setTemporal_collection(String temporal_collection) {
this.temporal_collection = temporal_collection;
}
public Integer getThread_count_per_split() {
return thread_count_per_split;
}
public void setThread_count_per_split(Integer thread_count_per_split) {
this.thread_count_per_split = thread_count_per_split;
}
public Boolean getTolerate_errors() {
return tolerate_errors;
}
public void setTolerate_errors(Boolean tolerate_errors) {
this.tolerate_errors = tolerate_errors;
}
public String getTransform_function() {
return transform_function;
}
public void setTransform_function(String transform_function) {
this.transform_function = transform_function;
}
public Integer getTransaction_size() {
return transaction_size;
}
public void setTransaction_size(Integer transaction_size) {
this.transaction_size = transaction_size;
}
public String getType_filter() {
return type_filter;
}
public void setType_filter(String type_filter) {
this.type_filter = type_filter;
}
public String getUri_id() {
return uri_id;
}
public void setUri_id(String uri_id) {
this.uri_id = uri_id;
}
public String getInput_host() {
return input_host;
}
public void setInput_host(String input_host) {
this.input_host = input_host;
}
public Integer getInput_port() {
return input_port;
}
public void setInput_port(Integer input_port) {
this.input_port = input_port;
}
public String getInput_username() {
return input_username;
}
public void setInput_username(String input_username) {
this.input_username = input_username;
}
public String getInput_password() {
return input_password;
}
public void setInput_password(String input_password) {
this.input_password = input_password;
}
public String getInput_database() {
return input_database;
}
public void setInput_database(String input_database) {
this.input_database = input_database;
}
public String getOutput_host() {
return output_host;
}
public void setOutput_host(String output_host) {
this.output_host = output_host;
}
public Integer getOutput_port() {
return output_port;
}
public void setOutput_port(Integer output_port) {
this.output_port = output_port;
}
public String getOutput_username() {
return output_username;
}
public void setOutput_username(String output_username) {
this.output_username = output_username;
}
public String getOutput_password() {
return output_password;
}
public void setOutput_password(String output_password) {
this.output_password = output_password;
}
public String getOutput_database() {
return output_database;
}
public void setOutput_database(String output_database) {
this.output_database = output_database;
}
public Boolean getCompress() {
return compress;
}
public void setCompress(Boolean compress) {
this.compress = compress;
}
public String getDocument_selector() {
return document_selector;
}
public void setDocument_selector(String document_selector) {
this.document_selector = document_selector;
}
public Boolean getIndented() {
return indented;
}
public void setIndented(Boolean indented) {
this.indented = indented;
}
public String getOutput_file_path() {
return output_file_path;
}
public void setOutput_file_path(String output_file_path) {
this.output_file_path = output_file_path;
}
public String getOutput_type() {
return output_type;
}
public void setOutput_type(String output_type) {
this.output_type = output_type;
}
public String getPath_namespace() {
return path_namespace;
}
public void setPath_namespace(String path_namespace) {
this.path_namespace = path_namespace;
}
public String getQuery_filter() {
return query_filter;
}
public void setQuery_filter(String query_filter) {
this.query_filter = query_filter;
}
public Boolean getSnapshot() {
return snapshot;
}
public void setSnapshot(Boolean snapshot) {
this.snapshot = snapshot;
}
public Map<String, String> getAdditionalOptions() {
return additionalOptions;
}
public void setAdditionalOptions(Map<String, String> additionalOptions) {
this.additionalOptions = additionalOptions;
}
public String getCopy_metadata() {
return copy_metadata;
}
public void setCopy_metadata(String copy_metadata) {
this.copy_metadata = copy_metadata;
}
public Boolean getInput_ssl() {
return input_ssl;
}
public void setInput_ssl(Boolean input_ssl) {
this.input_ssl = input_ssl;
}
public Boolean getOutput_ssl() {
return output_ssl;
}
public void setOutput_ssl(Boolean output_ssl) {
this.output_ssl = output_ssl;
}
public String getRedaction() {
return redaction;
}
public void setRedaction(String redaction) {
this.redaction = redaction;
}
public Boolean getRestrict_hosts() {
return restrict_hosts;
}
public void setRestrict_hosts(Boolean restrict_hosts) {
this.restrict_hosts = restrict_hosts;
}
public Boolean getRestrict_input_hosts() {
return restrict_input_hosts;
}
public void setRestrict_input_hosts(Boolean restrict_input_hosts) {
this.restrict_input_hosts = restrict_input_hosts;
}
public Boolean getRestrict_output_hosts() {
return restrict_output_hosts;
}
public void setRestrict_output_hosts(Boolean restrict_output_hosts) {
this.restrict_output_hosts = restrict_output_hosts;
}
public Boolean getSsl() {
return ssl;
}
public void setSsl(Boolean ssl) {
this.ssl = ssl;
}
public String getModules() {
return modules;
}
public void setModules(String modules) {
this.modules = modules;
}
public String getModules_root() {
return modules_root;
}
public void setModules_root(String modules_root) {
this.modules_root = modules_root;
}
}