001/*
002 * Copyright 2023-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2023-2024 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) 2023-2024 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.Date;
042import java.util.Iterator;
043import java.util.List;
044
045import com.unboundid.util.Mutable;
046import com.unboundid.util.NotNull;
047import com.unboundid.util.Nullable;
048import com.unboundid.util.ThreadSafety;
049import com.unboundid.util.ThreadSafetyLevel;
050import com.unboundid.util.Validator;
051
052
053
054/**
055 * This class defines a set of properties that may be used in conjunction with
056 * an LDIF export administrative task.
057 * <BR>
058 * <BLOCKQUOTE>
059 *   <B>NOTE:</B>  This class, and other classes within the
060 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
061 *   supported for use against Ping Identity, UnboundID, and
062 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
063 *   for proprietary functionality or for external specifications that are not
064 *   considered stable or mature enough to be guaranteed to work in an
065 *   interoperable way with other types of LDAP servers.
066 * </BLOCKQUOTE>
067 */
068@Mutable()
069@ThreadSafety(level=ThreadSafetyLevel.NOT_THREADSAFE)
070public final class ExportTaskProperties
071{
072  // Indicates whether to append the data to an existing file.
073  private boolean appendToLDIF;
074
075  // Indicates whether to compress the data.
076  private boolean compress;
077
078  // Indicates whether to encrypt the data.
079  private boolean encrypt;
080
081  // Indicates whether to sign the data.
082  private boolean sign;
083
084  // Indicates whether to generate an administrative alert if the task completes
085  // with an error.
086  @Nullable private Boolean alertOnError;
087
088  // Indicates whether to generate an administrative alert when the task starts
089  // running.
090  @Nullable private Boolean alertOnStart;
091
092  // Indicates whether to generate an administrative alert if the task completes
093  // successfully.
094  @Nullable private Boolean alertOnSuccess;
095
096  // The time at which the task should start running.
097  @Nullable private Date scheduledStartTime;
098
099  // The action to take if any of the dependencies for this task complete
100  // unsuccessfully.
101  @Nullable private FailedDependencyAction failedDependencyAction;
102
103  // The column at which to wrap long lines.
104  private int wrapColumn;
105
106  // The maximum write rate in megabytes per second.
107  @Nullable private Integer maxMegabytesPerSecond;
108
109  // The dependency IDs of any tasks on which the collect support data task
110  // should depend.
111  @NotNull private final List<String> dependencyIDs;
112
113  // The set of attributes to exclude from the export.
114  @NotNull private final List<String> excludeAttributes;
115
116  // The set of base DNs to exclude from the export.
117  @NotNull private final List<String> excludeBranches;
118
119  // The set of filters to use to identify entries to exclude.
120  @NotNull private final List<String> excludeFilters;
121
122  // The set of attributes to include in the export.
123  @NotNull private final List<String> includeAttributes;
124
125  // The set of base DNs to include in the export.
126  @NotNull private final List<String> includeBranches;
127
128  // The set of filters to use to identify entries to include.
129  @NotNull private final List<String> includeFilters;
130
131  // The addresses to email whenever the task completes, regardless of success
132  // or failure.
133  @NotNull private final List<String> notifyOnCompletion;
134
135  // The addresses to email if the task completes with an error.
136  @NotNull private final List<String> notifyOnError;
137
138  // The addresses to email when the task starts.
139  @NotNull private final List<String> notifyOnStart;
140
141  // The addresses to email if the task completes successfully.
142  @NotNull private final List<String> notifyOnSuccess;
143
144  // The names or DNs of the post-ldif-export task processors to invoke for
145  // the export.
146  @NotNull private final List<String> postExportTaskProcessors;
147
148  // The backend ID of the backend to export.
149  @NotNull private String backendID;
150
151  // The path to a file containing the passphrase to use to generate the
152  // encryption key.
153  @Nullable private String encryptionPassphraseFile;
154
155  // The identifier for the encryption settings definition to use to generate
156  // the encryption key.
157  @Nullable private String encryptionSettingsDefinitionID;
158
159  // The path to the LDIF file to generate.
160  @NotNull private String ldifFile;
161
162  // The task ID to use for the collect support data task.
163  @Nullable private String taskID;
164
165
166
167  /**
168   * Creates a new set of export task properties without default values for
169   * all properties except those specified.
170   *
171   * @param  backendID  The backend ID of the backend containing the data to
172   *                    export.  It must not be {@code null}.
173   * @param  ldifFile   The path to the LDIF file to create.  It may be an
174   *                    absolute path or a path relative to the server install
175   *                    root.  It must not be {@code null}.
176   */
177  public ExportTaskProperties(@NotNull final String backendID,
178                              @NotNull final String ldifFile)
179  {
180    this.backendID = backendID;
181    this.ldifFile = ldifFile;
182
183    appendToLDIF = false;
184    compress = false;
185    encrypt = false;
186    sign = false;
187    alertOnError = null;
188    alertOnStart = null;
189    alertOnSuccess = null;
190    scheduledStartTime = null;
191    failedDependencyAction = null;
192    wrapColumn = -1;
193    maxMegabytesPerSecond = null;
194    dependencyIDs = new ArrayList<>(5);
195    excludeAttributes = new ArrayList<>(5);
196    excludeBranches = new ArrayList<>(5);
197    excludeFilters = new ArrayList<>(5);
198    includeAttributes = new ArrayList<>(5);
199    includeBranches = new ArrayList<>(5);
200    includeFilters = new ArrayList<>(5);
201    notifyOnCompletion = new ArrayList<>(5);
202    notifyOnError = new ArrayList<>(5);
203    notifyOnStart = new ArrayList<>(5);
204    notifyOnSuccess = new ArrayList<>(5);
205    postExportTaskProcessors = new ArrayList<>(5);
206    encryptionPassphraseFile = null;
207    encryptionSettingsDefinitionID = null;
208    taskID = null;
209  }
210
211
212
213  /**
214   * Creates a new set of export task properties as a copy of the provided set
215   * of properties.
216   *
217   * @param  properties  The export task properties that should be used to
218   *                     create the new export task properties object.  It must
219   *                     not be {@code null}.
220   */
221  public ExportTaskProperties(@NotNull final ExportTaskProperties properties)
222  {
223    appendToLDIF = properties.appendToLDIF;
224    compress = properties.compress;
225    encrypt = properties.encrypt;
226    sign = properties.sign;
227    alertOnError = properties.alertOnError;
228    alertOnStart = properties.alertOnStart;
229    alertOnSuccess = properties.alertOnSuccess;
230    scheduledStartTime = properties.scheduledStartTime;
231    failedDependencyAction = properties.failedDependencyAction;
232    wrapColumn = properties.wrapColumn;
233    maxMegabytesPerSecond = properties.maxMegabytesPerSecond;
234    dependencyIDs = new ArrayList<>(properties.dependencyIDs);
235    excludeAttributes = new ArrayList<>(properties.excludeAttributes);
236    excludeBranches = new ArrayList<>(properties.excludeBranches);
237    excludeFilters = new ArrayList<>(properties.excludeFilters);
238    includeAttributes = new ArrayList<>(properties.includeAttributes);
239    includeBranches = new ArrayList<>(properties.includeBranches);
240    includeFilters = new ArrayList<>(properties.includeFilters);
241    notifyOnCompletion = new ArrayList<>(properties.notifyOnCompletion);
242    notifyOnError = new ArrayList<>(properties.notifyOnError);
243    notifyOnStart = new ArrayList<>(properties.notifyOnStart);
244    notifyOnSuccess = new ArrayList<>(properties.notifyOnSuccess);
245    postExportTaskProcessors =
246         new ArrayList<>(properties.postExportTaskProcessors);
247    backendID = properties.backendID;
248    encryptionPassphraseFile = properties.encryptionPassphraseFile;
249    encryptionSettingsDefinitionID = properties.encryptionSettingsDefinitionID;
250    ldifFile = properties.ldifFile;
251    taskID = properties.taskID;
252  }
253
254
255
256  /**
257   * Creates a new set of export task properties from the settings for the
258   * provided task.
259   *
260   * @param  task  The export task to use to create the task properties.
261   */
262  public ExportTaskProperties(@NotNull final ExportTask task)
263  {
264    appendToLDIF = task.appendToLDIF();
265    compress = task.compress();
266    encrypt = task.encrypt();
267    sign = task.sign();
268    alertOnError = task.getAlertOnError();
269    alertOnStart = task.getAlertOnStart();
270    alertOnSuccess = task.getAlertOnSuccess();
271    scheduledStartTime = task.getScheduledStartTime();
272    failedDependencyAction = task.getFailedDependencyAction();
273    wrapColumn = task.getWrapColumn();
274    maxMegabytesPerSecond = task.getMaxMegabytesPerSecond();
275    dependencyIDs = new ArrayList<>(task.getDependencyIDs());
276    excludeAttributes = new ArrayList<>(task.getExcludeAttributes());
277    excludeBranches = new ArrayList<>(task.getExcludeBranches());
278    excludeFilters = new ArrayList<>(task.getExcludeFilters());
279    includeAttributes = new ArrayList<>(task.getIncludeAttributes());
280    includeBranches = new ArrayList<>(task.getIncludeBranches());
281    includeFilters = new ArrayList<>(task.getIncludeFilters());
282    notifyOnCompletion = new ArrayList<>(task.getNotifyOnCompletionAddresses());
283    notifyOnError = new ArrayList<>(task.getNotifyOnErrorAddresses());
284    notifyOnStart = new ArrayList<>(task.getNotifyOnStartAddresses());
285    notifyOnSuccess = new ArrayList<>(task.getNotifyOnSuccessAddresses());
286    postExportTaskProcessors =
287         new ArrayList<>(task.getPostExportTaskProcessors());
288    backendID = task.getBackendID();
289    encryptionPassphraseFile = task.getEncryptionPassphraseFile();
290    encryptionSettingsDefinitionID = task.getEncryptionSettingsDefinitionID();
291    ldifFile = task.getLDIFFile();
292    taskID = task.getTaskID();
293  }
294
295
296
297  /**
298   * Retrieves the backend ID of the backend to be exported.
299   *
300   * @return  The backend ID of the backend to be exported.
301   */
302  @NotNull()
303  public String getBackendID()
304  {
305    return backendID;
306  }
307
308
309
310  /**
311   * Specifies the backend ID of the backend to be exported.
312   *
313   * @param  backendID  The backend ID of the backend to be exported.  It must
314   *                    not be {@code null}.
315   */
316  public void setBackendID(@NotNull final String backendID)
317  {
318    Validator.ensureNotNullWithMessage(backendID,
319         "ExportTaskProperties.backendID must not be null.");
320
321    this.backendID = backendID;
322  }
323
324
325
326  /**
327   * Retrieves the path to the LDIF file to be written.
328   *
329   * @return  The path to the LDIF file to be written.
330   */
331  @NotNull()
332  public String getLDIFFile()
333  {
334    return ldifFile;
335  }
336
337
338
339  /**
340   * Specifies the path to the LDIF file to be written.
341   *
342   * @param  ldifFile  The path to the LDIF file to be written.  It may be an
343   *                   absolute path or one that is relative to the server
344   *                   root.  It must not be {@code null}.
345   */
346  public void setLDIFFile(@NotNull final String ldifFile)
347  {
348    Validator.ensureNotNullWithMessage(backendID,
349         "ExportTaskProperties.ldifFile must not be null.");
350
351    this.ldifFile = ldifFile;
352  }
353
354
355
356  /**
357   * Indicates whether to append to an existing LDIF file rather than
358   * overwriting it.
359   *
360   * @return  {@code true} if the export should append to an existing LDIF file,
361   *          or {@code false} if the existing file should be overwritten.
362   */
363  public boolean appendToLDIF()
364  {
365    return appendToLDIF;
366  }
367
368
369
370  /**
371   * Specifies whether to append to an existing LDIF file rather than
372   * overwriting it.
373   *
374   * @param  appendToLDIF  Indicates whether to append to an existing LDIF file
375   *                       rather than overwriting it.
376   */
377  public void setAppendToLDIF(final boolean appendToLDIF)
378  {
379    this.appendToLDIF = appendToLDIF;
380  }
381
382
383
384  /**
385   * Retrieves the set of base DNs for the subtrees to include in the export.
386   *
387   * @return  The set of base DNs for the subtrees to include in the export, or
388   *          an empty list if no include base DNs should be specified.
389   */
390  @NotNull()
391  public List<String> getIncludeBranches()
392  {
393    return includeBranches;
394  }
395
396
397
398  /**
399   * Specifies the set of base DNs for the subtrees to include in the export.
400   *
401   * @param  includeBranches  The set of base DNs for the subtrees to include in
402   *                          the export.  It may be {@code null} or empty if no
403   *                          include branches should be specified.
404   */
405  public void setIncludeBranches(@Nullable final List<String> includeBranches)
406  {
407    this.includeBranches.clear();
408    if (includeBranches != null)
409    {
410      this.includeBranches.addAll(includeBranches);
411    }
412  }
413
414
415
416  /**
417   * Retrieves the set of base DNs for the subtrees to exclude from the export.
418   *
419   * @return  The set of base DNs for the subtrees to exclude from the export,
420   *          or an empty list if no exclude base DNs should be specified.
421   */
422  @NotNull()
423  public List<String> getExcludeBranches()
424  {
425    return excludeBranches;
426  }
427
428
429
430  /**
431   * Specifies the set of base DNs for the subtrees to exclude from the export.
432   *
433   * @param  excludeBranches  The set of base DNs for the subtrees to exclude
434   *                          from the export.  It may be {@code null} or empty
435   *                          if no exclude branches should be specified.
436   */
437  public void setExcludeBranches(@Nullable final List<String> excludeBranches)
438  {
439    this.excludeBranches.clear();
440    if (excludeBranches != null)
441    {
442      this.excludeBranches.addAll(excludeBranches);
443    }
444  }
445
446
447
448  /**
449   * Retrieves a set of filter strings to use to identify entries to include in
450   * the export.
451   *
452   * @return  A set of filter strings to use to identify entries to include in
453   *          the export, or an empty list if no include filters should be
454   *          specified.
455   */
456  @NotNull()
457  public List<String> getIncludeFilters()
458  {
459    return includeFilters;
460  }
461
462
463
464  /**
465   * Specifies a set of filter strings to use to identify entries to include in
466   * the export.
467   *
468   * @param  includeFilters  A set of filter strings to use to identify entries
469   *                         to include in the export.  It may be {@code null}
470   *                         or empty if no include filters should be specified.
471   */
472  public void setIncludeFilters(@Nullable final List<String> includeFilters)
473  {
474    this.includeFilters.clear();
475    if (includeFilters != null)
476    {
477      this.includeFilters.addAll(includeFilters);
478    }
479  }
480
481
482
483  /**
484   * Retrieves a set of filter strings to use to identify entries to exclude
485   * from the export.
486   *
487   * @return  A set of filter strings to use to identify entries to exclude from
488   *          the export, or an empty list if no exclude filters should be
489   *          specified.
490   */
491  @NotNull()
492  public List<String> getExcludeFilters()
493  {
494    return excludeFilters;
495  }
496
497
498
499  /**
500   * Specifies a set of filter strings to use to identify entries to exclude
501   * from the export.
502   *
503   * @param  excludeFilters  A set of filter strings to use to identify entries
504   *                         to exclude from the export.  It may be {@code null}
505   *                         or empty if no exclude filters should be specified.
506   */
507  public void setExcludeFilters(@Nullable final List<String> excludeFilters)
508  {
509    this.excludeFilters.clear();
510    if (excludeFilters != null)
511    {
512      this.excludeFilters.addAll(excludeFilters);
513    }
514  }
515
516
517
518  /**
519   * Retrieves the names of the attributes to include in the exported entries.
520   *
521   * @return  The names of the attributes to include in the exported entries, or
522   *          an empty list if no include attributes should be specified.
523   */
524  @NotNull()
525  public List<String> getIncludeAttributes()
526  {
527    return includeAttributes;
528  }
529
530
531
532  /**
533   * Specifies the names of the attributes to include in the exported entries.
534   *
535   * @param  includeAttributes  The names of the attributes to include in the
536   *                            exported entries.  It may be {@code null} or
537   *                            empty if no include attributes should be
538   *                            specified.
539   */
540  public void setIncludeAttributes(
541                   @Nullable final List<String> includeAttributes)
542  {
543    this.includeAttributes.clear();
544    if (includeAttributes != null)
545    {
546      this.includeAttributes.addAll(includeAttributes);
547    }
548  }
549
550
551
552  /**
553   * Retrieves the names of the attributes to exclude from the exported entries.
554   *
555   * @return  The names of the attributes to exclude from the exported entries,
556   *          or an empty list if no exclude attributes should be specified.
557   */
558  @NotNull()
559  public List<String> getExcludeAttributes()
560  {
561    return excludeAttributes;
562  }
563
564
565
566  /**
567   * Specifies the names of the attributes to exclude from the exported entries.
568   *
569   * @param  excludeAttributes  The names of the attributes to exclude from the
570   *                            exported entries.  It may be {@code null} or
571   *                            empty if no exclude attributes should be
572   *                            specified.
573   */
574  public void setExcludeAttributes(
575                   @Nullable final List<String> excludeAttributes)
576  {
577    this.excludeAttributes.clear();
578    if (excludeAttributes != null)
579    {
580      this.excludeAttributes.addAll(excludeAttributes);
581    }
582  }
583
584
585
586  /**
587   * Retrieves the column at which long lines should be wrapped.
588   *
589   * @return  The column at which long lines should be wrapped, or -1 if long
590   *          lines should not be wrapped.
591   */
592  public int getWrapColumn()
593  {
594    return wrapColumn;
595  }
596
597
598
599  /**
600   * Specifies the column at which long lines should be wrapped.
601   *
602   * @param  wrapColumn  The column at which long lines should be wrapped.  It
603   *                     may be less than or equal to zero if long lines should
604   *                     not be wrapped.
605   */
606  public void setWrapColumn(final int wrapColumn)
607  {
608    if (wrapColumn > 0)
609    {
610      this.wrapColumn = wrapColumn;
611    }
612    else
613    {
614      this.wrapColumn = -1;
615    }
616  }
617
618
619
620  /**
621   * Indicates whether the LDIF file should be compressed.
622   *
623   * @return  {@code true} if the LDIF file should be compressed, or
624   *          {@code false} if not.
625   */
626  public boolean compress()
627  {
628    return compress;
629  }
630
631
632
633  /**
634   * Specifies whether the LDIF file should be compressed.
635   *
636   * @param  compress  Indicates whether the LDIF file should be compressed.
637   */
638  public void setCompress(final boolean compress)
639  {
640    this.compress = compress;
641  }
642
643
644
645  /**
646   * Indicates whether the LDIF file should be encrypted.
647   *
648   * @return  {@code true} if the LDIF file should be encrypted, or
649   *          {@code false} if not.
650   */
651  public boolean encrypt()
652  {
653    return encrypt;
654  }
655
656
657
658  /**
659   * Specifies whether the LDIF file should be encrypted.
660   *
661   * @param  encrypt  Indicates whether the LDIF file should be encrypted.
662   */
663  public void setEncrypt(final boolean encrypt)
664  {
665    this.encrypt = encrypt;
666  }
667
668
669
670  /**
671   * Retrieves the path to a file containing the passphrase to use to generate
672   * the encryption key.
673   *
674   * @return  The path to a file containing the passphrase to use to generate
675   *          the encryption key, or {@code null} if the LDIF file should not
676   *          be encrypted or if it should be encrypted with a key obtained
677   *          through some other means.
678   */
679  @Nullable()
680  public String getEncryptionPassphraseFile()
681  {
682    return encryptionPassphraseFile;
683  }
684
685
686
687  /**
688   * Specifies the path to a file containing the passphrase to use to generate
689   * the encryption key.
690   *
691   * @param  encryptionPassphraseFile  The path to a file containing the
692   *                                   passphrase to use to generate the
693   *                                   encryption key.  It may be {@code null}
694   *                                   if the LDIF file should not be encrypted
695   *                                   or if it should be encrypted with a key
696   *                                   obtained through some other means.
697   */
698  public void setEncryptionPassphraseFile(
699                   @Nullable final String encryptionPassphraseFile)
700  {
701    this.encryptionPassphraseFile = encryptionPassphraseFile;
702  }
703
704
705
706  /**
707   * Retrieves the ID of the encryption settings definition to use to generate
708   * the encryption key.
709   *
710   * @return  The ID of the encryption settings definition to use to generate
711   *          the encryption key, or {@code null} if the LDIF file should not be
712   *          encrypted, if it should be encrypted with the server's preferred
713   *          encryption settings definition, or if it should be encrypted with
714   *          a key obtained through some other means.
715   */
716  @Nullable()
717  public String getEncryptionSettingsDefinitionID()
718  {
719    return encryptionSettingsDefinitionID;
720  }
721
722
723
724  /**
725   * Specifies the ID of the encryption settings definition to use to generate
726   * the encryption key.
727   *
728   * @param  encryptionSettingsDefinitionID  The ID of the encryption settings
729   *                                         definition to use to generate the
730   *                                         encryption key.  It may be
731   *                                         {@code null} if the LDIF file
732   *                                         should not be encrypted, if it
733   *                                         should be encrypted with the
734   *                                         server's preferred encryption
735   *                                         settings definition, or if it
736   *                                         should be encrypted with a key
737   *                                         obtained through some other means.
738   */
739  public void setEncryptionSettingsDefinitionID(
740                   @Nullable final String encryptionSettingsDefinitionID)
741  {
742    this.encryptionSettingsDefinitionID = encryptionSettingsDefinitionID;
743  }
744
745
746
747  /**
748   * Indicates whether the LDIF file should be cryptographically signed.
749   *
750   * @return  {@code true} if the LDIF file should be cryptographically signed,
751   *          or {@code false} if not.
752   */
753  public boolean sign()
754  {
755    return sign;
756  }
757
758
759
760  /**
761   * Specifies whether the LDIF file should be cryptographically signed.
762   *
763   * @param  sign  Indicates whether the LDIF file should be cryptographically
764   *               signed.
765   */
766  public void setSign(final boolean sign)
767  {
768    this.sign = sign;
769  }
770
771
772
773  /**
774   * Retrieves the maximum rate at which the LDIF file should be written, in
775   * megabytes per second.
776   *
777   * @return  The maximum rate at which the LDIF file should be written, in
778   *          megabytes per second, or {@code null} if no rate limiting should
779   *          be used.
780   */
781  @Nullable()
782  public Integer getMaxMegabytesPerSecond()
783  {
784    return maxMegabytesPerSecond;
785  }
786
787
788
789  /**
790   * Specifies the maximum rate at which the LDIF file should be written, in
791   * megabytes per second.
792   *
793   * @param  maxMegabytesPerSecond  The maximum rate at which the LDIF file
794   *                                should be written, in megabytes per second.
795   *                                A value of {@code null}, or one that is less
796   *                                than or equal to zero, indicates that no
797   *                                rate limiting should be used.
798   */
799  public void setMaxMegabytesPerSecond(
800                   @Nullable final Integer maxMegabytesPerSecond)
801  {
802    if ((maxMegabytesPerSecond == null) || (maxMegabytesPerSecond <= 0))
803    {
804      this.maxMegabytesPerSecond = null;
805    }
806    else
807    {
808      this.maxMegabytesPerSecond = maxMegabytesPerSecond;
809    }
810
811  }
812
813
814
815  /**
816   * Retrieves a list containing the names or DNs of any post-LDIF-export task
817   * processors that should be invoked for the export.
818   *
819   * @return  A list containing the names or DNs of any post-LDIF-export task
820   *          processors that should be invoked for the export.
821   */
822  @NotNull()
823  public List<String> getPostExportTaskProcessors()
824  {
825    return postExportTaskProcessors;
826  }
827
828
829
830  /**
831   * Specifies a list containing the names or DNs of any post-LDIF-export task
832   * processors that should be invoked for the export.
833   *
834   * @param  postExportTaskProcessors  A list containing the names or DNs of any
835   *                                   post-LDIF-export task processors that
836   *                                   should be invoked for the export.  It may
837   *                                   be {@code null} or empty if no
838   *                                   post-LDIF-export task processors should
839   *                                   be invoked.
840   */
841  public void setPostExportTaskProcessors(
842                   @Nullable final List<String> postExportTaskProcessors)
843  {
844    this.postExportTaskProcessors.clear();
845    if (postExportTaskProcessors != null)
846    {
847      this.postExportTaskProcessors.addAll(postExportTaskProcessors);
848    }
849  }
850
851
852
853  /**
854   * Retrieves the task ID that should be used for the task.
855   *
856   * @return  The task ID that should be used for the task, or {@code null} if a
857   *          random UUID should be generated for use as the task ID.
858   */
859  @Nullable()
860  public String getTaskID()
861  {
862    return taskID;
863  }
864
865
866
867  /**
868   *Specifies the task ID that should be used for the task.
869   *
870   * @param  taskID  The task ID that should be used for the task.  It may be
871   *                 {@code null} if a random UUID should be generated for use
872   *                 as the task ID.
873   */
874  public void setTaskID(@Nullable final String taskID)
875  {
876    this.taskID = taskID;
877  }
878
879
880
881  /**
882   * Retrieves the earliest time that the task should be eligible to start
883   * running.
884   *
885   * @return  The earliest time that the task should be eligible to start
886   *          running, or {@code null} if the task should be eligible to start
887   *          immediately (or as soon as all of its dependencies have been
888   *          satisfied).
889   */
890  @Nullable()
891  public Date getScheduledStartTime()
892  {
893    return scheduledStartTime;
894  }
895
896
897
898  /**
899   * Specifies the earliest time that the task should be eligible to start
900   * running.
901   *
902   * @param  scheduledStartTime  The earliest time that the task should be
903   *                             eligible to start running.  It may be
904   *                             {@code null} if the task should be eligible to
905   *                             start immediately (or as soon as all of its
906   *                             dependencies have been satisfied).
907   */
908  public void setScheduledStartTime(@Nullable final Date scheduledStartTime)
909  {
910    this.scheduledStartTime = scheduledStartTime;
911  }
912
913
914
915  /**
916   * Retrieves the task IDs for any tasks that must complete before the new
917   * collect support data task will be eligible to start running.
918   *
919   * @return  The task IDs for any tasks that must complete before the new
920   *          collect support data task will be eligible to start running, or
921   *          an empty list if the new task should not depend on any other
922   *          tasks.
923   */
924  @NotNull()
925  public List<String> getDependencyIDs()
926  {
927    return new ArrayList<>(dependencyIDs);
928  }
929
930
931
932  /**
933   * Specifies the task IDs for any tasks that must complete before the new
934   * collect support data task will be eligible to start running.
935   *
936   * @param  dependencyIDs  The task IDs for any tasks that must complete before
937   *                        the new collect support data task will be eligible
938   *                        to start running.  It may be {@code null} or empty
939   *                        if the new task should not depend on any other
940   *                        tasks.
941   */
942  public void setDependencyIDs(@Nullable final List<String> dependencyIDs)
943  {
944    this.dependencyIDs.clear();
945    if (dependencyIDs != null)
946    {
947      this.dependencyIDs.addAll(dependencyIDs);
948    }
949  }
950
951
952
953  /**
954   * Retrieves the action that the server should take if any of the tasks on
955   * which the new task depends did not complete successfully.
956   *
957   * @return  The action that the server should take if any of the tasks on
958   *          which the new task depends did not complete successfully, or
959   *          {@code null} if the property should not be specified when creating
960   *          the task (and the server should choose an appropriate failed
961   *          dependency action).
962   */
963  @Nullable()
964  public FailedDependencyAction getFailedDependencyAction()
965  {
966    return failedDependencyAction;
967  }
968
969
970
971  /**
972   * Specifies the action that the server should take if any of the tasks on
973   * which the new task depends did not complete successfully.
974   *
975   * @param  failedDependencyAction  The action that the server should take if
976   *                                 any of the tasks on which the new task
977   *                                 depends did not complete successfully.  It
978   *                                 may be {@code null} if the property should
979   *                                 not be specified when creating the task
980   *                                 (and the server should choose an
981   *                                 appropriate failed dependency action).
982   */
983  public void setFailedDependencyAction(
984       @Nullable final FailedDependencyAction failedDependencyAction)
985  {
986    this.failedDependencyAction = failedDependencyAction;
987  }
988
989
990
991  /**
992   * Retrieves the addresses to email whenever the task starts running.
993   *
994   * @return  The addresses to email whenever the task starts running, or an
995   *          empty list if no email notification should be sent when starting
996   *          the task.
997   */
998  @NotNull()
999  public List<String> getNotifyOnStart()
1000  {
1001    return new ArrayList<>(notifyOnStart);
1002  }
1003
1004
1005
1006  /**
1007   * Specifies the addresses to email whenever the task starts running.
1008   *
1009   * @param  notifyOnStart  The addresses to email whenever the task starts
1010   *                        running.  It amy be {@code null} or empty if no
1011   *                        email notification should be sent when starting the
1012   *                        task.
1013   */
1014  public void setNotifyOnStart(@Nullable final List<String> notifyOnStart)
1015  {
1016    this.notifyOnStart.clear();
1017    if (notifyOnStart != null)
1018    {
1019      this.notifyOnStart.addAll(notifyOnStart);
1020    }
1021  }
1022
1023
1024
1025  /**
1026   * Retrieves the addresses to email whenever the task completes, regardless of
1027   * its success or failure.
1028   *
1029   * @return  The addresses to email whenever the task completes, or an
1030   *          empty list if no email notification should be sent when the task
1031   *          completes.
1032   */
1033  @NotNull()
1034  public List<String> getNotifyOnCompletion()
1035  {
1036    return new ArrayList<>(notifyOnCompletion);
1037  }
1038
1039
1040
1041  /**
1042   * Specifies the addresses to email whenever the task completes, regardless of
1043   * its success or failure.
1044   *
1045   * @param  notifyOnCompletion  The addresses to email whenever the task
1046   *                             completes.  It amy be {@code null} or empty if
1047   *                             no email notification should be sent when the
1048   *                             task completes.
1049   */
1050  public void setNotifyOnCompletion(
1051                   @Nullable final List<String> notifyOnCompletion)
1052  {
1053    this.notifyOnCompletion.clear();
1054    if (notifyOnCompletion != null)
1055    {
1056      this.notifyOnCompletion.addAll(notifyOnCompletion);
1057    }
1058  }
1059
1060
1061
1062  /**
1063   * Retrieves the addresses to email if the task completes successfully.
1064   *
1065   * @return  The addresses to email if the task completes successfully, or an
1066   *          empty list if no email notification should be sent on successful
1067   *          completion.
1068   */
1069  @NotNull()
1070  public List<String> getNotifyOnSuccess()
1071  {
1072    return new ArrayList<>(notifyOnSuccess);
1073  }
1074
1075
1076
1077  /**
1078   * Specifies the addresses to email if the task completes successfully.
1079   *
1080   * @param  notifyOnSuccess  The addresses to email if the task completes
1081   *                          successfully.  It amy be {@code null} or empty if
1082   *                          no email notification should be sent on
1083   *                          successful completion.
1084   */
1085  public void setNotifyOnSuccess(@Nullable final List<String> notifyOnSuccess)
1086  {
1087    this.notifyOnSuccess.clear();
1088    if (notifyOnSuccess != null)
1089    {
1090      this.notifyOnSuccess.addAll(notifyOnSuccess);
1091    }
1092  }
1093
1094
1095
1096  /**
1097   * Retrieves the addresses to email if the task does not complete
1098   * successfully.
1099   *
1100   * @return  The addresses to email if the task does not complete successfully,
1101   *          or an empty list if no email notification should be sent on an
1102   *          unsuccessful completion.
1103   */
1104  @NotNull()
1105  public List<String> getNotifyOnError()
1106  {
1107    return new ArrayList<>(notifyOnError);
1108  }
1109
1110
1111
1112  /**
1113   * Specifies the addresses to email if the task does not complete
1114   * successfully.
1115   *
1116   * @param  notifyOnError  The addresses to email if the task does not complete
1117   *                        successfully.  It amy be {@code null} or empty if
1118   *                        no email notification should be sent on an
1119   *                        unsuccessful completion.
1120   */
1121  public void setNotifyOnError(@Nullable final List<String> notifyOnError)
1122  {
1123    this.notifyOnError.clear();
1124    if (notifyOnError != null)
1125    {
1126      this.notifyOnError.addAll(notifyOnError);
1127    }
1128  }
1129
1130
1131
1132  /**
1133   * Retrieves the flag that indicates whether the server should send an
1134   * administrative alert notification when the task starts running.
1135   *
1136   * @return  The flag that indicates whether the server should send an
1137   *          administrative alert notification when the task starts running,
1138   *          or {@code null} if the property should not be specified when the
1139   *          task is created (and the server will default to not sending any
1140   *          alert).
1141   */
1142  @Nullable()
1143  public Boolean getAlertOnStart()
1144  {
1145    return alertOnStart;
1146  }
1147
1148
1149
1150  /**
1151   * Specifies the flag that indicates whether the server should send an
1152   * administrative alert notification when the task starts running.
1153   *
1154   * @param  alertOnStart  The flag that indicates whether the server should
1155   *                       send an administrative alert notification when the
1156   *                       task starts running,  It may be {@code null} if the
1157   *                       property should not be specified when the task is
1158   *                       created (and the server will default to not sending
1159   *                       any alert).
1160   */
1161  public void setAlertOnStart(@Nullable final Boolean alertOnStart)
1162  {
1163    this.alertOnStart = alertOnStart;
1164  }
1165
1166
1167
1168  /**
1169   * Retrieves the flag that indicates whether the server should send an
1170   * administrative alert notification if the task completes successfully.
1171   *
1172   * @return  The flag that indicates whether the server should send an
1173   *          administrative alert notification if the task completes
1174   *          successfully, or {@code null} if the property should not be
1175   *          specified when the task is created (and the server will default to
1176   *          not sending any alert).
1177   */
1178  @Nullable()
1179  public Boolean getAlertOnSuccess()
1180  {
1181    return alertOnSuccess;
1182  }
1183
1184
1185
1186  /**
1187   * Specifies the flag that indicates whether the server should send an
1188   * administrative alert notification if the task completes successfully.
1189   *
1190   * @param  alertOnSuccess  The flag that indicates whether the server should
1191   *                         send an administrative alert notification if the
1192   *                         task completes successfully,  It may be
1193   *                         {@code null} if the property should not be
1194   *                         specified when the task is created (and the server
1195   *                         will default to not sending any alert).
1196   */
1197  public void setAlertOnSuccess(@Nullable final Boolean alertOnSuccess)
1198  {
1199    this.alertOnSuccess = alertOnSuccess;
1200  }
1201
1202
1203
1204  /**
1205   * Retrieves the flag that indicates whether the server should send an
1206   * administrative alert notification if the task does not complete
1207   * successfully.
1208   *
1209   * @return  The flag that indicates whether the server should send an
1210   *          administrative alert notification if the task does not complete
1211   *          successfully, or {@code null} if the property should not be
1212   *          specified when the task is created (and the server will default to
1213   *          not sending any alert).
1214   */
1215  @Nullable()
1216  public Boolean getAlertOnError()
1217  {
1218    return alertOnError;
1219  }
1220
1221
1222
1223  /**
1224   * Specifies the flag that indicates whether the server should send an
1225   * administrative alert notification if the task does not complete
1226   * successfully.
1227   *
1228   * @param  alertOnError  The flag that indicates whether the server should
1229   *                       send an administrative alert notification if the task
1230   *                       does not complete successfully,  It may be
1231   *                       {@code null} if the property should not be specified
1232   *                       when the task is created (and the server will default
1233   *                       to not sending any alert).
1234   */
1235  public void setAlertOnError(@Nullable final Boolean alertOnError)
1236  {
1237    this.alertOnError = alertOnError;
1238  }
1239
1240
1241
1242  /**
1243   * Retrieves a string representation of this collect support data task
1244   * properties object.
1245   *
1246   * @return  A string representation of this collect support data task
1247   *          properties object.
1248   */
1249  @Override()
1250  @NotNull()
1251  public String toString()
1252  {
1253    final StringBuilder buffer = new StringBuilder();
1254    toString(buffer);
1255    return buffer.toString();
1256  }
1257
1258
1259
1260  /**
1261   * Appends a string representation of this collect support data task
1262   * properties object to the provided buffer.
1263   *
1264   * @param  buffer  The buffer to which the string representation will be
1265   *                 appended.  It must not be {@code null}.
1266   */
1267  public void toString(@NotNull final StringBuilder buffer)
1268  {
1269    buffer.append("ExportTaskProperties(");
1270
1271    appendNameValuePair(buffer, "taskID", taskID);
1272    appendNameValuePair(buffer, "backendID", backendID);
1273    appendNameValuePair(buffer, "ldifFile", ldifFile);
1274    appendNameValuePair(buffer, "appendToLDIF", appendToLDIF);
1275    appendNameValuePair(buffer, "includeBranches", includeBranches);
1276    appendNameValuePair(buffer, "excludeBranches", excludeBranches);
1277    appendNameValuePair(buffer, "includeFilters", includeFilters);
1278    appendNameValuePair(buffer, "excludeFilters", excludeFilters);
1279    appendNameValuePair(buffer, "includeAttributes", includeAttributes);
1280    appendNameValuePair(buffer, "excludeAttributes", excludeAttributes);
1281    appendNameValuePair(buffer, "wrapColumn", wrapColumn);
1282    appendNameValuePair(buffer, "compress", compress);
1283    appendNameValuePair(buffer, "encrypt", encrypt);
1284    appendNameValuePair(buffer, "encryptionPassphraseFile",
1285         encryptionPassphraseFile);
1286    appendNameValuePair(buffer, "encryptionSettingsDefinitionID",
1287         encryptionSettingsDefinitionID);
1288    appendNameValuePair(buffer, "sign", sign);
1289    appendNameValuePair(buffer, "maxMegabytesPerSecond", maxMegabytesPerSecond);
1290    appendNameValuePair(buffer, "postExportTaskProcessors",
1291         postExportTaskProcessors);
1292    appendNameValuePair(buffer, "scheduledStartTime", scheduledStartTime);
1293    appendNameValuePair(buffer, "dependencyIDs", dependencyIDs);
1294    appendNameValuePair(buffer, "failedDependencyAction",
1295         failedDependencyAction);
1296    appendNameValuePair(buffer, "notifyOnStart", notifyOnStart);
1297    appendNameValuePair(buffer, "notifyOnCompletion", notifyOnCompletion);
1298    appendNameValuePair(buffer, "notifyOnSuccess", notifyOnSuccess);
1299    appendNameValuePair(buffer, "notifyOnError", notifyOnError);
1300    appendNameValuePair(buffer, "alertOnStart", alertOnStart);
1301    appendNameValuePair(buffer, "alertOnSuccess", alertOnSuccess);
1302    appendNameValuePair(buffer, "alertOnError", alertOnError);
1303
1304    buffer.append(')');
1305  }
1306
1307
1308
1309  /**
1310   * Appends a name-value pair to the provided buffer, if the value is
1311   * non-{@code null}.
1312   *
1313   * @param  buffer  The buffer to which the name-value pair should be appended.
1314   * @param  name    The name to be used.  It must not be {@code null}.
1315   * @param  value   The value to be used.  It may be {@code null} if there is
1316   *                 no value for the property.
1317   */
1318  private static void appendNameValuePair(@NotNull final StringBuilder buffer,
1319                                          @NotNull final String name,
1320                                          @Nullable final Object value)
1321  {
1322    if (value == null)
1323    {
1324      return;
1325    }
1326
1327    if ((buffer.length() > 0) &&
1328         (buffer.charAt(buffer.length() - 1) != '('))
1329    {
1330      buffer.append(", ");
1331    }
1332
1333    buffer.append(name);
1334    buffer.append("='");
1335    buffer.append(value);
1336    buffer.append('\'');
1337  }
1338
1339
1340
1341  /**
1342   * Appends a name-value pair to the provided buffer, if the value is
1343   * non-{@code null}.
1344   *
1345   * @param  buffer   The buffer to which the name-value pair should be
1346   *                  appended.
1347   * @param  name     The name to be used.  It must not be {@code null}.
1348   * @param  values   The list of values to be used.  It may be {@code null} or
1349   *                  empty if there are no values for the property.
1350   */
1351  private static void appendNameValuePair(@NotNull final StringBuilder buffer,
1352                                          @NotNull final String name,
1353                                          @Nullable final List<String> values)
1354  {
1355    if ((values == null) || values.isEmpty())
1356    {
1357      return;
1358    }
1359
1360    if ((buffer.length() > 0) &&
1361         (buffer.charAt(buffer.length() - 1) != '('))
1362    {
1363      buffer.append(", ");
1364    }
1365
1366    buffer.append(name);
1367    buffer.append("={ ");
1368
1369    final Iterator<String> iterator = values.iterator();
1370    while (iterator.hasNext())
1371    {
1372      buffer.append('\'');
1373      buffer.append(iterator.next());
1374      buffer.append('\'');
1375
1376      if (iterator.hasNext())
1377      {
1378        buffer.append(", ");
1379      }
1380    }
1381
1382    buffer.append('}');
1383  }
1384}