001/*
002 * Copyright 2010-2018 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2015-2018 Ping Identity Corporation
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License (GPLv2 only)
010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011 * as published by the Free Software Foundation.
012 *
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program; if not, see <http://www.gnu.org/licenses>.
020 */
021package com.unboundid.ldap.sdk.unboundidds.tasks;
022
023
024
025import java.util.Arrays;
026import java.util.Collections;
027import java.util.Date;
028import java.util.LinkedHashMap;
029import java.util.LinkedList;
030import java.util.List;
031import java.util.Map;
032
033import com.unboundid.ldap.sdk.Attribute;
034import com.unboundid.ldap.sdk.Entry;
035import com.unboundid.util.NotMutable;
036import com.unboundid.util.StaticUtils;
037import com.unboundid.util.ThreadSafety;
038import com.unboundid.util.ThreadSafetyLevel;
039
040import static com.unboundid.ldap.sdk.unboundidds.tasks.TaskMessages.*;
041import static com.unboundid.util.Validator.*;
042
043
044
045/**
046 * This class defines a Directory Server task that can be used to cause the
047 * server to generate administrative alerts, or to manage the set of degraded or
048 * unavailable alert types.
049 * <BR>
050 * <BLOCKQUOTE>
051 *   <B>NOTE:</B>  This class, and other classes within the
052 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
053 *   supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661
054 *   server products.  These classes provide support for proprietary
055 *   functionality or for external specifications that are not considered stable
056 *   or mature enough to be guaranteed to work in an interoperable way with
057 *   other types of LDAP servers.
058 * </BLOCKQUOTE>
059 * <BR>
060 * The properties that are available for use with this type of task include:
061 * <UL>
062 *   <LI>The alert type of the alert notification to generate.  If this is
063 *       provided, then an alert message must also be provided.</LI>
064 *   <LI>The alert message for the alert notification to generate.  If this is
065 *       provided, then an alert type must also be provided.</LI>
066 *   <LI>The names of the alert types to add to the set of degraded alert types
067 *       in the general monitor entry.</LI>
068 *   <LI>The names of the alert types to remove from the set of degraded alert
069 *       types in the general monitor entry.</LI>
070 *   <LI>The names of the alert types to add to the set of unavailable alert
071 *       types in the general monitor entry.</LI>
072 *   <LI>The names of the alert types to remove from the set of unavailable
073 *       alert types in the general monitor entry.</LI>
074 * </UL>
075 */
076@NotMutable()
077@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
078public final class AlertTask
079       extends Task
080{
081  /**
082   * The fully-qualified name of the Java class that is used for the alert task.
083   */
084  static final String ALERT_TASK_CLASS =
085       "com.unboundid.directory.server.tasks.AlertTask";
086
087
088
089  /**
090   * The name of the attribute used to specify the alert type for the alert to
091   * generate.
092   */
093  private static final String ATTR_ALERT_TYPE = "ds-task-alert-type";
094
095
096
097  /**
098   * The name of the attribute used to specify the message for the alert to
099   * generate.
100   */
101  private static final String ATTR_ALERT_MESSAGE = "ds-task-alert-message";
102
103
104
105  /**
106   * The name of the attribute used to specify the alert type(s) to add to the
107   * set of degraded alert types.
108   */
109  private static final String ATTR_ADD_DEGRADED_TYPE =
110       "ds-task-alert-add-degraded-type";
111
112
113
114  /**
115   * The name of the attribute used to specify the alert type(s) to remove from
116   * the set of degraded alert types.
117   */
118  private static final String ATTR_REMOVE_DEGRADED_TYPE =
119       "ds-task-alert-remove-degraded-type";
120
121
122
123  /**
124   * The name of the attribute used to specify the alert type(s) to add to the
125   * set of unavailable alert types.
126   */
127  private static final String ATTR_ADD_UNAVAILABLE_TYPE =
128       "ds-task-alert-add-unavailable-type";
129
130
131
132  /**
133   * The name of the attribute used to specify the alert type(s) to remove from
134   * the set of unavailable alert types.
135   */
136  private static final String ATTR_REMOVE_UNAVAILABLE_TYPE =
137       "ds-task-alert-remove-unavailable-type";
138
139
140
141  /**
142   * The name of the object class used in alert task entries.
143   */
144  private static final String OC_ALERT_TASK = "ds-task-alert";
145
146
147
148  /**
149   * The task property that will be used for the alert type.
150   */
151  private static final TaskProperty PROPERTY_ALERT_TYPE =
152     new TaskProperty(ATTR_ALERT_TYPE, INFO_ALERT_DISPLAY_NAME_TYPE.get(),
153          INFO_ALERT_DESCRIPTION_TYPE.get(), String.class, false, false,
154          false);
155
156
157
158  /**
159   * The task property that will be used for the alert message.
160   */
161  private static final TaskProperty PROPERTY_ALERT_MESSAGE =
162     new TaskProperty(ATTR_ALERT_MESSAGE, INFO_ALERT_DISPLAY_NAME_MESSAGE.get(),
163          INFO_ALERT_DESCRIPTION_MESSAGE.get(), String.class, false, false,
164          false);
165
166
167
168  /**
169   * The task property that will be used for the add degraded alert types.
170   */
171  private static final TaskProperty PROPERTY_ADD_DEGRADED_TYPE =
172     new TaskProperty(ATTR_ADD_DEGRADED_TYPE,
173          INFO_ALERT_DISPLAY_NAME_ADD_DEGRADED.get(),
174          INFO_ALERT_DESCRIPTION_ADD_DEGRADED.get(), String.class, false, true,
175          false);
176
177
178
179  /**
180   * The task property that will be used for the remove degraded alert types.
181   */
182  private static final TaskProperty PROPERTY_REMOVE_DEGRADED_TYPE =
183     new TaskProperty(ATTR_REMOVE_DEGRADED_TYPE,
184          INFO_ALERT_DISPLAY_NAME_REMOVE_DEGRADED.get(),
185          INFO_ALERT_DESCRIPTION_REMOVE_DEGRADED.get(), String.class, false,
186          true, false);
187
188
189
190  /**
191   * The task property that will be used for the add unavailable alert types.
192   */
193  private static final TaskProperty PROPERTY_ADD_UNAVAILABLE_TYPE =
194     new TaskProperty(ATTR_ADD_UNAVAILABLE_TYPE,
195          INFO_ALERT_DISPLAY_NAME_ADD_UNAVAILABLE.get(),
196          INFO_ALERT_DESCRIPTION_ADD_UNAVAILABLE.get(), String.class, false,
197          true, false);
198
199
200
201  /**
202   * The task property that will be used for the remove unavailable alert types.
203   */
204  private static final TaskProperty PROPERTY_REMOVE_UNAVAILABLE_TYPE =
205     new TaskProperty(ATTR_REMOVE_UNAVAILABLE_TYPE,
206          INFO_ALERT_DISPLAY_NAME_REMOVE_UNAVAILABLE.get(),
207          INFO_ALERT_DESCRIPTION_REMOVE_UNAVAILABLE.get(), String.class, false,
208          true, false);
209
210
211
212  /**
213   * The serial version UID for this serializable class.
214   */
215  private static final long serialVersionUID = 8253375533166941221L;
216
217
218
219  // The alert types to add to the set of degraded alert types.
220  private final List<String> addDegradedTypes;
221
222  // The alert types to add to the set of unavailable alert types.
223  private final List<String> addUnavailableTypes;
224
225  // The alert types to remove from the set of degraded alert types.
226  private final List<String> removeDegradedTypes;
227
228  // The alert types to remove from the set of unavailable alert types.
229  private final List<String> removeUnavailableTypes;
230
231  // The message for the alert to be generated.
232  private final String alertMessage;
233
234  // The name of the alert type for the alert to be generated.
235  private final String alertType;
236
237
238
239  /**
240   * Creates a new uninitialized alert task instance which should only be used
241   * for obtaining general information about this task, including the task name,
242   * description, and supported properties.  Attempts to use a task created with
243   * this constructor for any other reason will likely fail.
244   */
245  public AlertTask()
246  {
247    alertType              = null;
248    alertMessage           = null;
249    addDegradedTypes       = null;
250    addUnavailableTypes    = null;
251    removeDegradedTypes    = null;
252    removeUnavailableTypes = null;
253  }
254
255
256
257
258  /**
259   * Creates a new alert task that can be used to generate an administrative
260   * alert with the provided information.
261   *
262   * @param  alertType     The alert type to use for the generated alert.  It
263   *                       must not be {@code null}.
264   * @param  alertMessage  The message to use for the generated alert.  It must
265   *                       not be {@code null}.
266   */
267  public AlertTask(final String alertType, final String alertMessage)
268  {
269    this(null, alertType, alertMessage, null, null, null, null, null, null,
270         null, null, null);
271  }
272
273
274
275  /**
276   * Creates a new alert task that can be used to generate an administrative
277   * alert and/or update the set of degraded or unavailable alert types for the
278   * Directory Server.  At least one element must be provided.
279   *
280   * @param  alertType               The alert type to use for the generated
281   *                                 alert.  It may be {@code null} if no alert
282   *                                 should be generated, but if it is
283   *                                 non-{@code null} then the alert message
284   *                                 must also be non-{@code null}.
285   * @param  alertMessage            The message to use for the generated alert.
286   *                                 It may be {@code null} if no alert should
287   *                                 be generated, but if it is non-{@code null}
288   *                                 then the alert type must also be
289   *                                 non-{@code null}.
290   * @param  addDegradedTypes        The names of the alert types to add to the
291   *                                 Directory Server's set of degraded alert
292   *                                 types.  It may be {@code null} or empty if
293   *                                 no degraded alert types should be added.
294   * @param  removeDegradedTypes     The names of the alert types to remove from
295   *                                 the Directory Server's set of degraded
296   *                                 alert types.  It may be {@code null} or
297   *                                 empty if no degraded alert types should be
298   *                                 removed.
299   * @param  addUnavailableTypes     The names of the alert types to add to the
300   *                                 Directory Server's set of unavailable alert
301   *                                 types.  It may be {@code null} or empty if
302   *                                 no unavailable alert types should be added.
303   * @param  removeUnavailableTypes  The names of the alert types to remove from
304   *                                 the Directory Server's set of unavailable
305   *                                 alert types.  It may be {@code null} or
306   *                                 empty if no unavailable alert types should
307   *                                 be removed.
308   */
309  public AlertTask(final String alertType, final String alertMessage,
310                   final List<String> addDegradedTypes,
311                   final List<String> removeDegradedTypes,
312                   final List<String> addUnavailableTypes,
313                   final List<String> removeUnavailableTypes)
314  {
315    this(null, alertType, alertMessage, addDegradedTypes, removeDegradedTypes,
316         addUnavailableTypes, removeUnavailableTypes, null, null, null,
317         null, null);
318  }
319
320
321
322  /**
323   * Creates a new alert task that can be used to generate an administrative
324   * alert and/or update the set of degraded or unavailable alert types for the
325   * Directory Server.  At least one alert-related element must be provided.
326   *
327   * @param  taskID                  The task ID to use for this task.  If it is
328   *                                 {@code null} then a UUID will be generated
329   *                                 for use as the task ID.
330   * @param  alertType               The alert type to use for the generated
331   *                                 alert.  It may be {@code null} if no alert
332   *                                 should be generated, but if it is
333   *                                 non-{@code null} then the alert message
334   *                                 must also be non-{@code null}.
335   * @param  alertMessage            The message to use for the generated alert.
336   *                                 It may be {@code null} if no alert should
337   *                                 be generated, but if it is non-{@code null}
338   *                                 then the alert type must also be
339   *                                 non-{@code null}.
340   * @param  addDegradedTypes        The names of the alert types to add to the
341   *                                 Directory Server's set of degraded alert
342   *                                 types.  It may be {@code null} or empty if
343   *                                 no degraded alert types should be added.
344   * @param  removeDegradedTypes     The names of the alert types to remove from
345   *                                 the Directory Server's set of degraded
346   *                                 alert types.  It may be {@code null} or
347   *                                 empty if no degraded alert types should be
348   *                                 removed.
349   * @param  addUnavailableTypes     The names of the alert types to add to the
350   *                                 Directory Server's set of unavailable alert
351   *                                 types.  It may be {@code null} or empty if
352   *                                 no unavailable alert types should be added.
353   * @param  removeUnavailableTypes  The names of the alert types to remove from
354   *                                 the Directory Server's set of unavailable
355   *                                 alert types.  It may be {@code null} or
356   *                                 empty if no unavailable alert types should
357   *                                 be removed.
358   * @param  scheduledStartTime      The time that this task should start
359   *                                 running.
360   * @param  dependencyIDs           The list of task IDs that will be required
361   *                                 to complete before this task will be
362   *                                 eligible to start.
363   * @param  failedDependencyAction  Indicates what action should be taken if
364   *                                 any of the dependencies for this task do
365   *                                 not complete successfully.
366   * @param  notifyOnCompletion      The list of e-mail addresses of individuals
367   *                                 that should be notified when this task
368   *                                 completes.
369   * @param  notifyOnError           The list of e-mail addresses of individuals
370   *                                 that should be notified if this task does
371   *                                 not complete successfully.
372   */
373  public AlertTask(final String taskID, final String alertType,
374                   final String alertMessage,
375                   final List<String> addDegradedTypes,
376                   final List<String> removeDegradedTypes,
377                   final List<String> addUnavailableTypes,
378                   final List<String> removeUnavailableTypes,
379                   final Date scheduledStartTime,
380                   final List<String> dependencyIDs,
381                   final FailedDependencyAction failedDependencyAction,
382                   final List<String> notifyOnCompletion,
383                   final List<String> notifyOnError)
384  {
385    super(taskID, ALERT_TASK_CLASS, scheduledStartTime, dependencyIDs,
386         failedDependencyAction, notifyOnCompletion, notifyOnError);
387
388    this.alertType    = alertType;
389    this.alertMessage = alertMessage;
390
391    ensureTrue((alertType == null) == (alertMessage == null));
392
393
394    this.addDegradedTypes       = getStringList(addDegradedTypes);
395    this.removeDegradedTypes    = getStringList(removeDegradedTypes);
396    this.addUnavailableTypes    = getStringList(addUnavailableTypes);
397    this.removeUnavailableTypes = getStringList(removeUnavailableTypes);
398
399    if (alertType == null)
400    {
401      ensureFalse(this.addDegradedTypes.isEmpty() &&
402           this.removeDegradedTypes.isEmpty() &&
403           this.addUnavailableTypes.isEmpty() &&
404           this.removeUnavailableTypes.isEmpty());
405    }
406  }
407
408
409
410  /**
411   * Creates a new alert task from the provided entry.
412   *
413   * @param  entry  The entry to use to create this alert task.
414   *
415   * @throws  TaskException  If the provided entry cannot be parsed as an alert
416   *                         task entry.
417   */
418  public AlertTask(final Entry entry)
419         throws TaskException
420  {
421    super(entry);
422
423
424    // Get the alert type and message.  If either is present, then both must be.
425    alertType    = entry.getAttributeValue(ATTR_ALERT_TYPE);
426    alertMessage = entry.getAttributeValue(ATTR_ALERT_MESSAGE);
427
428    if ((alertType == null) != (alertMessage == null))
429    {
430      throw new TaskException(ERR_ALERT_TYPE_AND_MESSAGE_INTERDEPENDENT.get());
431    }
432
433
434    // Get the values to add/remove from the degraded/unavailable alert types.
435    addDegradedTypes       = parseStringList(entry, ATTR_ADD_DEGRADED_TYPE);
436    removeDegradedTypes    = parseStringList(entry, ATTR_REMOVE_DEGRADED_TYPE);
437    addUnavailableTypes    = parseStringList(entry, ATTR_ADD_UNAVAILABLE_TYPE);
438    removeUnavailableTypes = parseStringList(entry,
439         ATTR_REMOVE_UNAVAILABLE_TYPE);
440
441    if ((alertType == null) && addDegradedTypes.isEmpty() &&
442        removeDegradedTypes.isEmpty() && addUnavailableTypes.isEmpty() &&
443        removeUnavailableTypes.isEmpty())
444    {
445      throw new TaskException(ERR_ALERT_ENTRY_NO_ELEMENTS.get());
446    }
447  }
448
449
450
451  /**
452   * Creates a new alert task from the provided set of task properties.
453   *
454   * @param  properties  The set of task properties and their corresponding
455   *                     values to use for the task.  It must not be
456   *                     {@code null}.
457   *
458   * @throws  TaskException  If the provided set of properties cannot be used to
459   *                         create a valid alert task.
460   */
461  public AlertTask(final Map<TaskProperty,List<Object>> properties)
462         throws TaskException
463  {
464    super(ALERT_TASK_CLASS, properties);
465
466    String type = null;
467    String message = null;
468    final LinkedList<String> addDegraded = new LinkedList<String>();
469    final LinkedList<String> removeDegraded = new LinkedList<String>();
470    final LinkedList<String> addUnavailable = new LinkedList<String>();
471    final LinkedList<String> removeUnavailable = new LinkedList<String>();
472    for (final Map.Entry<TaskProperty,List<Object>> entry :
473         properties.entrySet())
474    {
475      final TaskProperty p = entry.getKey();
476      final String attrName = StaticUtils.toLowerCase(p.getAttributeName());
477      final List<Object> values = entry.getValue();
478
479      if (attrName.equals(ATTR_ALERT_TYPE))
480      {
481        type = parseString(p, values, type);
482      }
483      else if (attrName.equals(ATTR_ALERT_MESSAGE))
484      {
485        message = parseString(p, values, message);
486      }
487      else if (attrName.equals(ATTR_ADD_DEGRADED_TYPE))
488      {
489        final String[] s = parseStrings(p, values, null);
490        if (s != null)
491        {
492          addDegraded.addAll(Arrays.asList(s));
493        }
494      }
495      else if (attrName.equals(ATTR_REMOVE_DEGRADED_TYPE))
496      {
497        final String[] s = parseStrings(p, values, null);
498        if (s != null)
499        {
500          removeDegraded.addAll(Arrays.asList(s));
501        }
502      }
503      else if (attrName.equals(ATTR_ADD_UNAVAILABLE_TYPE))
504      {
505        final String[] s = parseStrings(p, values, null);
506        if (s != null)
507        {
508          addUnavailable.addAll(Arrays.asList(s));
509        }
510      }
511      else if (attrName.equals(ATTR_REMOVE_UNAVAILABLE_TYPE))
512      {
513        final String[] s = parseStrings(p, values, null);
514        if (s != null)
515        {
516          removeUnavailable.addAll(Arrays.asList(s));
517        }
518      }
519    }
520
521    alertType              = type;
522    alertMessage           = message;
523    addDegradedTypes       = Collections.unmodifiableList(addDegraded);
524    removeDegradedTypes    = Collections.unmodifiableList(removeDegraded);
525    addUnavailableTypes    = Collections.unmodifiableList(addUnavailable);
526    removeUnavailableTypes = Collections.unmodifiableList(removeUnavailable);
527
528    if ((alertType == null) != (alertMessage == null))
529    {
530      throw new TaskException(ERR_ALERT_TYPE_AND_MESSAGE_INTERDEPENDENT.get());
531    }
532
533    if ((alertType == null) && addDegradedTypes.isEmpty() &&
534        removeDegradedTypes.isEmpty() && addUnavailableTypes.isEmpty() &&
535        removeUnavailableTypes.isEmpty())
536    {
537      throw new TaskException(ERR_ALERT_PROPERTIES_NO_ELEMENTS.get());
538    }
539  }
540
541
542
543  /**
544   * {@inheritDoc}
545   */
546  @Override()
547  public String getTaskName()
548  {
549    return INFO_TASK_NAME_ALERT.get();
550  }
551
552
553
554  /**
555   * {@inheritDoc}
556   */
557  @Override()
558  public String getTaskDescription()
559  {
560    return INFO_TASK_DESCRIPTION_ALERT.get();
561  }
562
563
564
565  /**
566   * Retrieves the name of the alert type to use for the alert notification to
567   * be generated, if appropriate.
568   *
569   * @return  The name of the alert type to use for the alert notification to be
570   *          generated, or {@code null} if no alert should be generated.
571   */
572  public String getAlertType()
573  {
574    return alertType;
575  }
576
577
578
579  /**
580   * Retrieves the message to use for the alert notification to be generated, if
581   * appropriate.
582   *
583   * @return  The message to use for the alert notification to be generated, or
584   *          {@code null} if no alert should be generated.
585   */
586  public String getAlertMessage()
587  {
588    return alertMessage;
589  }
590
591
592
593  /**
594   * Retrieves the names of the alert types that should be added to the set of
595   * degraded alert types.
596   *
597   * @return  The names of the alert types that should be added to the set of
598   *          degraded alert types, or an empty list if no degraded alert types
599   *          should be added.
600   */
601  public List<String> getAddDegradedAlertTypes()
602  {
603    return addDegradedTypes;
604  }
605
606
607
608  /**
609   * Retrieves the names of the alert types that should be removed from the set
610   * of degraded alert types.
611   *
612   * @return  The names of the alert types that should be removed from the set
613   *          of degraded alert types, or an empty list if no degraded alert
614   *          types should be removed.
615   */
616  public List<String> getRemoveDegradedAlertTypes()
617  {
618    return removeDegradedTypes;
619  }
620
621
622
623  /**
624   * Retrieves the names of the alert types that should be added to the set of
625   * unavailable alert types.
626   *
627   * @return  The names of the alert types that should be added to the set of
628   *          unavailable alert types, or an empty list if no unavailable alert
629   *          types should be added.
630   */
631  public List<String> getAddUnavailableAlertTypes()
632  {
633    return addUnavailableTypes;
634  }
635
636
637
638  /**
639   * Retrieves the names of the alert types that should be removed from the set
640   * of unavailable alert types.
641   *
642   * @return  The names of the alert types that should be removed from the set
643   *          of unavailable alert types, or an empty list if no unavailable
644   *          alert types should be removed.
645   */
646  public List<String> getRemoveUnavailableAlertTypes()
647  {
648    return removeUnavailableTypes;
649  }
650
651
652
653  /**
654   * {@inheritDoc}
655   */
656  @Override()
657  protected List<String> getAdditionalObjectClasses()
658  {
659    return Arrays.asList(OC_ALERT_TASK);
660  }
661
662
663
664  /**
665   * {@inheritDoc}
666   */
667  @Override()
668  protected List<Attribute> getAdditionalAttributes()
669  {
670    final LinkedList<Attribute> attrList = new LinkedList<Attribute>();
671
672    if (alertType != null)
673    {
674      attrList.add(new Attribute(ATTR_ALERT_TYPE, alertType));
675      attrList.add(new Attribute(ATTR_ALERT_MESSAGE, alertMessage));
676    }
677
678    if (! addDegradedTypes.isEmpty())
679    {
680      attrList.add(new Attribute(ATTR_ADD_DEGRADED_TYPE, addDegradedTypes));
681    }
682
683    if (! removeDegradedTypes.isEmpty())
684    {
685      attrList.add(new Attribute(ATTR_REMOVE_DEGRADED_TYPE,
686           removeDegradedTypes));
687    }
688
689    if (! addUnavailableTypes.isEmpty())
690    {
691      attrList.add(new Attribute(ATTR_ADD_UNAVAILABLE_TYPE,
692           addUnavailableTypes));
693    }
694
695    if (! removeUnavailableTypes.isEmpty())
696    {
697      attrList.add(new Attribute(ATTR_REMOVE_UNAVAILABLE_TYPE,
698           removeUnavailableTypes));
699    }
700
701    return attrList;
702  }
703
704
705
706  /**
707   * {@inheritDoc}
708   */
709  @Override()
710  public List<TaskProperty> getTaskSpecificProperties()
711  {
712    return Collections.unmodifiableList(Arrays.asList(
713         PROPERTY_ALERT_TYPE, PROPERTY_ALERT_MESSAGE,
714         PROPERTY_ADD_DEGRADED_TYPE, PROPERTY_REMOVE_DEGRADED_TYPE,
715         PROPERTY_ADD_UNAVAILABLE_TYPE, PROPERTY_REMOVE_UNAVAILABLE_TYPE));
716  }
717
718
719
720  /**
721   * {@inheritDoc}
722   */
723  @Override()
724  public Map<TaskProperty,List<Object>> getTaskPropertyValues()
725  {
726    final LinkedHashMap<TaskProperty,List<Object>> props =
727         new LinkedHashMap<TaskProperty,List<Object>>(6);
728
729    if (alertType != null)
730    {
731      props.put(PROPERTY_ALERT_TYPE,
732           Collections.<Object>unmodifiableList(Arrays.asList(alertType)));
733      props.put(PROPERTY_ALERT_MESSAGE,
734           Collections.<Object>unmodifiableList(Arrays.asList(alertMessage)));
735    }
736
737    if (! addDegradedTypes.isEmpty())
738    {
739      props.put(PROPERTY_ADD_DEGRADED_TYPE,
740           Collections.<Object>unmodifiableList(addDegradedTypes));
741    }
742
743    if (! removeDegradedTypes.isEmpty())
744    {
745      props.put(PROPERTY_REMOVE_DEGRADED_TYPE,
746           Collections.<Object>unmodifiableList(removeDegradedTypes));
747    }
748
749    if (! addUnavailableTypes.isEmpty())
750    {
751      props.put(PROPERTY_ADD_UNAVAILABLE_TYPE,
752           Collections.<Object>unmodifiableList(addUnavailableTypes));
753    }
754
755    if (! removeUnavailableTypes.isEmpty())
756    {
757      props.put(PROPERTY_REMOVE_UNAVAILABLE_TYPE,
758           Collections.<Object>unmodifiableList(removeUnavailableTypes));
759    }
760
761    return Collections.unmodifiableMap(props);
762  }
763
764
765
766  /**
767   * Retrieves an unmodifiable list using information from the provided list.
768   * If the given list is {@code null}, then an empty list will be returned.
769   * Otherwise, an unmodifiable version of the provided list will be returned.
770   *
771   * @param  l  The list to be processed.
772   *
773   * @return  The resulting string list.
774   */
775  private static List<String> getStringList(final List<String> l)
776  {
777    if (l == null)
778    {
779      return Collections.emptyList();
780    }
781    else
782    {
783      return Collections.unmodifiableList(l);
784    }
785  }
786}