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