001/*
002 * Copyright 2009-2019 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2015-2019 Ping Identity Corporation
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License (GPLv2 only)
010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011 * as published by the Free Software Foundation.
012 *
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program; if not, see <http://www.gnu.org/licenses>.
020 */
021package com.unboundid.ldap.sdk.unboundidds.logs;
022
023
024
025import java.util.ArrayList;
026import java.util.Collections;
027import java.util.List;
028
029import com.unboundid.util.LDAPSDKException;
030import com.unboundid.util.NotMutable;
031import com.unboundid.util.ThreadSafety;
032import com.unboundid.util.ThreadSafetyLevel;
033import com.unboundid.util.Validator;
034
035
036
037/**
038 * This class defines an exception that may be thrown if a problem occurs while
039 * attempting to parse an audit log message.
040 * <BR>
041 * <BLOCKQUOTE>
042 *   <B>NOTE:</B>  This class, and other classes within the
043 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
044 *   supported for use against Ping Identity, UnboundID, and
045 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
046 *   for proprietary functionality or for external specifications that are not
047 *   considered stable or mature enough to be guaranteed to work in an
048 *   interoperable way with other types of LDAP servers.
049 * </BLOCKQUOTE>
050 */
051@NotMutable()
052@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
053public final class AuditLogException
054       extends LDAPSDKException
055{
056  /**
057   * The serial version UID for this serializable class.
058   */
059  private static final long  serialVersionUID = -3928437646247214211L;
060
061
062
063  // The malformed log message that triggered this exception.
064  private final List<String> logMessageLines;
065
066
067
068  /**
069   * Creates a new audit log exception with the provided information.
070   *
071   * @param  logMessageLines  A list of the lines that comprise the audit log
072   *                          message.  It must not be {@code null} but may be
073   *                          empty.
074   * @param  explanation      A message explaining the problem that occurred.
075   *                          It must not be {@code null}.
076   */
077  public AuditLogException(final List<String> logMessageLines,
078                           final String explanation)
079  {
080    this(logMessageLines, explanation, null);
081  }
082
083
084
085  /**
086   * Creates a new audit log exception with the provided information.
087   *
088   * @param  logMessageLines  A list of the lines that comprise the audit log
089   *                          message.  It must not be {@code null} but may be
090   *                          empty.
091   * @param  explanation      A message explaining the problem that occurred.
092   *                          It must not be {@code null}.
093   * @param  cause            An underlying exception that triggered this
094   *                          exception.
095   */
096  public AuditLogException(final List<String> logMessageLines,
097                           final String explanation, final Throwable cause)
098  {
099    super(explanation, cause);
100
101    Validator.ensureNotNull(logMessageLines);
102    Validator.ensureNotNull(explanation);
103
104    this.logMessageLines =
105         Collections.unmodifiableList(new ArrayList<>(logMessageLines));
106  }
107
108
109
110  /**
111   * Retrieves a list of the lines that comprise the audit log message that
112   * triggered this exception.
113   *
114   * @return  A list of the lines that comprise the audit log message that
115   *          triggered this exception, or an empty list if no log message lines
116   *          are available.
117   */
118  public List<String> getLogMessageLines()
119  {
120    return logMessageLines;
121  }
122}