001/* 002 * Copyright 2008-2019 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2015-2019 Ping Identity Corporation 007 * 008 * This program is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU General Public License (GPLv2 only) 010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 011 * as published by the Free Software Foundation. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Public License for more details. 017 * 018 * You should have received a copy of the GNU General Public License 019 * along with this program; if not, see <http://www.gnu.org/licenses>. 020 */ 021package com.unboundid.ldap.sdk.unboundidds.tasks; 022 023 024 025import java.util.ArrayList; 026import java.util.Arrays; 027import java.util.Collections; 028import java.util.Date; 029import java.util.LinkedHashMap; 030import java.util.List; 031import java.util.Map; 032 033import com.unboundid.ldap.sdk.Attribute; 034import com.unboundid.ldap.sdk.Entry; 035import com.unboundid.util.Debug; 036import com.unboundid.util.NotMutable; 037import com.unboundid.util.StaticUtils; 038import com.unboundid.util.ThreadSafety; 039import com.unboundid.util.ThreadSafetyLevel; 040import com.unboundid.util.Validator; 041 042import static com.unboundid.ldap.sdk.unboundidds.tasks.TaskMessages.*; 043 044 045 046/** 047 * This class defines a Directory Server task that can be used to export the 048 * contents of a backend to LDIF. 049 * <BR> 050 * <BLOCKQUOTE> 051 * <B>NOTE:</B> This class, and other classes within the 052 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 053 * supported for use against Ping Identity, UnboundID, and 054 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 055 * for proprietary functionality or for external specifications that are not 056 * considered stable or mature enough to be guaranteed to work in an 057 * interoperable way with other types of LDAP servers. 058 * </BLOCKQUOTE> 059 * <BR> 060 * The properties that are available for use with this type of task include: 061 * <UL> 062 * <LI>The backend ID for the backend from which the data is to be exported. 063 * It must be provided when scheduling a task of this type.</LI> 064 * <LI>The path (on the server system) and name of the LDIF file to be 065 * written. It must be provided when scheduling a task of this type.</LI> 066 * <LI>A flag that indicates whether to append to any existing file or to 067 * overwrite it.</LI> 068 * <LI>An optional list of base DNs for branches that should be included in 069 * the export.</LI> 070 * <LI>An optional list of base DNs for branches that should be excluded from 071 * the export.</LI> 072 * <LI>An optional list of filters that may be used to determine whether an 073 * entry should be included in the export.</LI> 074 * <LI>An optional list of filters that may be used to determine whether an 075 * entry should be excluded from the export.</LI> 076 * <LI>An optional list of attributes that should be included in entries that 077 * are exported.</LI> 078 * <LI>An optional list of attributes that should be excluded form entries 079 * that are exported.</LI> 080 * <LI>An integer value that specifies the column at which long lines should 081 * be wrapped. A value less than or equal to zero indicates that no 082 * wrapping should be performed.</LI> 083 * <LI>A flag that indicates whether to compress the LDIF data as it is 084 * written.</LI> 085 * <LI>A flag that indicates whether to encrypt the LDIF data as it is 086 * written.</LI> 087 * <LI>A flag that indicates whether to generate a signature for the LDIF data 088 * as it is written.</LI> 089 * <LI>The path to a file containing a passphrase to use to generate the 090 * encryption key.</LI> 091 * <LI>The ID of the encryption settings definition to use to generate the 092 * encryption key.</LI> 093 * <LI>The maximum rate in megabytes per second at which the LDIF file should 094 * be written.</LI> 095 * </UL> 096 */ 097@NotMutable() 098@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 099public final class ExportTask 100 extends Task 101{ 102 /** 103 * The fully-qualified name of the Java class that is used for the export 104 * task. 105 */ 106 static final String EXPORT_TASK_CLASS = 107 "com.unboundid.directory.server.tasks.ExportTask"; 108 109 110 111 /** 112 * The name of the attribute used to indicate whether to append to an existing 113 * file. 114 */ 115 private static final String ATTR_APPEND_TO_LDIF = 116 "ds-task-export-append-to-ldif"; 117 118 119 120 /** 121 * The name of the attribute used to specify the backend ID of the backend to 122 * export. 123 */ 124 private static final String ATTR_BACKEND_ID = "ds-task-export-backend-id"; 125 126 127 128 /** 129 * The name of the attribute used to indicate whether the exported LDIF should 130 * be compressed as it is written. 131 */ 132 private static final String ATTR_COMPRESS = "ds-task-export-compress-ldif"; 133 134 135 136 /** 137 * The name of the attribute used to indicate whether the exported LDIF should 138 * be encrypted as it is written. 139 */ 140 private static final String ATTR_ENCRYPT = "ds-task-export-encrypt-ldif"; 141 142 143 144 /** 145 * The name of the attribute used to specify the path to a file that contains 146 * the passphrase to use to generate the encryption key. 147 */ 148 private static final String ATTR_ENCRYPTION_PASSPHRASE_FILE = 149 "ds-task-export-encryption-passphrase-file"; 150 151 152 153 /** 154 * The name of the attribute used to specify the path to a file that contains 155 * the ID of the encryption settings definition to use to generate the 156 * encryption key. 157 */ 158 private static final String ATTR_ENCRYPTION_SETTINGS_DEFINITION_ID = 159 "ds-task-export-encryption-settings-definition-id"; 160 161 162 163 /** 164 * The name of the attribute used to specify the attributes to exclude from 165 * the export. 166 */ 167 private static final String ATTR_EXCLUDE_ATTRIBUTE = 168 "ds-task-export-exclude-attribute"; 169 170 171 172 /** 173 * The name of the attribute used to specify the base DNs to exclude from the 174 * export. 175 */ 176 private static final String ATTR_EXCLUDE_BRANCH = 177 "ds-task-export-exclude-branch"; 178 179 180 181 /** 182 * The name of the attribute used to specify the filters to use to identify 183 * entries to exclude from the export. 184 */ 185 private static final String ATTR_EXCLUDE_FILTER = 186 "ds-task-export-exclude-filter"; 187 188 189 190 /** 191 * The name of the attribute used to specify the attributes to include in the 192 * export. 193 */ 194 private static final String ATTR_INCLUDE_ATTRIBUTE = 195 "ds-task-export-include-attribute"; 196 197 198 199 /** 200 * The name of the attribute used to specify the base DNs to include in the 201 * export. 202 */ 203 private static final String ATTR_INCLUDE_BRANCH = 204 "ds-task-export-include-branch"; 205 206 207 208 /** 209 * The name of the attribute used to specify the filters to use to identify 210 * entries to include in the export. 211 */ 212 private static final String ATTR_INCLUDE_FILTER = 213 "ds-task-export-include-filter"; 214 215 216 217 /** 218 * The name of the attribute used to specify the path to the LDIF file to be 219 * written. 220 */ 221 private static final String ATTR_LDIF_FILE = "ds-task-export-ldif-file"; 222 223 224 225 /** 226 * The name of the attribute used to specify the maximum LDIF write rate in 227 * megabytes per second. 228 */ 229 private static final String ATTR_MAX_MEGABYTES_PER_SECOND = 230 "ds-task-export-max-megabytes-per-second"; 231 232 233 234 /** 235 * The name of the attribute used to indicate whether the exported LDIF should 236 * include a signed hash of the contents. 237 */ 238 private static final String ATTR_SIGN = "ds-task-export-sign-hash"; 239 240 241 242 /** 243 * The name of the attribute used to specify the column at which to wrap long 244 * lines in the export. 245 */ 246 private static final String ATTR_WRAP_COLUMN = "ds-task-export-wrap-column"; 247 248 249 250 /** 251 * The name of the object class used in export task entries. 252 */ 253 private static final String OC_EXPORT_TASK = "ds-task-export"; 254 255 256 257 /** 258 * The task property for the backend ID. 259 */ 260 private static final TaskProperty PROPERTY_BACKEND_ID = 261 new TaskProperty(ATTR_BACKEND_ID, INFO_DISPLAY_NAME_BACKEND_ID.get(), 262 INFO_DESCRIPTION_BACKEND_ID_EXPORT.get(), String.class, 263 true, false, false); 264 265 266 267 /** 268 * The task property for the LDIF file. 269 */ 270 private static final TaskProperty PROPERTY_LDIF_FILE = 271 new TaskProperty(ATTR_LDIF_FILE, INFO_DISPLAY_NAME_LDIF_FILE.get(), 272 INFO_DESCRIPTION_LDIF_FILE_EXPORT.get(), String.class, 273 true, false, false); 274 275 276 277 /** 278 * The task property for the append to LDIF flag. 279 */ 280 private static final TaskProperty PROPERTY_APPEND_TO_LDIF = 281 new TaskProperty(ATTR_APPEND_TO_LDIF, 282 INFO_DISPLAY_NAME_APPEND_TO_LDIF.get(), 283 INFO_DESCRIPTION_APPEND_TO_LDIF.get(), Boolean.class, 284 false, false, true); 285 286 287 288 /** 289 * The task property for the include branches. 290 */ 291 private static final TaskProperty PROPERTY_INCLUDE_BRANCH = 292 new TaskProperty(ATTR_INCLUDE_BRANCH, 293 INFO_DISPLAY_NAME_INCLUDE_BRANCH.get(), 294 INFO_DESCRIPTION_INCLUDE_BRANCH_EXPORT.get(), 295 String.class, false, true, true); 296 297 298 299 /** 300 * The task property for the exclude branches. 301 */ 302 private static final TaskProperty PROPERTY_EXCLUDE_BRANCH = 303 new TaskProperty(ATTR_EXCLUDE_BRANCH, 304 INFO_DISPLAY_NAME_EXCLUDE_BRANCH.get(), 305 INFO_DESCRIPTION_EXCLUDE_BRANCH_EXPORT.get(), 306 String.class, false, true, true); 307 308 309 310 /** 311 * The task property for the include filters. 312 */ 313 private static final TaskProperty PROPERTY_INCLUDE_FILTER = 314 new TaskProperty(ATTR_INCLUDE_FILTER, 315 INFO_DISPLAY_NAME_INCLUDE_FILTER.get(), 316 INFO_DESCRIPTION_INCLUDE_FILTER_EXPORT.get(), 317 String.class, false, true, true); 318 319 320 321 /** 322 * The task property for the exclude filters. 323 */ 324 private static final TaskProperty PROPERTY_EXCLUDE_FILTER = 325 new TaskProperty(ATTR_EXCLUDE_FILTER, 326 INFO_DISPLAY_NAME_EXCLUDE_FILTER.get(), 327 INFO_DESCRIPTION_EXCLUDE_FILTER_EXPORT.get(), 328 String.class, false, true, true); 329 330 331 332 /** 333 * The task property for the include attributes. 334 */ 335 private static final TaskProperty PROPERTY_INCLUDE_ATTRIBUTE = 336 new TaskProperty(ATTR_INCLUDE_ATTRIBUTE, 337 INFO_DISPLAY_NAME_INCLUDE_ATTRIBUTE.get(), 338 INFO_DESCRIPTION_INCLUDE_ATTRIBUTE_EXPORT.get(), 339 String.class, false, true, true); 340 341 342 343 /** 344 * The task property for the exclude attributes. 345 */ 346 private static final TaskProperty PROPERTY_EXCLUDE_ATTRIBUTE = 347 new TaskProperty(ATTR_EXCLUDE_ATTRIBUTE, 348 INFO_DISPLAY_NAME_EXCLUDE_ATTRIBUTE.get(), 349 INFO_DESCRIPTION_EXCLUDE_ATTRIBUTE_EXPORT.get(), 350 String.class, false, true, true); 351 352 353 354 /** 355 * The task property for the wrap column. 356 */ 357 private static final TaskProperty PROPERTY_WRAP_COLUMN = 358 new TaskProperty(ATTR_WRAP_COLUMN, INFO_DISPLAY_NAME_WRAP_COLUMN.get(), 359 INFO_DESCRIPTION_WRAP_COLUMN.get(), Long.class, false, 360 false, true); 361 362 363 364 /** 365 * The task property for the compress flag. 366 */ 367 private static final TaskProperty PROPERTY_COMPRESS = 368 new TaskProperty(ATTR_COMPRESS, INFO_DISPLAY_NAME_COMPRESS.get(), 369 INFO_DESCRIPTION_COMPRESS_EXPORT.get(), Boolean.class, 370 false, false, false); 371 372 373 374 /** 375 * The task property for the encrypt flag. 376 */ 377 private static final TaskProperty PROPERTY_ENCRYPT = 378 new TaskProperty(ATTR_ENCRYPT, INFO_DISPLAY_NAME_ENCRYPT.get(), 379 INFO_DESCRIPTION_ENCRYPT_EXPORT.get(), Boolean.class, 380 false, false, false); 381 382 383 384 /** 385 * The task property that will be used for the encryption passphrase file. 386 */ 387 private static final TaskProperty PROPERTY_ENCRYPTION_PASSPHRASE_FILE = 388 new TaskProperty(ATTR_ENCRYPTION_PASSPHRASE_FILE, 389 INFO_DISPLAY_NAME_ENCRYPTION_PASSPHRASE_FILE.get(), 390 INFO_DESCRIPTION_ENCRYPTION_PASSPHRASE_FILE.get(), 391 String.class, false, false, true); 392 393 394 395 /** 396 * The task property that will be used for the encryption settings definition 397 * ID. 398 */ 399 private static final TaskProperty PROPERTY_ENCRYPTION_SETTINGS_DEFINITION_ID = 400 new TaskProperty(ATTR_ENCRYPTION_SETTINGS_DEFINITION_ID, 401 INFO_DISPLAY_NAME_ENCRYPTION_SETTINGS_DEFINITION_ID.get(), 402 INFO_DESCRIPTION_ENCRYPTION_SETTINGS_DEFINITION_ID.get(), 403 String.class, false, false, true); 404 405 406 407 /** 408 * The task property for the sign flag. 409 */ 410 private static final TaskProperty PROPERTY_SIGN = 411 new TaskProperty(ATTR_SIGN, INFO_DISPLAY_NAME_SIGN.get(), 412 INFO_DESCRIPTION_SIGN_EXPORT.get(), Boolean.class, 413 false, false, false); 414 415 416 417 /** 418 * The task property that will be used for the maximum write rate in megabytes 419 * per second. 420 */ 421 private static final TaskProperty PROPERTY_MAX_MEGABYTES_PER_SECOND = 422 new TaskProperty(ATTR_MAX_MEGABYTES_PER_SECOND, 423 INFO_DISPLAY_NAME_EXPORT_MAX_MEGABYTES_PER_SECOND.get(), 424 INFO_DESCRIPTION_EXPORT_MAX_MEGABYTES_PER_SECOND.get(), 425 Long.class, false, false, true); 426 427 428 429 /** 430 * The serial version UID for this serializable class. 431 */ 432 private static final long serialVersionUID = -6807534587873728959L; 433 434 435 436 // Indicates whether to append the data to an existing file. 437 private final boolean appendToLDIF; 438 439 // Indicates whether to compress the data. 440 private final boolean compress; 441 442 // Indicates whether to encrypt the data. 443 private final boolean encrypt; 444 445 // Indicates whether to sign the data. 446 private final boolean sign; 447 448 // The column at which to wrap long lines. 449 private final int wrapColumn; 450 451 // The maximum write rate in megabytes per second. 452 private final Integer maxMegabytesPerSecond; 453 454 // The set of attributes to exclude from the export. 455 private final List<String> excludeAttributes; 456 457 // The set of base DNs to exclude from the export. 458 private final List<String> excludeBranches; 459 460 // The set of filters to use to identify entries to exclude. 461 private final List<String> excludeFilters; 462 463 // The set of attributes to include in the export. 464 private final List<String> includeAttributes; 465 466 // The set of base DNs to include in the export. 467 private final List<String> includeBranches; 468 469 // The set of filters to use to identify entries to include. 470 private final List<String> includeFilters; 471 472 // The backend ID of the backend to export. 473 private final String backendID; 474 475 // The path to a file containing the passphrase to use to generate the 476 // encryption key. 477 private final String encryptionPassphraseFile; 478 479 // The identifier for the encryption settings definition to use to generate 480 // the encryption key. 481 private final String encryptionSettingsDefinitionID; 482 483 // The path to the LDIF file to generate. 484 private final String ldifFile; 485 486 487 488 /** 489 * Creates a new uninitialized export task instance which should only be used 490 * for obtaining general information about this task, including the task name, 491 * description, and supported properties. Attempts to use a task created with 492 * this constructor for any other reason will likely fail. 493 */ 494 public ExportTask() 495 { 496 appendToLDIF = false; 497 compress = false; 498 encrypt = false; 499 sign = false; 500 wrapColumn = -1; 501 maxMegabytesPerSecond = null; 502 encryptionPassphraseFile = null; 503 encryptionSettingsDefinitionID = null; 504 excludeAttributes = null; 505 excludeBranches = null; 506 excludeFilters = null; 507 includeAttributes = null; 508 includeBranches = null; 509 includeFilters = null; 510 backendID = null; 511 ldifFile = null; 512 } 513 514 515 516 /** 517 * Creates a new export task with the provided information. 518 * 519 * @param taskID The task ID to use for this task. If it is {@code null} 520 * then a UUID will be generated for use as the task ID. 521 * @param backendID The backend ID of the backend containing the data to 522 * export. It must not be {@code null}. 523 * @param ldifFile The path to the LDIF file to create. It may be an 524 * absolute path or a path relative to the server install 525 * root. It must not be {@code null}. 526 */ 527 public ExportTask(final String taskID, final String backendID, 528 final String ldifFile) 529 { 530 this(taskID, backendID, ldifFile, false, null, null, null, null, null, null, 531 -1, false, false, false, null, null, null, null, null); 532 } 533 534 535 536 /** 537 * Creates a new export task with the provided information. 538 * 539 * @param taskID The task ID to use for this task. If it is 540 * {@code null} then a UUID will be generated 541 * for use as the task ID. 542 * @param backendID The backend ID of the backend to be 543 * exported. It must not be {@code null}. 544 * @param ldifFile The path to the LDIF file to be written. 545 * It may be an absolute path or one that is 546 * relative to the server root. It must not 547 * be {@code null}. 548 * @param appendToLDIF Indicates whether to an append to any 549 * existing file rather than overwriting it. 550 * @param includeBranches The set of base DNs of entries to include 551 * in the export. It may be {@code null} or 552 * empty if no entries should be excluded 553 * based on their location. 554 * @param excludeBranches The set of base DNs of entries to exclude 555 * from the export. It may be {@code null} or 556 * empty if no entries should be excluded 557 * based on their location. 558 * @param includeFilters The set of filters to use to match entries 559 * that should be included in the export. It 560 * may be {@code null} or empty if no entries 561 * should be excluded based on their content. 562 * @param excludeFilters The set of filters to use to match entries 563 * that should be excluded from the export. 564 * It may be {@code null} or empty if no 565 * entries should be excluded based on their 566 * content. 567 * @param includeAttributes The set of attributes that should be 568 * included in exported entries. It may be 569 * {@code null} or empty if all attributes 570 * should be included. 571 * @param excludeAttributes The set of attributes that should be 572 * excluded from exported entries. It may be 573 * {@code null} or empty if no attributes 574 * should be excluded. 575 * @param wrapColumn The column at which long lines should be 576 * wrapped. It may be less than or equal to 577 * zero to indicate that long lines should not 578 * be wrapped. 579 * @param compress Indicates whether the LDIF data should be 580 * compressed as it is written. 581 * @param encrypt Indicates whether the LDIF data should be 582 * encrypted as it is written. 583 * @param sign Indicates whether to include a signed hash 584 * of the content in the exported data. 585 * @param scheduledStartTime The time that this task should start 586 * running. 587 * @param dependencyIDs The list of task IDs that will be required 588 * to complete before this task will be 589 * eligible to start. 590 * @param failedDependencyAction Indicates what action should be taken if 591 * any of the dependencies for this task do 592 * not complete successfully. 593 * @param notifyOnCompletion The list of e-mail addresses of individuals 594 * that should be notified when this task 595 * completes. 596 * @param notifyOnError The list of e-mail addresses of individuals 597 * that should be notified if this task does 598 * not complete successfully. 599 */ 600 public ExportTask(final String taskID, final String backendID, 601 final String ldifFile, final boolean appendToLDIF, 602 final List<String> includeBranches, 603 final List<String> excludeBranches, 604 final List<String> includeFilters, 605 final List<String> excludeFilters, 606 final List<String> includeAttributes, 607 final List<String> excludeAttributes, final int wrapColumn, 608 final boolean compress, final boolean encrypt, 609 final boolean sign, final Date scheduledStartTime, 610 final List<String> dependencyIDs, 611 final FailedDependencyAction failedDependencyAction, 612 final List<String> notifyOnCompletion, 613 final List<String> notifyOnError) 614 { 615 this(taskID, backendID, ldifFile, appendToLDIF, includeBranches, 616 excludeBranches, includeFilters, excludeFilters, includeAttributes, 617 excludeAttributes, wrapColumn, compress, encrypt, null, null, sign, 618 null, scheduledStartTime, dependencyIDs, failedDependencyAction, 619 notifyOnCompletion, notifyOnError); 620 } 621 622 623 624 /** 625 * Creates a new export task with the provided information. 626 * 627 * @param taskID The task ID to use for this task. 628 * If it is {@code null} then a UUID 629 * will be generated for use as the 630 * task ID. 631 * @param backendID The backend ID of the backend to be 632 * exported. It must not be 633 * {@code null}. 634 * @param ldifFile The path to the LDIF file to be 635 * written. It may be an absolute 636 * path or one that is relative to the 637 * server root. It must not be 638 * {@code null}. 639 * @param appendToLDIF Indicates whether to an append to 640 * any existing file rather than 641 * overwriting it. 642 * @param includeBranches The set of base DNs of entries to 643 * include in the export. It may be 644 * {@code null} or empty if no entries 645 * should be excluded based on their 646 * location. 647 * @param excludeBranches The set of base DNs of entries to 648 * exclude from the export. It may be 649 * {@code null} or empty if no entries 650 * should be excluded based on their 651 * location. 652 * @param includeFilters The set of filters to use to match 653 * entries that should be included in 654 * the export. It may be {@code null} 655 * or empty if no entries should be 656 * excluded based on their content. 657 * @param excludeFilters The set of filters to use to match 658 * entries that should be excluded 659 * from the export. It may be 660 * {@code null} or empty if no entries 661 * should be excluded based on their 662 * content. 663 * @param includeAttributes The set of attributes that should 664 * be included in exported entries. 665 * It may be {@code null} or empty if 666 * all attributes should be included. 667 * @param excludeAttributes The set of attributes that should 668 * be excluded from exported entries. 669 * It may be {@code null} or empty if 670 * no attributes should be excluded. 671 * @param wrapColumn The column at which long lines 672 * should be wrapped. It may be less 673 * than or equal to zero to indicate 674 * that long lines should not be 675 * wrapped. 676 * @param compress Indicates whether the LDIF data 677 * should be compressed as it is 678 * written. 679 * @param encrypt Indicates whether the LDIF data 680 * should be encrypted as it is 681 * written. 682 * @param encryptionPassphraseFile The path to a file containing the 683 * passphrase to use to generate the 684 * encryption key. It amy be 685 * {@code null} if the LDIF file is 686 * not to be encrypted, or if the key 687 * should be obtained in some other 688 * way. 689 * @param encryptionSettingsDefinitionID The ID of the encryption settings 690 * definition use to generate the 691 * encryption key. It may be 692 * {@code null} if the LDIF file is 693 * not to be encrypted, or if the key 694 * should be obtained in some other 695 * way. 696 * @param sign Indicates whether to include a 697 * signed hash of the content in the 698 * exported data. 699 * @param maxMegabytesPerSecond The maximum rate in megabytes per 700 * second at which the LDIF file 701 * should be written. 702 * @param scheduledStartTime The time that this task should 703 * start running. 704 * @param dependencyIDs The list of task IDs that will be 705 * required to complete before this 706 * task will be eligible to start. 707 * @param failedDependencyAction Indicates what action should be 708 * taken if any of the dependencies 709 * for this task do not complete 710 * successfully. 711 * @param notifyOnCompletion The list of e-mail addresses of 712 * individuals that should be notified 713 * when this task completes. 714 * @param notifyOnError The list of e-mail addresses of 715 * individuals that should be notified 716 * if this task does not complete 717 * successfully. 718 */ 719 public ExportTask(final String taskID, final String backendID, 720 final String ldifFile, final boolean appendToLDIF, 721 final List<String> includeBranches, 722 final List<String> excludeBranches, 723 final List<String> includeFilters, 724 final List<String> excludeFilters, 725 final List<String> includeAttributes, 726 final List<String> excludeAttributes, final int wrapColumn, 727 final boolean compress, final boolean encrypt, 728 final String encryptionPassphraseFile, 729 final String encryptionSettingsDefinitionID, 730 final boolean sign, final Integer maxMegabytesPerSecond, 731 final Date scheduledStartTime, 732 final List<String> dependencyIDs, 733 final FailedDependencyAction failedDependencyAction, 734 final List<String> notifyOnCompletion, 735 final List<String> notifyOnError) 736 { 737 this(taskID, backendID, ldifFile, appendToLDIF, includeBranches, 738 excludeBranches, includeFilters, excludeFilters, includeAttributes, 739 excludeAttributes, wrapColumn, compress, encrypt, 740 encryptionPassphraseFile, encryptionSettingsDefinitionID, sign, 741 maxMegabytesPerSecond, scheduledStartTime, dependencyIDs, 742 failedDependencyAction, null, notifyOnCompletion, null, 743 notifyOnError, null, null, null); 744 } 745 746 747 748 /** 749 * Creates a new export task with the provided information. 750 * 751 * @param taskID The task ID to use for this task. 752 * If it is {@code null} then a UUID 753 * will be generated for use as the 754 * task ID. 755 * @param backendID The backend ID of the backend to be 756 * exported. It must not be 757 * {@code null}. 758 * @param ldifFile The path to the LDIF file to be 759 * written. It may be an absolute 760 * path or one that is relative to the 761 * server root. It must not be 762 * {@code null}. 763 * @param appendToLDIF Indicates whether to an append to 764 * any existing file rather than 765 * overwriting it. 766 * @param includeBranches The set of base DNs of entries to 767 * include in the export. It may be 768 * {@code null} or empty if no entries 769 * should be excluded based on their 770 * location. 771 * @param excludeBranches The set of base DNs of entries to 772 * exclude from the export. It may be 773 * {@code null} or empty if no entries 774 * should be excluded based on their 775 * location. 776 * @param includeFilters The set of filters to use to match 777 * entries that should be included in 778 * the export. It may be {@code null} 779 * or empty if no entries should be 780 * excluded based on their content. 781 * @param excludeFilters The set of filters to use to match 782 * entries that should be excluded 783 * from the export. It may be 784 * {@code null} or empty if no entries 785 * should be excluded based on their 786 * content. 787 * @param includeAttributes The set of attributes that should 788 * be included in exported entries. 789 * It may be {@code null} or empty if 790 * all attributes should be included. 791 * @param excludeAttributes The set of attributes that should 792 * be excluded from exported entries. 793 * It may be {@code null} or empty if 794 * no attributes should be excluded. 795 * @param wrapColumn The column at which long lines 796 * should be wrapped. It may be less 797 * than or equal to zero to indicate 798 * that long lines should not be 799 * wrapped. 800 * @param compress Indicates whether the LDIF data 801 * should be compressed as it is 802 * written. 803 * @param encrypt Indicates whether the LDIF data 804 * should be encrypted as it is 805 * written. 806 * @param encryptionPassphraseFile The path to a file containing the 807 * passphrase to use to generate the 808 * encryption key. It amy be 809 * {@code null} if the LDIF file is 810 * not to be encrypted, or if the key 811 * should be obtained in some other 812 * way. 813 * @param encryptionSettingsDefinitionID The ID of the encryption settings 814 * definition use to generate the 815 * encryption key. It may be 816 * {@code null} if the LDIF file is 817 * not to be encrypted, or if the key 818 * should be obtained in some other 819 * way. 820 * @param sign Indicates whether to include a 821 * signed hash of the content in the 822 * exported data. 823 * @param maxMegabytesPerSecond The maximum rate in megabytes per 824 * second at which the LDIF file 825 * should be written. 826 * @param scheduledStartTime The time that this task should 827 * start running. 828 * @param dependencyIDs The list of task IDs that will be 829 * required to complete before this 830 * task will be eligible to start. 831 * @param failedDependencyAction Indicates what action should be 832 * taken if any of the dependencies 833 * for this task do not complete 834 * successfully. 835 * @param notifyOnStart The list of e-mail addresses of 836 * individuals that should be notified 837 * when this task starts running. 838 * @param notifyOnCompletion The list of e-mail addresses of 839 * individuals that should be notified 840 * when this task completes. 841 * @param notifyOnSuccess The list of e-mail addresses of 842 * individuals that should be notified 843 * if this task completes 844 * successfully. 845 * @param notifyOnError The list of e-mail addresses of 846 * individuals that should be notified 847 * if this task does not complete 848 * successfully. 849 * @param alertOnStart Indicates whether the server should 850 * send an alert notification when 851 * this task starts. 852 * @param alertOnSuccess Indicates whether the server should 853 * send an alert notification if this 854 * task completes successfully. 855 * @param alertOnError Indicates whether the server should 856 * send an alert notification if this 857 * task fails to complete 858 * successfully. 859 */ 860 public ExportTask(final String taskID, final String backendID, 861 final String ldifFile, final boolean appendToLDIF, 862 final List<String> includeBranches, 863 final List<String> excludeBranches, 864 final List<String> includeFilters, 865 final List<String> excludeFilters, 866 final List<String> includeAttributes, 867 final List<String> excludeAttributes, final int wrapColumn, 868 final boolean compress, final boolean encrypt, 869 final String encryptionPassphraseFile, 870 final String encryptionSettingsDefinitionID, 871 final boolean sign, final Integer maxMegabytesPerSecond, 872 final Date scheduledStartTime, 873 final List<String> dependencyIDs, 874 final FailedDependencyAction failedDependencyAction, 875 final List<String> notifyOnStart, 876 final List<String> notifyOnCompletion, 877 final List<String> notifyOnSuccess, 878 final List<String> notifyOnError, 879 final Boolean alertOnStart, final Boolean alertOnSuccess, 880 final Boolean alertOnError) 881 { 882 super(taskID, EXPORT_TASK_CLASS, scheduledStartTime, 883 dependencyIDs, failedDependencyAction, notifyOnStart, 884 notifyOnCompletion, notifyOnSuccess, notifyOnError, alertOnStart, 885 alertOnSuccess, alertOnError); 886 887 Validator.ensureNotNull(backendID, ldifFile); 888 889 this.backendID = backendID; 890 this.ldifFile = ldifFile; 891 this.appendToLDIF = appendToLDIF; 892 this.wrapColumn = wrapColumn; 893 this.compress = compress; 894 this.encrypt = encrypt; 895 this.encryptionPassphraseFile = encryptionPassphraseFile; 896 this.encryptionSettingsDefinitionID = encryptionSettingsDefinitionID; 897 this.sign = sign; 898 this.maxMegabytesPerSecond = maxMegabytesPerSecond; 899 900 if (includeBranches == null) 901 { 902 this.includeBranches = Collections.emptyList(); 903 } 904 else 905 { 906 this.includeBranches = Collections.unmodifiableList(includeBranches); 907 } 908 909 if (excludeBranches == null) 910 { 911 this.excludeBranches = Collections.emptyList(); 912 } 913 else 914 { 915 this.excludeBranches = Collections.unmodifiableList(excludeBranches); 916 } 917 918 if (includeFilters == null) 919 { 920 this.includeFilters = Collections.emptyList(); 921 } 922 else 923 { 924 this.includeFilters = Collections.unmodifiableList(includeFilters); 925 } 926 927 if (excludeFilters == null) 928 { 929 this.excludeFilters = Collections.emptyList(); 930 } 931 else 932 { 933 this.excludeFilters = Collections.unmodifiableList(excludeFilters); 934 } 935 936 if (includeAttributes == null) 937 { 938 this.includeAttributes = Collections.emptyList(); 939 } 940 else 941 { 942 this.includeAttributes = Collections.unmodifiableList(includeAttributes); 943 } 944 945 if (excludeAttributes == null) 946 { 947 this.excludeAttributes = Collections.emptyList(); 948 } 949 else 950 { 951 this.excludeAttributes = Collections.unmodifiableList(excludeAttributes); 952 } 953 } 954 955 956 957 /** 958 * Creates a new export task from the provided entry. 959 * 960 * @param entry The entry to use to create this export task. 961 * 962 * @throws TaskException If the provided entry cannot be parsed as an export 963 * task entry. 964 */ 965 public ExportTask(final Entry entry) 966 throws TaskException 967 { 968 super(entry); 969 970 971 // Get the backend ID. It must be present. 972 backendID = entry.getAttributeValue(ATTR_BACKEND_ID); 973 if (backendID == null) 974 { 975 throw new TaskException(ERR_EXPORT_TASK_NO_BACKEND_ID.get( 976 getTaskEntryDN())); 977 } 978 979 980 // Get the LDIF file path. It must be present. 981 ldifFile = entry.getAttributeValue(ATTR_LDIF_FILE); 982 if (ldifFile == null) 983 { 984 throw new TaskException(ERR_EXPORT_TASK_NO_LDIF_FILE.get( 985 getTaskEntryDN())); 986 } 987 988 989 // Get the appendLDIF flag. It may be absent. 990 appendToLDIF = parseBooleanValue(entry, ATTR_APPEND_TO_LDIF, false); 991 992 993 // Get the list of include branches. It may be absent. 994 includeBranches = parseStringList(entry, ATTR_INCLUDE_BRANCH); 995 996 997 // Get the list of exclude branches. It may be absent. 998 excludeBranches = parseStringList(entry, ATTR_EXCLUDE_BRANCH); 999 1000 1001 // Get the list of include filters. It may be absent. 1002 includeFilters = parseStringList(entry, ATTR_INCLUDE_FILTER); 1003 1004 1005 // Get the list of exclude filters. It may be absent. 1006 excludeFilters = parseStringList(entry, ATTR_EXCLUDE_FILTER); 1007 1008 1009 // Get the list of include attributes. It may be absent. 1010 includeAttributes = parseStringList(entry, ATTR_INCLUDE_ATTRIBUTE); 1011 1012 1013 // Get the list of exclude attributes. It may be absent. 1014 excludeAttributes = parseStringList(entry, ATTR_EXCLUDE_ATTRIBUTE); 1015 1016 1017 // Get the wrap column. It may be absent. 1018 final String wrapStr = entry.getAttributeValue(ATTR_WRAP_COLUMN); 1019 if (wrapStr == null) 1020 { 1021 wrapColumn = -1; 1022 } 1023 else 1024 { 1025 try 1026 { 1027 wrapColumn = Integer.parseInt(wrapStr); 1028 } 1029 catch (final Exception e) 1030 { 1031 Debug.debugException(e); 1032 throw new TaskException(ERR_EXPORT_TASK_CANNOT_PARSE_WRAP_COLUMN.get( 1033 getTaskEntryDN(), wrapStr), e); 1034 } 1035 } 1036 1037 1038 // Get the compress flag. It may be absent. 1039 compress = parseBooleanValue(entry, ATTR_COMPRESS, false); 1040 1041 1042 // Get the encrypt flag. It may be absent. 1043 encrypt = parseBooleanValue(entry, ATTR_ENCRYPT, false); 1044 1045 1046 // Get the path to the encryption passphrase file. It may be absent. 1047 encryptionPassphraseFile = 1048 entry.getAttributeValue(ATTR_ENCRYPTION_PASSPHRASE_FILE); 1049 1050 1051 // Get the encryption settings definition ID. It may be absent. 1052 encryptionSettingsDefinitionID = 1053 entry.getAttributeValue(ATTR_ENCRYPTION_SETTINGS_DEFINITION_ID); 1054 1055 1056 // Get the sign flag. It may be absent. 1057 sign = parseBooleanValue(entry, ATTR_SIGN, false); 1058 1059 1060 // Get the maximum write rate in megabytes per second. It may be absent. 1061 maxMegabytesPerSecond = 1062 entry.getAttributeValueAsInteger(ATTR_MAX_MEGABYTES_PER_SECOND); 1063 } 1064 1065 1066 1067 /** 1068 * Creates a new export task from the provided set of task properties. 1069 * 1070 * @param properties The set of task properties and their corresponding 1071 * values to use for the task. It must not be 1072 * {@code null}. 1073 * 1074 * @throws TaskException If the provided set of properties cannot be used to 1075 * create a valid export task. 1076 */ 1077 public ExportTask(final Map<TaskProperty,List<Object>> properties) 1078 throws TaskException 1079 { 1080 super(EXPORT_TASK_CLASS, properties); 1081 1082 boolean a = false; 1083 boolean c = false; 1084 boolean e = false; 1085 boolean s = false; 1086 Integer maxMB = null; 1087 long w = 0; 1088 String b = null; 1089 String encID = null; 1090 String encPWFile = null; 1091 String l = null; 1092 String[] eA = StaticUtils.NO_STRINGS; 1093 String[] eB = StaticUtils.NO_STRINGS; 1094 String[] eF = StaticUtils.NO_STRINGS; 1095 String[] iA = StaticUtils.NO_STRINGS; 1096 String[] iB = StaticUtils.NO_STRINGS; 1097 String[] iF = StaticUtils.NO_STRINGS; 1098 1099 for (final Map.Entry<TaskProperty,List<Object>> entry : 1100 properties.entrySet()) 1101 { 1102 final TaskProperty p = entry.getKey(); 1103 final String attrName = p.getAttributeName(); 1104 final List<Object> values = entry.getValue(); 1105 1106 if (attrName.equalsIgnoreCase(ATTR_BACKEND_ID)) 1107 { 1108 b = parseString(p, values, b); 1109 } 1110 else if (attrName.equalsIgnoreCase(ATTR_LDIF_FILE)) 1111 { 1112 l = parseString(p, values, l); 1113 } 1114 else if (attrName.equalsIgnoreCase(ATTR_APPEND_TO_LDIF)) 1115 { 1116 a = parseBoolean(p, values, a); 1117 } 1118 else if (attrName.equalsIgnoreCase(ATTR_INCLUDE_BRANCH)) 1119 { 1120 iB = parseStrings(p, values, iB); 1121 } 1122 else if (attrName.equalsIgnoreCase(ATTR_EXCLUDE_BRANCH)) 1123 { 1124 eB = parseStrings(p, values, eB); 1125 } 1126 else if (attrName.equalsIgnoreCase(ATTR_INCLUDE_FILTER)) 1127 { 1128 iF = parseStrings(p, values, iF); 1129 } 1130 else if (attrName.equalsIgnoreCase(ATTR_EXCLUDE_FILTER)) 1131 { 1132 eF = parseStrings(p, values, eF); 1133 } 1134 else if (attrName.equalsIgnoreCase(ATTR_INCLUDE_ATTRIBUTE)) 1135 { 1136 iA = parseStrings(p, values, iA); 1137 } 1138 else if (attrName.equalsIgnoreCase(ATTR_EXCLUDE_ATTRIBUTE)) 1139 { 1140 eA = parseStrings(p, values, eA); 1141 } 1142 else if (attrName.equalsIgnoreCase(ATTR_WRAP_COLUMN)) 1143 { 1144 w = parseLong(p, values, w); 1145 } 1146 else if (attrName.equalsIgnoreCase(ATTR_COMPRESS)) 1147 { 1148 c = parseBoolean(p, values, c); 1149 } 1150 else if (attrName.equalsIgnoreCase(ATTR_ENCRYPT)) 1151 { 1152 e = parseBoolean(p, values, e); 1153 } 1154 else if (attrName.equalsIgnoreCase(ATTR_ENCRYPTION_PASSPHRASE_FILE)) 1155 { 1156 encPWFile = parseString(p, values, encPWFile); 1157 } 1158 else if (attrName.equalsIgnoreCase( 1159 ATTR_ENCRYPTION_SETTINGS_DEFINITION_ID)) 1160 { 1161 encID = parseString(p, values, encID); 1162 } 1163 else if (attrName.equalsIgnoreCase(ATTR_SIGN)) 1164 { 1165 s = parseBoolean(p, values, s); 1166 } 1167 else if (attrName.equalsIgnoreCase(ATTR_MAX_MEGABYTES_PER_SECOND)) 1168 { 1169 final Long maxMBLong = parseLong(p, values, null); 1170 if (maxMBLong == null) 1171 { 1172 maxMB = null; 1173 } 1174 else 1175 { 1176 maxMB = maxMBLong.intValue(); 1177 } 1178 } 1179 } 1180 1181 if (b == null) 1182 { 1183 throw new TaskException(ERR_EXPORT_TASK_NO_BACKEND_ID.get( 1184 getTaskEntryDN())); 1185 } 1186 1187 if (l == null) 1188 { 1189 throw new TaskException(ERR_EXPORT_TASK_NO_LDIF_FILE.get( 1190 getTaskEntryDN())); 1191 } 1192 1193 backendID = b; 1194 ldifFile = l; 1195 appendToLDIF = a; 1196 includeAttributes = Collections.unmodifiableList(Arrays.asList(iA)); 1197 excludeAttributes = Collections.unmodifiableList(Arrays.asList(eA)); 1198 includeBranches = Collections.unmodifiableList(Arrays.asList(iB)); 1199 excludeBranches = Collections.unmodifiableList(Arrays.asList(eB)); 1200 includeFilters = Collections.unmodifiableList(Arrays.asList(iF)); 1201 excludeFilters = Collections.unmodifiableList(Arrays.asList(eF)); 1202 wrapColumn = (int) w; 1203 compress = c; 1204 encrypt = e; 1205 encryptionPassphraseFile = encPWFile; 1206 encryptionSettingsDefinitionID = encID; 1207 sign = s; 1208 maxMegabytesPerSecond = maxMB; 1209 } 1210 1211 1212 1213 /** 1214 * {@inheritDoc} 1215 */ 1216 @Override() 1217 public String getTaskName() 1218 { 1219 return INFO_TASK_NAME_EXPORT.get(); 1220 } 1221 1222 1223 1224 /** 1225 * {@inheritDoc} 1226 */ 1227 @Override() 1228 public String getTaskDescription() 1229 { 1230 return INFO_TASK_DESCRIPTION_EXPORT.get(); 1231 } 1232 1233 1234 1235 /** 1236 * Retrieves the backend ID of the backend from which the data is to be 1237 * exported. 1238 * 1239 * @return The backend ID of the backend from which the data is to be 1240 * exported. 1241 */ 1242 public String getBackendID() 1243 { 1244 return backendID; 1245 } 1246 1247 1248 1249 /** 1250 * Retrieves the path to the LDIF file to which the exported data should be 1251 * written. It may be either an absolute path or one that is relative to the 1252 * server root. 1253 * 1254 * @return The path to the LDIF file to which the exported data should be 1255 * written. 1256 */ 1257 public String getLDIFFile() 1258 { 1259 return ldifFile; 1260 } 1261 1262 1263 1264 /** 1265 * Indicates whether to append to the LDIF file rather than overwriting it if 1266 * it already exists. 1267 * 1268 * @return {@code true} if the server should append to an existing LDIF file, 1269 * or {@code false} if the server should overwrite it. 1270 */ 1271 public boolean appendToLDIF() 1272 { 1273 return appendToLDIF; 1274 } 1275 1276 1277 1278 /** 1279 * Retrieves a list of base DNs of branches that should be included in the 1280 * export. 1281 * 1282 * @return A list of base DNs of branches that should be included in the 1283 * export, or an empty list if no entries should be excluded based on 1284 * their location. 1285 */ 1286 public List<String> getIncludeBranches() 1287 { 1288 return includeBranches; 1289 } 1290 1291 1292 1293 /** 1294 * Retrieves a list of base DNs of branches that should be excluded from the 1295 * export. 1296 * 1297 * @return A list of base DNs of branches that should be excluded from the 1298 * export, or an empty list if no entries should be excluded based on 1299 * their location. 1300 */ 1301 public List<String> getExcludeBranches() 1302 { 1303 return excludeBranches; 1304 } 1305 1306 1307 1308 /** 1309 * Retrieves a list of search filters that should be used to determine which 1310 * entries should be included in the export. 1311 * 1312 * @return A list of search filters that should be used to determine which 1313 * entries should be included in the export, or an empty list if no 1314 * entries should be excluded based on their content. 1315 */ 1316 public List<String> getIncludeFilters() 1317 { 1318 return includeFilters; 1319 } 1320 1321 1322 1323 /** 1324 * Retrieves a list of search filters that should be used to determine which 1325 * entries should be excluded from the export. 1326 * 1327 * @return A list of search filters that should be used to determine which 1328 * entries should be excluded from the export, or an empty list if no 1329 * entries should be excluded based on their content. 1330 */ 1331 public List<String> getExcludeFilters() 1332 { 1333 return excludeFilters; 1334 } 1335 1336 1337 1338 /** 1339 * Retrieves a list of the attributes that should be included in exported 1340 * entries. 1341 * 1342 * @return A list of the attributes that should be included in exported 1343 * entries, or an empty list if no attributes should be excluded. 1344 */ 1345 public List<String> getIncludeAttributes() 1346 { 1347 return includeAttributes; 1348 } 1349 1350 1351 1352 /** 1353 * Retrieves a list of the attributes that should be excluded from exported 1354 * entries. 1355 * 1356 * @return A list of the attributes that should be excluded from exported 1357 * entries, or an empty list if no attributes should be excluded. 1358 */ 1359 public List<String> getExcludeAttributes() 1360 { 1361 return excludeAttributes; 1362 } 1363 1364 1365 1366 /** 1367 * Retrieves the column number at which long lines should be wrapped. 1368 * 1369 * @return The column number at which long lines should be wrapped, or a 1370 * value less than or equal to zero to indicate that no wrapping 1371 * should be performed. 1372 */ 1373 public int getWrapColumn() 1374 { 1375 return wrapColumn; 1376 } 1377 1378 1379 1380 /** 1381 * Indicates whether the LDIF data should be compressed as it is exported. 1382 * 1383 * @return {@code true} if the LDIF data should be compressed as it is 1384 * exported, or {@code false} if not. 1385 */ 1386 public boolean compress() 1387 { 1388 return compress; 1389 } 1390 1391 1392 1393 /** 1394 * Indicates whether the LDIF data should be encrypted as it is exported. 1395 * 1396 * @return {@code true} if the LDIF data should be encrypted as it is 1397 * exported, or {@code false} if not. 1398 */ 1399 public boolean encrypt() 1400 { 1401 return encrypt; 1402 } 1403 1404 1405 1406 /** 1407 * Retrieves the path to a file that contains the passphrase to use to 1408 * generate the encryption key. 1409 * 1410 * @return The path to a file that contains the passphrase to use to 1411 * generate the encryption key, or {@code null} if the LDIF file 1412 * should not be encrypted or if the encryption key should be 1413 * obtained through some other means. 1414 */ 1415 public String getEncryptionPassphraseFile() 1416 { 1417 return encryptionPassphraseFile; 1418 } 1419 1420 1421 1422 /** 1423 * Retrieves the identifier of the encryption settings definition to use to 1424 * generate the encryption key. 1425 * 1426 * @return The identifier of the encryption settings definition to use to 1427 * generate the encryption key, or {@code null} if the LDIF file 1428 * should not be encrypted or if the encryption key should be 1429 * obtained through some other means. 1430 */ 1431 public String getEncryptionSettingsDefinitionID() 1432 { 1433 return encryptionSettingsDefinitionID; 1434 } 1435 1436 1437 1438 /** 1439 * Indicates whether the exported LDIF data should include a signed hash. 1440 * 1441 * @return {@code true} if the exported LDIF data should include a signed 1442 * hash, or {@code false} if not. 1443 */ 1444 public boolean sign() 1445 { 1446 return sign; 1447 } 1448 1449 1450 1451 /** 1452 * Retrieves the maximum rate, in megabytes per second, at which the LDIF file 1453 * should be written. 1454 * 1455 * @return The maximum rate, in megabytes per second, at which the LDIF file 1456 * should be written, or {@code null} if the writing should not be 1457 * rate limited. 1458 */ 1459 public Integer getMaxMegabytesPerSecond() 1460 { 1461 return maxMegabytesPerSecond; 1462 } 1463 1464 1465 1466 /** 1467 * {@inheritDoc} 1468 */ 1469 @Override() 1470 protected List<String> getAdditionalObjectClasses() 1471 { 1472 return Collections.singletonList(OC_EXPORT_TASK); 1473 } 1474 1475 1476 1477 /** 1478 * {@inheritDoc} 1479 */ 1480 @Override() 1481 protected List<Attribute> getAdditionalAttributes() 1482 { 1483 final ArrayList<Attribute> attrs = new ArrayList<>(20); 1484 1485 attrs.add(new Attribute(ATTR_BACKEND_ID, backendID)); 1486 attrs.add(new Attribute(ATTR_LDIF_FILE, ldifFile)); 1487 attrs.add(new Attribute(ATTR_APPEND_TO_LDIF, String.valueOf(appendToLDIF))); 1488 attrs.add(new Attribute(ATTR_COMPRESS, String.valueOf(compress))); 1489 attrs.add(new Attribute(ATTR_ENCRYPT, String.valueOf(encrypt))); 1490 attrs.add(new Attribute(ATTR_SIGN, String.valueOf(sign))); 1491 1492 if (! includeBranches.isEmpty()) 1493 { 1494 attrs.add(new Attribute(ATTR_INCLUDE_BRANCH, includeBranches)); 1495 } 1496 1497 if (! excludeBranches.isEmpty()) 1498 { 1499 attrs.add(new Attribute(ATTR_EXCLUDE_BRANCH, excludeBranches)); 1500 } 1501 1502 if (! includeAttributes.isEmpty()) 1503 { 1504 attrs.add(new Attribute(ATTR_INCLUDE_ATTRIBUTE, includeAttributes)); 1505 } 1506 1507 if (! excludeAttributes.isEmpty()) 1508 { 1509 attrs.add(new Attribute(ATTR_EXCLUDE_ATTRIBUTE, excludeAttributes)); 1510 } 1511 1512 if (! includeFilters.isEmpty()) 1513 { 1514 attrs.add(new Attribute(ATTR_INCLUDE_FILTER, includeFilters)); 1515 } 1516 1517 if (! excludeFilters.isEmpty()) 1518 { 1519 attrs.add(new Attribute(ATTR_EXCLUDE_FILTER, excludeFilters)); 1520 } 1521 1522 if (wrapColumn > 0) 1523 { 1524 attrs.add(new Attribute(ATTR_WRAP_COLUMN, String.valueOf(wrapColumn))); 1525 } 1526 1527 if (encryptionPassphraseFile != null) 1528 { 1529 attrs.add(new Attribute(ATTR_ENCRYPTION_PASSPHRASE_FILE, 1530 encryptionPassphraseFile)); 1531 } 1532 1533 if (encryptionSettingsDefinitionID != null) 1534 { 1535 attrs.add(new Attribute(ATTR_ENCRYPTION_SETTINGS_DEFINITION_ID, 1536 encryptionSettingsDefinitionID)); 1537 } 1538 1539 if (maxMegabytesPerSecond != null) 1540 { 1541 attrs.add(new Attribute(ATTR_MAX_MEGABYTES_PER_SECOND, 1542 String.valueOf(maxMegabytesPerSecond))); 1543 } 1544 1545 return attrs; 1546 } 1547 1548 1549 1550 /** 1551 * {@inheritDoc} 1552 */ 1553 @Override() 1554 public List<TaskProperty> getTaskSpecificProperties() 1555 { 1556 final List<TaskProperty> propList = Arrays.asList( 1557 PROPERTY_BACKEND_ID, 1558 PROPERTY_LDIF_FILE, 1559 PROPERTY_APPEND_TO_LDIF, 1560 PROPERTY_INCLUDE_BRANCH, 1561 PROPERTY_EXCLUDE_BRANCH, 1562 PROPERTY_INCLUDE_FILTER, 1563 PROPERTY_EXCLUDE_FILTER, 1564 PROPERTY_INCLUDE_ATTRIBUTE, 1565 PROPERTY_EXCLUDE_ATTRIBUTE, 1566 PROPERTY_WRAP_COLUMN, 1567 PROPERTY_COMPRESS, 1568 PROPERTY_ENCRYPT, 1569 PROPERTY_ENCRYPTION_PASSPHRASE_FILE, 1570 PROPERTY_ENCRYPTION_SETTINGS_DEFINITION_ID, 1571 PROPERTY_SIGN, 1572 PROPERTY_MAX_MEGABYTES_PER_SECOND); 1573 1574 return Collections.unmodifiableList(propList); 1575 } 1576 1577 1578 1579 /** 1580 * {@inheritDoc} 1581 */ 1582 @Override() 1583 public Map<TaskProperty,List<Object>> getTaskPropertyValues() 1584 { 1585 final LinkedHashMap<TaskProperty,List<Object>> props = 1586 new LinkedHashMap<>(StaticUtils.computeMapCapacity(30)); 1587 1588 props.put(PROPERTY_BACKEND_ID, 1589 Collections.<Object>singletonList(backendID)); 1590 1591 props.put(PROPERTY_LDIF_FILE, 1592 Collections.<Object>singletonList(ldifFile)); 1593 1594 props.put(PROPERTY_APPEND_TO_LDIF, 1595 Collections.<Object>singletonList(appendToLDIF)); 1596 1597 props.put(PROPERTY_INCLUDE_BRANCH, 1598 Collections.<Object>unmodifiableList(includeBranches)); 1599 1600 props.put(PROPERTY_EXCLUDE_BRANCH, 1601 Collections.<Object>unmodifiableList(excludeBranches)); 1602 1603 props.put(PROPERTY_INCLUDE_FILTER, 1604 Collections.<Object>unmodifiableList(includeFilters)); 1605 1606 props.put(PROPERTY_EXCLUDE_FILTER, 1607 Collections.<Object>unmodifiableList(excludeFilters)); 1608 1609 props.put(PROPERTY_INCLUDE_ATTRIBUTE, 1610 Collections.<Object>unmodifiableList(includeAttributes)); 1611 1612 props.put(PROPERTY_EXCLUDE_ATTRIBUTE, 1613 Collections.<Object>unmodifiableList(excludeAttributes)); 1614 1615 props.put(PROPERTY_WRAP_COLUMN, 1616 Collections.<Object>singletonList((long) wrapColumn)); 1617 1618 props.put(PROPERTY_COMPRESS, 1619 Collections.<Object>singletonList(compress)); 1620 1621 props.put(PROPERTY_ENCRYPT, 1622 Collections.<Object>singletonList(encrypt)); 1623 1624 if (encryptionPassphraseFile == null) 1625 { 1626 props.put(PROPERTY_ENCRYPTION_PASSPHRASE_FILE, Collections.emptyList()); 1627 } 1628 else 1629 { 1630 props.put(PROPERTY_ENCRYPTION_PASSPHRASE_FILE, 1631 Collections.<Object>singletonList(encryptionPassphraseFile)); 1632 } 1633 1634 if (encryptionSettingsDefinitionID == null) 1635 { 1636 props.put(PROPERTY_ENCRYPTION_SETTINGS_DEFINITION_ID, 1637 Collections.emptyList()); 1638 } 1639 else 1640 { 1641 props.put(PROPERTY_ENCRYPTION_SETTINGS_DEFINITION_ID, 1642 Collections.<Object>singletonList(encryptionSettingsDefinitionID)); 1643 } 1644 1645 props.put(PROPERTY_SIGN, Collections.<Object>singletonList(sign)); 1646 1647 if (maxMegabytesPerSecond == null) 1648 { 1649 props.put(PROPERTY_MAX_MEGABYTES_PER_SECOND, Collections.emptyList()); 1650 } 1651 else 1652 { 1653 props.put(PROPERTY_MAX_MEGABYTES_PER_SECOND, 1654 Collections.<Object>singletonList(maxMegabytesPerSecond.longValue())); 1655 } 1656 1657 props.putAll(super.getTaskPropertyValues()); 1658 return Collections.unmodifiableMap(props); 1659 } 1660}